Open
Conversation
Youssef1313
reviewed
Feb 13, 2026
src/OrchardCore/OrchardCore.SourceGenerators/ArgumentsProviderGenerator.cs
Outdated
Show resolved
Hide resolved
Contributor
|
This pull request has merge conflicts. Please resolve those before requesting a review. |
Refactored the Arguments utility and related types to return shared static empty instances instead of allocating new NamedEnumerable<T> objects for empty argument/name collections. Updated INamedEnumerable<T> to inherit from IReadOnlyCollection<T> and added a Count property for efficient checks. Introduced Arguments<T>.Empty for strongly-typed empty instances. Adjusted constructors and From methods to use arrays directly and return empty instances when appropriate. Improved parameter checks in ShapeFactoryExtensions for robustness and type safety. Suppressed CA1710 warning for INamedEnumerable<T>.
Introduced ArgumentsFromInterceptor source generator to optimize Arguments.From<T>() calls with anonymous types using C# interceptors, eliminating reflection overhead. Added comprehensive documentation covering usage, migration, and troubleshooting. Updated project files to support generated interceptor code. Added tests for interceptor and source generation paths.
…perty-based argument access. Updates source generator, Arguments.From, and tests to use the new pattern. Improves performance by avoiding array allocations and simplifies the property access model.
Member
Author
|
I added some small benchmarks, here are the result on my machine: |
Member
Author
|
I removed the extra |
hishamco
requested changes
Feb 20, 2026
Member
hishamco
left a comment
There was a problem hiding this comment.
Incredible!!
Finally, we have a source generator in OC, after my first attempt to generate the resources manifest
The only thing I need to change is move the docs outside the modules.
Member
Author
|
Sure, any suggestion? Also for the project itself, should it stay there? |
Member
|
The project should be there, IMHO, same as what I did a long time ago. We need to change the docs location |
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 pull request introduces significant improvements to how arguments are passed to shapes by leveraging source generators for strongly-typed argument classes, optimizes the internal implementation of the
Argumentssystem, and updates several modules to use these new patterns. It also adds new dependencies and project references to support these changes.Shape Arguments Refactoring and Source Generators Integration:
Introduced strongly-typed argument classes (e.g.,
NavigationArguments,MenuItemArguments,ContentZoneArguments) for shape creation, decorated with[GenerateArguments]to enable source-generated property access and improved performance. Updated shape creation calls throughout the codebase to use these new argument types instead of anonymous objects. [1] [2] [3] [4] [5] [6] [7] [8]Added the
OrchardCore.SourceGeneratorsproject and included it as an analyzer reference in the build system, ensuring that argument source generation is available for all projects except itself. [1] [2]Updated documentation navigation to include the new "Source Generators" module.
Arguments System Improvements:
Arguments.csto optimize named/positional argument handling: replaced lists with arrays andArraySegments, usedFrozenDictionaryfor faster lookups, improved zero-argument cases, and provided a genericFrom<T>method that leverages source-generated property access for types marked with[GenerateArguments]. [1] [2] [3] [4] [5]Dependency and Build System Updates:
Added new NuGet dependencies:
Microsoft.CodeAnalysis.AnalyzersandMicrosoft.CodeAnalysis.CSharpto support source generator functionality.Updated build properties to enable interceptors for the new generated code.
Fixes #15671