Skip to content

Break circular dependency: remove Test.Common reference from Lab.Api#5896

Merged
gladjohn merged 3 commits into
mainfrom
gladjohn/fix_lab_api_final
Apr 3, 2026
Merged

Break circular dependency: remove Test.Common reference from Lab.Api#5896
gladjohn merged 3 commits into
mainfrom
gladjohn/fix_lab_api_final

Conversation

@gladjohn

@gladjohn gladjohn commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes the ProjectReference from Microsoft.Identity.Lab.ApiMicrosoft.Identity.Test.Common to
break a circular dependency, and inverts the reference so Test.CommonLab.Api.

Changes

  • Moved ManagedIdentityTestUtil from Test.Common into Lab.Api/Helpers/ as the canonical
    definition (public, original namespace preserved).
  • Created a lightweight Assert class (Lab.Api/Helpers/Assert.cs) that throws
    InvalidOperationException, replacing all MSTest Assert usages in Lab.Api — Lab.Api has
    no MSTest dependency.
  • Copied CoreAssert, TestCommon, AppAccessorWithPartitionAsserts,
    UserAccessorWithPartitionAsserts
    into Lab.Api/Helpers/ using the custom Assert class.
  • Added ProjectReference from Test.CommonLab.Api (no cycle).
  • Updated using directives in Lab.Api mock files and PublicAPI.Unshipped.txt.

Dependency graph (after)

Lab.Api → MSAL.Client (no Test.Common, no MSTest) Test.Common → MSAL.Client + Lab.Api Test.Unit → Test.Common + Lab.Api

Validation

  • dotnet build LibsAndSamples.sln — ✅ (only pre-existing MAUI/WPF SDK errors)
  • Unit tests net8.0: 1831 passed, 19 skipped
  • Unit tests net48: 1836 passed, 19 skipped

Copilot AI review requested due to automatic review settings April 2, 2026 15:02
@gladjohn gladjohn requested a review from a team as a code owner April 2, 2026 15:02

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.

Pull request overview

This PR breaks the circular dependency between Microsoft.Identity.Lab.Api and Microsoft.Identity.Test.Common by removing the Lab.Api → Test.Common reference and inverting it to Test.Common → Lab.Api, while keeping needed test/mocking utilities available.

Changes:

  • Inverted the project reference direction (Test.Common now references Lab.Api; Lab.Api no longer references Test.Common).
  • Moved/canonicalized ManagedIdentityTestUtil into Lab.Api (while preserving its original public namespace) and updated Public API tracking accordingly.
  • Replaced MSTest Assert usage inside Lab.Api with an internal lightweight assertion helper and migrated/copies supporting helpers into Lab.Api.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/Microsoft.Identity.Test.Common/Microsoft.Identity.Test.Common.csproj Adds project reference to Lab.Api to invert the dependency direction.
tests/Microsoft.Identity.Test.Common/ManagedIdentityTestUtil.cs Removes the duplicate ManagedIdentityTestUtil from Test.Common (now sourced from Lab.Api).
src/client/Microsoft.Identity.Lab.Api/Microsoft.Identity.Lab.Api.csproj Removes ProjectReference to Test.Common to break the cycle.
src/client/Microsoft.Identity.Lab.Api/UI/MockWebUI.cs Replaces MSTest Assert dependency with Lab.Api internal assertion helper.
src/client/Microsoft.Identity.Lab.Api/Internal/TestConstants.cs Removes MSTest using to keep Lab.Api framework-agnostic.
src/client/Microsoft.Identity.Lab.Api/Http/TokenCacheHelper.cs Updates helper references to use utilities now located in Lab.Api.
src/client/Microsoft.Identity.Lab.Api/Http/MockHttpMessageHandler.cs Switches assertions to Lab.Api helper Assert and removes MSTest dependency.
src/client/Microsoft.Identity.Lab.Api/Http/MockHttpManager.cs Removes MSTest using and uses Lab.Api assertion helper.
src/client/Microsoft.Identity.Lab.Api/Http/MockHttpAndServiceBundle.cs Removes MSTest using and uses Lab.Api helper utilities.
src/client/Microsoft.Identity.Lab.Api/Http/MockHelpers.cs Removes MSTest logging dependency from Lab.Api mocks.
src/client/Microsoft.Identity.Lab.Api/Helpers/Assert.cs Introduces internal assertion helper (InvalidOperationException-based) to replace MSTest Assert in Lab.Api.
src/client/Microsoft.Identity.Lab.Api/Helpers/CoreAssert.cs Adds assertion utilities adapted to the new internal Assert.
src/client/Microsoft.Identity.Lab.Api/Helpers/TestCommon.cs Copies TestCommon helper logic into Lab.Api to remove reliance on Test.Common.
src/client/Microsoft.Identity.Lab.Api/Helpers/ManagedIdentityTestUtil.cs Hosts the canonical ManagedIdentityTestUtil implementation in Lab.Api while preserving the original public namespace.
src/client/Microsoft.Identity.Lab.Api/Helpers/AppAccessorWithPartitionAsserts.cs Adds strict partitioned app-cache accessor with internal assertions.
src/client/Microsoft.Identity.Lab.Api/Helpers/UserAccessorWithPartitionAsserts.cs Adds strict partitioned user-cache accessor with internal assertions.
src/client/Microsoft.Identity.Lab.Api/PublicAPI.Unshipped.txt Updates API tracking to reflect moved/public surface and signature ordering.

Comment thread src/client/Microsoft.Identity.Lab.Api/Helpers/UserAccessorWithPartitionAsserts.cs Outdated
Comment thread src/client/Microsoft.Identity.Lab.Api/Helpers/Assert.cs
@gladjohn

gladjohn commented Apr 2, 2026

Copy link
Copy Markdown
Contributor Author

published - https://www.nuget.org/packages/Microsoft.Identity.Lab.Api/0.1.3

and tested with IdWeb - AzureAD/microsoft-identity-web#3765

Can confirm this now works. No more circular dependency and no more MSTEST4 errors in IdWeb.

@gladjohn gladjohn enabled auto-merge (squash) April 2, 2026 19:47
Copilot AI review requested due to automatic review settings April 3, 2026 15: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.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Comment thread src/client/Microsoft.Identity.Lab.Api/Helpers/Assert.cs
@gladjohn gladjohn merged commit 2007082 into main Apr 3, 2026
16 checks passed
@gladjohn gladjohn deleted the gladjohn/fix_lab_api_final branch April 3, 2026 16:33
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.

4 participants