You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document diagnostic markup alternatives to WithSpan in roslyn-analyzers skill - #6552
My contribution adds a new instruction, prompt, agent, skill, workflow, or canvas extension file in the correct directory.
The file follows the required naming convention.
The content is clearly structured and follows the example format.
I have tested my instructions, prompt, agent, skill, workflow, or canvas extension with GitHub Copilot.
I have run npm start and verified that README.md is up to date.
I am targeting the main branch for this pull request.
Description
The roslyn-analyzers skill only showed [|...|] markup and called WithSpan a last resort. This documents the other markup forms so tests avoid hard-coded positions: {|DiagnosticId:code|} (ID in the markup, no DiagnosticResult needed) and {|#n:code|} paired with DiagnosticResult.WithLocation(n) when arguments, severity, or additional locations must be asserted. It also lists the relevant DiagnosticResult members and says to avoid WithSpan and WithLocation(line, column).
Type of Contribution
Update to existing instruction, prompt, agent, plugin, skill, workflow, or canvas extension.
Additional Notes
Docs-only change to skills/roslyn-analyzers/SKILL.md.
Validation: I applied the guidance to a real analyzer test in AArnott/Nerdbank.MessagePack (DefaultValueInitializerAnalyzerTests.NonConstantInitializerHasNoCodeFix), replacing WithSpan(6, 13, 6, 21) with a {|#0:Computed|} marker plus VerifyCS.Diagnostic().WithLocation(0).WithArguments("Computed"). It passes with TUnit on net10.0. {|NBMsgPack110:...|} markers are already used throughout that suite. I also confirmed that WithLocation(int) works for markers in an additional TestState.Sources file, and that an indexed marker without a matching DiagnosticResult fails (documented in the skill).
By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.
Risk tier:merge-risk:low — Documentation, metadata, generated output, or a small update to an existing resource Required to merge: passing submission-gate checks plus 1 approval from reviewers with write access.
Why this tier
Small update (36 changed lines) to existing resources with no added or removed files
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The guidance includes a non-compiling DiagnosticResult.WithLocation overload and lacks a real analyzer-test example verifying the documented assertions.
This pull request expands the roslyn-analyzers skill with guidance on using diagnostic markup and DiagnosticResult assertions instead of hard-coded source positions.
Changes:
Documents [|...|], {|DiagnosticId:...|}, and indexed {|#n:...|} markup forms.
Adds examples for diagnostic assertions and message-argument checks.
Lists relevant DiagnosticResult members and discourages hard-coded spans and line/column locations.
File
Description
skills/roslyn-analyzers/SKILL.md
Expands Roslyn analyzer test guidance with diagnostic markup patterns, DiagnosticResult usage, and recommendations for avoiding hard-coded locations.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The documentation still conflates WithOptions(...) with diagnostic assertions, so it should clarify that validation options such as IgnoreSeverity and IgnoreAdditionalLocations can disable checks and must be used deliberately.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Describe WithOptions as a validation option
skills/roslyn-analyzers/SKILL.md:451
WithOptions(...) does not assert a diagnostic detail; it controls validation behavior, including whether fields such as severity or additional locations are ignored. Grouping it with the assertion methods can lead readers to believe it verifies those fields, when it can instead disable their checks. Please describe it separately as a verifier/validation option and call out that options such as IgnoreSeverity and IgnoreAdditionalLocations should be used deliberately.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
An active documentation issue remains because the guidance inaccurately claims unmatched indexed markers necessarily fail, rather than requiring each validation marker to be paired with WithLocation(n).
- `WithLocation(int markupKey)`: binds to the `{|#n:...|}` span. Calling it again on the same result adds additional locations (for example related symbols), in order.
- Every `{|#n:...|}` marker must be matched by a `DiagnosticResult` using `WithLocation(n)`; an unmatched indexed marker fails with a diagnostic-count mismatch. When a code fix test's `fixedSource` still contains the diagnostic, add the same result to `FixedState.ExpectedDiagnostics`.
This branch has not been deployed
No deployments
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
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.
Pull Request Checklist
npm startand verified thatREADME.mdis up to date.mainbranch for this pull request.Description
The
roslyn-analyzersskill only showed[|...|]markup and calledWithSpana last resort. This documents the other markup forms so tests avoid hard-coded positions:{|DiagnosticId:code|}(ID in the markup, noDiagnosticResultneeded) and{|#n:code|}paired withDiagnosticResult.WithLocation(n)when arguments, severity, or additional locations must be asserted. It also lists the relevantDiagnosticResultmembers and says to avoidWithSpanandWithLocation(line, column).Type of Contribution
Additional Notes
Docs-only change to
skills/roslyn-analyzers/SKILL.md.Validation: I applied the guidance to a real analyzer test in AArnott/Nerdbank.MessagePack (
DefaultValueInitializerAnalyzerTests.NonConstantInitializerHasNoCodeFix), replacingWithSpan(6, 13, 6, 21)with a{|#0:Computed|}marker plusVerifyCS.Diagnostic().WithLocation(0).WithArguments("Computed"). It passes with TUnit on net10.0.{|NBMsgPack110:...|}markers are already used throughout that suite. I also confirmed thatWithLocation(int)works for markers in an additionalTestState.Sourcesfile, and that an indexed marker without a matchingDiagnosticResultfails (documented in the skill).By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.