Repository navigation
Fix light-up fallbacks for base syntax types - #4357
Merged
Merged
Conversation
Support parameter and expression/pattern wrappers on older Roslyn hosts, and dispatch member attributes and modifiers to derived APIs when base members are unavailable. Preserve modern accessors and cover compatibility across the compiler matrix. Fixes #3258 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Two regression suites are excluded from compiler-version inheritance, leaving their checks absent from later Roslyn hosts.
2 open issues
What changed in this PR
Fixes older-Roslyn compatibility in StyleCop’s syntax light-up layer, addressing #3258.
Changes:
- Adds parameter and expression-or-pattern fallbacks.
- Dispatches member operations to derived implementations when base APIs are unavailable.
- Adds regression tests, regenerates wrappers, and documents compatibility requirements.
| File | Description |
|---|---|
| tools/StyleCop.Analyzers.CodeGeneration/SyntaxLightupGenerator.cs | Generates fallback-aware wrappers. |
| test/StyleCop.Analyzers.Test/Lightup/SyntaxWrapperTests.cs | Tests parameter and expression fallbacks. |
| test/StyleCop.Analyzers.Test/Lightup/SyntaxWrapperHelperUnitTests.cs | Checks parameter fallback type resolution. |
| test/StyleCop.Analyzers.Test/Lightup/MemberDeclarationSyntaxExtensionsTests.cs | Tests member reads, updates, and unsupported cases. |
| test/StyleCop.Analyzers.Test/Lightup/LightupHelpersUnitTests.cs | Tests custom fallback delegates. |
| test/StyleCop.Analyzers.Test.CSharp9/Lightup/SyntaxWrapperCSharp9UnitTests.cs | Tests function-pointer parameter wrapping. |
| test/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxWrapperCSharp7UnitTests.cs | Tests pattern wrapping and conversions. |
| src/StyleCop.Analyzers/Lightup/MemberDeclarationSyntaxExtensions.cs | Adds derived-member fallback dispatch. |
| src/StyleCop.Analyzers/Lightup/LightupHelpers.cs | Supports fallback delegates and dual-hierarchy recognition. |
| src/StyleCop.Analyzers/Lightup/BaseParameterSyntaxWrapper.cs | Defines concrete parameter fallback support. |
| src/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SyntaxWrapperHelper.g.cs | Registers the generated parameter fallback. |
| src/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ExpressionOrPatternSyntaxWrapper.g.cs | Uses fallback-aware instance checks. |
| CONTRIBUTING.md | Documents syntax compatibility requirements. |
Review effort: Balanced
Use UnitTests class names recognized by DerivedTestGenerator so member, parameter, and expression fallback regressions run on both legacy and modern Roslyn hosts. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4357 +/- ##
==========================================
+ Coverage 97.62% 97.63% +0.01%
==========================================
Files 1336 1342 +6
Lines 149792 150378 +586
Branches 5098 5138 +40
==========================================
+ Hits 146239 146829 +590
+ Misses 2265 2247 -18
- Partials 1288 1302 +14 🚀 New features to boost your workflow:
|
This was referenced Nov 11, 2026
Bump StyleCop.Analyzers from 1.2.0-beta.556 to 1.3.180
microsoftgraph/aspnetcore-webhooks-sample#436
Open
Closed
Open
This was referenced Dec 1, 2026
Open
Open
Open
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.

Older Roslyn hosts lack syntax base types and members introduced in later compilers, leaving several light-up fallbacks incomplete.
Fixes #3258
Changes
Validation
The initial regression tests failed against unchanged product code: parameter and expression recognition failed, and member updates threw NotSupportedException. Added coverage for reads, updates, conversions, null handling, unsupported members, and function pointer parameters.
All light-up suites pass for C# 6 through C# 15 on both net10.0 and net472. Builds completed with zero warnings, and a non-incremental regeneration preserved the generated output.
Performance
No analyzer registrations, semantic-model work, or tree walks changed. Member access retains its existing delegates on modern hosts; older hosts use syntax-type dispatch without per-access reflection.