-
Notifications
You must be signed in to change notification settings - Fork 288
Unify ReflectionUtility and ReflectHelper to enable caching in deployment utilities #6815
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: Evangelink <[email protected]>
…loymentItemUtility to use ReflectHelper Co-authored-by: Evangelink <[email protected]>
…ions or ReflectHelper Co-authored-by: Evangelink <[email protected]>
Co-authored-by: Evangelink <[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.
@copilot some tests are broken, fix them:
@azure-pipelines
azure-pipelines
/ microsoft.testfx (Build Windows Debug)
test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/ns13ReflectionUtilityTests.cs#L50
test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/ns13ReflectionUtilityTests.cs(50,1): error : Verification failed for attributes.Length == 1 at line 50 of method 'GetCustomAttributesOnTypeShouldReturnAllAttributes' in file '/_/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/ns13ReflectionUtilityTests.cs'.
Check failure on line 63 in test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/ns13ReflectionUtilityTests.cs
@azure-pipelines
azure-pipelines
/ microsoft.testfx (Build Windows Debug)
test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/ns13ReflectionUtilityTests.cs#L63
test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/ns13ReflectionUtilityTests.cs(63,1): error : Verification failed for attributes.Length == 2 at line 63 of method 'GetCustomAttributesOnTypeShouldReturnAllAttributesWithBaseInheritance' in file '/_/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/ns13ReflectionUtilityTests.cs'.
Check failure on line 39 in test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/DesktopReflectionOperationsTests.cs
@azure-pipelines
azure-pipelines
/ microsoft.testfx (Build Windows Debug)
test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/DesktopReflectionOperationsTests.cs#L39
test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/DesktopReflectionOperationsTests.cs(39,1): error : Verification failed for attributes.Length == 1 at line 39 of method 'GetCustomAttributesOnTypeShouldReturnAllAttributes' in file '/_/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/DesktopReflectionOperationsTests.cs'.
Check failure on line 165 in test/Utilities/TestFramework.ForTestingMSTest/TestContainer.cs
@azure-pipelines
azure-pipelines
/ microsoft.testfx (Build Windows Debug)
test/Utilities/TestFramework.ForTestingMSTest/TestContainer.cs#L165
test/Utilities/TestFramework.ForTestingMSTest/TestContainer.cs(165,1): error : Verification failed for attributes.Length == 1 at line 50 of method 'GetCustomAttributesOnTypeShouldReturnAllAttributes' in file '/_/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/ns13ReflectionUtilityTests.cs'.
Check failure on line 165 in test/Utilities/TestFramework.ForTestingMSTest/TestContainer.cs
@azure-pipelines
azure-pipelines
/ microsoft.testfx (Build Windows Debug)
test/Utilities/TestFramework.ForTestingMSTest/TestContainer.cs#L165
test/Utilities/TestFramework.ForTestingMSTest/TestContainer.cs(165,1): error : Verification failed for attributes.Length == 2 at line 63 of method 'GetCustomAttributesOnTypeShouldReturnAllAttributesWithBaseInheritance' in file '/_/test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/ns13ReflectionUtilityTests.cs'.
…tes on non-NETFRAMEWORK Co-authored-by: Evangelink <[email protected]>
Fixed in dd36600. The issue was that on non-NETFRAMEWORK, I was calling |
Unify ReflectionUtility and ReflectHelper to enable caching in deployment utilities
DeploymentUtilitywas using direct reflection without caching, whileReflectHelperprovided cached attribute lookups viaConcurrentDictionary. The utilities couldn't useReflectHelperdue to namespace/access constraints.Changes
ReflectionUtilityimplementation intoReflectionOperationsservice layer (handles reflection-only load scenarios on .NET Framework)ReflectHelper.Instanceinstead ofReflectionUtility, enabling attribute cachingGetCustomAttributes(inherit: true)instead ofGetCustomAttributes(typeof(Attribute), inherit: true)to match original behavior on non-NETFRAMEWORKBefore/After
Test updates reflect the API changes from
GetCustomAttributes(memberInfo, typeof(T))toGetAttributes<T>(memberInfo).Fixes #3043
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.