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

Support device names with underscores (such as 'Default_Monitor') in JSONHelpers.isValidDeviceId #1826

Merged
merged 3 commits into from
Apr 2, 2020
Merged

Conversation

GeertvanHorrik
Copy link
Contributor

@GeertvanHorrik GeertvanHorrik commented Apr 1, 2020

Summary of the Pull Request

Fixes #1821

References

I think this could be related to #1807

PR Checklist

Detailed Description of the Pull Request / Additional comments

Fixes the JSONHelper::isValidDeviceId by splitting the first section on the '#' instead of by '_'. This allows to use underscores in monitor device names.

Validation Steps Performed

@@ -1011,7 +1017,7 @@ namespace FancyZonesUnitTests
for (int i = 0; i < 10; i++)
{
json::JsonObject obj = json::JsonObject::Parse(m_defaultCustomDeviceStr);
obj.SetNamedValue(L"device-id", json::JsonValue::CreateStringValue(std::to_wstring(i) + L"_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}"));
obj.SetNamedValue(L"device-id", json::JsonValue::CreateStringValue(std::to_wstring(i) + L"#_1920_1200_{39B25DD2-130D-4B5D-8851-4791D66B1539}"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Please see #1827
We can't force the # to be present since it is currently supported and several users may have it without it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is a device id without # actually a real-case scenario? I am happy to search for #, and only then use that logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it's a real case scenario as you can see in this issue #1777 (comment), where Windows fails to return a proper ID for a connected monitor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed a fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Excellent!

Copy link
Contributor

@enricogior enricogior left a comment

Choose a reason for hiding this comment

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

Tested and it works as expected.
Thank you very much for fixing this!

@ivan100sic
Copy link
Contributor

Perhaps you should add a test like this:

TEST_METHOD (DeviceIdWithoutHashInName)
{
    const auto deviceId = L"LOCALDISPLAY_5120_1440_{00000000-0000-0000-0000-000000000000}";
    Assert::IsTrue(isValidDeviceId(deviceId));
}

@enricogior
Copy link
Contributor

@ivan100sic
sure.

@stefansjfw
Copy link
Collaborator

Nice work! Works as expected!

@enricogior
Copy link
Contributor

@GeertvanHorrik if you can add the suggested test it would be great, but we can also add it after the PR is merged. We would like to merge it today.

@GeertvanHorrik
Copy link
Contributor Author

Will do it now.

@GeertvanHorrik
Copy link
Contributor Author

Done, ready for another review.

Copy link
Contributor

@ivan100sic ivan100sic left a comment

Choose a reason for hiding this comment

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

Good job! I like the extra test you added.

@enricogior enricogior merged commit 96fbc96 into microsoft:master Apr 2, 2020
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.

FanzyZones no longer working for remote desktop sessions in v0.16
4 participants