Skip to content

DataProtection isn't linker friendly #24705

@davidfowl

Description

@davidfowl

Here are the warnings:

C:\dev\git\aspnetcore\src\DataProtection\DataProtection\src\RegistryPolicyResolver.cs(40,47): Trim analysis warning IL2006: Microsoft.AspNetCore.DataProtection.RegistryPolicyResolver.PopulateOptions(Object,RegistryKey): The return value of method 'System.Object.GetType()' with dynamically accessed member kinds 'None' is passed into the implicit 'this' parameter of method 'System.Type.GetProperties()' which requires dynamically accessed member kinds 'PublicProperties'. To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicProperties'. [C:\Users\davifowl\source\repos\WebApplication60\WebApplication60\WebApplication60.csproj]
C:\dev\git\aspnetcore\src\DataProtection\DataProtection\src\RegistryPolicyResolver.cs(57,29): Trim analysis warning IL2006: Microsoft.AspNetCore.DataProtection.RegistryPolicyResolver.PopulateOptions(Object,RegistryKey): Reflection call 'System.Type.GetType(String,Boolean)' inside 'Microsoft.AspNetCore.DataProtection.RegistryPolicyResolver.PopulateOptions(Object,RegistryKey)' was detected with unknown value for the type name. [C:\Users\davifowl\source\repos\WebApplication60\WebApplication60\WebApplication60.csproj]
C:\dev\git\aspnetcore\src\DataProtection\DataProtection\src\RegistryPolicyResolver.cs(82,25): Trim analysis warning IL2006: Microsoft.AspNetCore.DataProtection.RegistryPolicyResolver.ReadKeyEscrowSinks(RegistryKey): Reflection call 'System.Type.GetType(String,Boolean)' inside 'Microsoft.AspNetCore.DataProtection.RegistryPolicyResolver.ReadKeyEscrowSinks(RegistryKey)' was detected with unknown value for the type name. [C:\Users\davifowl\source\repos\WebApplication60\WebApplication60\WebApplication60.csproj]
C:\dev\git\aspnetcore\src\DataProtection\DataProtection\src\SimpleActivator.cs(31,13): Trim analysis warning IL2006: Microsoft.AspNetCore.DataProtection.SimpleActivator.CreateInstance(Type,String): Reflection call 'System.Type.GetType(String,Boolean)' inside 'Microsoft.AspNetCore.DataProtection.SimpleActivator.CreateInstance(Type,String)' was detected with unknown value for the type name. [C:\Users\davifowl\source\repos\WebApplication60\WebApplication60\WebApplication60.csproj]
C:\dev\git\aspnetcore\src\DataProtection\DataProtection\src\SimpleActivator.cs(37,17): Trim analysis warning IL2006: Microsoft.AspNetCore.DataProtection.SimpleActivator.CreateInstance(Type,String): The return value of method 'System.Type.GetType(String,Boolean)' with dynamically accessed member kinds 'None' is passed into the implicit 'this' parameter of method 'System.Type.GetConstructor(Type[])' which requires dynamically accessed member kinds 'PublicParameterlessConstructor'. To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicParameterlessConstructor'. [C:\Users\davifowl\source\repos\WebApplication60\WebApplication60\WebApplication60.csproj]
C:\dev\git\aspnetcore\src\DataProtection\DataProtection\src\SimpleActivator.cs(40,21): Trim analysis warning IL2006: Microsoft.AspNetCore.DataProtection.SimpleActivator.CreateInstance(Type,String): The return value of method 'System.Type.GetType(String,Boolean)' with dynamically accessed member kinds 'None' is passed into the parameter #0 of method 'System.Object System.Activator::CreateInstance(System.Type)' which requires dynamically accessed member kinds 'PublicParameterlessConstructor'. To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicParameterlessConstructor'. [C:\Users\davifowl\source\repos\WebApplication60\WebApplication60\WebApplication60.csproj]
C:\dev\git\aspnetcore\src\DataProtection\DataProtection\src\SimpleActivator.cs(45,13): Trim analysis warning IL2006: Microsoft.AspNetCore.DataProtection.SimpleActivator.CreateInstance(Type,String): The return value of method 'System.Type.GetType(String,Boolean)' with dynamically accessed member kinds 'None' is passed into the implicit 'this' parameter of method 'System.Type.GetConstructor(Type[])' which requires dynamically accessed member kinds 'PublicConstructors'. To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicConstructors'. [C:\Users\davifowl\source\repos\WebApplication60\WebApplication60\WebApplication60.csproj]
C:\dev\git\aspnetcore\src\DataProtection\DataProtection\src\SimpleActivator.cs(53,13): Trim analysis warning IL2006: Microsoft.AspNetCore.DataProtection.SimpleActivator.CreateInstance(Type,String): The return value of method 'System.Type.GetType(String,Boolean)' with dynamically accessed member kinds 'None' is passed into the parameter #0 of method 'System.Object System.Activator::CreateInstance(System.Type)' which requires dynamically accessed member kinds 'PublicParameterlessConstructor'. To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicParameterlessConstructor'. [C:\Users\davifowl\source\repos\WebApplication60\WebApplication60\WebApplication60.csproj]
C:\dev\git\aspnetcore\src\DataProtection\DataProtection\src\TypeForwardingActivator.cs(54,17): Trim analysis warning IL2006: Microsoft.AspNetCore.DataProtection.TypeForwardingActivator.CreateInstance(Type,String,Boolean&): Reflection call 'System.Type.GetType(String,Boolean)' inside 'Microsoft.AspNetCore.DataProtection.TypeForwardingActivator.CreateInstance(Type,String,Boolean&)' was detected with unknown value for the type name. [C:\Users\davifowl\source\repos\WebApplication60\WebApplication60\WebApplication60.csproj]
C:\dev\git\aspnetcore\src\DataProtection\DataProtection\src\TypeForwardingActivator.cs(54,17): Trim analysis warning IL2006: Microsoft.AspNetCore.DataProtection.TypeForwardingActivator.CreateInstance(Type,String,Boolean&): Reflection call 'System.Type.GetType(String,Boolean)' inside 'Microsoft.AspNetCore.DataProtection.TypeForwardingActivator.CreateInstance(Type,String,Boolean&)' was detected with unknown value for the type name. [C:\Users\davifowl\source\repos\WebApplication60\WebApplication60\WebApplication60.csproj]
C:\dev\git\aspnetcore\src\DataProtection\DataProtection\src\AuthenticatedEncryption\ManagedAuthenticatedEncryptorFactory.cs(128,51): Trim analysis warning IL2006: Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ManagedAuthenticatedEncryptorFactory.AlgorithmActivator.AlgorithmActivatorCore<T>.AlgorithmActivatorCore`1(): The generic parameter 'T' from 'Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ManagedAuthenticatedEncryptorFactory.AlgorithmActivator.AlgorithmActivatorCore<T>' with dynamically accessed member kinds 'None' is passed into the generic parameter 'T' from 'System.Activator.CreateInstance<T>()' which requires dynamically accessed member kinds 'PublicParameterlessConstructor'. To fix this add DynamicallyAccessedMembersAttribute to it and specify at least these member kinds 'PublicParameterlessConstructor'. [C:\Users\davifowl\source\repos\WebApplication60\WebApplication60\WebApplication60.csproj]
C:\dev\git\aspnetcore\src\DataProtection\DataProtection\src\AuthenticatedEncryption\ConfigurationModel\ManagedAuthenticatedEncryptorDescriptorDeserializer.cs(73,17): Trim analysis warning IL2006: Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.ManagedAuthenticatedEncryptorDescriptorDeserializer.FriendlyNameToType(String): Reflection call 'System.Type.GetType(String,Boolean)' inside 'Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.ManagedAuthenticatedEncryptorDescriptorDeserializer.FriendlyNameToType(String)' was detected with unknown value for the type name. [C:\Users\davifowl\source\repos\WebApplication60\WebApplication60\WebApplication60.csproj]

Generally, DataProtection tries to load types from configuration, but these types are part of data protection itself so we can preserve these types so that loading works. Funnily enough, if we used the DI system, this wouldn't be a problem 😄

Components with dependencies on DataProtection:

  • Microsoft.AspNetCore.Authentication.Cookies
  • Microsoft.AspNetCore.Session
  • Microsoft.AspNetCore.Authentication
  • Microsoft.AspNetCore.Components.Web.Extensions
  • Microsoft.AspNetCore.Antiforgery
  • Microsoft.AspNetCore.Mvc.ViewFeatures
  • Microsoft.AspNetCore.Components.Server

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-fewThis issue impacts only small number of customersarea-dataprotectionIncludes: DataProtectionenhancementThis issue represents an ask for new feature or an enhancement to an existing onelinker-friendlinessTracking linker friendlinessseverity-blockingThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions