Fix fix-all correctness and authoring conformance across the .NET analyzers - #55538
Merged
tannergooding merged 22 commits intoAug 6, 2026
Merged
Conversation
|
Azure Pipelines: Successfully started running 2 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
…zers RS2000/RS2001 never ran: the package was only a transitive dependency, and the build/ folder that activates it is imported for direct PackageReferences only. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
CA2266 had no link and CA1517 pointed at CA1516's page; the rest carried a retired host or an uppercase slug segment. DiagnosticDescriptorHelper.Create derives the canonical form as learn.microsoft.com plus id.ToLowerInvariant(). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
RS2000/RS2001 compare only a row's ID, category and severity, so a row copy-pasted from its neighbour kept that rule's link. Absent links stay legal and the page is not fetched, since a rule is documented after it ships. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Without it a MEF part is constructed per request, or fails composition outright depending on the host. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Compilation.GetTypeByMetadataName bypasses the repo's per-compilation cache, and comparing ContainingType.ToDisplayString() to a literal allocates a display string per invocation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…Fixer Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
DiagnosticAnalyzer instances are shared across compilations. The field is assigned inline and only ever read, so this is an allocation fix rather than a correctness one. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ding them An expression-bodied property runs ImmutableArray.Create on every access. The declarations left expression-bodied build their array from a protected abstract descriptor, so an initializer would dispatch to a derived override from the base constructor. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Roslyn constructs every exported type it finds, and the generated rule table reported CodeFix: True for CA2215 on the strength of one. docs/rules-with-no-code-fix.md records the affected rules so the intent to write them survives. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
IOperation exposes arguments in evaluation order, which is syntactic in C#, so indexing by parameter ordinal reads the wrong argument for a named-and-reordered call and both fixers emitted code that does not compile. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ider WellKnownFixAllProviders.BatchFixer merges independent text edits, so it produces a wrong tree when diagnostics nest or overlap. What stays on it either crosses documents or unwraps a node from inside itself, neither of which a shared SyntaxEditor supports. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
An argument to Stream.ReadAsync can itself be a diagnosed ReadAsync call, so rebuilding the outer one from the original argument syntax re-emitted the inner one unfixed. The rewrite now reads its arguments and instance off the current tree. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Two nested if statements each guarded by Regex.IsMatch remove adjacent statements from the same block, so the batch fixer's text diffs overlap and only one of the two removals survives a pass. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Two ContainsKey guards in one member both asked the pre-fix semantic model for an unused name, so both introduced `value` -- CS0136 in C#, BC30288 in VB. The fix-all state records the names already handed out, scoped to the enclosing member so guards in different methods still both get `value`. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
An outer concatenation rebuilt string.Concat from the original operand syntax and replaced the whole root, re-emitting a nested one in its pre-fix form. A hardcoded NumberOfFixAllIterations = 2 had been hiding the second pass. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Two extractions in one type both chose `s_myChars`, because the name came from the type's members as they stood before the pass. The System import separately replaced the original root with a snapshot, discarding any fix applied after it. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
tannergooding
force-pushed
the
tannergooding-analyzer-conformance-sweep
branch
from
July 31, 2026 00:34
cc22566 to
001673d
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
3 tasks
Preserve the SyntaxEditor fix-all implementations while adapting them to the Roslyn 4.14 nullable API contracts. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Member
Author
|
Resolved merge conflicts from the update to 4.14 |
jeffhandley
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A mechanical conformance sweep over the release-tracking rows and the code fixers, plus the repo-wide migration onto
SyntaxEditorFixAllProviderintroduced by #55533.Fix-all.
WellKnownFixAllProviders.BatchFixercomputes each fix against the original document and text-merges the results, so overlapping edits silently lose one. 131 files referenced it, 17 still do. Five fixers were provably broken, each with a test that fails without the change:ReadAsyncargument re-emitted unfixedNumberOfFixAllIterations = 2ContainsKeyguards both introducingvalue-- CS0136 / BC30288s_myCharsWhat stays on the batch fixer either crosses documents or unwraps a node from inside itself, neither of which one shared
SyntaxEditorsupports.79 exported fixers that never register a fix, deleted. Roslyn constructs every exported type it finds, and the generated rule table reported
CodeFix: Trueon the strength of one.docs/rules-with-no-code-fix.mdrecords the affected rules so the intent to write them survives.Release tracking. RS2000/RS2001 never ran -- the package was only a transitive dependency, and the
build/folder that activates it is imported for directPackageReferences only. Nothing validated theDocumentationcolumn either: CA2266 had no link and CA1517 pointed at CA1516's page. 10 rows fixed, and the docs generator now fails on a mismatch.Authoring conformance.
[Shared]on 12 fixers missing it, well-known types throughWellKnownTypeProviderrather thanCompilation.GetTypeByMetadataNameplus aToDisplayString()comparison,SupportedDiagnostics/FixableDiagnosticIdscached rather than rebuilt per access, and CA2208/CA1421 reading arguments by parameter ordinal --IOperationexposes them in evaluation order, which is syntactic in C#, so both emitted non-compiling code for a named-and-reordered call.Out of scope. No rule IDs, severities or
RuleLevelvalues change. Of the sweep's four checks,RuleLevel-versus-tracked-severity found no mismatches, and mutable analyzer state found one allocation nit rather than a correctness bug.Note
Drafted with agent assistance.