-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
area-Extensions-Logginglinkable-frameworkIssues associated with delivering a linker friendly frameworkIssues associated with delivering a linker friendly framework
Milestone
Description
ILlinker : Unrecognized reflection pattern warning IL2006: Microsoft.Extensions.Logging.ProviderAliasUtilities::GetAlias(System.Type): The return value of method 'System.Type System.Object::GetType()' with dynamically accessed member kinds 'None' is passed into the implicit 'this' parameter of method 'System.Reflection.PropertyInfo System.Type::GetProperty(System.String,System.Reflection.BindingFlags)' which requires dynamically accessed member kinds 'PublicProperties'. To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicProperties'. [C:\dev\git\aspnetcore\src\Hosting\test\testassets\BasicLinkedApp\BasicLinkedApp.csproj]
This is the logic:
Here's some linker friendlier logic:
internal static class ProviderAliasUtilities
{
private const string AliasAttibuteTypeFullName = "Microsoft.Extensions.Logging.ProviderAliasAttribute";
internal static string GetAlias(Type providerType)
{
foreach (var attributeData in providerType.GetCustomAttributesData())
{
if (attributeData.AttributeType.FullName == AliasAttibuteTypeFullName)
{
if (attributeData.ConstructorArguments.Count > 0)
{
return attributeData.ConstructorArguments[0].Value?.ToString();
}
}
}
return null;
}
}There are likely other provider specific issues but I haven't encountered those as yet.
cc @eerhardt
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-Extensions-Logginglinkable-frameworkIssues associated with delivering a linker friendly frameworkIssues associated with delivering a linker friendly framework