Skip to content

Add unit tests for GetInstalledWorkloads#52438

Merged
JeremyKuhne merged 2 commits intodotnet:mainfrom
JeremyKuhne:vswltests
Jan 15, 2026
Merged

Add unit tests for GetInstalledWorkloads#52438
JeremyKuhne merged 2 commits intodotnet:mainfrom
JeremyKuhne:vswltests

Conversation

@JeremyKuhne
Copy link
Member

Add simple mocks and unit tests for GetInstalledWorkloads.

These tests will help facilitate converting to direct COM for VS, which will allow AOT.

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 adds comprehensive unit tests for the GetInstalledWorkloads method in the Visual Studio workload detection functionality. It introduces mock implementations of Visual Studio Setup Configuration COM interfaces to enable testing without requiring actual VS installations, facilitating future conversion to direct COM for AOT compatibility.

Changes:

  • Added 18 unit tests covering various scenarios for workload detection from Visual Studio installations
  • Created mock implementations of COM interfaces (ISetupInstance2, ISetupPackageReference, IEnumSetupInstances, ISetupConfiguration2)
  • Modified GetInstalledWorkloads to accept an optional setupConfiguration parameter for dependency injection
  • Enabled nullable reference types in the production code by removing #nullable disable

Reviewed changes

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

File Description
test/dotnet.Tests/dotnet.Tests.csproj Added package reference for Microsoft.VisualStudio.Setup.Configuration.Interop to support COM interface testing
test/dotnet.Tests/CommandTests/Workload/List/VisualStudioWorkloadsTests.cs New test file with 18 unit tests and mock implementations for VS Setup Configuration COM interfaces
src/Cli/dotnet/Commands/Workload/List/VisualStudioWorkloads.cs Modified to support dependency injection of setup configuration, enabled nullable reference types, and improved code formatting

Add simple mocks and unit tests for GetInstalledWorkloads.

These tests will help facilitate converting to direct COM for VS, which will allow AOT.
@JeremyKuhne JeremyKuhne merged commit a2fd414 into dotnet:main Jan 15, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants