[release/8.0] Fix ambiguous route analyzer false positive with switch #52035
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.
[release/8.0] Fix ambiguous route analyzer false positive with switch
The ambiguous route analyzer excludes comparing routes that are in different code paths because there is no way to know which code path is used at runtime.
The current logic doesn't correctly exclude routes in switch statements and expressions. The following will flag the two routes:
The fix separates routes in switch statements into different code paths for analysis.
Fixes #51285
Customer Impact
Without this fix, ASP.NET Core apps could get false positive warnings about duplicate routes.
Customers can workaround the bad warnings by disabling the analyzer.
Regression?
Risk
Fix is to an analyzer. No runtime impact.
Verification
Before:
After:
Packaging changes reviewed?