Skip to content

5.1 | APIScan | MSAL WithClientName (3rd attempt) #3367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: release/5.1
Choose a base branch
from

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.

Issues

An attempt to resolve ADO APIScan issue, but technically no longer necessary.

Testing

Local build succeeds, far too much work to setup to validate locally.

(second attempt with less mistakes)
@benrr101 benrr101 requested review from a team and Copilot May 20, 2025 17:41
Copy link

@Copilot 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 changes to the MSAL application building code to use CreateWithApplicationOptions and remove the usage of formerly undocumented APIs.

  • Unifies client application creation using a builder pattern.
  • Adjusts configuration for different frameworks (NETSTANDARD vs NETFRAMEWORK).
Comments suppressed due to low confidence (2)

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

  • The new implementation no longer applies WithParentActivityOrWindow for NETSTANDARD (_parentActivityOrWindowFunc), which was present in the previous version. Please verify this change is intentional and that no functionality is lost compared to the original branch.
PublicClientApplicationBuilder builder = PublicClientApplicationBuilder.CreateWithApplicationOptions(new PublicClientApplicationOptions

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

  • Automated tests appear to be lacking for the new MSAL client configuration paths. Consider adding tests to validate the builder setup for both NETSTANDARD and NETFRAMEWORK scenarios.
return builder.Build();

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Missing .NET Standard case?

.WithClientName(Common.DbConnectionStringDefaults.ApplicationName)
.WithClientVersion(Common.ADP.GetAssemblyVersion().ToString())
.WithRedirectUri(publicClientAppKey._redirectUri)
.WithParentActivityOrWindow(_parentActivityOrWindowFunc)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need this specific .NET Standard handling like on 5.2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, man this PR is cursed.

Copy link
Contributor

@mdaigle mdaigle left a comment

Choose a reason for hiding this comment

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

Same comment as @paulmedynski

@benrr101 benrr101 requested review from mdaigle and paulmedynski May 20, 2025 22:44
Copy link

codecov bot commented May 21, 2025

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 71.74%. Comparing base (5df1ac3) to head (b5c38f3).

Files with missing lines Patch % Lines
...SqlClient/ActiveDirectoryAuthenticationProvider.cs 91.66% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           release/5.1    #3367      +/-   ##
===============================================
- Coverage        71.86%   71.74%   -0.13%     
===============================================
  Files              293      293              
  Lines            61650    61647       -3     
===============================================
- Hits             44307    44228      -79     
- Misses           17343    17419      +76     
Flag Coverage Δ
addons 92.38% <ø> (ø)
netcore 75.79% <100.00%> (-0.23%) ⬇️
netfx 69.50% <91.66%> (-0.02%) ⬇️

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.

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