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

Make sure extensions libraries are marked <IsAotCompatible>true</IsAotCompatible> #4622

Closed
davidfowl opened this issue Oct 27, 2023 · 8 comments
Assignees
Labels
area-fundamentals enhancement This issue represents an ask for new feature or an enhancement to an existing one

Comments

@davidfowl
Copy link
Member

davidfowl commented Oct 27, 2023

While trying to use the Http resilisnce library auth PublishAot I got warnings:

EnableReloads

ILC : Trim analysis warning IL2091: Microsoft.Extensions.Http.Resilience.ResilienceHandlerContext.EnableReloads<TOptions>(String): 'TOptions' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' in 'Polly.DependencyInjection
.AddResiliencePipelineContext`1.EnableReloads<TOptions>(String)'. The generic parameter 'TOptions' of 'Microsoft.Extensions.Http.Resilience.ResilienceHandlerContext.EnableReloads<TOptions>(String)' does not have matching annotations. The source value must declare at le
ast the same requirements as those declared on the target location it is assigned to. [C:\dev\git\eShop\src\Ordering.BackgroundTasks\Ordering.BackgroundTasks.csproj]
ILC : Trim analysis warning IL2026: Polly.Timeout.TimeoutStrategyOptions.Timeout: Using member 'System.ComponentModel.DataAnnotations.RangeAttribute.RangeAttribute(Type,String,String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming
application code. Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All. [C:\dev\git\eShop\src\Ordering.BackgroundTasks\Ordering.BackgroundTasks.csproj]
ILC : Trim analysis warning IL2026: Polly.Timeout.TimeoutStrategyOptions.Timeout: Using member 'System.ComponentModel.DataAnnotations.RangeAttribute.RangeAttribute(Type,String,String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming
application code. Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMembers All. [C:\dev\git\eShop\src\Ordering.BackgroundTasks\Ordering.BackgroundTasks.csproj]
ILC : Trim analysis warning IL2026: Microsoft.Extensions.Http.Resilience.Internal.Validators.HttpStandardResilienceOptionsValidator.Validate(String,HttpStandardResilienceOptions): Using member 'System.ComponentModel.DataAnnotations.ValidationContext.ValidationContext(O
bject)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The Type of instance cannot be statically discovered and the Type's properties can be trimmed. [C:\dev\git\eShop\src\Ordering.BackgroundTasks\Ordering.Backgrou
ndTasks.csproj]

Options Validation cc @tarekgh ?

ILC : Trim analysis warning IL2026: __OptionValidationStaticInstances.<Validators_g>F8B1F3D42962A35D8FF1B1489612AEF6C36F3713335EFF79DB68A25973333C495____Attributes..cctor(): Using member 'System.ComponentModel.DataAnnotations.LengthAttribute.LengthAttribute(Int32,Int32
)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Uses reflection to get the 'Count' property on types that don't implement ICollection. This 'Count' property may be trimmed. Ensure it is preserved. [C:\dev\git\eSh
op\src\Ordering.BackgroundTasks\Ordering.BackgroundTasks.csproj]
ILC : Trim analysis warning IL2026: __OptionValidationStaticInstances.<Validators_g>F8B1F3D42962A35D8FF1B1489612AEF6C36F3713335EFF79DB68A25973333C495____Attributes..cctor(): Using member 'System.ComponentModel.DataAnnotations.RangeAttribute.RangeAttribute(Type,String,S
tring)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMemb
ers All. [C:\dev\git\eShop\src\Ordering.BackgroundTasks\Ordering.BackgroundTasks.csproj]
ILC : Trim analysis warning IL2026: __OptionValidationStaticInstances.<Validators_g>F8B1F3D42962A35D8FF1B1489612AEF6C36F3713335EFF79DB68A25973333C495____Attributes..cctor(): Using member 'System.ComponentModel.DataAnnotations.RangeAttribute.RangeAttribute(Type,String,S
tring)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMemb
ers All. [C:\dev\git\eShop\src\Ordering.BackgroundTasks\Ordering.BackgroundTasks.csproj]
ILC : Trim analysis warning IL2026: __OptionValidationStaticInstances.<Validators_g>F8B1F3D42962A35D8FF1B1489612AEF6C36F3713335EFF79DB68A25973333C495____Attributes..cctor(): Using member 'System.ComponentModel.DataAnnotations.RangeAttribute.RangeAttribute(Type,String,S
tring)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Generic TypeConverters may require the generic types to be annotated. For example, NullableConverter requires the underlying type to be DynamicallyAccessedMemb
ers All. [C:\dev\git\eShop\src\Ordering.BackgroundTasks\Ordering.BackgroundTasks.csproj]
ILC : Trim analysis warning IL2026: Microsoft.Extensions.Http.Resilience.__HttpRateLimiterStrategyOptionsValidator__.Validate(String,HttpRateLimiterStrategyOptions): Using member 'System.ComponentModel.DataAnnotations.ValidationContext.ValidationContext(Object)' which
has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The Type of instance cannot be statically discovered and the Type's properties can be trimmed. [C:\dev\git\eShop\src\Ordering.BackgroundTasks\Ordering.BackgroundTasks.csproj
]
ILC : Trim analysis warning IL2026: Microsoft.Extensions.Http.Resilience.__HttpTimeoutStrategyOptionsValidator__.Validate(String,HttpTimeoutStrategyOptions): Using member 'System.ComponentModel.DataAnnotations.ValidationContext.ValidationContext(Object)' which has 'Req
uiresUnreferencedCodeAttribute' can break functionality when trimming application code. The Type of instance cannot be statically discovered and the Type's properties can be trimmed. [C:\dev\git\eShop\src\Ordering.BackgroundTasks\Ordering.BackgroundTasks.csproj]
ILC : Trim analysis warning IL2026: Microsoft.Extensions.Http.Resilience.__HttpRetryStrategyOptionsValidator__.Validate(String,HttpRetryStrategyOptions): Using member 'System.ComponentModel.DataAnnotations.ValidationContext.ValidationContext(Object)' which has 'Require
sUnreferencedCodeAttribute' can break functionality when trimming application code. The Type of instance cannot be statically discovered and the Type's properties can be trimmed. [C:\dev\git\eShop\src\Ordering.BackgroundTasks\Ordering.BackgroundTasks.csproj]
ILC : Trim analysis warning IL2026: Microsoft.Extensions.Http.Resilience.__HttpCircuitBreakerStrategyOptionsValidator__.Validate(String,HttpCircuitBreakerStrategyOptions): Using member 'System.ComponentModel.DataAnnotations.ValidationContext.ValidationContext(Object)'
which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. The Type of instance cannot be statically discovered and the Type's properties can be trimmed. [C:\dev\git\eShop\src\Ordering.BackgroundTasks\Ordering.BackgroundTasks.
csproj]

We should do a pass and make sure that we avoid warnings to make sure its possible to use these libraries with NativeAOT.

@davidfowl
Copy link
Member Author

cc @eerhardt

@davidfowl
Copy link
Member Author

It seems like we need to at a minimum rebuild with this dotnet/runtime#93193 to get rid of the source gen warnings with options validation?

@tarekgh
Copy link
Member

tarekgh commented Oct 27, 2023

@davidfowl right. You need dotnet/runtime#93193 to get rid of the trimming warnings. Could you please give it a try and let me know if you still see any case?

@tarekgh
Copy link
Member

tarekgh commented Oct 27, 2023

I thought the extensions repo already picked recent version of the source gen. isn't the case?

eerhardt added a commit to eerhardt/extensions that referenced this issue Oct 27, 2023
joperezr pushed a commit that referenced this issue Oct 27, 2023
github-actions bot pushed a commit that referenced this issue Oct 27, 2023
joperezr pushed a commit that referenced this issue Oct 27, 2023
@martincostello
Copy link
Member

Was this intended to be fixed in 8.0.0? I'm seeing these warnings in an app using the 8.0.100 SDK and the 8.0.0 packages.

@dariusclay
Copy link
Contributor

I think there is still work to be done per #4625

@eerhardt
Copy link
Member

eerhardt commented Nov 15, 2023

#4625 is targeting the dev branch, which is the "9.0" train. There are a handful of source generator bugs in dotnet/runtime that we need to get into an 8.0.x servicing build to unblock this work. Once that is done, I will port #4625 to main which will resolve these warnings for the "8" train. It may take a couple servicing releases to get them all addressed.

@geeknoid geeknoid added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Nov 27, 2023
@eerhardt
Copy link
Member

This was fixed with #4871.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-fundamentals enhancement This issue represents an ask for new feature or an enhancement to an existing one
Projects
None yet
Development

No branches or pull requests

8 participants