Skip to content

AoT Support #941

@Simonl9l

Description

@Simonl9l

Describe the feature

When using this Assembly in an AOT project we get the following Trim Warnings:

IL2057: Serilog.Settings.KeyValuePairs.SettingValueConversions.<>c.<.cctor>b__5_2(String): Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String,Boolean)'. It's not possible to guarantee the availability of the target type. 

IL2072: Serilog.Capturing.PropertyValueConverter.CreatePropertyValue(Object,Destructuring,Int32): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'Serilog.Capturing.PropertyValueConverter.TryConvertStructure(Object,Type,Destructuring,StructureValue&)'. The return value of method 'System.Object.GetType()' 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. 

IL2070: Serilog.Exceptions.Reflection.ReflectionInfoExtractor.GetExceptionPropertiesForDestructuring(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperties(BindingFlags)'. The parameter 'valueType' of method 'Serilog.Exceptions.Reflection.ReflectionInfoExtractor.GetExceptionPropertiesForDestructuring(Type)' 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. 

IL2026: Serilog.Exceptions.Destructurers.ExceptionDestructurer.DestructureCommonExceptionProperties(Exception,IExceptionPropertiesBag,Func`2<Exception,IReadOnlyDictionary`2<String,Object>>,Func`2<IDictionary,Object>): Using member 'System.Exception.TargetSite.get' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 

IL2026: Serilog.Exceptions.Destructurers.ExceptionDestructurer.DestructureCommonExceptionProperties(Exception,IExceptionPropertiesBag,Func`2<Exception,IReadOnlyDictionary`2<String,Object>>,Func`2<IDictionary,Object>): Using member 'System.Exception.TargetSite.get' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Metadata for the method might be incomplete or removed. 

Is there anything that you can do to fix this?

Whist we can declare this package as an AoT Root in out csproj, it won be great to get the issues cleanup if possible

Thansk!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIssues describing an enhancement or pull requests adding an enhancement.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions