View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0001897||NoesisGUI||C# SDK||public||2021-01-21 15:53||2021-03-29 11:22|
|Target Version||3.0.12||Fixed in Version||3.0.12|
|Summary||0001897: .NET 5 has broken RunClassConstructor workaround|
unfortunately this workaround is no longer valid for .NET 5. Dependency properties are NOT recreated and remain disposed.
Simply calling "RuntimeHelpers.RunClassConstructor(type.TypeHandle);" doesn't work for this case too.
I'm urgently looking for a fix as it breaks our game.
|Tags||No tags attached.|
Apparently, TypeInitializer.Invoke(null, null) does nothing in .NET 5.
I've tried to manually reset the static field for dependency property (had to make it non-readonly) and calling TypeInitializer.Invoke(null, null) after it. Nothing has changed, the field remains null.
Besides dependency properties, there could be an issue with OverrideMetadata located in some static constructors and not being called too.
Wow, it's a big issue.
I've implemented a workaround but it's not good.
1. I've created a store of all the registered dependency properties (with their metadata) and "resurrect" all the registered dependency properties of type instead of using its TypeInitializer (by resurrection I mean construction of new native data and replacing the original pointer in the existing (disposed) dependency property instance). Surprisingly, it works very well!
2. I've created a store of all the OverrideMetadata calls (that are often used for DefaultStyleKeyProperty override) to store the DefaultValue of the provided metadata. I restore it for each registered type during TypeInitializer. It "seems" to work but I see that some style overrides are missing.
Considering my further steps.
Screenshot at 21-06-16.png (470,829 bytes)
The style seems to apply properly but either DataTrigger or ChangePropertyAction doesn't work.
For example, foreground change doesn't apply here (see the attachments, the one where there is no orange foreground for "Configure" text is broken.
Screenshot at 21-06-35.png (454,889 bytes)
Screenshot at 21-06-35-2.png (454,889 bytes)
Screenshot at 21-06-16-2.png (470,829 bytes)
|Got it working! Apparently, I needed to store not only DefaultValue but also PropertyChangedCallback and CoerceValueCallback. I no longer see any issues but need to perform further testing.|
I guess you implemented something similar to what you were saying in ticket 0001840.
Could you please share where did introduce that registry of properties?
How did you solve the problem of OverrideMetadata?
I totally forgot about the old ticket. Indeed, it's a similar solution.
It works well as I've tested it for a while now!
For OverrideMetadata I've also created a dictionary of Type->override. It's not ideal but does the job well for our case (as in our case all static constructors call OverrideMetadata for themselves only and not some other type).
If it would be convenient, I can provide a pull-request on Github so you can see the diff.
|The pull request on GitHub would be great, this was something we wanted to change sooner or later, but that problem with .NET 5 will force us to fix it now.|
Sure. Here is the pull request https://github.com/Noesis/Managed/pull/4
|2021-01-21 15:53||ai_enabled||New Issue|
|2021-01-21 16:35||ai_enabled||Note Added: 0006976|
|2021-01-21 16:35||ai_enabled||Note Edited: 0006976||View Revisions|
|2021-01-21 16:42||ai_enabled||Note Added: 0006977|
|2021-01-21 18:11||sfernandez||Relationship added||related to 0001840|
|2021-01-21 18:59||ai_enabled||Note Added: 0006980|
|2021-01-21 19:07||ai_enabled||File Added: Screenshot at 21-06-16.png|
|2021-01-21 19:07||ai_enabled||File Added: Screenshot at 21-06-35.png|
|2021-01-21 19:07||ai_enabled||Note Added: 0006981|
|2021-01-21 19:07||ai_enabled||File Added: Screenshot at 21-06-35-2.png|
|2021-01-21 19:07||ai_enabled||File Added: Screenshot at 21-06-16-2.png|
|2021-01-21 19:26||ai_enabled||Note Added: 0006982|
|2021-01-21 19:41||sfernandez||Assigned To||=> sfernandez|
|2021-01-21 19:41||sfernandez||Status||new => feedback|
|2021-01-21 19:41||sfernandez||Note Added: 0006983|
|2021-01-21 20:28||ai_enabled||Note Added: 0006984|
|2021-01-21 20:28||ai_enabled||Status||feedback => assigned|
|2021-01-21 20:28||ai_enabled||Note Edited: 0006984||View Revisions|
|2021-01-21 20:36||sfernandez||Status||assigned => feedback|
|2021-01-21 20:36||sfernandez||Note Added: 0006986|
|2021-02-08 20:07||ai_enabled||Note Added: 0007024|
|2021-02-08 20:07||ai_enabled||Status||feedback => assigned|
|2021-03-29 11:22||sfernandez||Status||assigned => resolved|
|2021-03-29 11:22||sfernandez||Resolution||open => fixed|
|2021-03-29 11:22||sfernandez||Fixed in Version||=> 3.0.12|
|2021-03-29 11:22||sfernandez||Target Version||=> 3.0.12|