Skip to content

Conversation

@benrr101
Copy link
Contributor

Description: Backporting rewriting MSAL application building code to use CreateWithApplicationOptions and avoid (formerly) undocumented APIs. See #3354 for full details of change.

Copilot AI review requested due to automatic review settings May 19, 2025 17:32
@benrr101 benrr101 requested a review from a team as a code owner May 19, 2025 17:32
@benrr101 benrr101 changed the base branch from main to release/5.1 May 19, 2025 17:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR backports the MSAL application builder refactoring and adds a comprehensive set of CI pipeline templates for building, testing, and validating signed packages, while also updating documentation snippets, configs, and build scripts.

  • Add new YAML templates for .NET Framework/.NET Core build-and-test and signed-package validation
  • Update documentation samples to mask passwords and fix minor build command quoting
  • Introduce audit sources and policy exclusions in NuGet.config and related .config files

Reviewed Changes

Copilot reviewed 156 out of 156 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
eng/pipelines/common/templates/steps/build-and-run-tests-netfx-step.yml New .NET Framework build & test step template
eng/pipelines/common/templates/steps/build-and-run-tests-netcore-step.yml New .NET Core build & test step template
eng/pipelines/common/templates/steps/build-all-configurations-signed-dlls-step.yml New step for building signed DLLs across configurations
eng/pipelines/common/templates/jobs/validate-signed-package-job.yml New job for verifying NuGet signature, strong names, and file versions
eng/pipelines/common/templates/jobs/run-tests-package-reference-job.yml New job for running tests against the signed package
eng/pipelines/common/templates/jobs/build-signed-package-job.yml Updated signed-package build job integration
eng/pipelines/common/templates/jobs/build-signed-akv-package-job.yml Updated AKV-provider signed-package build job
doc/snippets/Microsoft.Data.SqlClient/SqlConnectionStringBuilder.xml Masked shown password in snippet
doc/snippets/Microsoft.Data.SqlClient/SqlColumnEncryptionEnclaveProvider.xml Fixed spelling and added isRetry parameter documentation
doc/samples/SqlConnectionStringBuilder_Remove.cs Masked password in sample
doc/samples/SqlConnectionStringBuilder_IntegratedSecurity.cs Masked password in sample
doc/samples/SqlConnectionStringBuilder3.cs Masked password in sample
doc/samples/SqlConnectionStringBuilder.cs Masked password and removed dangling quote
build.proj Removed stray quotation mark in DotnetBuildCmd
NuGet.config Added <auditSources> section
BUILDGUIDE.md Removed outdated AzureKeyVault entries
.config/tsaoptions.json New TSA options config
.config/PolicheckExclusions.xml New PolicyCheck exclusions
.config/CredScanSuppressions.json New CredScan suppressions
Comments suppressed due to low confidence (4)

eng/pipelines/common/templates/jobs/run-tests-package-reference-job.yml:18

  • The dependsOn default value is set to the literal empty, which differs from other jobs using an empty string (''). Consider aligning defaults to avoid conditional mismatches.
-  - name: dependsOn
-    type: string
-    default: empty

eng/pipelines/common/templates/jobs/build-signed-package-job.yml:27

  • Parameter is declared as publishSymbols but later referenced as PublishSymbols. YAML parameter names are case-sensitive; unify casing to ensure correct value propagation.
-  - name: publishSymbols
+    type: boolean

eng/pipelines/common/templates/jobs/build-signed-akv-package-job.yml:27

  • The publishSymbols parameter is later accessed as PublishSymbols. Adjust the parameter name or references to match casing so it's recognized.
-  - name: publishSymbols
+    type: boolean

eng/pipelines/common/templates/jobs/validate-signed-package-job.yml:149

  • The variable $(extractedNugetPath) is never defined; it should likely use $(pathToDownloadedNuget) or be set prior to use.
Get-ChildItem -Path $(extractedNugetPath) -Directory  | select Name | foreach {

@benrr101 benrr101 requested a review from Copilot May 19, 2025 17:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Backport MSAL application builder changes to use the documented CreateWithApplicationOptions API and simplify framework-specific branching.

  • Switch to PublicClientApplicationBuilder.CreateWithApplicationOptions with PublicClientApplicationOptions
  • Consolidate and conditionally apply parent-window/activity delegates for .NET Framework and .NET Standard
  • Remove outdated, undocumented API calls
Comments suppressed due to low confidence (2)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs:553

  • [nitpick] You could combine the #if NETFRAMEWORK and #if NETSTANDARD blocks into an #if/elif structure to reduce repeated directive lines and improve readability.
#if NETFRAMEWORK

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs:559

  • Add a unit test to verify that the CreateClientAppInstance method correctly applies the parent-activity delegate in the NETSTANDARD target and the Win32 window delegate in NETFRAMEWORK.
#if NETSTANDARD

// Optionally set clientId when available
if (tokenCredentialKey._clientId is not null)
PublicClientApplicationBuilder builder = PublicClientApplicationBuilder
.CreateWithApplicationOptions(new PublicClientApplicationOptions
Copy link

Copilot AI May 19, 2025

Choose a reason for hiding this comment

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

Consider moving the authority into PublicClientApplicationOptions.Authority instead of calling .WithAuthority(...) afterward to keep all application options in one place.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mdaigle Sadly it's not that easy. 1) Copilot hallucinated an Authority property on PublicClientApplicationOptions, 2) it takes an enum value while _audience is a string. Although internally WithAuthority uses a method to convert a string into an AadAuthorityAudience enum value, that method is internal and inaccessible to us.

return publicClientApplication;
}

private static TokenCredentialData CreateTokenCredentialInstance(TokenCredentialKey tokenCredentialKey, string secret)
Copy link
Contributor

Choose a reason for hiding this comment

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

unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, it was a mistake 🤦‍♂️

@benrr101 benrr101 requested review from Copilot and mdaigle May 19, 2025 21:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Backport MSAL client construction to use CreateWithApplicationOptions, replacing previous undocumented API usage and consolidating helper methods.

  • Refactored CreateClientAppInstance to leverage PublicClientApplicationBuilder.CreateWithApplicationOptions
  • Removed old builder overloads and duplicated helper methods, then reintroduced them below for consistency
Comments suppressed due to low confidence (1)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs:596

  • Add unit tests for the new CreateClientAppInstance path to verify options (ClientName, ClientVersion, RedirectUri, parent window) are correctly applied.
PublicClientApplicationBuilder builder = PublicClientApplicationBuilder

@codecov
Copy link

codecov bot commented May 20, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 71.78%. Comparing base (5df1ac3) to head (d7ff43d).

Files with missing lines Patch % Lines
...SqlClient/ActiveDirectoryAuthenticationProvider.cs 83.33% 4 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           release/5.1    #3358      +/-   ##
===============================================
- Coverage        71.86%   71.78%   -0.09%     
===============================================
  Files              293      293              
  Lines            61650    61647       -3     
===============================================
- Hits             44307    44251      -56     
- Misses           17343    17396      +53     
Flag Coverage Δ
addons 92.38% <ø> (ø)
netcore 75.83% <86.36%> (-0.20%) ⬇️
netfx 69.53% <83.33%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@benrr101
Copy link
Contributor Author

Man I really hosed this PR up. How the heck did I make so many mistakes here???

@benrr101
Copy link
Contributor Author

This PR has become a mess since diff doesn't look right anymore. Closing and replacing with #3367

@benrr101 benrr101 closed this May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants