-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
Labels
area-Tools-ILLink.NET linker development as well as trimming analyzers.NET linker development as well as trimming analyzers
Milestone
Description
Description
The second usage of GetInterfaceMap causes
IL2072: 'interfaceType' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetInterfaceMap(Type)'. The return value of method 'System.Linq.Enumerable.First<TSource>(IEnumerable<TSource>)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
while the first usage doesn't cause any warning.
I am not sure whether it's how it's supposed to be or it's an actual bug.
Reproduction Steps
object o = new();
var type = o.GetType();
var @interface = type.GetInterfaces().First();
_ = type.GetInterfaceMap(@interface).TargetMethods;
_ = type.GetInterfaceMap(@interface);Expected behavior
I am not sure
Actual behavior
The warning is reported or not depending on whether some field is referenced or not
Regression?
No response
Known Workarounds
No response
Configuration
.NET 8
Other information
No response
Copilot
Metadata
Metadata
Labels
area-Tools-ILLink.NET linker development as well as trimming analyzers.NET linker development as well as trimming analyzers
Type
Projects
Status
No status