Skip to content

Update Roslyn to 4.14, SDK to 10, C# LangVersion to 14#241

Draft
Copilot wants to merge 5 commits into
masterfrom
copilot/update-roslyn-package
Draft

Update Roslyn to 4.14, SDK to 10, C# LangVersion to 14#241
Copilot wants to merge 5 commits into
masterfrom
copilot/update-roslyn-package

Conversation

Copilot AI commented May 26, 2026

Copy link
Copy Markdown
  • Remove Microsoft.CodeAnalysis.NetAnalyzers package reference from all 6 csproj files and add EnableNETAnalyzers to Directory.Build.props
  • Migrate all ruleset suppressions to .editorconfig and a GlobalAnalyzerConfigFiles item for test projects
  • Delete obsolete .ruleset files and remove CodeAnalysisRuleSet properties
  • Replace [SuppressMessage] attributes with #pragma warning disable/restore in TriviaSyntaxFactory.cs and WhitespaceAnalyzer.cs
  • Make IsZeroLiteral parameter nullable (object?) to remove null-forgiving on constant.Value!
  • Make AsLong parameter nullable to remove null-forgiving in FlagsHelper.cs
  • Make CreateFixAction codeActionEquivalenceKey parameter nullable (string?) to remove null-forgiving on fixAllContext.CodeActionEquivalenceKey!
  • Align EditorConfigContent and workspace options to both use tab_width/indent_size = 4
  • Build and test to verify all changes work

Copilot AI linked an issue May 26, 2026 that may be closed by this pull request
- Update global.json SDK from 8.0.300 to 10.0.100
- Update Directory.Build.props LangVersion from 8.0 to 14
- Update ShortVersion from 3.7.2 to 4.14.0
- Update Microsoft.CodeAnalysis.CSharp.Workspaces to 4.14.0
- Update WTG.Analyzers.Utils.nuspec dependency to 4.14.0
- Fix nullable reference type errors from Roslyn 4.14 API changes
- Fix RS1034 (prefer IsKind) in SyntaxTreeExtensions and VisibilityAnalyzer
- Fix RS1039 (GetDeclaredSymbol) in IsAsyncVoidMethodVisitor
- Add EnforceExtendedAnalyzerRules to analyzer projects
- Suppress RS1035 for legitimate Environment.NewLine usage
- Suppress RS1038/RS1041 in rulesets for analyzer assemblies
- Update test framework to use editorconfig-based formatting
- Add CS0308/CS8389 to InvalidSyntax test suppress list

Agent-Logs-Url: https://github.com/WiseTechGlobal/WTG.Analyzers/sessions/1bf1805e-e249-4851-b70b-35abb7035209

Co-authored-by: brian-reichle <18721383+brian-reichle@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Roslyn package to version 4.14 Update Roslyn to 4.14, SDK to 10, C# LangVersion to 14 May 26, 2026
Copilot AI requested a review from brian-reichle May 26, 2026 07:32
Copilot AI and others added 2 commits May 26, 2026 07:56
… editorconfig, use #pragma, remove null-forgiving operators

- Remove Microsoft.CodeAnalysis.NetAnalyzers package from all projects
- Add EnableNETAnalyzers to Directory.Build.props to use SDK-bundled analyzers
- Migrate all ruleset suppressions to .editorconfig and global analyzer config
- Delete obsolete .ruleset files
- Replace [SuppressMessage] with #pragma warning disable/restore
- Make IsZeroLiteral and AsLong parameters nullable to avoid null-forgiving
- Make CreateFixAction codeActionEquivalenceKey parameter nullable
- Fix CA1859 in test code (use concrete Dictionary type)
- Restore workspace formatting options for SyntaxNode-based Formatter.Format

Agent-Logs-Url: https://github.com/WiseTechGlobal/WTG.Analyzers/sessions/9d8cf272-23dd-44fd-964b-1bf7c5e2e4b4

Co-authored-by: brian-reichle <18721383+brian-reichle@users.noreply.github.com>

return Formatter.Format(root, Formatter.Annotation, document.Project.Solution.Workspace);
var formattedDoc = await Formatter.FormatAsync(document, Formatter.Annotation).ConfigureAwait(false);
return (await formattedDoc.GetSyntaxRootAsync().ConfigureAwait(false))!;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot, use NRT.Assert instead of the null forgiving operator.

eg.

var syntaxRoot = ...
NRT.Assert(syntaxRoot != null, "GetSyntaxRootAsync should not return null for a C# document.");
return syntaxRoot;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the NRT class isn't available in the TestFramework project (it's in a shared project only imported by netstandard2.0 projects), I used the ?? throw pattern instead, which is already established in this file (see line 222). Fixed in 64a3e4b.

var workspace = new AdhocWorkspace();
var solution = workspace.CurrentSolution;

#pragma warning disable CS0618 // OptionSet/WithChangedOption is obsolete - needed for Formatter.Format with SyntaxNode overload

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot
If it's obsolete, then we should prefer switching to the recommended replacement.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the obsolete OptionSet/WithChangedOption usage entirely. CreateWorkspace() now just returns a plain AdhocWorkspace(), and the ExpressionRemoverTest uses document-based Formatter.FormatAsync (which picks up settings from the .editorconfig added to the project) instead of the obsolete Formatter.Format(node, workspace, options) overload. Fixed in 64a3e4b.


return new DiagnosticResultLocation(
loc.Path,
Path.GetFileName(loc.Path),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot
why do we need to strip off the path?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't necessary — reverted in 64a3e4b.

var codeActionEquivalenceKey = fixAllContext.CodeActionEquivalenceKey;
var codeAction = CodeAction.Create(Title, c => Task.FromResult(solution), codeActionEquivalenceKey);
return Task.FromResult(codeAction);
CodeAction? codeAction = CodeAction.Create(Title, c => Task.FromResult(solution), codeActionEquivalenceKey);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot
codeAction should continue to be defined as var. The next line specifies CodeAction? via the type argument, so we shouldn't need to specify it here too.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 64a3e4b — changed back to var.

…te workspace options, revert DiagnosticConversion.cs, fix var usage

- CodeFixer.cs: Replace null-forgiving operator with ?? throw pattern
- ModelUtils.cs: Remove obsolete OptionSet/WithChangedOption API usage
- ExpressionRemoverTest.cs: Use Document-based formatting (recommended replacement)
- DiagnosticConversion.cs: Revert unnecessary Path.GetFileName change
- DocumentBatchedFixAllProvider.cs: Change explicit CodeAction? type back to var

Agent-Logs-Url: https://github.com/WiseTechGlobal/WTG.Analyzers/sessions/279b9f0c-d556-4a56-bd53-5fe54f245905

Co-authored-by: brian-reichle <18721383+brian-reichle@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Roslyn

2 participants