Skip to content

Consider error diagnostic when SqlClient used when invariant globalization enabled. #2043

Description

@mitchdenny

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

In the ASP.NET repo we have updated our API, Worker, and gRPC templates to use invariant globalization. Initially we enabled invariant globalization for those project templates regardless of whether the publishing target was native AOT or not but received feedback that this created friction for SQL client users. As a result we are opting out of invariant globalization non-native-AOT usage.

For native AOT users (where invariant globalization is the default) we believe that there is an opportunity for the SQL client team to raise a diagnostic alert to let them know that they should disable invariant globalization if their project happens to have it enabled.

Describe the solution you'd like

A extend/create Roslyn analyzer which warns if the project in which SqlClient is invoked from has Invariant Globalization enabled that a diagnostic error is raised. This would shift detection of this issue left for the developer instead of crashing at runtime.

Describe alternatives you've considered

We considered disabling invariant globalization for AOT scenarios, but for API scenarios we believe invariant globalization is a better initial choice. Given this it doesn't really make sense for us to have an analyzer for AOT usage in the ASP.NET repo, epecially since SqlClient's lack of support for invariant globalization isn't an ASP.NET specific issue (we understand that there are good reasons for SqlClient to depend on globalization support).

Additional context

Here is the original PR where we enabled invariant globalization: dotnet/aspnetcore#47066
Here is a customer issue reporting the usability problem to us: dotnet/aspnetcore#48186
Here is out PR opting out of invariant globalization for non-AOT scenarios: dotnet/aspnetcore#48238

Activity

  1. JRahnama commented on May 25, 2023

    @JRahnama
    Contributor

    @mitchdenny thanks for the suggestion. We will discuss this internally and will update you later.

  2. mungojam commented on Dec 8, 2023

    @mungojam

    Will SqlClient ever support invariant globalization? The new AWS lambda runtime doesn't have icu, so needs invariant globalization and this then means SqlClient can't be used there, without jumping through some hoops to bundle it with the deployed app

  3. David-Engel commented on Dec 12, 2023

    @David-Engel
    Contributor

    Will SqlClient ever support invariant globalization? The new AWS lambda runtime doesn't have icu, so needs invariant globalization and this then means SqlClient can't be used there

    Unlikely. It would take a lot of effort and testing to ensure every part of the code behaves correctly in globalization invariant mode when processing all different types of data. Currently, I don't see that rising in priority over other things any time soon.

    This issue (the analyzer check), however, seems relatively easy. We are going to look into it and see what it would entail.

  4. added
    Up-for-Grabs 🙌
    on Dec 12, 2023
  5. self-assigned this
    on Dec 28, 2023
  6. H-Yeo commented on Dec 28, 2023

    @H-Yeo
    Contributor

    Also relates to: this topic #1913

  7. Frulfump commented on Oct 15, 2025

    @Frulfump

    Will SqlClient ever support invariant globalization? The new AWS lambda runtime doesn't have icu, so needs invariant globalization and this then means SqlClient can't be used there

    Unlikely. It would take a lot of effort and testing to ensure every part of the code behaves correctly in globalization invariant mode when processing all different types of data. Currently, I don't see that rising in priority over other things any time soon.

    This issue (the analyzer check), however, seems relatively easy. We are going to look into it and see what it would entail.

    Has anything changed in that regard now that almost two years have passed?

    The diagnostic would still be really nice!

  8. moved this from To triage to Backlog in SqlClient Boardon Dec 23, 2025
  9. priyankatiwari08 commented on Sep 17, 2026

    @priyankatiwari08
    Contributor

    /triage

  10. github-actions commented on Sep 17, 2026

    @github-actions

    🔍 Triage Summary (on-demand re-triage)

    Check Result
    Issue type Feature
    Environment N/A (feature request, not a bug)
    Area Area\Engineering
    Duplicates Potentially related: #3742 (open, "Revisit support for globalization invariant mode"); already cross-linked to #1913 (closed) in earlier comments
    Regression Not indicated

    Analysis

    This is a long-standing feature request asking for a Roslyn analyzer/diagnostic that warns developers when SqlClient is referenced in a project with Invariant Globalization enabled (particularly relevant for Native AOT publishing, where invariant globalization is the default). The maintainers previously acknowledged the request in 2023 as "relatively easy" to investigate but no analyzer has landed yet. A recent comment (Oct 2025) and the just-added /triage comment show continued community interest. Severity assessment: P2 — no functional regression or crash, but it's a recurring pain point for Native AOT/invariant-globalization users and has accumulated reactions/interest over multiple years.

    Next Steps

    • Since this is a well-specified, low-complexity feature request (build-time analyzer, not runtime driver behavior) with prior maintainer buy-in, consider assigning to Copilot coding agent to scope and implement a Roslyn analyzer (e.g., under a new or existing analyzer project) that detects InvariantGlobalization=true (via RuntimeHostConfigurationOption/.runtimeconfig.json or MSBuild property) in consuming projects and emits a build warning/diagnostic when Microsoft.Data.SqlClient is referenced.
    • Review Revisit support for globalization invariant mode #3742 for any overlapping design discussion before starting implementation, since it covers the broader "support invariant globalization" topic that this analyzer would complement (detect-and-warn vs. full support).
    • Confirm current priority with maintainers given the multi-year age of the request and renewed community interest.

    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 #2043 · copilot · auto · 55.6 AIC · ⌖ 13.1 AIC · ⊞ 11.9K · ◷

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Up-for-Grabs 🙌

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions