Skip to content

Consolidate generated expression classes into partial classes#3

Merged
koenbeuk merged 2 commits intomainfrom
feat/consolidated-generated-classes
Mar 27, 2026
Merged

Consolidate generated expression classes into partial classes#3
koenbeuk merged 2 commits intomainfrom
feat/consolidated-generated-classes

Conversation

@koenbeuk
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings March 26, 2026 01:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates ExpressiveSharp’s codegen naming so multiple generated “expression factory” members for the same declaring type can be consolidated into a single static partial class, and adjusts runtime/registry lookup to find per-member expression factory methods by name.

Changes:

  • Switch generated expression containers from “one class per member” to “one partial class per declaring type”, with per-member methods named like Foo_P0_int_Expression() (and transformers as Foo_Transformers()).
  • Update ExpressiveResolver to resolve expression factories via GenerateClassFullName(...) + GenerateMethodSuffix(...) + "_Expression".
  • Extend the generator registry model/emitter to store and emit the expression factory method name per entry.

Reviewed changes

Copilot reviewed 218 out of 218 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/ExpressiveSharp.Tests/Services/ExpressionClassNameGeneratorTests.cs Adds unit coverage for new name/suffix generation behaviors.
src/ExpressiveSharp/Services/ExpressiveResolver.cs Updates runtime reflection lookup to target consolidated partial classes and per-member expression methods/transformers.
src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEntry.cs Adds ExpressionMethodName to registry entries.
src/ExpressiveSharp.Generator/Registry/ExpressionRegistryEmitter.cs Emits registry calls including expression method name and derives per-member transformer method name.
src/ExpressiveSharp.Generator/Emitter/ExpressionTreeEmitter.cs Adjusts string.Concat(string,string) MethodInfo resolution fallback emission.
tests/ExpressiveSharp.Generator.Tests/**/*.verified.txt Updates generator snapshot baselines to reflect consolidated partial classes and renamed expression/transformer methods (and inline reflection usage).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@koenbeuk koenbeuk force-pushed the feat/consolidated-generated-classes branch from 5f228a9 to 10cb0f6 Compare March 27, 2026 02:05
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'ExpressiveSharp Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 9978ec1 Previous: 4baf560 Ratio
ExpressiveSharp.Benchmarks.ExpressionReplacerBenchmarks.Replace_DeepChain 13002.490152994791 ns (± 6425.537256203266) 8015.039352416992 ns (± 559.6747508158047) 1.62
ExpressiveSharp.Benchmarks.TransformerBenchmarks.ExpandExpressives_FullPipeline 13514.363464355469 ns (± 6951.544460967931) 8102.771881103516 ns (± 201.41206292411348) 1.67
ExpressiveSharp.Benchmarks.GeneratorBenchmarks.RunGenerator(ExpressiveCount: 1) 2714891.921875 ns (± 1060104.9464125987) 934107.2679036459 ns (± 90659.51793884508) 2.91
ExpressiveSharp.Benchmarks.GeneratorBenchmarks.RunGenerator_NoiseChange(ExpressiveCount: 1) 2297760.6588541665 ns (± 875595.1862309682) 1876945.7799479167 ns (± 152359.06827196968) 1.22
ExpressiveSharp.Benchmarks.GeneratorBenchmarks.RunGenerator(ExpressiveCount: 100) 134912102.7777778 ns (± 40366816.45858579) 71178709.5 ns (± 1356732.741957425) 1.90
ExpressiveSharp.Benchmarks.GeneratorBenchmarks.RunGenerator_Incremental_ExpressiveChange(ExpressiveCount: 100) 99518402.58333333 ns (± 17769475.68744676) 79640457.58333333 ns (± 13073268.121748274) 1.25

This comment was automatically generated by workflow using github-action-benchmark.

- Add EndsWith guard around transformer method name Substring
  derivation in the generated Register helper for defense-in-depth
- Re-add [EditorBrowsable(Never)] to generated partial classes via
  a single attribute-only partial file per unique class, emitted from
  the registry phase
- Include generic/extension classes as metadata-only registry entries
  so they also receive the EditorBrowsable attribute
- Add GenericClass_GetsEditorBrowsableAttribute test verifying generic
  classes get the attribute with correct type parameters

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@koenbeuk koenbeuk merged commit 0046f23 into main Mar 27, 2026
3 checks passed
@koenbeuk koenbeuk deleted the feat/consolidated-generated-classes branch March 27, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants