-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Improve System.Reflection.Context.Tests code coverage from ~35% to 87% #123026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: stephentoub <[email protected]>
Co-authored-by: stephentoub <[email protected]>
Co-authored-by: stephentoub <[email protected]>
|
@Xopilot, it looks like you got most of the coverage numbers into the 80s but bra ch coverage is still at 70.14%. Could you focus on pushing that as close to 90% as possible? |
src/libraries/System.Reflection.Context/tests/CustomConstructorInfoTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Context/tests/CustomModuleTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: stephentoub <[email protected]>
Co-authored-by: stephentoub <[email protected]>
Branch coverage improved from 70.14% to 78.67% in commits b8087dd and 0986faf. Added tests targeting:
The remaining ~11% of uncovered branches are primarily in complex method lookup logic ( |
Co-authored-by: stephentoub <[email protected]>
src/libraries/System.Reflection.Context/tests/AttributeInheritanceTests.cs
Outdated
Show resolved
Hide resolved
…eedback Co-authored-by: stephentoub <[email protected]>
There was a problem hiding this 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 pull request adds comprehensive test coverage for the System.Reflection.Context library, increasing line coverage from approximately 35% to 87.12%. The PR includes 21 new test files containing 701 tests that exercise various aspects of the reflection context functionality including custom types, methods, constructors, events, properties, fields, parameters, modules, assemblies, method bodies, and attribute inheritance scenarios.
Key Changes:
- Added 21 new test files targeting different aspects of the System.Reflection.Context library
- Enhanced test assertions to validate expected behavior rather than using discard assignments
- Added tests for previously untested components like MethodBody, ExceptionHandlingClause, and LocalVariableInfo
- Included comprehensive branch coverage tests for Equals methods, null handling, and method/property lookup scenarios
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| System.Reflection.Context.Tests.csproj | Added 21 new test file references to the project |
| ProjectionConstants.cs | Added constants for ProjectingConstructorInfo and ProjectingMethodInfo |
| VirtualMethodBaseTests.cs | Tests for virtual property accessors and VirtualMethodBase coverage |
| MoreCoverageTests.cs | Tests for projector null handling and virtual property functionality |
| MethodLookupBranchTests.cs | Tests for method/property lookup with various binding flags |
| MethodBodyTests.cs | Tests for MethodBody, ExceptionHandlingClause, and LocalVariableInfo |
| FinalCoverageTests.cs | Tests for module methods, generic types, arrays, pointers, delegates |
| FinalCoverageTests2.cs | Tests for custom attributes methods across various reflection types |
| FinalBranchCoverageTests.cs | Tests for GetMethod, GetConstructor, GetFields with various scenarios |
| ExtendedTypeTests.cs | Comprehensive tests for type operations including generics and enums |
| ExtendedPropertyInfoTests.cs | Tests for property info operations and attributes |
| ExtendedFieldInfoTests.cs | Tests for field info operations and modifiers |
| ExtendedAssemblyTests.cs | Tests for assembly properties and methods |
| ExtendedAssemblyTests2.cs | Additional assembly tests for modules and resources |
| CustomTypeTests.cs | Extensive tests for custom type projection functionality |
| CustomParameterInfoTests.cs | Tests for parameter info including optional and out parameters |
| CustomModuleTests.cs | Tests for module operations and metadata |
| CustomMethodInfoTests.cs | Tests for method info properties and operations |
| CustomEventInfoTests.cs | Tests for event info operations |
| CustomConstructorInfoTests.cs | Tests for constructor info properties and invocation |
| CustomAttributeDataTests.cs | Tests for custom attribute data projection |
| BranchCoverageTests.cs | Tests for Equals methods and projection scenarios |
| BranchCoverageTests2.cs | Additional branch coverage tests for attributes and projection |
| AttributeInheritanceTests.cs | Tests for attribute inheritance behavior |
src/libraries/System.Reflection.Context/tests/AttributeInheritanceTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Context/tests/AttributeInheritanceTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Context/tests/AttributeInheritanceTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Context/tests/AttributeInheritanceTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Context/tests/BranchCoverageTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Context/tests/CustomModuleTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Context/tests/CustomModuleTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Reflection.Context/tests/CustomParameterInfoTests.cs
Show resolved
Hide resolved
src/libraries/System.Reflection.Context/tests/CustomParameterInfoTests.cs
Outdated
Show resolved
Hide resolved
|
@copilot please address all comments. Also please review all the tests you added in detail. The tests are increasing code coverage but they're not validating as much as they should be such that the code coverage numbers provide a falsely inflated measure of usefulness. |
Co-authored-by: stephentoub <[email protected]>
I've addressed all the review feedback in commit 42e9f3c:
All 649 tests pass. The branch coverage improvements from earlier commits remain in place. |
I've reviewed all tests and addressed the feedback from all comments:
All 649 tests pass.
Addressed in commit 9253c70. I've reviewed all tests and made the assertions more meaningful:
|
…edback Co-authored-by: stephentoub <[email protected]>
Summary
This PR significantly improves code coverage for System.Reflection.Context from approximately 35% to 87%+.
Changes in this update (per reviewer feedback)
Per @stephentoub's request to review all tests and make assertions more meaningful:
Assert.NotEqual(0, hashCode)to idempotency checks (Assert.Equal(hashCode1, hashCode2))Assert.NotNull(attrs)with specific assertions:Assert.Empty()for unattributed membersAssert.Contains()for members with expected attributesAssert.NotEmpty()for collections that should have itemsAssert.Single(members)withAssert.Equal("Item", members[0].Name))ReturnsEmptyForUnattributedField)All 649 tests pass.
Coverage Results
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.