Skip to content

Conversation

@Evangelink
Copy link
Member

@Evangelink Evangelink commented Feb 4, 2026

Fixes #3043

@Evangelink Evangelink marked this pull request as ready for review February 6, 2026 13:39
@Evangelink Evangelink enabled auto-merge February 6, 2026 13:39
# Conflicts:
#	src/Adapter/MSTestAdapter.PlatformServices/Services/ReflectionOperations.cs
#	test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Execution/TestPropertyAttributeTests.cs
#	test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Execution/TypeCacheTests.cs
#	test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Helpers/ReflectHelperTests.cs
…tion

# Conflicts:
#	src/Adapter/MSTestAdapter.PlatformServices/Services/ReflectionOperations.cs
#	src/Adapter/MSTestAdapter.PlatformServices/Services/TestDeployment.cs
#	src/Adapter/MSTestAdapter.PlatformServices/Utilities/DeploymentItemUtility.cs
#	src/Adapter/MSTestAdapter.PlatformServices/Utilities/DeploymentUtilityBase.cs
#	src/Adapter/MSTestAdapter.PlatformServices/Utilities/ReflectionOperationsNetFrameworkAttributeHelpers.cs
#	test/IntegrationTests/PlatformServices.Desktop.IntegrationTests/ReflectionUtilityTests.cs
#	test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/DesktopTestDeploymentTests.cs
#	test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Services/TestDeploymentTests.cs
#	test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/DeploymentItemUtilityTests.cs
#	test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/DeploymentUtilityTests.cs
#	test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Utilities/ReflectionUtilityTests.cs
Copy link
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

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

I guess we are good now that everything uses the caching ReflectHelper on current main?

(Except that we need to investigate if it's possible to simplify the implementation of reflection operations under .NET Framework)

// PERF: This was moved from Dictionary<MemberInfo, Dictionary<string, object>> to Concurrent<ICustomAttributeProvider, Attribute[]>
// storing an array allows us to store multiple attributes of the same type if we find them. It also has lower memory footprint, and is faster
// when we are going through the whole collection. Giving us overall better perf.
private readonly ConcurrentDictionary<ICustomAttributeProvider, Attribute[]> _attributeCache = [];
Copy link
Member

Choose a reason for hiding this comment

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

reflection operations itself isn't expected to be doing the caching, I think.

It was introduced only as a way to abstract how we do reflection (e.g, real reflection or something based on source generation). Then, reflection operations is supposed to be called by ReflectHelper which does the caching.

Copy link
Member Author

Choose a reason for hiding this comment

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

Does it change anything? We had 2 helpers for reflection and now we have a single one, that seems to be matching.

Copy link
Member

Choose a reason for hiding this comment

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

We had 2 helpers for reflection

Yup but mostly one that wraps the other and only one of them should be used by the rest of the product, not two separate helpers that are used across the product (as it was with ReflectHelper and ReflectionUtility before the past refactorings).

My concerns here are:

  • We might be complicating things when we want to introduce different reflection-like mechanisms, as we no longer have a centralized place that can do the caching.
  • The PR does more than unification, as it removes also the logic behind reflection-only assemblies, which I don't know exactly if it will have any impacts in any edge case scenarios. While it's a logic I would like to remove and simplify, I want to be 100% sure about it to avoid regressions.

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.

Unify ReflectionUtility and ReflectionHelper classes

2 participants