Add unit tests for GetInstalledWorkloads#52438
Merged
JeremyKuhne merged 2 commits intodotnet:mainfrom Jan 15, 2026
Merged
Conversation
baronfel
approved these changes
Jan 13, 2026
Contributor
There was a problem hiding this comment.
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
GetInstalledWorkloadsto accept an optionalsetupConfigurationparameter 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 |
test/dotnet.Tests/CommandTests/Workload/List/VisualStudioWorkloadsTests.cs
Outdated
Show resolved
Hide resolved
075b90c to
d836424
Compare
MiYanni
approved these changes
Jan 14, 2026
Add simple mocks and unit tests for GetInstalledWorkloads. These tests will help facilitate converting to direct COM for VS, which will allow AOT.
d836424 to
00f199e
Compare
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.
Add simple mocks and unit tests for GetInstalledWorkloads.
These tests will help facilitate converting to direct COM for VS, which will allow AOT.