Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use MMI instead of System.Management for dotnet core #25

Closed
wants to merge 27 commits into from

Conversation

shshzi
Copy link
Contributor

@shshzi shshzi commented Feb 7, 2021

This is to fix a problem where using a self-contained dotnet core application that uses System.Management requires specific dotnet framework to be installed on the machine (see here). Instead, we use MMI which is the recommended way. This still fails on some machine, such as Windows 7 SP1 without WMF3.0 installed so changes were made to fail silently and only use obtainable information when creating DeviceId.

  • Add support for MMI (Microsoft.Management.Infrastructure) in dotnet core instead of deprecated System.Management
  • Add DeviceIdComponentFailedToObtainValueException to indicate when a component can't be obtained (as opposed to having an empty or null value)

shshzi and others added 27 commits April 14, 2020 21:10
Add FileDeviceIdComponent, RegistryValueDeviceIdComponent and UnsupportedDeviceIdComponent.
* Ensure multi-values are sorted.
* Return null rather than empty string or "NoValue" when no value is present.
* Treat null values as empty strings when encoding.
* Use System.Text.Json instead of Newtonsoft.
* Don't include the dependency in the .NET 4 build, as it's not needed.
Previously WmiDeviceIdComponent queried all properties from the class. Now it only queries one property specified by _wmiProperty which makes the whole process near-instant.
And by "error handling" I just mean silently swallowing exceptions.
The following components are added:
* ProcessorId (as Apple Serial Number)
* SystemDriveSerialNumber
It didn't really fit under ProcessorId. It doesn't really fit in OSInstallationID either but it's a slightly better option.
… instead of deprecated System.Management

Add DeviceIdComponentFailedToObtainValueException to indicate when a component can't be obtained (as opposed to having an empty or null value)
… instead of deprecated System.Management

Add DeviceIdComponentFailedToObtainValueException to indicate when a component can't be obtained (as opposed to having an empty or null value)
@MatthewKing
Copy link
Owner

Hi. Thanks for this PR - it looks very useful. Are you able to rebase it on the top of the current branch so it's a bit easier to review and merge please? Thanks in advance.

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.

6 participants