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

4.0.x C# error messages needlessly obfuscated #67451

Closed
FyiurAmron opened this issue Oct 15, 2022 · 0 comments · Fixed by #71943
Closed

4.0.x C# error messages needlessly obfuscated #67451

FyiurAmron opened this issue Oct 15, 2022 · 0 comments · Fixed by #71943

Comments

@FyiurAmron
Copy link

FyiurAmron commented Oct 15, 2022

Godot version

4.0.x + .NET (all versions until at least beta3 inclusive)

System information

any .NET-supporting (Windows e.g.)

Issue description

As of 4.0.x, the errors emitted by .NET runtime are wrapped with C++ exception and reported as such. Although the usual information from the C# exception is available, it's not directly visible, and the 1st-order culprit is always the 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* ): , which is completely redundant in the logs:

image

All the useful information is hidden under the tree:

image

Since this is a debugging message, it should be as clear and useful as possible. Current opening line hardly says anything, and since 99% of the runtime errors in case of a Godot app with C# scripting will be reported this way, In 3.5.x (and previous), this was a lot more sane:

image

, which could be expanded to

image

Basically, the expected fix would be to change the reported debugging error message from

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* ): System.NullReferenceException: Object reference not set to an instance of an object.
  <C++ Error>    Exception
  <C++ Source>   C:\Codes\Godot\_Projects\SolitaireWarrior\scripts\Logic\BattleSceneController.cs:24 @ SolitaireWarrior.Logic.BattleSceneController..ctor(SolitaireWarrior.Logic.BattleScene )()
  <Stack Trace>  BattleSceneController.cs:24 @ SolitaireWarrior.Logic.BattleSceneController..ctor(SolitaireWarrior.Logic.BattleScene )()
                 BattleSceneNode.cs:9 @ void SolitaireWarrior.Nodes.BattleSceneNode._Ready()()
                 Node.cs:1809 @ Boolean Godot.Node.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name& , Godot.NativeInterop.NativeVariantPtrArgs , Int32 , Godot.NativeInterop.godot_variant& )()
                 Node3D.cs:1016 @ Boolean Godot.Node3D.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name& , Godot.NativeInterop.NativeVariantPtrArgs , Int32 , Godot.NativeInterop.godot_variant& )()
                 SolitaireWarrior.Nodes.BattleSceneNode_ScriptMethods_Generated.cs:26 @ Boolean SolitaireWarrior.Nodes.BattleSceneNode.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name& , Godot.NativeInterop.NativeVariantPtrArgs , Int32 , 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* )()

into e.g.

SolitaireWarrior.Logic.BattleSceneController..ctor(SolitaireWarrior.Logic.BattleScene )(): System.NullReferenceException: Object reference not set to an instance of an object.
  <C++ Error>    Exception
  <C++ Source>   C:\Codes\Godot\_Projects\SolitaireWarrior\scripts\Logic\BattleSceneController.cs:24 @ SolitaireWarrior.Logic.BattleSceneController..ctor(SolitaireWarrior.Logic.BattleScene )()
  <Stack Trace>  BattleSceneController.cs:24 @ SolitaireWarrior.Logic.BattleSceneController..ctor(SolitaireWarrior.Logic.BattleScene )()
                 BattleSceneNode.cs:9 @ void SolitaireWarrior.Nodes.BattleSceneNode._Ready()()
                 Node.cs:1809 @ Boolean Godot.Node.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name& , Godot.NativeInterop.NativeVariantPtrArgs , Int32 , Godot.NativeInterop.godot_variant& )()
                 Node3D.cs:1016 @ Boolean Godot.Node3D.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name& , Godot.NativeInterop.NativeVariantPtrArgs , Int32 , Godot.NativeInterop.godot_variant& )()
                 SolitaireWarrior.Nodes.BattleSceneNode_ScriptMethods_Generated.cs:26 @ Boolean SolitaireWarrior.Nodes.BattleSceneNode.InvokeGodotClassMethod(Godot.NativeInterop.godot_string_name& , Godot.NativeInterop.NativeVariantPtrArgs , Int32 , 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* )()

If, for whatever reason, the current (4.0.x) behaviour would be considered useful (although I don't see how), there could be a config option to select the type of log message emitted.

Steps to reproduce

  1. create any C# project with a runtime error,
  2. run,
  3. look at the error message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants