Skip to content

V2.0.0#4

Merged
kampute merged 43 commits into
mainfrom
v2.0.0
Dec 17, 2025
Merged

V2.0.0#4
kampute merged 43 commits into
mainfrom
v2.0.0

Conversation

@kampute

@kampute kampute commented Dec 16, 2025

Copy link
Copy Markdown
Owner

This pull request introduces several significant updates across the codebase to add support for C# extension blocks and extension members, update dependencies, and improve documentation generation. The most impactful changes include the addition of extension block handling in language rendering, improvements to documentation composition for composite types, updates to .NET 10 and dependency versions, and enhancements to the internal APIs for writing member modifiers and signatures.

Extension block and extension member support:

  • Added handling for extension blocks and members throughout the codebase, including new logic in CSharp.TypeMembers.cs to render extension receivers and generic constraints, and updates to the DocumentationModelType enum to include ExtensionBlock. [1] [2] [3] [4] [5]
  • Updated name qualification logic to correctly handle extension members via the IWithExtensionBehavior interface.

Documentation composition improvements:

  • Refactored DocumentationComposer to generate documentation for composite type members (including explicit interface members and extension members) in a single method, improving maintainability and extensibility. [1] [2]

.NET and dependency updates:

  • Updated the project to target .NET 10, changed the GitHub Actions workflow to use .NET SDK 10.0.x, and bumped the System.Reflection.MetadataLoadContext dependency to 10.0.1. [1] [2] [3]
  • Updated the project version to 2.0.0 to reflect these breaking and feature changes.

Language and rendering enhancements:

  • Added new C# keywords and operator tokens to the language data, including support for compound assignment and unsigned right shift operators. [1] [2]
  • Improved the rendering of member modifiers and signatures to use new overloads that accept the full member object, allowing for more accurate visibility and virtuality handling, especially for extension and explicit interface members. [1] [2] [3] [4]

Other improvements and fixes:

  • Updated XML doc provider instantiation for better error handling and resource management.
  • Made minor documentation and code quality improvements, such as clarifying comments, fixing typos, and updating test guidelines. [1] [2] [3] [4] [5] [6] [7]

Let me know if you want to discuss any of these changes in more detail!

- Enhance IInterfaceType for new interface features in C# 14
- Implement compound assignment operators (AdditionAssignment, SubtractionAssignment, IncrementAssignment, DecrementAssignment)
- Add support for extension members (methods and properties)
- Introduce 'allow ref struct' generic type constraint
- Remove redundant primitive type handling, improve IType interface
- Rename string extension methods: ReplaceMany -> ReplaceChars, RemoveMany -> RemoveChars
- Add new TranslateChars string manipulation method
- Update tests to use new Acme sample types and cover new features
- Remove obsolete PrimitiveTypeTests.cs and TestTypes.cs
- Update MockHelper and other utilities to use renamed methods
Refactored `ExtensionMemberStub` to `ExtensionStub` for consistency, replacing `ReceiverParameter` with `Receiver` across the codebase. Simplified methods like `GetGroupReceivers` (replaced with `GetGroupMarkerMethod`) and streamlined logic in `GetGroupStubs`.

Added `IsClassicExtensionMethod` to the `IMethod` interface to identify classic extension methods. Updated `ExtensionMethodInfo` and `ExtensionPropertyInfo` constructors to align with the new `Receiver` property.

Improved documentation for interfaces and methods to enhance clarity and maintainability. These changes improve code readability, reduce complexity, and ensure better alignment with the updated design.
Introduce an optional `asDeclared` parameter to `GetMethodMetadata` for greater flexibility in retrieving method metadata. When `asDeclared` is `false` (default), extension methods are normalized to reflect their usage form. When `true`, metadata is retrieved in its declared form.

Update the `IMemberAdapterRepository` interface to reflect this change, including detailed XML documentation explaining the behavior of the `asDeclared` parameter and its impact on extension methods.

Refactor normalization logic in `GetMethodMetadata` to conditionally normalize `MethodInfo` based on the `asDeclared` parameter. Update extension method handling in the implementation to use `asDeclared: true` where appropriate.

Enhance the generic overload of `GetMethodMetadata<T>` with remarks clarifying that it always resolves extension methods to their usage form.

Expand documentation for `GetMethodMetadata` to include detailed explanations of behavior, metadata types returned, and examples. Ensure consistent handling of extension and declared methods across the interface and implementation.
Added a new generic method `GenericMethodWithGenericParameter<S>`
to the `Acme` namespace. This method takes a `List<S>` as input
and returns the first element of the list.

Updated `CSharpTests.cs` to include test cases for verifying the
method's signature formatting and full declaration formatting.

Updated `MethodTests.cs` to include test cases for:
- Verifying the method's implementation.
- Checking if the method is generic.
- Validating the count of type and regular parameters.
- Ensuring the return type is correct.
- Verifying the method's metadata code reference.
Updated XML documentation for extension members in the `Acme`
namespace to provide clearer descriptions for generic types.
Added a new `ClassicExtensionMethod` for `ISampleInterface`.

Updated `ExtensionContainerTests.cs` to reflect the increased
number of declared extension methods. Adjusted the expected
result from 15 to 16.

Included `ClassicExtensionMethod` in the validation list in
`ClassTypeTests.cs` to ensure proper test coverage.
Refactored `ConstructCodeReference` methods in `MethodAdaptor.cs`,
`PropertyAdapter.cs`, and `TypeMemberAdapter.cs` to improve
extensibility and support for extension methods and properties.

Enhanced `XmlDocProviderTests.cs` with additional test cases for
extension methods and properties, ensuring correct classification
and behavior. Updated test setup to include additional XML
documentation files and trimmed summary strings in test results.
Added assertions to validate metadata containers and members.
Added a `ToString` method override in the `ExtensionMethodInfo`
class to provide a string representation of the extension
method, including the receiver parameter's type and the
method itself (either `ReceiverMethod` or `DeclaredMethod`).

Added a `ToString` method override in the `ExtensionPropertyInfo`
class to provide a string representation of the extension
property, including the receiver parameter's type and the
property itself (`ReceiverProperty`).

These changes improve debugging and logging by offering
clearer and more informative representations of extension
methods and properties.
The GetMetadata extension for MethodInfo now supports an optional
asDeclared parameter to control extension method resolution. XML
documentation is updated, and the parameter is passed to the
repository to enable retrieval in declared or usage form.
Added tests for extension methods in Acme.SampleExtensions. Updated property tests: added explicit interface property case for SampleProperties, removed Dictionary<,>.IsReadOnly explicit interface test. Cleaned up unused imports in PropertyTests.cs.
Added instruction to reference types and members from Acme.cs in test cases when applicable, improving clarity and consistency in testing practices.
Added comprehensive XML documentation comments to all classes, interfaces, structs, fields, properties, methods, events, operators, generic types, extension methods, and nested types in the Acme namespace. Documentation includes summaries, parameter and return descriptions, and <inheritdoc/> tags for interface implementations. Improves code readability and enables API documentation generation. No functional changes.
Added comprehensive tests for types, constructors, operators, events, and fields, in addition to existing method and property tests. Utilized NUnit's [TestCase] for broader scenario coverage, including generics, explicit interface implementations, extension members, and operator overloads. Refactored test implementations to use reflection and metadata extraction for consistency and robustness. Updated assertions to ensure correct member type checks, improving type safety and test clarity. These changes significantly improve the reliability and maintainability of the XML documentation provider's test suite.
Revised XML documentation for extension properties to be more concise and general. Added internal static NamespaceDoc class to provide namespace-level documentation for Acme.
Enhanced canonical type resolution to compare generic parameter
declaring types by full name, ensuring correctness for nested
and complex generics. Updated tests to reflect the new logic.
Introduce IXmlDocResolver and XmlDocRepository to separate raw XML doc resolution from higher-level documentation provision. Move XML parsing, include, and inheritdoc logic to XmlDocRepository. Update XmlDocProvider to focus on parsed doc entries. Revise tests and documentation for improved modularity and testability.
Introduce IExtensionBlock abstraction and ExtensionBlockInfo to generalize extension member infrastructure. Refactor all extension-related APIs and adapters to use extension blocks instead of receiver parameters. Move member collection utilities to new MemberCollectionExtensions. Update tests and documentation accordingly. Add pluggable assembly factory to MetadataProvider. Bump dependencies. This enables richer, more maintainable extension member support.
- Introduce IExtensionBlockMemberInfo and related interfaces for block-based extension member reflection
- Add ExtensionBlockMethodInfo and ExtensionBlockPropertyInfo for logical views of extension members
- Remove legacy extension member interfaces/classes in favor of block-centric model
- Update IExtensionBlock, IAssembly, IClassType, and adapters to expose extension blocks and members directly
- Refactor ExtensionReflectionRepository and ExtensionContainerInfo to support new block model and robust member matching
- Update C# language formatting and tests for new extension member handling
- Move and modernize AttributeNames and ModifierNames constants
- Improve documentation, type safety, and null checks throughout the API
ExtensionBlockInfo now derives from MemberInfo, enabling extension blocks to participate fully in .NET reflection APIs. ExtensionBlockMethodInfo and ExtensionBlockPropertyInfo override all relevant members for accurate metadata and throw NotSupportedException for unsupported operations. Methods/Properties arrays are renamed for clarity. ExtensionBlockAdapter and IExtensionBlock are refactored to align with the new model, removing redundant properties and improving code reference logic. MemberAdapterRepository now caches ExtensionBlockInfo as MemberInfo. Improves consistency, discoverability, and documentation throughout extension block metadata handling.
Systematically replace the generic type parameter T with W in extension methods and member definitions in Acme.SampleExtensions, including XML docs. Update all related test cases to expect W instead of T for consistency across implementation and tests.
…e in method overrides

Refined the IsSatisfiableBy method to support covariant return types for non-interface members, enhancing method override compatibility. Updated XML documentation to clearly describe compatibility rules and scenarios, providing more precise guidance for implementers.
- Distinguish IsSubstitutableBy from IsAssignableFrom; document and implement strict parametric compatibility for signature matching.
- Thoroughly document IType.IsSubstitutableBy, listing precise compatibility rules and clarifying that variance/assignability are not considered.
- Update adapters to enforce stricter substitutability logic for generics and decorated types.
- Rename IWithExtensionBehavior.IsExtensionOf to Extends and update all usages.
- Add comprehensive IsSubstitutableBy test cases for class, struct, interface, enum, delegate, and decorator types.
- Refactor ParameterTests method names for clarity and consistency.
- Update Acme sample code and tests to reflect new method signatures and documentation.
- Improve overall type compatibility predictability and test coverage.
Remove IsSubstitutableBy from IType and adapters, introducing IsSatisfiableBy as an extension method for signature-matching scenarios. IsSubstitutableBy now only exists on ITypeParameter for constraint checks. All usages and tests updated to use IsSatisfiableBy, with new comprehensive tests added. Documentation updated to clarify the distinction between assignability (IsAssignableFrom) and signature satisfaction (IsSatisfiableBy), improving clarity and maintainability.
Renamed the Accepts method to IsDeclarationOriginOf in TypeParameterAdapter to better reflect its purpose of identifying the origin declaration of a type parameter. Updated XML documentation, variable names, and logic to match the new intent. Adjusted all relevant call sites and preserved existing logic for generic, nested, and interface type parameter relationships.
Refactor type parameter constraint checking by replacing IsSubstitutableBy with IsSatisfiableBy (including a new overload for type parameters). Remove the IsSatisfiableBy extension method on IType and update all usages to use more context-aware logic. Introduce AdapterHelper.IsValidTypeSubstitution to accurately determine valid type substitutions in method overrides and interface implementations, handling complex generic and inheritance scenarios. Update assignability and constraint logic in GenericCapableTypeAdapter and TypeParameterAdapter to reflect .NET variance and constraints. Adjust signature matching in PropertyAdapter, EventAdapter, and ParameterAdapter to use the new substitution logic. Update and expand tests for these changes. Remove obsolete or redundant code for improved clarity and correctness.
Simplify AdapterHelper.IsValidTypeSubstitution to use direct type parameter constraint checks and equality, removing complex generic hierarchy resolution. Update HasMatchingSignature methods to use a local compatibility helper. Improve TypeParameterAdapter constraint satisfaction and add an Equals override. Remove redundant unit tests for old logic and add comprehensive tests for type parameter satisfaction. Clarify IWithInterfaces.Interfaces documentation and fix test case references for generic members.
Simplify AdapterHelper.IsValidTypeSubstitution to use direct type parameter constraint checks and equality, removing complex generic hierarchy resolution. Update HasMatchingSignature methods to use a local compatibility helper. Improve TypeParameterAdapter constraint satisfaction and add an Equals override. Remove redundant unit tests for old logic and add comprehensive tests for type parameter satisfaction. Clarify IWithInterfaces.Interfaces documentation and fix test case references for generic members.
Extended IMemberAdapterRepository to handle ExtensionBlockInfo by invoking GetExtensionBlockMetadata, enabling processing of extension blocks alongside other member types.
Implemented sealed IsDirectDeclaration property in both
GenericCapableTypeAdapter and TypeParameterAdapter. The property
returns true for direct (non-constructed) generic types and false
for type parameters. Removed redundant implementation in
TypeParameterAdapter for clarity.
Refactored the IsAssignableFrom method in generic-capable type adapters to use pattern matching and local functions for each assignability scenario. Introduced a static helper for type argument constraint checks, improved performance with inlining, and removed redundant code for better readability and maintainability.
Renamed the UnqualifiedName property to SimpleName in the
IGenericCapableType interface and all related implementations.
Updated all references and documentation to use the new name,
clarifying that this property returns the type name without
the generic arity suffix.
Major overhaul of XML documentation provider infrastructure:
- Replace TryGetDoc with strongly-typed TryGetNamespaceDoc and TryGetMemberDoc in IXmlDocProvider.
- XmlDocProvider now wraps IXmlDocResolver and injects extension block docs for extension members.
- Add ExtensionBlock property to XmlDocEntry for <extensionblock> support.
- Refactor ExtensionBlockInfo for lazy loading and improved code reference handling.
- Remove legacy caching (XmlDocProviderCache) and related extension methods.
- Add XElementHelper.HasAttribute extension.
- Update tests and helpers for new API; add tests for extension block docs.
- Improves type safety, extensibility, and metadata integration.
Introduce ExtensionBlockModel and DocumentationModelType.ExtensionBlock to represent extension blocks. Update ClassModel to expose extension blocks from metadata. Refactor member collection initialization in CompositeTypeModel and EnumModel to use the Metadata property for consistency. Improve explicit interface member handling. These changes enable first-class documentation and querying of extension blocks.
Added a unit test case to ensure the XML documentation summary
for the FixedBuffer field in Acme.SampleFields is correctly
retrieved by TryGetMemberDoc_ForFields_ReturnsCorrectDoc.
…date StructTypeTests with additional test case

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request introduces version 2.0.0 with comprehensive support for C# extension blocks and extension members, updates to .NET 10, dependency version updates, and extensive test refactoring. The changes enhance the library's ability to extract and model modern C# language features while maintaining the existing pipeline architecture for documentation generation.

Key changes:

  • Added support for C# extension blocks and extension members with new metadata types and XML documentation elements
  • Updated target framework to .NET 10 and upgraded System.Reflection.MetadataLoadContext to version 10.0.1
  • Refactored test suite to use new test types in the Acme namespace, replacing the old TestTypes class
  • Added new tests for extension blocks, extension properties, and extension methods
  • Removed obsolete test files (XmlDocProviderCacheTests.cs, PrimitiveTypeTests.cs) and test helper types

Reviewed changes

Copilot reviewed 148 out of 149 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
tests/XmlDoc/XmlDocRepositoryTests.cs New test file covering XML documentation repository functionality with inheritance and inclusion scenarios
tests/XmlDoc/XmlDocProviderTests.cs Significantly expanded with comprehensive tests for all member types including extension blocks and members
tests/XmlDoc/XmlDocProviderCacheTests.cs Deleted - functionality likely consolidated elsewhere
tests/XmlDoc/XmlDocExtensionsTests.cs Updated to use new Acme test types and removed redundant tests
tests/XmlDoc/XmlDocEntryTests.cs Added test for new ExtensionBlock XML documentation element
tests/TestTypes.cs Deleted - replaced by more comprehensive Acme namespace test types
tests/Support/StringManipulationTests.cs Updated test names: ReplaceMany→ReplaceChars, RemoveMany→RemoveChars, added TranslateChars tests
tests/Support/StringBuilderPoolTests.cs Simplified tests, removed disposed object test, updated implicit conversion test
tests/Routing/SearchBasedApiDocUrlResolverTests.cs Updated test cases to use standard library types for explicit interface implementation examples
tests/MockHelper.cs Refactored to use XmlDocRepository and XmlDocProvider separately, updated mock method names
tests/Metadata/TypeParameterTests.cs Comprehensive updates with new Acme types, added IsSatisfiableBy tests (renamed from IsSubstitutableBy)
tests/Metadata/TypeDecoratorTests.cs Added edge case tests for array and pointer type comparisons
tests/Metadata/StructTypeTests.cs Extensively updated with nested generic struct tests and extension member tests
tests/Metadata/Reflection/ExtensionContainerInfoTests.cs New test file covering extension container functionality
tests/Metadata/PropertyTests.cs Comprehensive updates using Acme types with better coverage of property types and scenarios
tests/Metadata/PrimitiveTypeTests.cs Deleted - tests likely moved or unnecessary for the library's focus
tests/Metadata/ParameterTests.cs Significantly expanded with better parameter testing coverage including extension methods
tests/Metadata/OperatorTests.cs Expanded to cover compound assignment operators and interface operators
tests/Metadata/MethodTests.cs Comprehensive updates with extension method tests and interface method tests
tests/Metadata/MetadataProviderTests.cs Added extensive tests for extension method and property metadata retrieval
tests/Metadata/MetadataExtensionsTests.cs Updated with new Acme types and improved test assertions
tests/Metadata/MemberInfoComparerTests.cs Updated to use Acme types, simplified some test cases
tests/Metadata/MemberCollectionExtensionTests.cs New comprehensive test file for binary search and collection extension methods
tests/Metadata/InterfaceTypeTests.cs Extensively updated with nested interface tests and extension member tests
tests/Metadata/FieldTests.cs Updated with new field types and test patterns
tests/Metadata/EventTests.cs Updated with comprehensive event tests including explicit interface implementations
tests/Metadata/EnumTypeTests.cs Simplified with improved assertions
src/DocumentationModelType.cs Added ExtensionBlock enum value for the new extension block documentation model

Comment thread src/Metadata/Adapters/TypeParameterAdapter.cs Outdated
Comment thread tests/Metadata/Adapters/MemberAdaptorRepositoryTests.cs Outdated
Comment thread tests/Metadata/Adapters/MemberAdaptorRepositoryTests.cs Outdated
Comment thread tests/Metadata/Adapters/MemberAdaptorRepositoryTests.cs Outdated
Comment thread src/Metadata/Adapters/ClassTypeAdapter.cs Outdated
Comment thread src/Metadata/Adapters/TypeParameterAdapter.cs
Comment thread src/Metadata/Adapters/TypeParameterAdapter.cs
Comment thread src/Metadata/Adapters/PropertyAdapter.cs Outdated
Comment thread src/Metadata/MetadataProvider.cs Outdated
Comment thread tests/Acme.cs
Systematically apply the static modifier to lambda expressions and delegates in LINQ queries, Moq setups, and other delegate usages across the codebase and tests. This improves performance and code safety by preventing closures and reducing allocations. No functional changes were made.
Replaced '== true' with 'is true' in the IsInitOnly property implementation to enhance null safety and code clarity. This ensures the property only returns true when the modifier is explicitly present, and handles null values more robustly.
Renamed local variables in ClassTypeAdapter and TypeParameterAdapter for clarity. Enhanced HasDefaultConstructor to explicitly handle interfaces and enums. Simplified test setup in MemberAdaptorRepositoryTests by removing unnecessary mock object creation.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 154 out of 156 changed files in this pull request and generated 1 comment.

Comment thread src/Metadata/Adapters/ClassTypeAdapter.cs
Changed System.Reflection.MetadataLoadContext package reference from 10.0.1 to 10.0.* to automatically receive the latest patch updates within the 10.0 series. This helps ensure the project benefits from bug fixes and improvements without manual version updates.
@kampute
kampute merged commit 6ec45de into main Dec 17, 2025
1 check passed
@kampute
kampute deleted the v2.0.0 branch December 17, 2025 18:11
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.

3 participants