Skip to content

Implement phase 1 of AOT-safe authentication registration - #4806

Closed
paulmedynski wants to merge 2 commits into
dev/paul/aot/planfrom
dev/paul/aot/phase-1
Closed

paulmedynski wants to merge 2 commits into
dev/paul/aot/planfrom
dev/paul/aot/phase-1

Conversation

@paulmedynski

Copy link
Copy Markdown
Contributor

Description

Implements phase 1 of the AOT-safe authentication provider registration proposal. This draft targets dev/paul/aot/plan so the diff contains the implementation and related documentation updates, rather than the original design-plan commit.

  • Move the provider registry and bootstrap into Extensions.Abstractions and replace the public API's reflective bridge with direct registry calls. Relocate SqlAuthenticationInitializer and retain its driver type forward for the 8.0 major release.
  • Preserve GetProvider/SetProvider null/false failure results. Log actionable configuration, provider, callback and runtime-version errors, including cached bootstrap failures when tracing is enabled after the initial failure.
  • Preserve configuration and initializer precedence over application registrations, and application precedence over discovered Azure defaults. Support reentrant initializer registration.
  • Multi-target Abstractions to netstandard2.0;net10.0, add compatibility attributes, and guard reflective configuration and Azure discovery so trimmed and NativeAOT .NET 10 publishes remove those paths.
  • Add build/transitive checks for exact SqlClient family package versions, including packages.config and an emergency build opt-out, plus untrimmed runtime assembly-version checks. Mixed family versions remain unsupported.
  • Move five authentication resource strings and their existing 13 translations into Abstractions; remove the unused driver helpers and resource entries.
  • Add process-isolated configuration, runtime-version, trimmed and NativeAOT tests. Exclude nested fixture directories from parent test-project default items to prevent their build outputs contaminating .NET Framework assembly resolution.
  • Wire the new checks into CI/PR jobs after existing tests using DotNetCoreCLI@2, with the shared tool-restore step immediately after SDK/runtime installation.
  • Expand XML documentation and update package readmes, feature documentation and the implementation plan. The phase-2 factory API and source generator are not included.

Compatibility notes: no new public registration-method signatures or registry-error exception contract are introduced. Failed replacement does not publish the new provider. Bootstrap failures remain cached for the process lifetime and require correcting the cause and restarting. Exact-version enforcement intentionally rejects unsupported mixed-family graphs.

  • Tests added or updated
  • Public API changes documented
  • Verified against customer repro (not applicable: no customer repro provided)
  • Ensure no breaking changes introduced to existing GetProvider/SetProvider failure results

Issues

No linked issue. Implements the phase-1 plan on dev/paul/aot/plan.

Testing

Added or updated coverage for direct registration without the driver, initial null lookup followed by set/get, replacement callbacks and failure-state preservation, actionable EventSource diagnostics, configuration handler contracts, initializer registration, precedence, disabled feature switches, cached bootstrap failures, runtime version mismatches, package-version enforcement and trimmed/NativeAOT registration.

Validation performed locally on Linux:

Command Result
dotnet build build.proj -t:BuildAll --verbosity quiet Passed; zero warnings/errors.
dotnet test src/Microsoft.Data.SqlClient.Extensions/Abstractions/test/Abstractions.Test.csproj --framework net10.0 --no-restore --verbosity quiet Passed; 34 tests.
dotnet test src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj --framework net10.0 --no-build --no-restore --filter 'FullyQualifiedName~AuthenticationConfigurationSchemaTest|FullyQualifiedName~EnableAppConfigSwitchTest|FullyQualifiedName~SqlAuthenticationProviderManagerTests' --verbosity quiet Passed; 10 affected driver tests.
dotnet tool run pwsh -- -File src/Microsoft.Data.SqlClient.Extensions/Abstractions/test/RunAuthenticationTests.ps1 Passed; all eight configuration/runtime-version scenarios, exercising both bootstrap entry points.
dotnet tool run pwsh -- -File src/Microsoft.Data.SqlClient.Extensions/Abstractions/test/RunAuthenticationTests.ps1 -Publish Passed; all eight scenarios plus trimmed and NativeAOT publish/execution checks.
dotnet tool run pwsh -- -File src/Microsoft.Data.SqlClient.Extensions/Abstractions/test/RunVersionChecks.ps1 Passed; exact family versions, packages.config, excluded SqlServer package and emergency opt-out.
dotnet build src/Microsoft.Data.SqlClient.Extensions/Abstractions/test/ConfigurationTest/ConfigurationTest.csproj --framework net462 --configuration Release --verbosity quiet Passed; zero warnings/errors.

The .NET Framework targets compile, but Windows/net462 test execution was not performed on Linux. Azure pipelines and SQL Server integration tests were not run locally.

Earlier validation also identified two existing baseline issues outside this change: the driver localization check lacks ADP_IsolationLevelResetTimeout translations in 13 cultures, and one build-orchestration documentation-path quoting assertion fails. Those unrelated issues have not been changed.

Guidelines

Please review the contribution guidelines before submitting a pull request:

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.

🟡 Changes recommended

The runtime-version guard remains permanently enabled in publish outputs, so the claimed untrimmed-only reflective path is not removed.

2 open findings
What changed in this PR

Implements phase 1 of AOT-safe authentication registration by moving provider bootstrap and registration into Extensions.Abstractions while preserving compatibility.

Changes:

  • Replaces reflective registration with a direct provider registry and relocates the initializer.
  • Adds package-version enforcement, feature gates, diagnostics, and localized resources.
  • Adds process-isolated configuration, trimming, NativeAOT, and pipeline coverage.

Existing feedback: Not available because no PR number or review threads were supplied.

File Description
.config/​LocalizationValidationAllowlist.json Adds Abstractions allowlist section.
.github/​instructions/​architecture.instructions.md Documents Abstractions TFMs.
.github/​instructions/​features.instructions.md Documents authentication switches.
BUILDGUIDE.md Updates framework matrix.
doc/​design-notes/​aot-auth-provider-proposal/​README.md Updates phase-one behavior.
doc/​design-notes/​aot-auth-provider-proposal/​backporting.md Revises compatibility guidance.
doc/​design-notes/​aot-auth-provider-proposal/​design.md Updates registry failure design.
doc/​design-notes/​aot-auth-provider-proposal/​findings.md Revises bootstrap-failure resolution.
doc/​design-notes/​aot-auth-provider-proposal/​implementation-plan.md Records implementation and validation.
eng/​pipelines/​jobs/​test-abstractions-package-ci-job.yml Adds authentication/version checks.
eng/​pipelines/​onebranch/​jobs/​build-buildproj-job.yml Adds Abstractions localization validation.
eng/​pipelines/​onebranch/​scripts/​tests/​validate-localization.Tests.ps1 Tests independent allowlists.
eng/​pipelines/​onebranch/​scripts/​validate-localization.ps1 Supports selectable allowlist sections.
eng/​pipelines/​onebranch/​steps/​validate-localization-step.yml Parameterizes resource validation.
eng/​pipelines/​pr/​jobs/​test-buildproj-job.yml Adds PR authentication checks.
eng/​pipelines/​scripts/​tests/​Build-Orchestration.Tests.ps1 Updates expected project TFMs.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​build/​Microsoft.Data.SqlClient.Extensions.Abstractions.targets Enforces family package versions.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​doc/​SqlAuthenticationProvider.xml Documents registry behavior.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Abstractions.csproj Adds net10/AOT and package assets.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​AuthenticationFeatureSwitches.cs Defines trimming guards and switches.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​AuthenticationStrings.cs Provides localized authentication errors.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​PackageReadme.md Documents registration and version policy.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.cs.resx Moves Czech authentication strings.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.de.resx Moves German authentication strings.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.es.resx Moves Spanish authentication strings.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.fr.resx Moves French authentication strings.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.it.resx Moves Italian authentication strings.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.ja.resx Moves Japanese authentication strings.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.ko.resx Moves Korean authentication strings.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.pl.resx Moves Polish authentication strings.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.pt-BR.resx Moves Portuguese authentication strings.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.resx Adds neutral authentication strings.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.ru.resx Moves Russian authentication strings.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.tr.resx Moves Turkish authentication strings.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.zh-Hans.resx Moves Simplified Chinese strings.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​Resources/​Strings.zh-Hant.resx Moves Traditional Chinese strings.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​SqlAuthenticationInitializer.cs Relocates the initializer API.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​SqlAuthenticationProvider.Internal.cs Removes the reflective driver bridge.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​SqlAuthenticationProvider.cs Calls the registry directly.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​SqlAuthenticationProviderRegistry.cs Implements bootstrap, precedence, and registration.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​src/​TrimmingAttributes.cs Adds netstandard compatibility attributes.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​Abstractions.Test.csproj Excludes nested fixture outputs.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​AuthenticationRegistryTest.cs Tests registry failures and callbacks.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​AzureProviderConstructionTest.cs Tests Azure constructor selection.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​ConfigurationTest/​ConfigurationTest.csproj Defines process-isolated fixture.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​ConfigurationTest/​Program.cs Exercises bootstrap scenarios.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​ConfigurationTest/​app.config Defines current configuration fixture.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​ConfigurationTest/​bad-initializer.config Defines invalid initializer fixture.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​ConfigurationTest/​bad-provider.config Defines missing provider fixture.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​ConfigurationTest/​bad-unsupported.config Defines unsupported provider fixture.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​ConfigurationTest/​legacy.config Defines legacy configuration fixture.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​PublishTest/​Program.cs Tests published explicit registration.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​PublishTest/​PublishTest.csproj Configures trimmed/AOT publishing.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​RunAuthenticationTests.ps1 Runs isolated authentication fixtures.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​RunVersionChecks.ps1 Tests package-version enforcement.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​RuntimeVersionTest/​RuntimeVersionTest.csproj Produces mismatched driver fixture.
src/​Microsoft.Data.SqlClient.Extensions/​Abstractions/​test/​SqlAuthenticationProviderTest.cs Verifies driver-independent registration.
src/​Microsoft.Data.SqlClient/​ref/​Microsoft.Data.SqlClient.cs Removes relocated initializer declaration.
src/​Microsoft.Data.SqlClient/​src/​Microsoft/​Data/​SqlClient/​Connection/​SqlConnectionInternal.cs Uses the public registry lookup.
src/​Microsoft.Data.SqlClient/​src/​Microsoft/​Data/​SqlClient/​SqlAuthenticationProviderConfigurationSection.cs Preserves configuration handlers.
src/​Microsoft.Data.SqlClient/​src/​Microsoft/​Data/​SqlClient/​SqlUtil.cs Removes relocated error helpers.
src/​Microsoft.Data.SqlClient/​src/​PackageReadme.md Documents AOT registration requirements.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.Designer.cs Removes relocated resource accessors.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.cs.resx Removes moved Czech strings.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.de.resx Removes moved German strings.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.es.resx Removes moved Spanish strings.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.fr.resx Removes moved French strings.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.it.resx Removes moved Italian strings.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.ja.resx Removes moved Japanese strings.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.ko.resx Removes moved Korean strings.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.pl.resx Removes moved Polish strings.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.pt-BR.resx Removes moved Portuguese strings.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.resx Removes moved neutral strings.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.ru.resx Removes moved Russian strings.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.tr.resx Removes moved Turkish strings.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.zh-Hans.resx Removes moved Simplified Chinese strings.
src/​Microsoft.Data.SqlClient/​src/​Resources/​Strings.zh-Hant.resx Removes moved Traditional Chinese strings.
src/​Microsoft.Data.SqlClient/​src/​TypeForwards.Abstractions.cs Adds initializer type forwarding.
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​Microsoft/​Data/​SqlClient/​AuthenticationConfigurationSchemaTest.cs Pins handler and forwarding contracts.
src/​Microsoft.Data.SqlClient/​tests/​UnitTests/​Microsoft/​Data/​SqlClient/​EnableAppConfigSwitchTest.cs Moves authentication-switch coverage.
Files not reviewed (1)
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

[FeatureGuard(typeof(RequiresDynamicCodeAttribute))]
[UnconditionalSuppressMessage("Trimming", "IL4000",
Justification = "Runtime assembly replacement is unavailable in fixed trimmed/AOT images; the package graph is checked at build time.")]
internal static bool IsRuntimeVersionValidationSupported => true;

| Switch Name | Default | Description |
|-------------|---------|-------------|
| `Switch.Microsoft.Data.SqlClient.EnableAppConfig` | `true` | Enables authentication app.config parsing and initializer execution; trimmed/AOT .NET 10 publishes remove this guarded path |
Capture configuration forwarding, cached switches, resilient diagnostics, validation updates, and interactive-agent branch guidance before constructing the PR stack.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 14:56

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

The broad authentication, compatibility, packaging, and pipeline changes require final human review, with documentation and pipeline-description discrepancies still outstanding.

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

🧠 Review effort: Balanced

- stage: test_authentication
displayName: Test Authentication Registration
# The scripts build their own Release fixtures and require no package artifacts or SQL secrets.
dependsOn: []
@github-project-automation github-project-automation Bot moved this from To triage to Done in SqlClient Board Oct 20, 2026
@paulmedynski

Copy link
Copy Markdown
Contributor Author

Closed in favour of the PR stack starting with #4816

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Entra ID authentication broken under NativeAOT in v7.0 — Extensions.Azure reflection-based discovery is AOT-incompatible

2 participants