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

[Trimming] Make Microsoft.Graph for .NET trimming compatible. #2111

Closed
RobsonPontin opened this issue Sep 1, 2023 · 0 comments · Fixed by #2178
Closed

[Trimming] Make Microsoft.Graph for .NET trimming compatible. #2111

RobsonPontin opened this issue Sep 1, 2023 · 0 comments · Fixed by #2178

Comments

@RobsonPontin
Copy link

RobsonPontin commented Sep 1, 2023

Is your feature request related to a problem? Please describe.

Yes, I'm writing a WinUI 3 Application (using Windows App SDK) which must be published as trimmed since .NET supports it, but the Microsoft.Graph dependency does not support it and give me trim warnings.

Describe the solution you'd like

Fix all cases using reflection and every single trim warning to make the SDK fully trimmable.
This is a requirement for Native AOT which is coming soon for Windows App SDK with .NET 8.

Full list of trim warnings for version 5.25.0.

1>ILLink : Trim analysis warning IL2075: Microsoft.Graph.DriveItemRequestBuilderExtensions.GetPathParameters(Object): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The return value of method 'System.Type.BaseType.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.
1>ILLink : Trim analysis warning IL2075: Microsoft.Graph.DriveItemRequestBuilderExtensions.GetRequestAdapter(Object): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The return value of method 'System.Type.BaseType.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.
1>ILLink : Trim analysis warning IL2075: Microsoft.Graph.DriveItemRequestBuilderExtensions.GetUrlTemplate(Object): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The return value of method 'System.Type.BaseType.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.
1>ILLink : Trim analysis warning IL2075: Microsoft.Graph.DriveItemRequestBuilderExtensions.UpdateUrlTemplate<T>(T, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetFields(BindingFlags)'. The return value of method 'System.Type.BaseType.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.
1>ILLink : Trim analysis warning IL2026: Microsoft.Graph.DeltaResponseHandler<T>.<GetResponseString>d__3.MoveNext(): Using member 'System.Text.Json.JsonSerializer.Serialize<TValue>(TValue, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.
1>ILLink : Trim analysis warning IL2026: Microsoft.Graph.DeltaResponseHandler<T>.<HandleResponseAsync>d__2<NativeResponseType,ModelType>.MoveNext(): Using member 'System.Text.Json.JsonSerializer.Deserialize<TValue>(Stream, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.
1>ILLink : Trim analysis warning IL2026: Microsoft.Graph.ResponseHandler<T>.<HandleResponseAsync>d__2<NativeResponseType,ModelType>.MoveNext(): Using member 'System.Text.Json.JsonSerializer.Deserialize<TValue>(Stream, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.
1>ILLink : Trim analysis warning IL2026: Microsoft.Graph.AsyncMonitor<T>.<PollForOperationCompletionAsync>d__4.MoveNext(): Using member 'System.Text.Json.JsonSerializer.DeserializeAsync<TValue>(Stream, JsonSerializerOptions, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.
1>ILLink : Trim analysis warning IL2026: Microsoft.Graph.AsyncMonitor<T>.<PollForOperationCompletionAsync>d__4.MoveNext(): Using member 'System.Text.Json.JsonSerializer.DeserializeAsync<TValue>(Stream, JsonSerializerOptions, CancellationToken)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.
1>ILLink : Trim analysis warning IL2026: Microsoft.Graph.DeltaResponseHandler<T>.AddOrReplacePropertyToObject(JsonElement, String, Object): Using member 'System.Text.Json.JsonSerializer.Serialize<TValue>(TValue, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.
1>ILLink : Trim analysis warning IL2026: Microsoft.Graph.DeltaResponseHandler<T>.AddOrReplacePropertyToObject(JsonElement, String, Object): Using member 'System.Text.Json.JsonSerializer.Serialize<TValue>(TValue, JsonSerializerOptions)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.
1>ILLink : Trim analysis warning IL2075: Microsoft.Graph.LargeFileUploadTask<T>.ExtractSessionFromParsable(IParsable): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. 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.
1>ILLink : Trim analysis warning IL2075: Microsoft.Graph.LargeFileUploadTask<T>.ExtractSessionFromParsable(IParsable): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. 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.
1>ILLink : Trim analysis warning IL2075: Microsoft.Graph.LargeFileUploadTask<T>.ExtractSessionFromParsable(IParsable): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. 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.
1>ILLink : Trim analysis warning IL2075: Microsoft.Graph.PageIterator<TEntity,TCollectionPage>.ExtractEntityListFromParsable(PageIterator<TEntity,TCollectionPage>.TCollectionPage): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. 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.
1>ILLink : Trim analysis warning IL2075: Microsoft.Graph.PageIterator<TEntity,TCollectionPage>.ExtractNextLinkFromParsable(PageIterator<TEntity,TCollectionPage>.TCollectionPage, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. 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.

Describe alternatives you've considered

The alternative would be not using the .NET SDK but using REST API instead, but we should strive to improve the SDK instead.

Additional context

I have a sample application here which has a WinUI 3 C# App publishing as trimmed with Microsoft.Graph dependencies which can be used to check all warning generated even in Debug mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants