Repository navigation
feat: integrate switch patterns and C# 14 extensions for v0.8.0 - #58
Merged
Merged
Conversation
…56) * fix: lower switch type and relational patterns without changing semantics * fix: preserve method symbols during inlining and report unsupported rewrites * test: cover switch semantics, symbol substitution and safe inlining * test: use observably side-effectful argument in AM0020 regression * fix: initialize shared nested diagnostic collections once * docs: align usage samples with generated APIs * docs: align usage samples with generated APIs * fix: do not classify null-forgiving operator as a side effect * fix: avoid redundant parentheses for already-grouped arguments * test: align switch-safe inlining golden output formatting * fix: address method-group receiver substitution and update-only switch review * fix: preserve binding in conditional indexers and switch pattern locals * fix: avoid redeclaring pattern designation local * test: keep Ignore indexed access case separate from nullable coalescing * test: make Ignore-mode non-null precondition explicit * fix: group lower-precedence switch governing expressions after helper inlining * test: prevent switch helper inlining from changing && comparison precedence * fix: preserve switch guard precedence after helper inlining * fix: visit LINQ method-group receiver outside callee call stack * fix: reject effectful switch inputs duplicated by expression lowering * test: repeated method-group helper in LINQ chain is not circular * test: detect repeated switch inputs without rejecting single evaluation * fix: bind declaration pattern locals within nested pattern wrappers * test: nested parenthesized pattern local resolves without capturing caller name * fix: preserve helper-body precedence at direct-call inline site * test: direct inline and switch arm preserve arithmetic precedence * fix: preserve inlining precedence without unnecessary grouping in snapshots * fix: allow repeated switch input evaluation like ExpressiveSharp * test: allow repeated governing calls and ToLower switch expression * fix: parenthesize cast operands and right-associative coalescing inliners * fix: preserve helper declared return conversions when inlining * fix: guard relational narrowing and correct NaN/null pattern semantics * fix: retain safe-repeatability for synthesized null-conditional ternaries * fix: make AM0020 path-sensitive and detect reordered effectful arguments * test: cast, coalescing, numeric conversion, null-pattern and nullable inlining regressions * test: relational/NaN diagnostics and AM0020 path and argument-order safety * docs: explain ExpressiveSharp-compatible switch input re-evaluation policy * docs: align AM0020 message with reordered or omitted argument protections * refactor: remove AM0020 evaluation guard from helper inlining * refactor: drop AM0020 blocking from projection generation * refactor: remove AM0020 checks from update generation * refactor: remove AM0020 checks from adaptation generation * refactor: remove obsolete AM0020 diagnostic descriptor * test: verify unguarded effectful helper inlining * docs: explain unguarded helper argument substitution policy * docs: remove obsolete AM0020 reference from README * refactor: carry symbol bindings in switch pattern lowering results * feat: lower type var and recursive property switch patterns * feat: lower verified array and list patterns with noncapturing slices * feat: verify record components and preserve nested switch conversions * fix: preserve pattern narrowing and helper parameter conversions * fix: group converted lambda arguments during helper inlining * docs: record switch parity coverage and final verification * update packages, reference System.Security.Cryptography.Pkcs" Version="10.0.14 directly until Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing fixed to refer good version of Pkcs * style: remove extra blank lines in semantic regression tests
Add source-generated C# 14 extension methods/properties and symbol-aware composition. Ship shared-source Roslyn 4.8 and 5.0 analyzer bands with automatic compatible selection. Validated: 191 tests; actual compiler 4.8/4.14/5.0/5.9 package matrix on Windows and Linux; Release/Debug builds; clean no-build packing; final Codex review without findings. Squash merge into dev_v0_8_0 explicitly approved by owner.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
This integrates the switch-pattern and C# 14 extension-member work from #56 and #57 into main for the v0.8.0 development milestone.
Supported switch expressions now lower to readable conditional C# with symbol-aware captures, property patterns, verified array/List patterns and non-capturing slices, and synthesized record positional patterns. Unsupported or non-exhaustive switches receive AM0019; update-only adaptations retain ordinary C# switch behavior.
C# 14 instance extension methods and expression-bodied getter properties generate ordinary static expression factories in their outer partial class. Source-defined helpers compose transitively across classic and C# 14 members, preserving receiver/argument conversions, lambda scopes, inferred anonymous member names and compile-time constants.
Compiler compatibility is preserved through two shared-source netstandard2.0 analyzer assets:
A pinned-source and 16-case runtime comparison with ExpressiveSharp confirms the shared conditional-tree approach and documents intentional coverage differences and upstream edge cases. The comparison also found and fixed unnamed tuple signature normalization so unsupported tuple patterns produce AM0019 without crashing the mapper. Comparison report.
Structural improvements centralize mapper declaration validation, symbol-based generated member reservations, shared inlining state, operation-based argument binding, child expansion and static reference handling. Nullable value overloads remain distinct, classic invalid declarations/collisions receive AM0022/AM0023, and method-group expansion preserves return conversions. Existing generated-source snapshots are unchanged.
Validation of the current implementation:
NullConditionalRewrite.Ignore remains the default. Receiver/argument expansion may repeat, skip or reorder evaluation by the documented design; AM0020 is not restored. SQL translation remains provider dependent, with scalar SQLite projections tested.
Documented exclusions include captured slices/custom deconstruction, and unsupported extension forms such as generic blocks/methods, static members, block/accessor bodies, query syntax, bound extension method groups, optional/params/ref parameters and ref-like receivers. AM0021 explains unsupported extension generation requests.
Switch support matrix · Extension compatibility matrix · Roslyn multiversion evidence
Source: dev_v0_8_0 at e5d8089.
Structural changes and validation
Target: main at 3fcc1a7.
Package version is 0.8.0, with both analyzer assemblies at 0.8.0.0. Installation docs and expected generated-code version stamps are updated. The 0.8.0 package passes compiler selection and runtime checks on Roslyn 4.8, 4.14, 5.0 and SDK/Roslyn 5.9. No release, tag or NuGet publication is included.