-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed as not planned
Labels
Description
Compile this code with NativeAOT and check linker report:
using System.ComponentModel;
using System.Reflection;
using System.Runtime.CompilerServices;
Console.WriteLine(GetDisplayName<MyClass>());
[MethodImpl(MethodImplOptions.NoInlining)]
static string? GetDisplayName<T>()
{
var attr = typeof(T).GetCustomAttribute<DisplayNameAttribute>();
return attr?.DisplayName;
}
[DisplayName("Test"), Dummy]
public class MyClass
{
}
public class DummyAttribute : Attribute
{
}Expected:
DymmyAttribute is not included into the final executable since it is "never" read (I guess GetCustomAttribute<T> enumerates all attributes to find the requested one, but this is an implementation detail and linker can be taught to be smarter about it)
Actual:
DymmyAttribute is included into the final executable
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status