Fix Roslyn analyzer tutorial: Correct test case categorization #47120
+31
−29
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.
The "Create tests for valid declarations" section incorrectly categorized some test cases as failing when they actually pass due to existing analyzer logic.
Problem
The tutorial stated that four test cases "you haven't handled yet" would fail when running tests:
VariableIsAlreadyConst_NoDiagnostic
NoInitializer_NoDiagnostic
InitializerIsNotConstant_NoDiagnostic
MultipleInitializers_NoDiagnostic
However, the first two tests actually pass because the analyzer already handles these conditions:
const
keyword check in the analyzerSolution
Reorganized the documentation to correctly categorize the tests:
Tests that pass (already handled):
const
(moved from "failing" section)Tests that actually fail (need to be implemented):
Updated the text from "you'll see these new test cases fail" to "you'll see these last two test cases fail" for accuracy.
Impact
Tutorial readers will no longer be confused by tests that the documentation claims should fail but actually pass, making the learning experience clearer and more accurate.
Fixes #23501.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Internal previews