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

Validating device id when you have multiple versions #85

Open
andrewwong0893 opened this issue Feb 28, 2024 · 1 comment
Open

Validating device id when you have multiple versions #85

andrewwong0893 opened this issue Feb 28, 2024 · 1 comment

Comments

@andrewwong0893
Copy link

Hello,

Correct me if I am wrong but I have the following example:

var id = new DeviceIdBuilder()
    .AddMachineName()
    .AddMacAddress(excludeWireless: true)
    .OnWindows(windows => windows.AddMachineGuid());

var idManager = new DeviceIdManager()
    .AddBuilder(1, builder => builder
        .AddMacAddress(excludeWireless: true)
        .OnWindows(windows => windows.AddMachineGuid()))
    .AddBuilder(2, builder => builder
        .AddMachineName()
        .AddMacAddress(excludeWireless: true)
        .OnWindows(windows => windows.AddMachineGuid()));

If I were to run the following

var isValid = idManager.Validate(id.ToString());

I get a failed result when I expected this to pass.

If I was to comment out the .AddMachineName() and then run it, version one of the ID Manager would then say it is valid.

When I dived into validate method of the ID Manager, it looks like I am expecting to send a string of the following format: ${version}${deviceId}

This seems counter-intuitive as the DeviceIdBuilder does not output a version.

Looking into your other methods in DeviceIdManager, you have an override for ToString which basically does the exact same thing as the builder but it includes the version number in.

Should I be using the manager instead?

@MatthewKing
Copy link
Owner

MatthewKing commented Mar 11, 2024

Hello. Yep, you should be using the manager. DeviceIdBuilder knows nothing about versions. You need to use DeviceIdManager to generate your versioned device ID, using the DeviceIdManager.GetDeviceId method (or the ToString method).

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

No branches or pull requests

2 participants