Skip to content

chore: Remove System.Management dependency from Portability.RuntimeInformation - #3225

Merged
timcassell merged 1 commit into
dotnet:masterfrom
filzrev:chore-remove-some-systemmanagement-deps
Aug 8, 2026
Merged

chore: Remove System.Management dependency from Portability.RuntimeInformation#3225
timcassell merged 1 commit into
dotnet:masterfrom
filzrev:chore-remove-some-systemmanagement-deps

Conversation

@filzrev

@filzrev filzrev commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

This PR contains following changes.

1. Modify RuntimeInformation.GetAntivirusProducts

Remove dependency to System.Management and migrate code to used PowerShell/Pwsh based implementation.

This code is called only when EnvironmentAnalyser raise warnings.
So external process invocation overhead can be ignored (it takes about 500-700ms)

2. Modift RuntimeInformation.GetVirtualMachineHypervisor

Remove dependency to System.Management and modify code to get values from equivalent registry settings.

3. Add test on BenchmarkDotNet.Tests/Environments/HostEnvironmentInfoTests.cs

Add tests to verify GetAntivirusProducts lazy initialized value.

Comment thread tests/BenchmarkDotNet.Tests/Environments/HostEnvironmentInfoTests.cs Outdated

@timcassell timcassell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What's the gain here? It doesn't look like the dependency is removed from BDN entirely.

@filzrev
filzrev force-pushed the chore-remove-some-systemmanagement-deps branch from 7feeafa to 9ce7228 Compare August 8, 2026 03:29
@filzrev

filzrev commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

What's the gain here? It doesn't look like the dependency is removed from BDN entirely.

When running NativeAot benchmarks following System.Management related warning are raised.

warning IL2104: Assembly 'System.Management' produced trim warnings. For more information see https://aka.ms/il2104
warning IL3053: Assembly 'System.Management' produced AOT analysis warnings.

As far as I've confirmed,
Existing WMI/CIM queries works under NativeAot when BuiltInComInteropSupport=true is enabled.

Though, it's better to remove System.Management dependency completely. Because System.Management is not expected to support trimming.

Remaining System.Management dependency is MosCpuDetector.
And it'll be handled on another PR. (It needs to add another Win32 API dependencies)

@timcassell
timcassell merged commit b515068 into dotnet:master Aug 8, 2026
11 checks passed
@timcassell timcassell added this to the v0.16.0 milestone Aug 8, 2026
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.

2 participants