View Issue Details

IDProjectCategoryView StatusLast Update
0001897NoesisGUIC# SDKpublic2021-03-29 11:22
Reporterai_enabledAssigned Tosfernandez 
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.0.9 
Target Version3.0.12Fixed in Version3.0.12 
Summary0001897: .NET 5 has broken RunClassConstructor workaround
DescriptionHi guys,
code https://github.com/Noesis/Managed/blob/151a432f4ce2610bb0d70332e7014f4c442405b4/Src/Noesis/Core/Src/Core/Extend.cs#L1687
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.

Regards!
TagsNo tags attached.
PlatformAny

Relationships

related to 0001840 assignedsfernandez NoesisGUI reloading issue: RunClassConstructor invokes static constructor to reinit dependency properties 

Activities

ai_enabled

ai_enabled

2021-01-21 16:35

updater   ~0006976

Last edited: 2021-01-21 16:35

View 2 revisions

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.

ai_enabled

ai_enabled

2021-01-21 16:42

updater   ~0006977

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.
ai_enabled

ai_enabled

2021-01-21 18:59

updater   ~0006980

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.
ai_enabled

ai_enabled

2021-01-21 19:07

updater  

Screenshot at 21-06-16.png (470,829 bytes)
ai_enabled

ai_enabled

2021-01-21 19:07

updater   ~0006981

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)
ai_enabled

ai_enabled

2021-01-21 19:07

updater  

Screenshot at 21-06-35-2.png (454,889 bytes)
ai_enabled

ai_enabled

2021-01-21 19:07

updater  

Screenshot at 21-06-16-2.png (470,829 bytes)
ai_enabled

ai_enabled

2021-01-21 19:26

updater   ~0006982

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.
sfernandez

sfernandez

2021-01-21 19:41

manager   ~0006983

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?
ai_enabled

ai_enabled

2021-01-21 20:28

updater   ~0006984

Last edited: 2021-01-21 20:28

View 2 revisions

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.

sfernandez

sfernandez

2021-01-21 20:36

manager   ~0006986

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.
ai_enabled

ai_enabled

2021-02-08 20:07

updater   ~0007024

Sure. Here is the pull request https://github.com/Noesis/Managed/pull/4
Enjoy!

Issue History

Date Modified Username Field Change
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