Visitar URL original
Localize authentication errors in Abstractions by paulmedynski · Pull Request #4852 · dotnet/SqlClient · GitHub
Skip to content

Localize authentication errors in Abstractions - #4852

Merged
paulmedynski merged 4 commits into
mainfrom
dev/automation/aot-authentication-localization
Nov 12, 2026
Merged

paulmedynski merged 4 commits into
mainfrom
dev/automation/aot-authentication-localization

Conversation

@paulmedynski

@paulmedynski paulmedynski commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Description

Localize authentication diagnostics using resources owned by Microsoft.Data.SqlClient.Extensions.Abstractions, without depending on the driver's resource helpers or loading the driver to format an error.

Implementation

  • Add the internal AuthenticationStrings helper and resource-backed exception factories.
  • Move five existing authentication resource keys, with neutral English and 13 translated cultures, from the driver to Abstractions. These translations are not newly introduced localization.
  • Add eight additional neutral-English resource messages. Untranslated messages fall back to neutral English.
  • Replace six hard-coded exception-construction sites in authentication configuration and registration with resource-backed factories, retaining their exception types.
  • Select resources with CurrentUICulture and format arguments with CurrentCulture, including parent-culture and neutral-resource fallback.
  • Trace recoverable resource lookup/formatting failures and return a diagnostic fallback containing the resource key and argument values. Unformattable arguments use a type-name placeholder; fatal exceptions propagate.
  • Set explicit embedded-resource names, remove relocated driver resource entries and generated internal accessors, document the behavior, and add regression tests.

Public API and compatibility

No breaking public API surface changes and no new or changed public declarations. No public/protected types, constructors, methods, properties, signatures, type forwards, or reference-assembly declarations are added, removed, or changed. AuthenticationStrings and its factories are internal.

There are observable diagnostic behavior changes:

Area Change relative to the target branch
Authentication error messages The affected paths use resource-backed messages instead of temporary hard-coded English text. Wording can change even in English; translated cultures now receive the applicable Abstractions satellite message. This can affect EventSource traces containing those exceptions.
Localization failure handling The new formatter traces recoverable missing-resource or formatting failures and produces a key-and-arguments fallback rather than letting those failures replace the diagnostic. Fatal errors are not converted to fallback messages.
Resource ownership/deployment The moved messages are resolved from Abstractions and its satellite assemblies rather than driver resources. Deployment or custom resource tooling must account for the new owning assembly.

These are diagnostic behavior changes, not a change to the authentication contract. Consumers or tests that match exact exception/trace text or inspect internal resource names may need adjustment.

Issues

No separate issue is linked.

Testing

Copilot AI balanced review requested due to automatic review settings October 16, 2026 13:14
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Oct 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

CI validation remains incomplete, and this extraction lacks rerun .NET Framework and trimmed/NativeAOT runtime validation.

0 open findings

What changed in this PR

Moves authentication error localization into Abstractions following #4821, without changing public APIs.

Changes:

  • Replaces six placeholder exceptions with resource-backed factories and resilient message formatting.
  • Relocates five messages across neutral English and 13 translated cultures.
  • Adds localization, fallback, diagnostic, and exception-preservation tests and documentation.
File Description
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.zh-Hant.resx Removes relocated Traditional Chinese messages.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.zh-Hans.resx Removes relocated Simplified Chinese messages.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.tr.resx Removes relocated Turkish messages.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.ru.resx Removes relocated Russian messages.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.resx Removes relocated neutral messages.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.pt-BR.resx Removes relocated Brazilian Portuguese messages.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.pl.resx Removes relocated Polish messages.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.ko.resx Removes relocated Korean messages.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.ja.resx Removes relocated Japanese messages.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.it.resx Removes relocated Italian messages.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.fr.resx Removes relocated French messages.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.es.resx Removes relocated Spanish messages.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.Designer.cs Removes relocated resource accessors.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.de.resx Removes relocated German messages.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.cs.resx Removes relocated Czech messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​AzureProviderConstructionTest.cs Checks broker error details.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​AuthenticationStringsTest.cs Tests localization, fallbacks, diagnostics, and causes.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​SqlAuthenticationProviderRegistry.cs Uses localized exception factories.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.zh-Hant.resx Adds Traditional Chinese authentication messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.zh-Hans.resx Adds Simplified Chinese authentication messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.tr.resx Adds Turkish authentication messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.ru.resx Adds Russian authentication messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.resx Adds neutral authentication messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.pt-BR.resx Adds Brazilian Portuguese authentication messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.pl.resx Adds Polish authentication messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.ko.resx Adds Korean authentication messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.ja.resx Adds Japanese authentication messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.it.resx Adds Italian authentication messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.fr.resx Adds French authentication messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.es.resx Adds Spanish authentication messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.de.resx Adds German authentication messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.cs.resx Adds Czech authentication messages.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​PackageReadme.md Documents fallback and fatal-error behavior.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​AuthenticationStrings.cs Implements localized formatting and exception factories.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Abstractions.csproj Sets explicit embedded resource names.
Files not reviewed (1)
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@paulmedynski
paulmedynski added this pull request to stack #4853 October 16, 2026 13:39
@paulmedynski paulmedynski added this to the 8.0.0-preview1 milestone Oct 16, 2026
@paulmedynski paulmedynski changed the title AOT: Localize authentication errors in Abstractions AOT 3: Localize authentication errors in Abstractions Oct 16, 2026
@paulmedynski paulmedynski moved this from To triage to In progress in SqlClient Board Oct 16, 2026
Copilot AI balanced review requested due to automatic review settings October 16, 2026 13:50
@paulmedynski
paulmedynski force-pushed the dev/automation/aot-authentication-localization branch from 891338d to 2023eab Compare October 16, 2026 13:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

This extraction lacks rerun .NET Framework and trimmed/NativeAOT runtime validation, so final human approval remains necessary.

0 open findings

Files not reviewed (1)
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

🧠 Review effort: Balanced

@paulmedynski paulmedynski left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Carrying forward my localization-related self-review feedback and reviewer context from #4821 now that this code has moved into this PR. The two inline comments preserve the original feedback and link back to their source threads. This is a feedback transfer, not a new full code review; no tests were run. The other open feedback threads remain on #4821 because their affected code remains in that layer.

@paulmedynski
paulmedynski force-pushed the dev/automation/aot-authentication-localization branch from 2023eab to 0cf9b26 Compare October 16, 2026 18:04
Copilot AI balanced review requested due to automatic review settings October 16, 2026 18:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Resource headers need correction, while cross-framework satellite packaging and NativeAOT behavior remain unverified.

1 open finding
Files not reviewed (1)
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

🧠 Review effort: Balanced

@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.71%. Comparing base (5aaa9ef) to head (773bb5f).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4852      +/-   ##
==========================================
- Coverage   74.02%   71.71%   -2.31%     
==========================================
  Files         313      313              
  Lines       45726    70864   +25138     
==========================================
+ Hits        33848    50821   +16973     
- Misses      11878    20043    +8165     
Flag Coverage Δ
CI-SqlClient ?
sqlclient-pr 71.71% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI balanced review requested due to automatic review settings October 19, 2026 17:13
@paulmedynski
paulmedynski force-pushed the dev/automation/aot-authentication-localization branch from 0cf9b26 to d8d9316 Compare October 19, 2026 17:13
@paulmedynski paulmedynski changed the title AOT 3: Localize authentication errors in Abstractions AOT 4: Localize authentication errors in Abstractions Oct 19, 2026
@paulmedynski
paulmedynski removed this pull request from stack #4853 October 19, 2026 17:16
@paulmedynski paulmedynski removed the Author attention needed PRs that require author to respond or make updates to PR. label Oct 28, 2026
@paulmedynski paulmedynski moved this from In progress to In review in SqlClient Board Oct 29, 2026
@paulmedynski
paulmedynski removed this pull request from stack #4861 October 29, 2026 14:13
@paulmedynski
paulmedynski added this pull request to stack #4943 October 29, 2026 14:13
benrr101
benrr101 previously approved these changes Oct 29, 2026

@benrr101 benrr101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

cheenamalhotra
cheenamalhotra previously approved these changes Oct 30, 2026
@cheenamalhotra

cheenamalhotra commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Unrelated to AOT support - I would recommend updating title and desc, but can be kept in stack since it's dependent on AOT work.

@paulmedynski paulmedynski modified the milestones: 8.0.0-preview1, 8.0.0 Nov 3, 2026
Base automatically changed from dev/paul/aot/phase-1.3 to main November 4, 2026 17:51
Restore resource-backed authentication exception factories, neutral and satellite resources, resource embedding, fallback tests and driver resource cleanup as a separate stacked layer. Verify French parent-culture lookup alongside neutral messages.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Fix authentication localization review feedback in #4852

Restore complete ResX headers across all authentication resource cultures and explain culture selection and diagnostic fallback intent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Complete authentication exception localization in #4852

Move remaining configuration and registration exception messages into neutral resources, preserve framework exception messages, and focus string tests on helper behavior rather than translation availability.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Cover authentication resource lookup and refine exception factories in #4852

Use French as the stable satellite for direct lookup, parent fallback, neutral fallback, and independent UI/formatting culture coverage. Return concrete exception types from authentication factories.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@paulmedynski
paulmedynski dismissed stale reviews from cheenamalhotra and benrr101 via cf83356 November 6, 2026 13:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Required supplementary review checks could not be completed because policy and skill references were supplied only as reviewed-checkout paths, without trusted immutable copies.

No open issues 🎉

1 file not reviewed
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Review effort: Balanced

benrr101
benrr101 previously approved these changes Nov 6, 2026
cheenamalhotra
cheenamalhotra previously approved these changes Nov 6, 2026
apoorvdeshmukh
apoorvdeshmukh previously approved these changes Nov 10, 2026
Preserve upstream WAM translations in Abstractions, align the neutral upgrade message with version 7.0.2, and cover all localized WAM errors.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Mandatory review-policy references were not supplied at a trusted immutable revision, leaving policy-dependent checks for human verification.

No open issues 🎉

1 file not reviewed
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Review effort: Balanced

Remove the unused WAM upgrade resources and factory, add the neutral access-token validation resource, and replace the exception-factory theory with focused tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Required policy checks could not be completed because skill and review-policy references were available only from the reviewed worktree, without a protected-host or immutable trusted-base source.

No open issues 🎉

1 file not reviewed
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Review effort: Balanced

@paulmedynski paulmedynski left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracking self-review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Required supplemental review checks could not be completed because neither trusted policy/reference file copies nor an immutable base revision were supplied.

No open issues 🎉

1 file not reviewed
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Review effort: Balanced

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

Labels

Area\Azure Connectivity Use this to tag issues that are related to Azure connectivity. Hotfix 8.0.0 PRs that must be backported to release/8.0 Localization Needed PRs that contain changes that would need localization

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants