-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Microsoft.Extensions.Configuration APIs haven't been AOT-annotated #71654
Comments
This is boils down to patterns like this runtime/src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs Lines 289 to 304 in 338db1a
which looks very similar to what FSharp do with |
I assume from the |
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue DetailsConsider this small application using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Configuration;
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
var appSettings = GetAppSettings(config);
Console.WriteLine($"{appSettings.Database}: {appSettings.ConnectionString}");
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:UnrecognizedReflectionPattern",
Justification = "AppSettings is consists only from primitive type and thus will never be trimmed")]
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL3050:UnrecognizedReflectionPattern",
Justification = "AppSettings is consists only from primitive type and thus will never be trimmed")]
AppSettings GetAppSettings(IConfiguration config)
{
return config.Get<AppSettings>();
}
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
public class AppSettings
{
public string? ConnectionString { get; set; }
public DatabaseServer Database { get; set; } = DatabaseServer.None;
}
public enum DatabaseServer
{
None,
SqlServer,
PostgreSql,
MySql
} With following packages
and `appsettings.json {
"ConnectionString": "Server=tfb-database;Database=hello_world;User Id=benchmarkdbuser;Password=benchmarkdbpass;Maximum Pool Size=1024;SslMode=None;ConnectionReset=false;ConnectionIdlePingTime=900;ConnectionIdleTimeout=0;AutoEnlist=false;DefaultCommandTimeout=0;ConnectionTimeout=0;IgnorePrepare=false;",
"Database": "mysql"
} ILC spill warnings
From my understanding
|
I assume this is just because the APIs haven't been annotated with |
You are right. I really misinterpret results and regular trimming works fine. |
They have been annotated with
This API is marked as runtime/src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs Lines 34 to 48 in 0cb001f
|
Good question. So far we haven’t had RUC suppress RDC, but maybe we should @tlakollo @MichalStrehovsky |
The way I see it is:
My opinion as expresed before is that the attributes are independent, they even have different behaviors depending on the attribute (for example |
Two comments on that. Basically +1 on what Tlaka just wrote.
|
It would be good to annotate these APIs for |
The only libraries that aren't enabled yet are DependencyInjection and Hosting. These will come in a separate PR. Contributes to dotnet#71654
The only libraries that aren't enabled yet are DependencyInjection and Hosting. These will come in a separate PR. Contributes to #71654
Using MEDI is annotated as RequiresDynamicCode because it supports enumerable and generic servcies with ValueTypes. When using DI with ValuesTypes, the array and generic code might not be available. Contributes to dotnet#71654
Using MEDI is annotated as RequiresDynamicCode because it supports enumerable and generic servcies with ValueTypes. When using DI with ValuesTypes, the array and generic code might not be available. Contributes to #71654
* EnableAOTAnalyzer for Microsoft.Extensions.Hosting Fix #71654 Plus clean up the interop in GetParentProcess.
Consider this small application
With following packages
and `appsettings.json
ILC spill warnings
From my understanding
AppSettings
is safe to mapIConfiguration
and I want express that. But as you can see all my silly attempts fails.The text was updated successfully, but these errors were encountered: