Godot version: 3.0.6.stable.mono.official.8314054
OS/device including version: Ubuntu 17.10 artful
Kernal: x86_64 Linux 4.13.0-46-generic
Issue description: An error was printed when I put an entry into a dictionary, and the entry is not set.
The error message is very inconsistent, sometimes it puts Method/Function Failed, returning: Variant() and other times it puts special characters like
Steps to reproduce:
Godot.Dictionary<int, TestHolder> dict = new Godot.Dictionary<int, TestHolder>();
dict[0] = new TestHolder();
GD.Print(dict[0]);
public struct TestHolder
{
}
Minimal reproduction project: Project.zip
A Godot.Dictionary can only store Variant supported types. It's the same for API methods that receive Variant; the parameter type in C# is System.Object and the user must make sure not to pass something with an invalid type.
This will be changed soon however, and you will be able to store anything where a Variant is expected, so this won't stay as a problem for too long.
I'm surprised about the error messages you mention though, since there is a custom message for this error: https://github.com/godotengine/godot/blob/399910ddd82e84f078ebefb3ed2c51d2ef989235/modules/mono/mono_gd/gd_mono_marshal.cpp#L680-L682
Hey, it's my brother! Neikeq is correct that it should throw a different error.
@neikeq Assuming we can get the correct error to be thrown, it might be a good idea if the error was a bit more user-friendly. Something like: "The type " + type.type_class->get_name() + " cannot be used with Godot.Collections.Dictionary, only built-in Godot types can be used".
@neikeq looking at what you posted, would there be a reason for DEBUG_ENABLED to not be enabled preventing that error showing up https://github.com/godotengine/godot/blob/5bd0ff003fdd82cf84a557251633ebb83bad4fd5/core/error_macros.h#L93 and like you said line 682 triggers based on the error message they see, but for w/e reason err explain isn't showing anything which would only happen if debug enabled wasn't set right?
Ah, yes. I guess that's the reason. I thought he would be running from the editor.
I updated the minimal reproduction project to Godot 3.2.3: TestProjectBut3.2.3.zip
And I discovered that the correct error message now shows up:

I think this issue is resolved now, the error message when trying to perform this invalid operation is now descriptive.
Closing as fixed.
Most helpful comment
A
Godot.Dictionarycan only store Variant supported types. It's the same for API methods that receive Variant; the parameter type in C# isSystem.Objectand the user must make sure not to pass something with an invalid type.This will be changed soon however, and you will be able to store anything where a Variant is expected, so this won't stay as a problem for too long.
I'm surprised about the error messages you mention though, since there is a custom message for this error: https://github.com/godotengine/godot/blob/399910ddd82e84f078ebefb3ed2c51d2ef989235/modules/mono/mono_gd/gd_mono_marshal.cpp#L680-L682