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

Made custom data in layouts typed #356

Closed
wants to merge 1 commit into from

Conversation

RobertBeekman
Copy link
Collaborator

@RobertBeekman RobertBeekman commented Oct 31, 2023

I've been working on layout support in the Artemis workshop but I'm having some struggles serializing layouts.
The layout editor 'solves' this problem using this monstrosity: https://github.com/RobertBeekman/RGB.NET-Layout-Editor/blob/a91c944fedbcf320bdf0be2a25fbc267798a91af/src/LayoutEditor.UI/Pages/DeviceLayoutEditorViewModel.cs#L131C14-L131C14

I'd rather not adapt that for Artemis though, since I feel like the manual XML manipulation is a bit much.
To that end looked into what can be done to simplify things and I landed on this (sadly breaking) change.

@@ -14,7 +14,23 @@ namespace RGB.NET.Layout;
/// </summary>
[Serializable]
[XmlRoot("Device")]
public class DeviceLayout : IDeviceLayout
public class DeviceLayout : DeviceLayout<object, object>
Copy link
Collaborator Author

@RobertBeekman RobertBeekman Oct 31, 2023

Choose a reason for hiding this comment

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

I'm not a 100% sure on this, it's a nice shortcut to deal with layouts if you're not interested in custom data but it creates this scenario, which confused me a bit at first:

DeviceLayout layoutA = new DeviceLayout();
DeviceLayout<object, object> layoutB = new DeviceLayout<object, object>();

layoutA = layoutB; // not possible as DeviceLayout<object, object> is technically a subtype of DeviceLayout
layoutB = layoutA; // possible because DeviceLayout is a derived type of DeviceLayout<object, object>

@RobertBeekman
Copy link
Collaborator Author

Turns out the layout editor is just stupid

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.

1 participant