{"record":{"id":"6f695b88fb5f7dc5","repo":"stride3d/stride","slug":"the-name-of-a-project-cannot-be-set","errorCode":null,"errorMessage":"The name of a project cannot be set","messagePattern":"The name of a project cannot be set","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Core.Assets.Editor/ViewModel/ProjectViewModel.cs","lineNumber":57,"sourceCode":"        }\n    }\n\n    // TODO: For the moment we consider that a project has only a single parent profile. Sharing project in several profile is not supported.\n    public class ProjectViewModel : PackageViewModel\n    {\n        private bool isCurrentProject;\n\n        public ProjectViewModel(SessionViewModel session, SolutionProject project, bool packageAlreadyInSession)\n            : base(session, project, packageAlreadyInSession)\n        {\n            content.Add(Code = new ProjectCodeViewModel(this));\n        }\n\n        public SolutionProject Project => (SolutionProject)PackageContainer;\n\n        public ProjectCodeViewModel Code { get; }\n\n        public override string Name { get { return Project.Name; } set { if (value != Name) throw new InvalidOperationException(\"The name of a project cannot be set\"); } }\n\n        public UFile ProjectPath => Project.FullPath;\n\n        // TODO CSPROJ=XKPKG\n        public ProjectType Type => Project.Type;\n\n        public PlatformType Platform => Project.Platform;\n\n        /// <summary>\n        /// Gets the generic type (either PlatformType or ProjectType)\n        /// </summary>\n        /// TODO: Remove this code as this is an ugly workaround\n        public object GenericType => Platform != PlatformType.Shared ? (object)Platform : Type;\n\n        public bool IsCurrentProject\n        {\n            get { return isCurrentProject; }\n            internal set","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Core.Assets.Editor/ViewModel/ProjectViewModel.cs#L39-L75","documentation":"ProjectViewModel exposes the project name as read-only by reflecting SolutionProject.Name. The Name setter throws InvalidOperationException whenever a different value is assigned, because a project's name cannot be changed through this view model. This enforces the invariant that project identity is managed by the solution, not the view model.","triggerScenarios":"Assigning any string other than the current Name to ProjectViewModel.Name, e.g. through data binding, a rename UI, or serialization code writing back properties.","commonSituations":"A generic property-grid or rename dialog tries to rename every item in the solution tree including projects; two-way WPF binding writes back the same-looking name with different casing/whitespace.","solutions":["Do not attempt to rename projects via ProjectViewModel.Name; use the solution-level rename API for projects.","Make the UI mark project names as read-only so the setter is never invoked.","Check the item type before binding a rename command (only allow renaming non-project items).","Remove the setter call from serialization/import code paths that iterate all properties."],"exampleFix":"// before\nviewModel.Name = newName; // throws for projects\n// after\nif (viewModel is ProjectViewModel)\n    throw new NotSupportedException(\"Rename projects via the solution, not ProjectViewModel\");\nviewModel.Name = newName;","handlingStrategy":"validation","validationCode":"if (viewModel is ProjectViewModel)\n    throw new NotSupportedException(\"Projects cannot be renamed via ProjectViewModel\");","typeGuard":"bool isProject = item is ProjectViewModel;","tryCatchPattern":"try { vm.Name = newName; }\ncatch (InvalidOperationException) { /* read-only: use solution rename API */ }","preventionTips":["Bind Name as read-only for project tree nodes","Only enable rename UI for non-project items","Never two-way bind ProjectViewModel.Name"],"tags":["csharp","viewmodel","read-only-property"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}