{"record":{"id":"fbcab5b660526795","repo":"stride3d/stride","slug":"code-upgrade-for-projectchanges-newproject-name-produced","errorCode":null,"errorMessage":"Code upgrade for [{projectChanges.NewProject.Name}] produced changes other than regular document text (added/removed docs, references, etc.); the runner persists changed .cs text only.","messagePattern":"Code upgrade for \\[(.+?)\\] produced changes other than regular document text \\(added/removed docs, references, etc\\.\\); the runner persists changed \\.cs text only\\.","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Assets/CodeUpgrade/RoslynCodeUpgradeRunner.cs","lineNumber":193,"sourceCode":"    // anything else would need workspace.TryApplyChanges() to reach the .csproj, so fail loud instead of dropping it.\n    private static void EnsureNoUnsupportedChanges(ProjectChanges projectChanges)\n    {\n        if (projectChanges.GetAddedDocuments().Any()\n            || projectChanges.GetRemovedDocuments().Any()\n            || projectChanges.GetChangedAdditionalDocuments().Any()\n            || projectChanges.GetAddedAdditionalDocuments().Any()\n            || projectChanges.GetRemovedAdditionalDocuments().Any()\n            || projectChanges.GetChangedAnalyzerConfigDocuments().Any()\n            || projectChanges.GetAddedAnalyzerConfigDocuments().Any()\n            || projectChanges.GetRemovedAnalyzerConfigDocuments().Any()\n            || projectChanges.GetAddedMetadataReferences().Any()\n            || projectChanges.GetRemovedMetadataReferences().Any()\n            || projectChanges.GetAddedProjectReferences().Any()\n            || projectChanges.GetRemovedProjectReferences().Any()\n            || projectChanges.GetAddedAnalyzerReferences().Any()\n            || projectChanges.GetRemovedAnalyzerReferences().Any())\n        {\n            throw new NotImplementedException(\n                $\"Code upgrade for [{projectChanges.NewProject.Name}] produced changes other than regular document \" +\n                \"text (added/removed docs, references, etc.); the runner persists changed .cs text only.\");\n        }\n    }\n\n    private static bool PathsEqual(string? a, string? b)\n    {\n        if (a is null || b is null)\n            return false;\n        return string.Equals(Path.GetFullPath(a), Path.GetFullPath(b), StringComparison.OrdinalIgnoreCase);\n    }\n}\n","sourceCodeStart":175,"sourceCodeEnd":206,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Assets/CodeUpgrade/RoslynCodeUpgradeRunner.cs#L175-L206","documentation":"After applying Roslyn upgrades, EnsureNoUnsupportedChanges verifies that the workspace produced only regular document text changes. If a rule also added/removed documents or changed project/metadata/analyzer references, the runner cannot persist those, so it throws NotImplementedException to prevent silent loss of changes.","triggerScenarios":"RunAsync applies upgrades whose solution changes include added/removed documents, or added/removed project, metadata, or analyzer references on projectChanges.","commonSituations":"Custom upgrade rules that add new files or edit project references (e.g. adding NuGet/package references) instead of only rewriting existing .cs text; rules migrating APIs that require new dependency assemblies.","solutions":["Rewrite the upgrade rule to only modify text of existing documents","Manually apply the reference/document additions the rule wanted, then re-run only text edits","Split the upgrade: automated text edits via the runner, manual steps for references/new files","If you own the runner, extend persistence to handle non-text changes"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// dry-run rule against a sample project and inspect the resulting changes\nvar changes = upgradeRule.GetChanges(sampleProject);\nif (changes.AddedDocuments.Any() || changes.AddedProjects.Any())\n    logger.Warning(\"Rule produces non-text changes; runner will reject it.\");","typeGuard":"static bool IsTextOnly(ProjectChanges changes) =>\n    !changes.GetAddedDocuments().Any() && !changes.GetRemovedDocuments().Any() &&\n    !changes.GetAddedProjectReferences().Any() && !changes.GetRemovedProjectReferences().Any();","tryCatchPattern":"try\n{\n    await RunUpgradesAsync(solution);\n}\ncatch (NotImplementedException ex) when (ex.Message.Contains(\"produced changes other than regular document text\"))\n{\n    logger.Error($\"Upgrade rule too broad, apply its reference/new-file steps manually: {ex.Message}\");\n}","preventionTips":["Write upgrade rules that only rewrite existing document text","Handle dependency/reference changes as documented manual steps","Dry-run custom rules against a sample project first","Never add/remove documents inside an upgrade rule"],"tags":["code-upgrade","roslyn","unsupported-feature"],"backgroundTag":"method-not-implemented","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"}