Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various trimming warnings in DotNext.Metaprogramming #217

Open
alexrp opened this issue Jan 26, 2024 · 15 comments · May be fixed by #219
Open

Various trimming warnings in DotNext.Metaprogramming #217

alexrp opened this issue Jan 26, 2024 · 15 comments · May be fixed by #219
Assignees
Labels
enhancement New feature or request

Comments

@alexrp
Copy link

alexrp commented Jan 26, 2024

I just tried turning on trimming for my app, and noticed some warnings coming from DotNext.Metaprogramming:

    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(166,17): Trim analysis error IL2026: DotNext.Metaprogramming.MatchBuilder.<>c__DisplayClass16_0.<StructuralPattern>b__0(ParameterExpression): Using member 'System.Linq.Expressions.Expression.PropertyOrField(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(184,88): Trim analysis error IL2026: DotNext.Metaprogramming.MatchBuilder.<>c__DisplayClass18_0.<Case>b__0(ParameterExpression): Using member 'System.Linq.Expressions.Expression.PropertyOrField(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(196,113): Trim analysis error IL2026: DotNext.Metaprogramming.MatchBuilder.<>c__DisplayClass19_0.<Case>b__0(ParameterExpression): Using member 'System.Linq.Expressions.Expression.PropertyOrField(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(196,113): Trim analysis error IL2026: DotNext.Metaprogramming.MatchBuilder.<>c__DisplayClass19_0.<Case>b__0(ParameterExpression): Using member 'System.Linq.Expressions.Expression.PropertyOrField(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(210,142): Trim analysis error IL2026: DotNext.Metaprogramming.MatchBuilder.<>c__DisplayClass20_0.<Case>b__0(ParameterExpression): Using member 'System.Linq.Expressions.Expression.PropertyOrField(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(210,142): Trim analysis error IL2026: DotNext.Metaprogramming.MatchBuilder.<>c__DisplayClass20_0.<Case>b__0(ParameterExpression): Using member 'System.Linq.Expressions.Expression.PropertyOrField(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(210,142): Trim analysis error IL2026: DotNext.Metaprogramming.MatchBuilder.<>c__DisplayClass20_0.<Case>b__0(ParameterExpression): Using member 'System.Linq.Expressions.Expression.PropertyOrField(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/CollectionAccessExpression.cs(87,32): Trim analysis error IL2067: DotNext.Linq.Expressions.CollectionAccessExpression.<GetIndexers>d__5.MoveNext(): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'DotNext.Reflection.TypeExtensions.GetBaseTypes(Type, Boolean, Boolean)'. The parameter 'collection' of method 'DotNext.Linq.Expressions.CollectionAccessExpression.GetIndexers(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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/CollectionAccessExpression.cs(92,13): Trim analysis error IL2075: DotNext.Linq.Expressions.CollectionAccessExpression.<GetIndexers>d__5.MoveNext(): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'. The return value of method 'System.Collections.Generic.IEnumerator<T>.Current.get' 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.
    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(226,34): Trim analysis error IL2075: DotNext.Metaprogramming.MatchBuilder.<GetProperties>d__22.MoveNext(): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperties(BindingFlags)'. 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.
    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(232,31): Trim analysis error IL2075: DotNext.Metaprogramming.MatchBuilder.<GetProperties>d__22.MoveNext(): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields' in call to 'System.Type.GetFields(BindingFlags)'. 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/SliceExpression.cs(74,32): Trim analysis error IL2067: DotNext.Linq.Expressions.SliceExpression.<GetSliceMethods>d__3.MoveNext(): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'DotNext.Reflection.TypeExtensions.GetBaseTypes(Type, Boolean, Boolean)'. The parameter 'collection' of method 'DotNext.Linq.Expressions.SliceExpression.GetSliceMethods(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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/SliceExpression.cs(76,36): Trim analysis error IL2075: DotNext.Linq.Expressions.SliceExpression.<GetSliceMethods>d__3.MoveNext(): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'System.Type.FindMembers(MemberTypes, BindingFlags, MemberFilter, Object)'. The return value of method 'System.Collections.Generic.IEnumerator<T>.Current.get' 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.
    /_/src/DotNext.Metaprogramming/Metaprogramming/AsyncLambdaExpression.cs(23,9): Trim analysis error IL2091: DotNext.Metaprogramming.AsyncLambdaExpression<TDelegate>.AsyncLambdaExpression`1(Boolean): 'TDelegate' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in 'DotNext.Reflection.DelegateType.GetInvokeMethod<TDelegate>()'. The generic parameter 'TDelegate' of 'DotNext.Metaprogramming.AsyncLambdaExpression<TDelegate>' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/AsyncResultExpression.cs(91,9): Trim analysis error IL2075: DotNext.Linq.Expressions.AsyncResultExpression.Reduce(ParameterExpression, LabelTarget): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachine.cs(166,9): Trim analysis error IL2091: DotNext.Runtime.CompilerServices.AsyncStateMachine<TState>.MoveNext<TAwaiter>(TAwaiter&, UInt32): 'TAwaiter' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in 'DotNext.Runtime.CompilerServices.Awaiter<TAwaiter>'. The generic parameter 'TAwaiter' of 'DotNext.Runtime.CompilerServices.AsyncStateMachine<TState>.MoveNext<TAwaiter>(TAwaiter&, UInt32)' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachine.cs(166,9): Trim analysis error IL2091: DotNext.Runtime.CompilerServices.AsyncStateMachine<TState>.MoveNext<TAwaiter>(TAwaiter&, UInt32): 'TAwaiter' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in 'DotNext.Runtime.CompilerServices.Awaiter<TAwaiter>.IsCompletedGetter'. The generic parameter 'TAwaiter' of 'DotNext.Runtime.CompilerServices.AsyncStateMachine<TState>.MoveNext<TAwaiter>(TAwaiter&, UInt32)' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachine.cs(351,9): Trim analysis error IL2091: DotNext.Runtime.CompilerServices.AsyncStateMachine<TState,TResult>.MoveNext<TAwaiter>(TAwaiter&, UInt32): 'TAwaiter' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in 'DotNext.Runtime.CompilerServices.Awaiter<TAwaiter>'. The generic parameter 'TAwaiter' of 'DotNext.Runtime.CompilerServices.AsyncStateMachine<TState,TResult>.MoveNext<TAwaiter>(TAwaiter&, UInt32)' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachine.cs(351,9): Trim analysis error IL2091: DotNext.Runtime.CompilerServices.AsyncStateMachine<TState,TResult>.MoveNext<TAwaiter>(TAwaiter&, UInt32): 'TAwaiter' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in 'DotNext.Runtime.CompilerServices.Awaiter<TAwaiter>.IsCompletedGetter'. The generic parameter 'TAwaiter' of 'DotNext.Runtime.CompilerServices.AsyncStateMachine<TState,TResult>.MoveNext<TAwaiter>(TAwaiter&, UInt32)' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachineBuilder.cs(444,9): Trim analysis error IL2091: DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.AsyncStateMachineBuilder`1(IReadOnlyList<ParameterExpression>): 'TDelegate' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in 'DotNext.Reflection.DelegateType.GetInvokeMethod<TDelegate>()'. The generic parameter 'TDelegate' of 'DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachineBuilder.cs(495,9): Trim analysis error IL2075: DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.Build(LambdaExpression): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachineBuilder.cs(449,12): Trim analysis error IL2067: DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.BuildTransitionDelegate(Type): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'DotNext.Reflection.TypeExtensions.GetGenericArguments(Type, Type)'. The parameter 'stateMachineType' of method 'DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.BuildTransitionDelegate(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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachineBuilder.cs(449,12): Trim analysis error IL2055: DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.BuildTransitionDelegate(Type): Call to 'System.Type.MakeGenericType(Type[])' can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic type.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/AwaitExpression.cs(38,13): Trim analysis error IL2075: DotNext.Linq.Expressions.AwaitExpression.AwaitExpression(Expression, Boolean): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/AwaitExpression.cs(44,9): Trim analysis error IL2075: DotNext.Linq.Expressions.AwaitExpression.AwaitExpression(Expression, Boolean): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/AwaitExpression.cs(46,9): Trim analysis error IL2075: DotNext.Linq.Expressions.AwaitExpression.AwaitExpression(Expression, Boolean): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(573,17): Trim analysis error IL2026: DotNext.Metaprogramming.MatchBuilder.MatchByThreeMembersStatement.CaseStatementBuilder.DotNext.ISupplier<System.Linq.Expressions.ParameterExpression,System.Linq.Expressions.Expression>.Invoke(ParameterExpression): Using member 'System.Linq.Expressions.Expression.PropertyOrField(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(529,17): Trim analysis error IL2026: DotNext.Metaprogramming.MatchBuilder.MatchByTwoMembersStatement.CaseStatementBuilder.DotNext.ISupplier<System.Linq.Expressions.ParameterExpression,System.Linq.Expressions.Expression>.Invoke(ParameterExpression): Using member 'System.Linq.Expressions.Expression.PropertyOrField(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(488,17): Trim analysis error IL2026: DotNext.Metaprogramming.MatchBuilder.MatchByMemberStatement.CaseStatementBuilder.DotNext.ISupplier<System.Linq.Expressions.ParameterExpression,System.Linq.Expressions.Expression>.Invoke(ParameterExpression): Using member 'System.Linq.Expressions.Expression.PropertyOrField(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(529,17): Trim analysis error IL2026: DotNext.Metaprogramming.MatchBuilder.MatchByTwoMembersStatement.CaseStatementBuilder.DotNext.ISupplier<System.Linq.Expressions.ParameterExpression,System.Linq.Expressions.Expression>.Invoke(ParameterExpression): Using member 'System.Linq.Expressions.Expression.PropertyOrField(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(573,17): Trim analysis error IL2026: DotNext.Metaprogramming.MatchBuilder.MatchByThreeMembersStatement.CaseStatementBuilder.DotNext.ISupplier<System.Linq.Expressions.ParameterExpression,System.Linq.Expressions.Expression>.Invoke(ParameterExpression): Using member 'System.Linq.Expressions.Expression.PropertyOrField(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Metaprogramming/MatchBuilder.cs(573,17): Trim analysis error IL2026: DotNext.Metaprogramming.MatchBuilder.MatchByThreeMembersStatement.CaseStatementBuilder.DotNext.ISupplier<System.Linq.Expressions.ParameterExpression,System.Linq.Expressions.Expression>.Invoke(ParameterExpression): Using member 'System.Linq.Expressions.Expression.PropertyOrField(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/ClosureAnalyzer.cs(29,13): Trim analysis error IL2026: DotNext.Runtime.CompilerServices.ClosureAnalyzer.Visit(Expression): Using member 'System.Linq.Expressions.Expression.Field(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/CollectionAccessExpression.cs(117,13): Trim analysis error IL2072: DotNext.Linq.Expressions.CollectionAccessExpression.Type.get: 'collectionType' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'DotNext.Reflection.CollectionType.GetItemType(Type)'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/CollectionAccessExpression.cs(72,32): Trim analysis error IL2067: DotNext.Linq.Expressions.CollectionAccessExpression.GetCountProperty(Type): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'DotNext.Reflection.TypeExtensions.GetBaseTypes(Type, Boolean, Boolean)'. The parameter 'collection' of method 'DotNext.Linq.Expressions.CollectionAccessExpression.GetCountProperty(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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/CollectionAccessExpression.cs(74,13): Trim analysis error IL2075: DotNext.Linq.Expressions.CollectionAccessExpression.GetCountProperty(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'. The return value of method 'System.Collections.Generic.IEnumerator<T>.Current.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/CollectionAccessExpression.cs(77,13): Trim analysis error IL2075: DotNext.Linq.Expressions.CollectionAccessExpression.GetCountProperty(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'. The return value of method 'System.Collections.Generic.IEnumerator<T>.Current.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1461,9): Trim analysis error IL2075: DotNext.Linq.Expressions.ExpressionBuilder.AsResult(Expression): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'System.Type.GetConstructor(Type[])'. The return value of method 'System.Reflection.MemberInfo.DeclaringType.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(747,9): Trim analysis error IL2070: DotNext.Linq.Expressions.ExpressionBuilder.Call(Expression, Type, String, Expression[]): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, Type[])'. The parameter 'interfaceType' of method 'DotNext.Linq.Expressions.ExpressionBuilder.Call(Expression, Type, String, Expression[])' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(761,9): Trim analysis error IL2070: DotNext.Linq.Expressions.ExpressionBuilder.CallStatic(Type, String, Expression[]): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])'. The parameter 'type' of method 'DotNext.Linq.Expressions.ExpressionBuilder.CallStatic(Type, String, Expression[])' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(943,13): Trim analysis error IL2026: DotNext.Linq.Expressions.ExpressionBuilder.Count(Expression): Using member 'System.Linq.Expressions.Expression.Property(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(944,9): Trim analysis error IL2072: DotNext.Linq.Expressions.ExpressionBuilder.Count(Expression): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'DotNext.Reflection.CollectionType.GetImplementedCollection(Type)'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(945,9): Trim analysis error IL2072: DotNext.Linq.Expressions.ExpressionBuilder.Count(Expression): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties', 'DynamicallyAccessedMemberTypes.NonPublicProperties' in call to 'System.Linq.Expressions.Expression.Property(Expression, Type, String)'. The return value of method 'DotNext.Reflection.CollectionType.GetImplementedCollection(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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(876,12): Trim analysis error IL2026: DotNext.Linq.Expressions.ExpressionBuilder.Field(Expression, String): Using member 'System.Linq.Expressions.Expression.Field(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1479,9): Trim analysis error IL2026: DotNext.Linq.Expressions.ExpressionBuilder.MakeIndex(Expression, Expression[]): Using member 'System.Linq.Expressions.Expression.Property(Expression, String, Expression[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1142,13): Trim analysis error IL2067: DotNext.Linq.Expressions.ExpressionBuilder.New(Type, Expression[]): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Linq.Expressions.Expression.New(Type)'. The parameter 'type' of method 'DotNext.Linq.Expressions.ExpressionBuilder.New(Type, Expression[])' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2111: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Method 'System.Activator.CreateInstance(Type, Object[])' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2111: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Method 'System.Activator.CreateInstance(Type, BindingFlags, Binder, Object[], CultureInfo, Object[])' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2026: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Using member 'System.Activator.CreateInstance(String, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Type and its constructor could be removed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2111: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Method 'System.Activator.CreateInstance(Type, BindingFlags, Binder, Object[], CultureInfo)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2111: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Method 'System.Activator.CreateInstance(Type)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2111: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Method 'System.Activator.CreateInstance(Type, Object[], Object[])' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2026: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Using member 'System.Activator.CreateInstance(String, String, Object[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Type and its constructor could be removed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2111: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Method 'System.Activator.CreateInstance(Type, Boolean)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2026: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Using member 'System.Activator.CreateInstance(String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Type and its constructor could be removed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1144,9): Trim analysis error IL2070: DotNext.Linq.Expressions.ExpressionBuilder.New(Type, Expression[]): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'System.Type.GetConstructor(Type[])'. The parameter 'type' of method 'DotNext.Linq.Expressions.ExpressionBuilder.New(Type, Expression[])' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2026: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Using member 'System.Activator.CreateInstance(String, String, Object[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Type and its constructor could be removed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2111: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Method 'System.Activator.CreateInstance(Type, BindingFlags, Binder, Object[], CultureInfo, Object[])' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2026: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Using member 'System.Activator.CreateInstanceFrom(String, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Type and its constructor could be removed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2026: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Using member 'System.Activator.CreateInstance(String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Type and its constructor could be removed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2111: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Method 'System.Activator.CreateInstance(Type, Boolean)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2026: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Using member 'System.Activator.CreateInstance(String, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Type and its constructor could be removed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2111: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Method 'System.Activator.CreateInstance(Type, BindingFlags, Binder, Object[], CultureInfo)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2026: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Using member 'System.Activator.CreateInstanceFrom(String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Type and its constructor could be removed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2026: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Using member 'System.Activator.CreateInstanceFrom(String, String, Object[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Type and its constructor could be removed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2111: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Method 'System.Activator.CreateInstance(Type)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2111: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Method 'System.Activator.CreateInstance(Type, Object[], Object[])' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1209,9): Trim analysis error IL2111: DotNext.Linq.Expressions.ExpressionBuilder.New(Expression, Expression[]): Method 'System.Activator.CreateInstance(Type, Object[])' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(838,12): Trim analysis error IL2026: DotNext.Linq.Expressions.ExpressionBuilder.Property(Expression, String): Using member 'System.Linq.Expressions.Expression.Property(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(823,9): Trim analysis error IL2070: DotNext.Linq.Expressions.ExpressionBuilder.Property(Expression, Type, String, Expression, Expression[]): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'. The parameter 'interfaceType' of method 'DotNext.Linq.Expressions.ExpressionBuilder.Property(Expression, Type, String, Expression, Expression[])' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(804,9): Trim analysis error IL2070: DotNext.Linq.Expressions.ExpressionBuilder.Property(Expression, Type, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String, BindingFlags)'. The parameter 'interfaceType' of method 'DotNext.Linq.Expressions.ExpressionBuilder.Property(Expression, Type, String)' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(852,12): Trim analysis error IL2026: DotNext.Linq.Expressions.ExpressionBuilder.Property(Expression, String, Expression, Expression[]): Using member 'System.Linq.Expressions.Expression.Property(Expression, String, Expression[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ForEachExpression.cs(70,9): Trim analysis error IL2072: DotNext.Linq.Expressions.ForEachExpression.ForEachExpression(Expression, Expression, Boolean, LabelTarget, LabelTarget): 'collectionType' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'DotNext.Reflection.CollectionType.GetItemType(Type, Type&)'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ForEachExpression.cs(41,9): Trim analysis error IL2072: DotNext.Linq.Expressions.ForEachExpression.ForEachExpression(Expression, LabelTarget, LabelTarget): 'collectionType' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'DotNext.Reflection.CollectionType.GetItemType(Type, Type&)'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ForEachExpression.cs(47,13): Trim analysis error IL2075: DotNext.Linq.Expressions.ForEachExpression.ForEachExpression(Expression, LabelTarget, LabelTarget): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, Type[])'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ForEachExpression.cs(49,13): Trim analysis error IL2026: DotNext.Linq.Expressions.ForEachExpression.ForEachExpression(Expression, LabelTarget, LabelTarget): Using member 'System.Linq.Expressions.Expression.Call(Expression, String, Type[], Expression[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ForEachExpression.cs(87,9): Trim analysis error IL2026: DotNext.Linq.Expressions.ForEachExpression.ForEachExpression(Expression, Expression, Boolean, LabelTarget, LabelTarget): Using member 'System.Linq.Expressions.Expression.Property(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ForEachExpression.cs(62,9): Trim analysis error IL2026: DotNext.Linq.Expressions.ForEachExpression.ForEachExpression(Expression, LabelTarget, LabelTarget): Using member 'System.Linq.Expressions.Expression.Property(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ForEachExpression.cs(213,13): Trim analysis error IL2072: DotNext.Linq.Expressions.ForEachExpression.Reduce(): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'DotNext.Reflection.DisposableType.GetDisposeAsyncMethod(Type)'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ForEachExpression.cs(219,13): Trim analysis error IL2072: DotNext.Linq.Expressions.ForEachExpression.Reduce(): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'DotNext.Reflection.DisposableType.GetDisposeMethod(Type)'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/InterpolatedStringTemplateBuilder.cs(175,9): Trim analysis error IL2075: DotNext.Runtime.CompilerServices.InterpolatedStringTemplateBuilder.Build(): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'System.Type.GetConstructor(Type[])'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/InterpolatedStringTemplateBuilder.cs(177,9): Trim analysis error IL2026: DotNext.Runtime.CompilerServices.InterpolatedStringTemplateBuilder.Build(): Using member 'System.Linq.Expressions.Expression.Property(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/InterpolatedStringTemplateBuilder.cs(184,9): Trim analysis error IL2075: DotNext.Runtime.CompilerServices.InterpolatedStringTemplateBuilder.Build(): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'System.Type.GetConstructor(Type[])'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/InterpolatedStringTemplateBuilder.cs(205,9): Trim analysis error IL2026: DotNext.Runtime.CompilerServices.InterpolatedStringTemplateBuilder.Build(): Using member 'System.Linq.Expressions.Expression.Call(Expression, String, Type[], Expression[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/InterpolatedStringTemplateBuilder.cs(209,9): Trim analysis error IL2026: DotNext.Runtime.CompilerServices.InterpolatedStringTemplateBuilder.Build(): Using member 'System.Linq.Expressions.Expression.Call(Expression, String, Type[], Expression[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ItemIndexExpression.cs(68,12): Trim analysis error IL2026: DotNext.Linq.Expressions.ItemIndexExpression.GetOffset(Expression, Expression): Using member 'System.Linq.Expressions.Expression.Call(Expression, String, Type[], Expression[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Metaprogramming/LambdaExpression.cs(59,9): Trim analysis error IL2091: DotNext.Metaprogramming.LambdaExpression<TDelegate>.LambdaExpression`1(Boolean): 'TDelegate' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in 'DotNext.Reflection.DelegateType.GetInvokeMethod<TDelegate>()'. The generic parameter 'TDelegate' of 'DotNext.Metaprogramming.LambdaExpression<TDelegate>' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/MemberBindings.cs(28,9): Trim analysis error IL2070: DotNext.Linq.Expressions.MemberBindings.Bind(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.All' in call to 'System.Type.FindMembers(MemberTypes, BindingFlags, MemberFilter, Object)'. The parameter 'target' of method 'DotNext.Linq.Expressions.MemberBindings.Bind(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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/MetaExpression.cs(18,5): Trim analysis error IL2026: DotNext.Linq.Expressions.MetaExpression..cctor(): Using member 'System.Linq.Expressions.Expression.PropertyOrField(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/MoveNextExpression.cs(34,9): Trim analysis error IL2075: DotNext.Runtime.CompilerServices.MoveNextExpression.Reduce(ParameterExpression): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, Int32, BindingFlags, Binder, Type[], ParameterModifier[])'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/MoveNextExpression.cs(34,9): Trim analysis error IL2060: DotNext.Runtime.CompilerServices.MoveNextExpression.Reduce(ParameterExpression): Call to 'System.Reflection.MethodInfo.MakeGenericMethod(Type[])' can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/MutationExpression.cs(34,17): Trim analysis error IL2075: DotNext.Linq.Expressions.MutationExpression.MutationExpression(Expression, IReadOnlyList<MemberAssignment>): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags, Type[])'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachine.Pooling.cs(166,9): Trim analysis error IL2091: DotNext.Runtime.CompilerServices.PoolingAsyncStateMachine<TState>.MoveNext<TAwaiter>(TAwaiter&, UInt32): 'TAwaiter' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in 'DotNext.Runtime.CompilerServices.Awaiter<TAwaiter>'. The generic parameter 'TAwaiter' of 'DotNext.Runtime.CompilerServices.PoolingAsyncStateMachine<TState>.MoveNext<TAwaiter>(TAwaiter&, UInt32)' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachine.Pooling.cs(166,9): Trim analysis error IL2091: DotNext.Runtime.CompilerServices.PoolingAsyncStateMachine<TState>.MoveNext<TAwaiter>(TAwaiter&, UInt32): 'TAwaiter' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in 'DotNext.Runtime.CompilerServices.Awaiter<TAwaiter>.IsCompletedGetter'. The generic parameter 'TAwaiter' of 'DotNext.Runtime.CompilerServices.PoolingAsyncStateMachine<TState>.MoveNext<TAwaiter>(TAwaiter&, UInt32)' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachine.Pooling.cs(351,9): Trim analysis error IL2091: DotNext.Runtime.CompilerServices.PoolingAsyncStateMachine<TState,TResult>.MoveNext<TAwaiter>(TAwaiter&, UInt32): 'TAwaiter' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in 'DotNext.Runtime.CompilerServices.Awaiter<TAwaiter>'. The generic parameter 'TAwaiter' of 'DotNext.Runtime.CompilerServices.PoolingAsyncStateMachine<TState,TResult>.MoveNext<TAwaiter>(TAwaiter&, UInt32)' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachine.Pooling.cs(351,9): Trim analysis error IL2091: DotNext.Runtime.CompilerServices.PoolingAsyncStateMachine<TState,TResult>.MoveNext<TAwaiter>(TAwaiter&, UInt32): 'TAwaiter' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in 'DotNext.Runtime.CompilerServices.Awaiter<TAwaiter>.IsCompletedGetter'. The generic parameter 'TAwaiter' of 'DotNext.Runtime.CompilerServices.PoolingAsyncStateMachine<TState,TResult>.MoveNext<TAwaiter>(TAwaiter&, UInt32)' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/RangeExpression.cs(41,12): Trim analysis error IL2026: DotNext.Linq.Expressions.RangeExpression.GetOffsetAndLength(Expression, Expression): Using member 'System.Linq.Expressions.Expression.Call(Expression, String, Type[], Expression[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/RangeExpression.cs(47,9): Trim analysis error IL2026: DotNext.Linq.Expressions.RangeExpression.GetOffsetAndLength(Expression, Expression, ParameterExpression&, MemberExpression&, MemberExpression&): Using member 'System.Linq.Expressions.Expression.Field(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/RangeExpression.cs(48,9): Trim analysis error IL2026: DotNext.Linq.Expressions.RangeExpression.GetOffsetAndLength(Expression, Expression, ParameterExpression&, MemberExpression&, MemberExpression&): Using member 'System.Linq.Expressions.Expression.Field(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/RecoverFromExceptionExpression.cs(24,9): Trim analysis error IL2075: DotNext.Runtime.CompilerServices.RecoverFromExceptionExpression.Reduce(ParameterExpression): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/RecoverFromExceptionExpression.cs(26,9): Trim analysis error IL2060: DotNext.Runtime.CompilerServices.RecoverFromExceptionExpression.Reduce(ParameterExpression): Call to 'System.Reflection.MethodInfo.MakeGenericMethod(Type[])' can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/InterpolatedStringTemplateBuilder.cs(50,17): Trim analysis error IL2026: DotNext.Runtime.CompilerServices.InterpolatedStringTemplateBuilder.Segment.WriteStatement(IList<Expression>, ParameterExpression, ParameterExpression, ParameterExpression&): Using member 'System.Linq.Expressions.Expression.Call(Expression, String, Type[], Expression[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/InterpolatedStringTemplateBuilder.cs(59,17): Trim analysis error IL2026: DotNext.Runtime.CompilerServices.InterpolatedStringTemplateBuilder.Segment.WriteStatement(IList<Expression>, ParameterExpression, ParameterExpression, ParameterExpression&): Using member 'System.Linq.Expressions.Expression.Call(Expression, String, Type[], Expression[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/SliceExpression.cs(102,9): Trim analysis error IL2111: DotNext.Linq.Expressions.SliceExpression.SubArray(Expression, Expression): Method 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(Type)' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/SliceExpression.cs(102,9): Trim analysis error IL2026: DotNext.Linq.Expressions.SliceExpression.SubArray(Expression, Expression): Using member 'System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(RuntimeTypeHandle)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimmer can't guarantee existence of class constructor.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachineBuilder.cs(523,17): Trim analysis error IL2070: DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.StateMachineBuilder.Build(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Type.MakeGenericType(Type[])'. The parameter 'stateType' of method 'DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.StateMachineBuilder.Build(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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachineBuilder.cs(523,17): Trim analysis error IL2070: DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.StateMachineBuilder.Build(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Type.MakeGenericType(Type[])'. The parameter 'stateType' of method 'DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.StateMachineBuilder.Build(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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachineBuilder.cs(528,17): Trim analysis error IL2070: DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.StateMachineBuilder.Build(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Type.MakeGenericType(Type[])'. The parameter 'stateType' of method 'DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.StateMachineBuilder.Build(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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachineBuilder.cs(528,17): Trim analysis error IL2070: DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.StateMachineBuilder.Build(Type): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Type.MakeGenericType(Type[])'. The parameter 'stateType' of method 'DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.StateMachineBuilder.Build(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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachineBuilder.cs(528,17): Trim analysis error IL2055: DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.StateMachineBuilder.Build(Type): Call to 'System.Type.MakeGenericType(Type[])' can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic type.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/AsyncStateMachineBuilder.cs(528,17): Trim analysis error IL2055: DotNext.Runtime.CompilerServices.AsyncStateMachineBuilder<TDelegate>.StateMachineBuilder.Build(Type): Call to 'System.Type.MakeGenericType(Type[])' can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic type.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/TaskType.cs(40,13): Trim analysis error IL2067: DotNext.Runtime.CompilerServices.TaskType.TaskType(Type): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'DotNext.Reflection.TypeExtensions.IsGenericInstanceOf(Type, Type)'. The parameter 'taskType' of method 'DotNext.Runtime.CompilerServices.TaskType.TaskType(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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/TaskType.cs(41,17): Trim analysis error IL2067: DotNext.Runtime.CompilerServices.TaskType.TaskType(Type): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'DotNext.Reflection.TypeExtensions.GetGenericArguments(Type, Type)'. The parameter 'taskType' of method 'DotNext.Runtime.CompilerServices.TaskType.TaskType(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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/TaskType.cs(48,12): Trim analysis error IL2026: DotNext.Runtime.CompilerServices.TaskType.AdjustTaskType(MethodCallExpression): Using member 'System.Linq.Expressions.Expression.Call(Expression, String, Type[], Expression[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/UsingExpression.cs(29,9): Trim analysis error IL2072: DotNext.Linq.Expressions.UsingExpression.UsingExpression(Expression): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'DotNext.Reflection.DisposableType.GetDisposeMethod(Type)'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/UsingExpression.cs(43,9): Trim analysis error IL2072: DotNext.Linq.Expressions.UsingExpression.UsingExpression(Expression, Boolean): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'DotNext.Reflection.DisposableType.GetDisposeAsyncMethod(Type)'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/ValueTupleBuilder.cs(42,13): Trim analysis error IL2026: DotNext.Runtime.CompilerServices.ValueTupleBuilder.Build(Expression, Span<MemberExpression>): Using member 'System.Linq.Expressions.Expression.Field(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/ValueTupleBuilder.cs(45,13): Trim analysis error IL2026: DotNext.Runtime.CompilerServices.ValueTupleBuilder.Build(Expression, Span<MemberExpression>): Using member 'System.Linq.Expressions.Expression.Field(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Runtime/CompilerServices/ValueTupleBuilder.cs(36,14): Trim analysis error IL2075: DotNext.Runtime.CompilerServices.ValueTupleBuilder.Build(): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Type.MakeGenericType(Type[])'. The return value of method 'DotNext.Runtime.CompilerServices.ValueTupleBuilder.Build()' 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.

At first glance, it seems like most of these can be fixed by plumbing the right attributes through.

@sakno
Copy link
Collaborator

sakno commented Jan 28, 2024

Hi @alexrp , DotNex.Metaprogramming doesn't support trimming for obvious reasons: runtime code generation and heavy use of Reflection.

@alexrp
Copy link
Author

alexrp commented Jan 28, 2024

Is there any reason in principle why it couldn't work? Obviously there would be some responsibility on my own part to root some Types/MethodInfos that I pass into DotNext.Metaprogramming, but as far as the library's use of reflection goes, wouldn't it just be a matter of annotating with the right attributes?

@sakno
Copy link
Collaborator

sakno commented Jan 28, 2024

Almost every method in the library should be marked with RequiresUnreferencedCodeAttribute. It means that IL trimmer is unable to determine which methods should not be trimmed from your code because DotNext.Metaprogramming uses LINQ Expression Trees and runtime code generation. I considered this work as useless because you need to inform IL trimmer manually through configuration about all program elements used internally in the library through Reflection.

@alexrp
Copy link
Author

alexrp commented Jan 28, 2024

Hmm, I don't quite follow.

Wouldn't you just need to annotate the API surface of the library with [DynamicallyAccessedMembers(...)], [DynamicDependency(...)], etc as necessary? (And then plumb those through wherever the analyzer demands it.) It seems to me like the dependencies shouldn't be too hard to reason about, unless the library internally reflects over entire assemblies or something?

I think System.Linq.Expressions is fully supported with trimming. If you browse the various factory and helper methods in the library, you can see that these annotations are being used there. Now, they still annotate the public API surface with [RequiresUnreferencedCode], but AFAIK, this is just to notify the user that they may be relying on members to be present that the linker can't catch. (This same principle is applied to other things like Assembly.DefinedTypes too, where it may be fine if you know what you're doing, but the warning is there just to make you take an extra look and audit the usage.) In general, as long as your reflection dependencies are obvious to the trimmer's dataflow analysis, you can just suppress the warning about the [RequiresUnreferencedCode] attribute.

So, in other words, I think there is value in DotNext.Metaprogramming adding these annotations because they would help the trimmer's analysis. But also, adding [RequiresUnreferencedCode] to the top-level public API surface makes sense too. That way, the trimmer's dataflow analysis will work as expected when the user isn't doing anything crazy (like e.g. passing generated, non-literal property names in), and the [RequiresUnreferencedCode] will prompt the user to audit their code, after which they can disable that specific warning.

Does this make sense?

@sakno
Copy link
Collaborator

sakno commented Jan 28, 2024

Wouldn't you just need to annotate the API surface of the library with [DynamicallyAccessedMembers(...)]

Because it doesn't work in general. For instance, AwaitExpression requires reflection over Task<T> and T is not known at compile time. It means that I cannot declare dependency statically using attribute.

[DynamicDependency(DynamicallyAccessedMemberTypes.PublicMethods, typeof(Task<>))]

This is a valid declaration of open type in C#, however I'm 95% sure that IL trimmer doesn't understand that. I mean it doesn't understand that it need to keep all public methods for any instantiation of type Task<>.

@alexrp
Copy link
Author

alexrp commented Jan 28, 2024

It seems there was some work done recently related to open generics: dotnet/runtime#96648

That said, I don't actually know if this at all addresses your specific example of preserving Task<T> members. But at the very least, it seems to be an indication that the trimmer team cares about use cases related to open generics?

In the worst case, I think DotNext.Metaprogramming could embed a root descriptor file that preserve Task<>. You can see that the docs for the format even have examples for open generics.


By the way, the log in the original issue is with TrimMode=partial. Here is one with TrimMode=full which limits the analysis to code that I actually use:

    /_/src/DotNext.Metaprogramming/Linq/Expressions/AwaitExpression.cs(38,13): Trim analysis warning IL2075: DotNext.Linq.Expressions.AwaitExpression.AwaitExpression(Expression, Boolean): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/AwaitExpression.cs(44,9): Trim analysis warning IL2075: DotNext.Linq.Expressions.AwaitExpression.AwaitExpression(Expression, Boolean): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/AwaitExpression.cs(46,9): Trim analysis warning IL2075: DotNext.Linq.Expressions.AwaitExpression.AwaitExpression(Expression, Boolean): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(747,9): Trim analysis warning IL2070: DotNext.Linq.Expressions.ExpressionBuilder.Call(Expression, Type, String, Expression[]): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, Type[])'. The parameter 'interfaceType' of method 'DotNext.Linq.Expressions.ExpressionBuilder.Call(Expression, Type, String, Expression[])' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1142,13): Trim analysis warning IL2067: DotNext.Linq.Expressions.ExpressionBuilder.New(Type, Expression[]): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in call to 'System.Linq.Expressions.Expression.New(Type)'. The parameter 'type' of method 'DotNext.Linq.Expressions.ExpressionBuilder.New(Type, Expression[])' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(1144,9): Trim analysis warning IL2070: DotNext.Linq.Expressions.ExpressionBuilder.New(Type, Expression[]): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' in call to 'System.Type.GetConstructor(Type[])'. The parameter 'type' of method 'DotNext.Linq.Expressions.ExpressionBuilder.New(Type, Expression[])' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ExpressionBuilder.cs(838,12): Trim analysis warning IL2026: DotNext.Linq.Expressions.ExpressionBuilder.Property(Expression, String): Using member 'System.Linq.Expressions.Expression.Property(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ForEachExpression.cs(41,9): Trim analysis warning IL2072: DotNext.Linq.Expressions.ForEachExpression.ForEachExpression(Expression, LabelTarget, LabelTarget): 'collectionType' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'DotNext.Reflection.CollectionType.GetItemType(Type, Type&)'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ForEachExpression.cs(47,13): Trim analysis warning IL2075: DotNext.Linq.Expressions.ForEachExpression.ForEachExpression(Expression, LabelTarget, LabelTarget): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String, Type[])'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ForEachExpression.cs(49,13): Trim analysis warning IL2026: DotNext.Linq.Expressions.ForEachExpression.ForEachExpression(Expression, LabelTarget, LabelTarget): Using member 'System.Linq.Expressions.Expression.Call(Expression, String, Type[], Expression[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ForEachExpression.cs(62,9): Trim analysis warning IL2026: DotNext.Linq.Expressions.ForEachExpression.ForEachExpression(Expression, LabelTarget, LabelTarget): Using member 'System.Linq.Expressions.Expression.Property(Expression, String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Creating Expressions requires unreferenced code because the members being referenced by the Expression may be trimmed.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ForEachExpression.cs(213,13): Trim analysis warning IL2072: DotNext.Linq.Expressions.ForEachExpression.Reduce(): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'DotNext.Reflection.DisposableType.GetDisposeAsyncMethod(Type)'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Linq/Expressions/ForEachExpression.cs(219,13): Trim analysis warning IL2072: DotNext.Linq.Expressions.ForEachExpression.Reduce(): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'DotNext.Reflection.DisposableType.GetDisposeMethod(Type)'. The return value of method 'System.Linq.Expressions.Expression.Type.get' 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.
    /_/src/DotNext.Metaprogramming/Metaprogramming/LambdaExpression.cs(59,9): Trim analysis warning IL2091: DotNext.Metaprogramming.LambdaExpression<TDelegate>.LambdaExpression`1(Boolean): 'TDelegate' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in 'DotNext.Reflection.DelegateType.GetInvokeMethod<TDelegate>()'. The generic parameter 'TDelegate' of 'DotNext.Metaprogramming.LambdaExpression<TDelegate>' 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.

I wonder why AwaitExpression is even included? I don't use it anywhere in my code. 🤔 The code I generate with DotNext.Metaprogramming is fully sync.

@sakno
Copy link
Collaborator

sakno commented Jan 28, 2024

It seems there was some work done recently related to open generics

It's done for DynamicallyAccessedMembers, not for DynamicDependency.

There are lot of complex cases not covered with attributes. For instance, ForEachExpression and many other classes override Reduce method. It has conversion from custom Expression Tree to well-known expression types. It requires reflection. However, the method cannot be marked with one of those attributes aimed for IL trimming because it's virtual. Otherwise, it produces a warning. In this case all I have is to mark entire class with RequiresUnreferencedCode attribute and delegate configuration of IL trimming to the library consumer.

@alexrp
Copy link
Author

alexrp commented Jan 28, 2024

In this case all I have is to mark entire class with RequiresUnreferencedCode attribute

I suppose applying dependency attributes to the ForEachExpression class itself would not work?

and delegate configuration of IL trimming to the library consumer.

I am not actually opposed to doing this, by the way. The fundamental problem here is that, even if I do this, I am still left with all these trim analysis warnings coming from DotNext.Metaprogramming. AFAIK, the only way I can silence them is by suppressing all trimmer warnings, even from my own assemblies and other third-party dependencies, which is not good. 🙁

@sakno
Copy link
Collaborator

sakno commented Jan 28, 2024

class itself would not work?

No. It works with Expression.Type property which is not controlled by ForEachExpression and others. There is no way to mark the property declared in external assembly.

@alexrp
Copy link
Author

alexrp commented Jan 28, 2024

Ok, I see what you mean. Thinking a bit more about it, I can't think of a good solution there either.

What do you think about best-effort annotations? I.e.:

  • Annotate the obvious cases where attributes can actually help
  • Do what the BCL does with applying [RequiresUnreferencedCode] to the public API surface where unannotated reflection is done underneath (e.g. ForEachExpression), to notify the user that they must audit their code and the trimming result to make sure everything necessary is preserved.
  • Finally, use some [UnconditionalSuppressMessage] attributes as necessary for situations like Reduce() where reflection happens, but the user has already been notified through [RequiresUnreferencedCode] on the relevant factory method(s).

It seems like this would bring the best user experience here. Depending on APIs used, there would still be some work for the user to do to preserve reflected-upon types/members, but at least there would no longer be any unactionable/unsuppressible trim analysis warnings. The warnings that would be there for [RequiresUnreferencedCode] can just be suppressed locally in code when the user has audited each case.

@sakno
Copy link
Collaborator

sakno commented Jan 28, 2024

What do you think about best-effort annotations?

I tried this approach several times and it requires a lot of work to analyze each case accurately.

Sad to hear that <TrimMode>partial</TrimMode> doesn't work.

@alexrp
Copy link
Author

alexrp commented Jan 28, 2024

I tried this approach several times and it requires a lot of work to analyze each case accurately.

If I can find the time to go through the library and do this, would you take a PR for it? No promises that I can get the approach to work either, but I can at least try.

Sad to hear that <TrimMode>partial</TrimMode> doesn't work.

Yeah, I initially thought that this mode was what I wanted for dependencies like this that aren't marked trimmable. But then you just get unsuppressible analysis warnings as shown here. It seems that, either way, there's just no winning unless you annotate the library. It's honestly a pretty annoying design on the part of the trimming infrastructure.

@sakno
Copy link
Collaborator

sakno commented Jan 28, 2024

would you take a PR for it?

I'll submit initial PR so you can be a co-author to continue this work. Anyway, this library probably will never be AOT compatible.

@alexrp
Copy link
Author

alexrp commented Jan 28, 2024

Anyway, this library probably will never be AOT compatible.

That's fine. I wouldn't even try to use S.L.E with AOT; that seems like a recipe for a bad time. I'm just hoping we can get basic trimming somewhat working (even if it still requires some effort from the user side) so I can reduce the size of my published (JIT) app.

@sakno
Copy link
Collaborator

sakno commented Jan 28, 2024

Done, draft PR is opened (see above).

@sakno sakno added the enhancement New feature or request label Jan 28, 2024
@sakno sakno linked a pull request Jan 28, 2024 that will close this issue
@sakno sakno linked a pull request Jan 30, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Opened
Development

Successfully merging a pull request may close this issue.

2 participants