Skip to content

NativeAOT support: get to zero warnings #1947

Open
1 of 1 issue completed
Open

Description

@roji

Right now, when publishing a NativeAOT app using SqlClient, many warnings are emitted. To properly support NativeAOT, SqlClient will need to get to a place where no warnings are emitted, so the user can be 100% confident that the application will function correctly.

Note that this is related, but not the same as #1942, which is about reducing the binary size. However, the same technique can be used for both: if an entry point (e.g. slim data source builder) is introduced, which by default doesn't include functionality that is large and/or unsafe for NativeAOT, then programs not explicitly bringing in that functionality won't get warnings etc.

Activity

  1. kant2002 commented on Mar 7, 2023

    @kant2002
    Contributor

    I add project settings to be enable trimming analysis here #1943 , That allow bookkeeping warnings which should be fixed.

  2. added
    Up-for-Grabs 🙌Issues that are ready to be picked up for anyone interested. Please self-assign and remove the label
    and removed on Mar 8, 2023
  3. lozn00 commented on May 20, 2023

    @lozn00

    This error did not appear before, is it a compatibility issue with different 7.0 versions of aot? I plan to downgrade, but uninstalling directly is difficult to downgrade @jkotas

  4. lozn00 commented on May 20, 2023

    @lozn00

    I tried uninstalling the application using aspnetcore-runtime-7.0.5-win-x64 dotnet-sdk-7.0.302-win-x64 (1) or after the window->installed application was uninstalled,
    I still see 7.0.5 when using dotnet --info, this 7.0.5 is buggy, bug A type initializer threw an exception home computer uses 7.0.4 to test sql The client library is normal.

    So, I directly used dotnet --info to get the 7.0.5 folder, and directly brute-deleted it, but got other headaches
    fatal error LNK1123: 转换到 COFF 期间失败

    I also upgraded to net 8.0 but also got some bugs that frustrated me very much
    System.MissingMethodException

    Before I reinstalled the computer, my source code worked, I reinstalled the computer, the version of the computer was .net 7.0.5 Therefore, I think that I was able to work properly because I used an old version of .NET 7.0

  5. steveberdy commented on Dec 6, 2024

    @steveberdy

    @roji @jkotas I'd like to take a stab at this if you could assign it to me.

  6. roji commented on Dec 6, 2024

    @roji
    MemberAuthor

    @steveberdy this is SqlClient - neither @jkotas nor myself are owners/maintainers in this repo. I highly suggested first discussing the plan around this with the SqlClient owners and proceeding step-by-step.

  7. steveberdy commented on Dec 6, 2024

    @steveberdy

    Thanks, sorry about that. @cheenamalhotra are you a code owner? It looks like you have approved and merged PRs. If so, it'd be great if we could have a discussion on implementing AOT compatibility

  8. cheenamalhotra commented on Dec 6, 2024

    @cheenamalhotra
    Member

    Hi @steveberdy

    Yes, I am one of the engineers on the team. I noticed your #2742 (comment) as well, did you want to propose the changes to Active Directory Auth provider as you mentioned here? Let us know your thoughts, and we're here to review and support.

  9. steveberdy commented on Dec 6, 2024

    @steveberdy

    @cheenamalhotra I'd be happy to! I'm working on the changes, and I'm setting up AOT-compatibility, trim warnings, etc. I'll make a PR. If there are any trim or AOT issues, I'd be happy to check them out as well.

  10. moved this from To triage to Backlog in SqlClient Boardon Jan 8, 2026
  11. 4 remaining items

  12. priyankatiwari08 commented on Sep 17, 2026

    @priyankatiwari08
    Contributor

    /triage

  13. github-actions commented on Sep 17, 2026

    @github-actions

    🔍 Triage Summary (on-demand re-triage)

    Check Result
    Issue type Task
    Environment Not applicable (engineering/compatibility task, not a bug report)
    Area Area\Engineering
    Duplicates None found (related but distinct: #1942 tracks binary size reduction via a slim data source builder)
    Regression Not applicable

    Analysis

    This is a long-running engineering task to eliminate all trimming/NativeAOT warnings from Microsoft.Data.SqlClient so apps published with PublishAot can be fully trusted. Good progress has been made recently: PRs #4683 and #4684 addressed easy trim-warning cases, and per the 2026-09-16 update, additional PRs are ready for review, narrowing remaining warnings down to two known areas — UDT support (tracked in #4413) and SqlAuthenticationProviderManager (addressed in ongoing PR #4573). Severity: P2 (compatibility/quality-of-life improvement, not a functional regression, but valuable for NativeAOT/trimming adopters).

    Next Steps

    Note: This triage summary is auto-generated by an AI agent. The analysis and suggestions above have not been verified by a human maintainer. Please treat as preliminary guidance only.

    Generated by SqlClient Issue Auto-Triage for #1947 · copilot · auto · 55.9 AIC · ⌖ 13 AIC · ⊞ 11.9K · ◷

  14. thomhurst commented on Nov 2, 2026

    @thomhurst

    Microsoft.Data.SqlClient 7.1.1 still fails a strict Native AOT publish on .NET SDK 10.0.403 / .NET runtime 10.0.14, Windows x64. A SQL-password connection using only open, parameterized reads and conditional updates retains IL2026 diagnostics in SqlDiagnosticListener, IL2057 in SqlAuthenticationProviderManager and SqlConfigurableRetryLogicLoader, and IL2067/IL2070 in CreateAzureAuthenticationProvider.

    A standalone reproduction is:

    dotnet new console --aot -n SqlClientAotProbe
    cd SqlClientAotProbe
    dotnet add package Microsoft.Data.SqlClient --version 7.1.1
    dotnet add package System.Security.Cryptography.Pkcs --version 10.0.14
    dotnet publish -c Release -r win-x64 -p:IlcTreatWarningsAsErrors=true -p:TrimmerSingleWarn=false

    Replace Program.cs before publishing:

    using Microsoft.Data.SqlClient;
    await using var connection = new SqlConnection(
        "Server=127.0.0.1,1433;User ID=sa;Password=example;Encrypt=False");
    await connection.OpenAsync();
    using var command = new SqlCommand("SELECT COUNT_BIG(*) FROM sys.tables", connection);
    Console.WriteLine(await command.ExecuteScalarAsync());

    The Pkcs reference avoids the separately tracked #4958 audit warnings. No Azure extension, custom authentication provider, UDT or retry provider is configured. The pinned source still reads configuration and discovers provider types in SqlAuthenticationProviderManager. Main and #4349 show ongoing work, so this is additional released-version evidence rather than a new duplicate issue.

    Please include this basic SQL-password path in the warning-clean publish coverage. This currently limits the optional SQL Server integration in Relayer #288.

  15. moved this from Backlog to In progress in SqlClient Boardon Nov 3, 2026
  16. moved this from In progress to Done in SqlClient Boardon Nov 4, 2026
  17. paulmedynski commented on Nov 4, 2026

    @paulmedynski
    Contributor

    I doubt #4821 addressed all of the concerns here, so re-opening for further analysis.

  18. charlesroddie commented on Nov 6, 2026

    @charlesroddie
    Contributor

    Re-measured by claude on main at f072438.

    Library-wide analysis

    net10.0, -p:IsAotCompatible=true: 17 unique warnings (down from 31 on 14 October).

    Area Count
    UDT serialization (Server.*, SqlConnection.CheckGetExtendedUDTInfo) 10
    SqlConfigurableRetryLogicLoader 5
    SqlConnectionStringBuilder 2
    • The retry loader's 5 are removed at publish time by EnableAppConfig; the analyzer cannot see publish-time switch values.
    • SqlConnectionStringBuilder (IL2113/IL2115) came with the net10.0 retarget: design-time TypeConverter reflection, unused at run time.

    In a published app

    Trimmed publish of a small ASP.NET Core app using a table-valued parameter, a reader, SqlBatch and GetSchema. Excludes 3 warnings from Azure Monitor itself.

    Configuration SqlClient warnings
    Defaults 22 — System.Configuration 9, retry loader 5, UDT 7, auth (EnsureBootstrapped) 1
    EnableAppConfig=false 8 — UDT 7, auth 1
    and EnableAzureExtensionDiscovery=false 7 — all UDT

    CLR UDTs are the only remaining source (#4413).

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

Metadata

Metadata

Assignees

Labels

Up-for-Grabs 🙌Issues that are ready to be picked up for anyone interested. Please self-assign and remove the label

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions