Skip to content

APIScan | MSAL WithClientId usage #3354

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

Merged
merged 1 commit into from
May 19, 2025
Merged

Conversation

benrr101
Copy link
Contributor

This PR is now officially "optional" - see description for details

Description: APIScan was giving us two major errors - usage of undocumented SNI APIs (which we are working on an exception for) and usage of undocumented MSAL APIs. This PR addresses the latter by replacing usages of undocumented With* methods by providing builder constructor with the application options.

When I went back into the automated builds to check to make sure I got all the undocumented MSAL APIs covered, I discovered the errors were no longer in the APIscan results. As it turns out, the APIs have since been documented and are no longer throwing errors. However, in working out a replacement for the formerly-undocumented methods, I worked out a slightly cleaner implementation. So, this change is completely optional from a APIScan perspective, but I think it still has some small value.

Testing: Since this all has to do with AAD, I don't really have the right setup to setup for local testing. Everything still builds, let's see what CI says.

@Copilot Copilot AI review requested due to automatic review settings May 16, 2025 23:13
@benrr101 benrr101 requested a review from a team as a code owner May 16, 2025 23:13
Copy link
Contributor

@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 refactors the MSAL client application initialization by replacing undocumented With* methods with a builder-based approach using application options. The key changes include:

  • Switching to PublicClientApplicationBuilder.CreateWithApplicationOptions.
  • Introducing a conditional addition of WithParentActivityOrWindow for NETFRAMEWORK builds.
  • Consolidating the builder configuration and build process.
Comments suppressed due to low confidence (1)

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

  • Consider adding unit tests to validate both the branch where _iWin32WindowFunc is set and the branch where it is null to ensure the builder configuration is correct in all cases.
if (_iWin32WindowFunc is not null)

Copy link

codecov bot commented May 17, 2025

Codecov Report

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

Project coverage is 67.05%. Comparing base (dc1298a) to head (74d2faa).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...SqlClient/ActiveDirectoryAuthenticationProvider.cs 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3354      +/-   ##
==========================================
+ Coverage   65.16%   67.05%   +1.88%     
==========================================
  Files         300      300              
  Lines       65379    65376       -3     
==========================================
+ Hits        42606    43839    +1233     
+ Misses      22773    21537    -1236     
Flag Coverage Δ
addons 92.58% <ø> (ø)
netcore 72.20% <100.00%> (+3.78%) ⬆️
netfx 65.20% <91.66%> (-1.13%) ⬇️

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.

Copy link
Member

@cheenamalhotra cheenamalhotra left a comment

Choose a reason for hiding this comment

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

LGTM, please also backport this change to release branches we support, to avoid getting flagged in other branches.

@cheenamalhotra cheenamalhotra added this to the 6.1-preview2 milestone May 17, 2025
@cheenamalhotra cheenamalhotra requested a review from a team May 17, 2025 20:44
@benrr101 benrr101 merged commit 6d2473d into main May 19, 2025
251 checks passed
@benrr101 benrr101 deleted the dev/russellben/apiscan-withclientid branch May 19, 2025 16:37
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