Filip-Drabinski / Godot.DependencyInjection

Godot.DependencyInjection
MIT License
53 stars 6 forks source link

Upgrade to 0.3.0 from 0.2.3 fails with get_RawNode error #25

Open hawkerm opened 1 year ago

hawkerm commented 1 year ago

Describe the bug Tried updating to latest 0.3.0 and saw an issue from the Godot Debug window, if I downgrade the same code to 0.2.3 (and is the same code I had with 0.2.2) - it works fine.

To Reproduce Steps to reproduce the behavior:

  1. Follow instructions in Readme to add package to project
  2. Take the project with <PackageReference Include="Godot.DependencyInjection" Version="0.2.3"/> dependency
  3. Update to 0.3.0
  4. See failure

E 0:00:01:0026 :0 @ void Godot.DependencyInjection.DependencyInjectionManagerNode._EnterTree(): System.TypeLoadException: Method 'get_RawNode' in type 'Godot.DependencyInjection.NodeWrapper' from assembly 'Godot.DependencyInjection, Version=0.3.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation. <C++ Error> System.TypeLoadException <C++ Source> :0 @ void Godot.DependencyInjection.DependencyInjectionManagerNode._EnterTree()

:0 @ void Godot.DependencyInjection.DependencyInjectionManagerNode._EnterTree() Node.cs:2057 @ Boolean Godot.Node.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name& , Godot.NativeInterop.NativeVariantPtrArgs , Godot.NativeInterop.godot_variant& ) :0 @ Boolean Godot.DependencyInjection.DependencyInjectionManagerNode.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name& , Godot.NativeInterop.NativeVariantPtrArgs , Godot.NativeInterop.godot_variant& ) CSharpInstanceBridge.cs:24 @ Godot.NativeInterop.godot_bool Godot.Bridge.CSharpInstanceBridge.Call(IntPtr , Godot.NativeInterop.godot_string_name* , Godot.NativeInterop.godot_variant** , Int32 , Godot.NativeInterop.godot_variant_call_error* , Godot.NativeInterop.godot_variant* ) **Expected behavior** Dependency Injection system should load. **Screenshots** If applicable, add screenshots to help explain your problem. ![image](https://github.com/Filip-Drabinski/Godot.DependencyInjection/assets/8959496/0b3c44c0-fa58-49f5-bedc-7a0e259d0e37) **Desktop (please complete the following information):** - OS: Windows 10, Godot 4.1.1 **Additional context** Add any other context about the problem here.
EricDoherty commented 8 months ago

I get the same error and had to go back to 0.2.3. I downloaded the source for 0.3.0, but I am not sure where it is getting Nodewrapper's get_RawNode from. NodeWrapper has a RawNode property in the class and interface. Is it a source generator thing, I can't find any generated source with that reference either.

grofit commented 6 months ago

Just tried this library and got the same thing, any luck diagnosing it? (I have barely used Godot so have no context as to what is blowing up or why).

sylvie-spiral commented 1 month ago

Under the hood, C# used to (probably still does) compiles properties to a get and set so that other Common Language Model languages that might not support properties can access them.

Cloning the project after receiving the same error, I changed this line: internal readonly struct NodeWrapper : INodeWrapper

{
    object INodeWrapper.RawNode => Node;

Note that since this is an internal struct, the change should be non-breaking to the public API. I think C# is optimizing out the property accessor because it's an internal struct and nothing references that property in the code - I think it's not picking up that the interface references it, because of typing in the routine where it's used. But that's a guess.