You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-10 13:00:37 +00:00
C#: Array, Dictionary and marshaling refactoring
- Array and Dictionary now store `Variant` instead of `System.Object`. - Removed generic Array and Dictionary. They cause too much issues, heavily relying on reflection and very limited by the lack of a generic specialization. - Removed support for non-Godot collections. Support for them also relied heavily on reflection for marshaling. Support for them will likely be re-introduced in the future, but it will have to rely on source generators instead of reflection. - Reduced our use of reflection. The remaining usages will be moved to source generators soon. The only usage that I'm not sure yet how to replace is dynamic invocation of delegates.
This commit is contained in:
@@ -80,28 +80,9 @@ namespace Godot.SourceGenerators.Sample
|
||||
[Export] private Vector3[] field_Vector3Array = { Vector3.Up, Vector3.Down, Vector3.Left, Vector3.Right };
|
||||
[Export] private Color[] field_ColorArray = { Colors.Aqua, Colors.Aquamarine, Colors.Azure, Colors.Beige };
|
||||
[Export] private Godot.Object[] field_GodotObjectOrDerivedArray = { null };
|
||||
|
||||
// Generics
|
||||
[Export] private Godot.Collections.Dictionary<string, string> field_GodotGenericDictionary =
|
||||
new Godot.Collections.Dictionary<string, string> { { "key1", "value1" }, { "key2", "value2" } };
|
||||
|
||||
[Export] private Godot.Collections.Array<string> field_GodotGenericArray =
|
||||
new Godot.Collections.Array<string> { "elem1", "elem2", "elem3" };
|
||||
|
||||
[Export] private System.Collections.Generic.Dictionary<string, string> field_SystemGenericDictionary =
|
||||
new System.Collections.Generic.Dictionary<string, string> { { "key1", "value1" }, { "key2", "value2" } };
|
||||
|
||||
[Export] private System.Collections.Generic.List<string> field_SystemGenericList =
|
||||
new System.Collections.Generic.List<string> { "elem1", "elem2", "elem3" };
|
||||
|
||||
[Export] private System.Collections.Generic.IDictionary<string, string> field_GenericIDictionary =
|
||||
new System.Collections.Generic.Dictionary<string, string> { { "key1", "value1" }, { "key2", "value2" } };
|
||||
|
||||
[Export] private System.Collections.Generic.ICollection<string> field_GenericICollection =
|
||||
new System.Collections.Generic.List<string> { "elem1", "elem2", "elem3" };
|
||||
|
||||
[Export] private System.Collections.Generic.IEnumerable<string> field_GenericIEnumerable =
|
||||
new System.Collections.Generic.List<string> { "elem1", "elem2", "elem3" };
|
||||
[Export] private StringName[] field_StringNameArray = { "foo", "bar" };
|
||||
[Export] private NodePath[] field_NodePathArray = { "foo", "bar" };
|
||||
[Export] private RID[] field_RIDArray = { default, default, default };
|
||||
|
||||
// Variant
|
||||
[Export] private Variant field_Variant = "foo";
|
||||
@@ -118,15 +99,5 @@ namespace Godot.SourceGenerators.Sample
|
||||
|
||||
[Export] private Godot.Collections.Array field_GodotArray =
|
||||
new() { "foo", 10, Vector2.Up, Colors.Chocolate };
|
||||
|
||||
[Export] private System.Collections.IDictionary field_IDictionary =
|
||||
new System.Collections.Generic.Dictionary<object, object>
|
||||
{ { "foo", 10 }, { Vector2.Up, Colors.Chocolate } };
|
||||
|
||||
[Export] private System.Collections.ICollection field_ICollection =
|
||||
new System.Collections.Generic.List<object> { "foo", 10, Vector2.Up, Colors.Chocolate };
|
||||
|
||||
[Export] private System.Collections.IEnumerable field_IEnumerable =
|
||||
new System.Collections.Generic.List<object> { "foo", 10, Vector2.Up, Colors.Chocolate };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user