Break circular dependency: remove Test.Common reference from Lab.Api#5896
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
ManagedIdentityTestUtilinto Lab.Api (while preserving its original public namespace) and updated Public API tracking accordingly. - Replaced MSTest
Assertusage 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. |
RyAuld
approved these changes
Apr 2, 2026
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. |
Avery-Dunn
approved these changes
Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the
ProjectReferencefromMicrosoft.Identity.Lab.Api→Microsoft.Identity.Test.Commontobreak a circular dependency, and inverts the reference so
Test.Common→Lab.Api.Changes
ManagedIdentityTestUtilfromTest.CommonintoLab.Api/Helpers/as the canonicaldefinition (public, original namespace preserved).
Assertclass (Lab.Api/Helpers/Assert.cs) that throwsInvalidOperationException, replacing all MSTestAssertusages in Lab.Api — Lab.Api hasno MSTest dependency.
CoreAssert,TestCommon,AppAccessorWithPartitionAsserts,UserAccessorWithPartitionAssertsintoLab.Api/Helpers/using the custom Assert class.ProjectReferencefromTest.Common→Lab.Api(no cycle).usingdirectives in Lab.Api mock files andPublicAPI.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)