[release/5.0] Use reflection-only context for InternalsVisibleToAttribute type comparison #4939
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.
Description
Backport fix from 6.0 to 5.0: Compilation error MC3064 when importing internal user control from signed class library.
Customer Impact
Internal types contained in assemblies with InternalsVisibleTo attributes that are referenced in markup cause a markup compiler error: error MC3064: Only public or internal classes can be used within markup. 'InternalClass' type is not public or internal.
Regression
This is a regression from .NET Framework.
Risk
Very low. This code is only exercised when WPF applications are compiled. This is a single-line change that has been in .NET 6.0 since February.
Testing
Repro'd the issue on release/5.0 when importing an internal user control from signed class library:
error MC3064: Only public or internal classes can be used within markup.
After applying the fix and rebuilding the WindowsDesktop SDK, referencing internal types in markup that are contained in an assembly with InternalsVisibleTo (which grants access to the target assembly) now works as expected when targeting .NET 5.0.