Repository navigation
Conversation
The analyzer collected all targets and reported every diagnostic from a CompilationEndAction. Locations were rebuilt from stored paths and spans (LocationKind.ExternalFile), so #pragma, [SuppressMessage] and per-file .editorconfig severities never applied, and the IDE did not show the diagnostics while typing. The analyzer now registers a symbol action per named type, builds the model for that type only and runs the shared parser and plan builder on it. Each type reports only the diagnostics located in its own declaration, mapped to the declaring syntax tree. Diagnostics at a matcher are reported when the matcher type itself is analyzed, which also removes duplicates that were reported once per target. MOG002 is now evaluated per target and reported at the typeof reference in Matchers. Its message names the target type. The acceptance fixture reports suppressed diagnostics, because the [SuppressMessage] attributes that declare expected diagnostics now suppress them, and it fails on analyzer exceptions. MOG002 expectations move from the matchers to the targets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In-memory regression tests for the analyzer: #pragma warning disable and [SuppressMessage] on the method suppress MOG001, reported locations are in source and span the attribute, and MOG002 is reported at the typeof reference of the target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The error-level MOG diagnostics in the acceptance project are now suppressed by the [SuppressMessage] attributes that declare them as expected, so the project builds without downgrading their severity. Verified with full builds in both attributes-only modes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Document that diagnostics are reported live and can be suppressed with #pragma, [SuppressMessage] or .editorconfig severities, that MOG002 is reported per target at the typeof reference, and how expected diagnostics are declared now that the acceptance project no longer uses a .globalconfig. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
Problem
#pragma warning disable MOGxxx,[SuppressMessage("MethodOverloadsGenerator", "MOGxxx")]and per-file.editorconfigseverities had no effect on MOG001–MOG019. The analyzer rebuilt locations from stored paths and spans (Location.Create(path, span, lineSpan)), which yieldsLocationKind.ExternalFilelocations without aSyntaxTree. Roslyn only applies in-source suppression to in-source locations.CompilationEndAction, so they did not show up live in the IDE (only on build or with full solution analysis). Every run re-parsed all targets and built the complete overload plan just to get diagnostics.Change
MethodOverloadsDiagnosticsAnalyzerregisters aSymbolActionper named type. It builds the model for that type only and runs the existingParserandOverloadPlanBuilderon it, so generator and analyzer keep sharing one set of rules.SyntaxTree(Location.Create(tree, span)). If several declarations share a path (e.g. in-memory trees without a path), the old path-based location is used as a fallback.typeof(T)reference inMatchers, and the message names the target:Matcher '{0}' has no subsequence match for any target method in '{1}'.Behavior changes
Class_39_2,Class_40_2andBug_Class_1_Bucket(the latter declares no methods at all).Known limitation (follow-up planned)
The matcher role is implicit: a type becomes a matcher only because some other type references it via
Matchers = [typeof(T)]. When a matcher type is analyzed on its own, its methods look like direct targets. In the acceptance project this produces two false MOG006 (severityHidden, not visible in build output or the error list):Class_4_Matcher.Matcher_2andBug_Class_1_ICommandRuntimeFactoryMatchers.Matcher.The same root cause affects the generator: referencing a type as a matcher anywhere disables direct generation for that type's own
[GenerateOverloads]methods. A separate PR will make the role explicit with a marker attribute on matcher types (strict: an unmarked type inMatchersis an error).Test infrastructure
AcceptanceFixtureruns the analyzer withreportSuppressedDiagnostics: true. The[SuppressMessage]attributes that declare expected diagnostics now really suppress them, so suppressed diagnostics are kept in the actual set (IsSuppressed == true). Analyzer exceptions are captured, and a new test fails on them.AcceptanceTestData.GetRootFromPathis removed. Locations now carry theirSyntaxTree.DiagnosticSuppressionTests:#pragmaand[SuppressMessage]suppress MOG001, the location is in source and spans the attribute, and MOG002 sits attypeof(IMatcher)..globalconfigVerified: without the severity downgrades the acceptance project builds with 0 errors in both modes, because the error-level diagnostics are suppressed by their
[SuppressMessage]. The file was removed. The full build (AttributesOnly=false) printed 15 MOG warnings before this PR and prints 0 now. The 59 CS8625 warnings are unchanged.Verification
dotnet test --nologo: 120 passed.ExternalFile.SourceFile, 30 of them suppressed.typeof, 3 new MOG002 (shared matchers), 2 MOG006 false positives (known limitation).dotnet build ref/...csproj -c Release -nodeReuse:false --no-incrementalwithTenekonMethodOverloadsSourceGeneratorAttributesOnly=trueand=false: 0 errors.Out of scope
extension(...)blocks, interfaces not mapped, comparison per class only, return type missing from the key) and tidy-up items.🤖 Generated with Claude Code