MatthewKing / DeviceId

A simple library providing functionality to generate a 'device ID' that can be used to uniquely identify a computer.
MIT License
722 stars 118 forks source link

AddUserName() on Windows: Optionally normalize case #80

Closed IsThatUniqueEnough closed 8 months ago

IsThatUniqueEnough commented 8 months ago

AddUserName() creates a component that returns the value of Environment.UserName. Usernames on windows are case-insensitive and Environment.UserName returns the name exactly as entered when the user logged in. So for a user named "sam" the component could e.g. return "sam", "Sam", "sAm",... depending on how the user typed the name while logging in.

For ID'ing purposes it would be desireable to (optionally?) normalize the case of the value to e.g. all lower case.

MatthewKing commented 8 months ago

Thanks, good catch.

I'd like to normalize this by default but I don't want to break backwards compatibility. I'll probably add it as an optional feature that is disabled by default for the current version (v6), and then next version (v7) will have a breaking change to enable normalization by default.

MatthewKing commented 8 months ago

I've added a normalize parameter to AddUserName. Default is false for now, but will consider changing it to true in a future major version release. Thanks again for this issue report.

IsThatUniqueEnough commented 8 months ago

Thanks, Yesterdays changes all work like a charm.

When changing the default please consider that usernames on systems other than Windows can be case sensitive. If they aren't I'm not sure whether Environment.UserName is normalized or as typed.

The least surprising behaviour would probably be to default to normalization on Windows only.