Conversation
Expand default constructor to include public, protected, and protected internal parameterless constructors. Update `IsDefaultConstructor` logic, documentation, and related comments. Adjust model logic to omit undocumented default constructors. Revise unit tests and option descriptions to reflect new definition.
Improve detection of compiler-generated bridge methods by handling generic methods as well. Include more tests to cover this scenario.
There was a problem hiding this comment.
Pull request overview
This pull request refines constructor and explicit interface implementation handling in the metadata and model layers, along with expanded test coverage for interface methods with in parameters. The changes improve how default constructors are identified and omitted from documentation, enhance compiler-generated bridge method detection for explicit interface implementations, and add comprehensive test cases for generic and non-generic interface methods with in parameters.
Key changes:
- Broadened the definition of "default constructor" to include public, protected, and protected internal parameterless constructors, and updated logic to omit undocumented default constructors from the model
- Enhanced bridge method detection in
CompositeTypeAdapter.IsCompilerGeneratedBridgeMethodto handle generic methods withinparameters and perform more accurate signature matching - Added test data and test cases for interface methods with
inparameters, including generic overloads and explicit implementations
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Metadata/IConstructor.cs | Updated IsDefaultConstructor definition to include protected and protected internal constructors |
| src/Models/CompositeTypeModel.cs | Modified constructor initialization to omit single undocumented default constructors from the collection |
| src/Metadata/Adapters/CompositeTypeAdapter.cs | Enhanced bridge method detection with separate handling for generic and non-generic methods, added helper methods for parameter matching |
| src/XmlDoc/XmlDocInspectionOptions.cs | Updated documentation comment to reflect broader definition of default constructors |
| tests/Acme.cs | Changed interface method parameter from int to decimal, added generic method overloads with in parameters, added operator overloads, and added indexer to test interface |
| tests/Metadata/ConstructorTests.cs | Updated test method names and consolidated test cases for default constructor detection, added overload count test |
| tests/Metadata/MethodTests.cs | Renamed test method and added overload count test for various method types |
| tests/Metadata/PropertyTests.cs | Added overload count test for indexers |
| tests/Metadata/OperatorTests.cs | Added overload count test for operators |
| tests/Metadata/ClassTypeTests.cs | Added expected method names for new interface method implementations |
| tests/Metadata/InterfaceTypeTests.cs | Added expected method names for new generic interface method overloads |
| tests/Metadata/StructTypeTests.cs | Added expected method names for new interface method implementations |
| tests/Languages/CSharpTests.cs | Removed test case for explicit interface implementation with in parameter |
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 several improvements and refinements to the handling of constructors and explicit interface implementations in the documentation toolkit. The changes enhance the accuracy of metadata extraction, reduce noise in generated documentation by omitting trivial constructors, and expand test coverage for complex interface scenarios. Additionally, the logic for identifying compiler-generated bridge methods for explicit interface implementations has been made more robust.
Constructor Handling Improvements:
IsDefaultConstructorinIConstructorto consider any non-static, parameterless constructor as default, regardless of visibility, and clarified the documentation accordingly.CompositeTypeModelso that if a type only has a default constructor with no documentation, it is omitted from the constructor collection, reducing clutter in generated documentation. [1] [2]TypeParameterAdapterto only consider constructors of accessible types and require that default constructors are public, ensuring more accurate filtering.Explicit Interface Implementation and Bridge Method Detection:
inparameters. The new approach checks for the presence ofinparameters and searches for corresponding public methods, improving accuracy and maintainability. [1] [2]Test Coverage and Sample Expansion:
Acme.csto cover generic interface methods withinparameters, overloads, and operator overloads, ensuring the toolkit correctly handles these scenarios. [1] [2] [3] [4] [5] [6]Build and Configuration Adjustments:
kampose.jsonassembly glob pattern to support all target frameworks, improving compatibility.2.0.1in the project file.This pull request introduces improvements and clarifications to the handling of constructors and explicit interface method implementations, especially those with in-parameters, in the metadata and model layers. It also updates and expands the test suite to cover these scenarios more thoroughly. The most important changes are grouped below.Constructor Handling Improvements
IsDefaultConstructorin theIConstructorinterface was updated to consider any non-static, parameterless constructor as default, regardless of visibility, and the remarks were clarified.TypeParameterAdapterwas updated to ensure only accessible, public, non-abstract types with public default constructors are considered, improving accuracy for generic constraints.CompositeTypeModelnow omits default constructors from its constructor collection if they are the only constructor and lack documentation, aligning with the new definition and reducing noise in metadata representations. [1] [2]Explicit Interface Implementation & Bridge Method Detection
CompositeTypeAdapterwas refactored and expanded. It now specifically checks for explicit interface implementations with in-parameters and properly matches generic and non-generic methods, improving metadata accuracy for these cases.System.Runtime.CompilerServiceswas added to enable method inlining.Test Suite Enhancements
Default Constructor Semantics and Accessibility:
IsDefaultConstructor) now ignores visibility, treating any instance parameterless constructor as default, regardless of its access modifier. This is reflected in both the interface and its documentation.CompositeTypeModelomits the default constructor from its collection if it is the only constructor and lacks documentation, treating it as implicit. [1] [2]Compiler-Generated Bridge Method Detection:
System.Runtime.CompilerServicesto support method inlining.Test Suite Enhancements:
Acme.csto include new interface methods and overloads with in parameters, as well as explicit and implicit implementations in various classes and interfaces. [1] [2] [3] [4] [5] [6]Documentation Improvements:
These changes collectively improve the accuracy of metadata representation, ensure more robust handling of C# language features, and provide better test coverage for edge cases.This pull request introduces several improvements and refinements to how constructors and explicit interface implementations are handled in the metadata and model layers, along with expanded and corrected test coverage. The main changes enhance the identification of default constructors, improve the exclusion of compiler-generated bridge methods, and add new test cases for generic and in-parameter interface methods.
Constructor handling improvements:
IsDefaultConstructorinIConstructorto include public, protected, and protected internal parameterless constructors, not just public ones. Updated remarks and logic accordingly.CompositeTypeModelso that if a type only has a default constructor with no documentation, it is omitted from the constructor list, treating it as implicit. [1] [2]Compiler-generated bridge method exclusion:
CompositeTypeAdapter.IsCompilerGeneratedBridgeMethodto more accurately detect and exclude compiler-generated bridge methods for explicit interface implementations withinparameters, including handling generic methods and matching signatures.System.Runtime.CompilerServicesimport forMethodImplOptions.AggressiveInliningused in helper methods.Test suite enhancements:
inparameters and their implementations, including generic overloads and explicit interface implementations. [1] [2] [3] [4] [5] [6]InterfaceMethodWithInParam).Other improvements:
ISampleExtendedConstructedGenericInterfacein the test suite for broader interface coverage.These changes collectively improve the accuracy and clarity of the metadata and documentation generation, especially around constructors and explicit interface methods involving advanced parameter types.