mirror of
https://github.com/qmlnet/qmlnet.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #135] Structs confuse their members #81
Labels
No labels
bug
enhancement
help wanted
help wanted
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/qmlnet#81
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vadi2 on GitHub (May 17, 2019).
Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/135
If I have the following as a struct:
Then the interop to QML will... confuse what member stores what. For example the following debug output:
C# code:
QML code:
Will have this strange result:
C#:
severity: Error, text: Instance failed constraint sdf-20 "No slicing on the root element", location: StructureDefinition.differential[0]
QML:
severity: , text: Error, location: Instance failed constraint sdf-20 "No slicing on the root element"
Changing the struct to be a class magically fixed everything.
@pauldotknopf commented on GitHub (Jun 10, 2019):
This does indeed appear to be an issue with Qml.Net. I will look into it.
However, I strongly suggest not having mutable structs. If you need mutability, just make it a class.
@pauldotknopf commented on GitHub (Jun 10, 2019):
I tried to resolve the problem, couldn't work it out.
I've added a failing test if someone else wants to take a stab at it.
See commit
c8fac8f@pauldotknopf commented on GitHub (Jun 10, 2019):
I use SharpLab to inspect IL.