You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-21 14:57:09 +00:00
Cleanup C# projects, code quality & style
New rules: - Do not silence CA1805 any more - Limit where we silence CA1707, CA1711, CA1720 - Enforce severity=warning for IDE0040 - Enforce Allman style braces - Enforce naming conventions (IDE1006 is still severity=suggestion) Fixes: - Fix REFL045, CS1572, CS1573 - Suppress CS0618 when generating `InvokeGodotClassMethod` - Fix indent when generating GD_constants.cs - Temporarily silence CS1734 in generated code - Fix a lot of naming rule violations Misc.: - Remove ReSharper comments for RedundantNameQualifier - Remove suppression attributes for RedundantNameQualifier - Remove severity=warnings for CA1716, CA1304 (already included in the level of analysis we run)
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
namespace Godot.SourceGenerators.Sample
|
||||
{
|
||||
partial class Bar : GodotObject
|
||||
public partial class Bar : GodotObject
|
||||
{
|
||||
}
|
||||
|
||||
// Foo in another file
|
||||
partial class Foo
|
||||
public partial class Foo
|
||||
{
|
||||
}
|
||||
|
||||
partial class NotSameNameAsFile : GodotObject
|
||||
public partial class NotSameNameAsFile : GodotObject
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,106 +13,106 @@ namespace Godot.SourceGenerators.Sample
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public partial class ExportedFields : GodotObject
|
||||
{
|
||||
[Export] private Boolean field_Boolean = true;
|
||||
[Export] private Char field_Char = 'f';
|
||||
[Export] private SByte field_SByte = 10;
|
||||
[Export] private Int16 field_Int16 = 10;
|
||||
[Export] private Int32 field_Int32 = 10;
|
||||
[Export] private Int64 field_Int64 = 10;
|
||||
[Export] private Byte field_Byte = 10;
|
||||
[Export] private UInt16 field_UInt16 = 10;
|
||||
[Export] private UInt32 field_UInt32 = 10;
|
||||
[Export] private UInt64 field_UInt64 = 10;
|
||||
[Export] private Single field_Single = 10;
|
||||
[Export] private Double field_Double = 10;
|
||||
[Export] private String field_String = "foo";
|
||||
[Export] private Boolean _fieldBoolean = true;
|
||||
[Export] private Char _fieldChar = 'f';
|
||||
[Export] private SByte _fieldSByte = 10;
|
||||
[Export] private Int16 _fieldInt16 = 10;
|
||||
[Export] private Int32 _fieldInt32 = 10;
|
||||
[Export] private Int64 _fieldInt64 = 10;
|
||||
[Export] private Byte _fieldByte = 10;
|
||||
[Export] private UInt16 _fieldUInt16 = 10;
|
||||
[Export] private UInt32 _fieldUInt32 = 10;
|
||||
[Export] private UInt64 _fieldUInt64 = 10;
|
||||
[Export] private Single _fieldSingle = 10;
|
||||
[Export] private Double _fieldDouble = 10;
|
||||
[Export] private String _fieldString = "foo";
|
||||
|
||||
// Godot structs
|
||||
[Export] private Vector2 field_Vector2 = new(10f, 10f);
|
||||
[Export] private Vector2I field_Vector2I = Vector2I.Up;
|
||||
[Export] private Rect2 field_Rect2 = new(new Vector2(10f, 10f), new Vector2(10f, 10f));
|
||||
[Export] private Rect2I field_Rect2I = new(new Vector2I(10, 10), new Vector2I(10, 10));
|
||||
[Export] private Transform2D field_Transform2D = Transform2D.Identity;
|
||||
[Export] private Vector3 field_Vector3 = new(10f, 10f, 10f);
|
||||
[Export] private Vector3I field_Vector3I = Vector3I.Back;
|
||||
[Export] private Basis field_Basis = new Basis(Quaternion.Identity);
|
||||
[Export] private Quaternion field_Quaternion = new Quaternion(Basis.Identity);
|
||||
[Export] private Transform3D field_Transform3D = Transform3D.Identity;
|
||||
[Export] private Vector4 field_Vector4 = new(10f, 10f, 10f, 10f);
|
||||
[Export] private Vector4I field_Vector4I = Vector4I.One;
|
||||
[Export] private Projection field_Projection = Projection.Identity;
|
||||
[Export] private Aabb field_Aabb = new Aabb(10f, 10f, 10f, new Vector3(1f, 1f, 1f));
|
||||
[Export] private Color field_Color = Colors.Aquamarine;
|
||||
[Export] private Plane field_Plane = Plane.PlaneXZ;
|
||||
[Export] private Callable field_Callable = new Callable(Engine.GetMainLoop(), "_process");
|
||||
[Export] private Signal field_Signal = new Signal(Engine.GetMainLoop(), "property_list_changed");
|
||||
[Export] private Vector2 _fieldVector2 = new(10f, 10f);
|
||||
[Export] private Vector2I _fieldVector2I = Vector2I.Up;
|
||||
[Export] private Rect2 _fieldRect2 = new(new Vector2(10f, 10f), new Vector2(10f, 10f));
|
||||
[Export] private Rect2I _fieldRect2I = new(new Vector2I(10, 10), new Vector2I(10, 10));
|
||||
[Export] private Transform2D _fieldTransform2D = Transform2D.Identity;
|
||||
[Export] private Vector3 _fieldVector3 = new(10f, 10f, 10f);
|
||||
[Export] private Vector3I _fieldVector3I = Vector3I.Back;
|
||||
[Export] private Basis _fieldBasis = new Basis(Quaternion.Identity);
|
||||
[Export] private Quaternion _fieldQuaternion = new Quaternion(Basis.Identity);
|
||||
[Export] private Transform3D _fieldTransform3D = Transform3D.Identity;
|
||||
[Export] private Vector4 _fieldVector4 = new(10f, 10f, 10f, 10f);
|
||||
[Export] private Vector4I _fieldVector4I = Vector4I.One;
|
||||
[Export] private Projection _fieldProjection = Projection.Identity;
|
||||
[Export] private Aabb _fieldAabb = new Aabb(10f, 10f, 10f, new Vector3(1f, 1f, 1f));
|
||||
[Export] private Color _fieldColor = Colors.Aquamarine;
|
||||
[Export] private Plane _fieldPlane = Plane.PlaneXZ;
|
||||
[Export] private Callable _fieldCallable = new Callable(Engine.GetMainLoop(), "_process");
|
||||
[Export] private Signal _fieldSignal = new Signal(Engine.GetMainLoop(), "property_list_changed");
|
||||
|
||||
// Enums
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
enum MyEnum
|
||||
public enum MyEnum
|
||||
{
|
||||
A,
|
||||
B,
|
||||
C
|
||||
}
|
||||
|
||||
[Export] private MyEnum field_Enum = MyEnum.C;
|
||||
[Export] private MyEnum _fieldEnum = MyEnum.C;
|
||||
|
||||
[Flags]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
enum MyFlagsEnum
|
||||
public enum MyFlagsEnum
|
||||
{
|
||||
A,
|
||||
B,
|
||||
C
|
||||
}
|
||||
|
||||
[Export] private MyFlagsEnum field_FlagsEnum = MyFlagsEnum.C;
|
||||
[Export] private MyFlagsEnum _fieldFlagsEnum = MyFlagsEnum.C;
|
||||
|
||||
// Arrays
|
||||
[Export] private Byte[] field_ByteArray = { 0, 1, 2, 3, 4, 5, 6 };
|
||||
[Export] private Int32[] field_Int32Array = { 0, 1, 2, 3, 4, 5, 6 };
|
||||
[Export] private Int64[] field_Int64Array = { 0, 1, 2, 3, 4, 5, 6 };
|
||||
[Export] private Single[] field_SingleArray = { 0f, 1f, 2f, 3f, 4f, 5f, 6f };
|
||||
[Export] private Double[] field_DoubleArray = { 0d, 1d, 2d, 3d, 4d, 5d, 6d };
|
||||
[Export] private String[] field_StringArray = { "foo", "bar" };
|
||||
[Export(PropertyHint.Enum, "A,B,C")] private String[] field_StringArrayEnum = { "foo", "bar" };
|
||||
[Export] private Vector2[] field_Vector2Array = { Vector2.Up, Vector2.Down, Vector2.Left, Vector2.Right };
|
||||
[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 GodotObject[] field_GodotObjectOrDerivedArray = { null };
|
||||
[Export] private StringName[] field_StringNameArray = { "foo", "bar" };
|
||||
[Export] private NodePath[] field_NodePathArray = { "foo", "bar" };
|
||||
[Export] private Rid[] field_RidArray = { default, default, default };
|
||||
[Export] private Byte[] _fieldByteArray = { 0, 1, 2, 3, 4, 5, 6 };
|
||||
[Export] private Int32[] _fieldInt32Array = { 0, 1, 2, 3, 4, 5, 6 };
|
||||
[Export] private Int64[] _fieldInt64Array = { 0, 1, 2, 3, 4, 5, 6 };
|
||||
[Export] private Single[] _fieldSingleArray = { 0f, 1f, 2f, 3f, 4f, 5f, 6f };
|
||||
[Export] private Double[] _fieldDoubleArray = { 0d, 1d, 2d, 3d, 4d, 5d, 6d };
|
||||
[Export] private String[] _fieldStringArray = { "foo", "bar" };
|
||||
[Export(PropertyHint.Enum, "A,B,C")] private String[] _fieldStringArrayEnum = { "foo", "bar" };
|
||||
[Export] private Vector2[] _fieldVector2Array = { Vector2.Up, Vector2.Down, Vector2.Left, Vector2.Right };
|
||||
[Export] private Vector3[] _fieldVector3Array = { Vector3.Up, Vector3.Down, Vector3.Left, Vector3.Right };
|
||||
[Export] private Color[] _fieldColorArray = { Colors.Aqua, Colors.Aquamarine, Colors.Azure, Colors.Beige };
|
||||
[Export] private GodotObject[] _fieldGodotObjectOrDerivedArray = { null };
|
||||
[Export] private StringName[] _fieldStringNameArray = { "foo", "bar" };
|
||||
[Export] private NodePath[] _fieldNodePathArray = { "foo", "bar" };
|
||||
[Export] private Rid[] _fieldRidArray = { default, default, default };
|
||||
// Note we use Array and not System.Array. This tests the generated namespace qualification.
|
||||
[Export] private Int32[] field_empty_Int32Array = Array.Empty<Int32>();
|
||||
[Export] private Int32[] _fieldEmptyInt32Array = Array.Empty<Int32>();
|
||||
// Note we use List and not System.Collections.Generic.
|
||||
[Export] private int[] field_array_from_list = new List<int>(Array.Empty<int>()).ToArray();
|
||||
[Export] private int[] _fieldArrayFromList = new List<int>(Array.Empty<int>()).ToArray();
|
||||
|
||||
// Variant
|
||||
[Export] private Variant field_Variant = "foo";
|
||||
[Export] private Variant _fieldVariant = "foo";
|
||||
|
||||
// Classes
|
||||
[Export] private GodotObject field_GodotObjectOrDerived;
|
||||
[Export] private Godot.Texture field_GodotResourceTexture;
|
||||
[Export] private StringName field_StringName = new StringName("foo");
|
||||
[Export] private NodePath field_NodePath = new NodePath("foo");
|
||||
[Export] private Rid field_Rid;
|
||||
[Export] private GodotObject _fieldGodotObjectOrDerived;
|
||||
[Export] private Godot.Texture _fieldGodotResourceTexture;
|
||||
[Export] private StringName _fieldStringName = new StringName("foo");
|
||||
[Export] private NodePath _fieldNodePath = new NodePath("foo");
|
||||
[Export] private Rid _fieldRid;
|
||||
|
||||
[Export]
|
||||
private Godot.Collections.Dictionary field_GodotDictionary =
|
||||
private Godot.Collections.Dictionary _fieldGodotDictionary =
|
||||
new() { { "foo", 10 }, { Vector2.Up, Colors.Chocolate } };
|
||||
|
||||
[Export]
|
||||
private Godot.Collections.Array field_GodotArray =
|
||||
private Godot.Collections.Array _fieldGodotArray =
|
||||
new() { "foo", 10, Vector2.Up, Colors.Chocolate };
|
||||
|
||||
[Export]
|
||||
private Godot.Collections.Dictionary<string, bool> field_GodotGenericDictionary =
|
||||
private Godot.Collections.Dictionary<string, bool> _fieldGodotGenericDictionary =
|
||||
new() { { "foo", true }, { "bar", false } };
|
||||
|
||||
[Export]
|
||||
private Godot.Collections.Array<int> field_GodotGenericArray =
|
||||
private Godot.Collections.Array<int> _fieldGodotGenericArray =
|
||||
new() { 0, 1, 2, 3, 4, 5, 6 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,41 +13,41 @@ namespace Godot.SourceGenerators.Sample
|
||||
public partial class ExportedProperties : GodotObject
|
||||
{
|
||||
// Do not generate default value
|
||||
private String _notGenerate_Property_String = new string("not generate");
|
||||
private String _notGeneratePropertyString = new string("not generate");
|
||||
[Export]
|
||||
public String NotGenerate_Complex_Lamda_Property
|
||||
public String NotGenerateComplexLambdaProperty
|
||||
{
|
||||
get => _notGenerate_Property_String + Convert.ToInt32("1");
|
||||
set => _notGenerate_Property_String = value;
|
||||
get => _notGeneratePropertyString + Convert.ToInt32("1");
|
||||
set => _notGeneratePropertyString = value;
|
||||
}
|
||||
|
||||
[Export]
|
||||
public String NotGenerate_Lamda_NoField_Property
|
||||
public String NotGenerateLambdaNoFieldProperty
|
||||
{
|
||||
get => new string("not generate");
|
||||
set => _notGenerate_Property_String = value;
|
||||
set => _notGeneratePropertyString = value;
|
||||
}
|
||||
|
||||
[Export]
|
||||
public String NotGenerate_Complex_Return_Property
|
||||
public String NotGenerateComplexReturnProperty
|
||||
{
|
||||
get
|
||||
{
|
||||
return _notGenerate_Property_String + Convert.ToInt32("1");
|
||||
return _notGeneratePropertyString + Convert.ToInt32("1");
|
||||
}
|
||||
set
|
||||
{
|
||||
_notGenerate_Property_String = value;
|
||||
_notGeneratePropertyString = value;
|
||||
}
|
||||
}
|
||||
|
||||
private int _notGenerate_Property_Int = 1;
|
||||
private int _notGeneratePropertyInt = 1;
|
||||
[Export]
|
||||
public string NotGenerate_Returns_Property
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_notGenerate_Property_Int == 1)
|
||||
if (_notGeneratePropertyInt == 1)
|
||||
{
|
||||
return "a";
|
||||
}
|
||||
@@ -58,145 +58,145 @@ namespace Godot.SourceGenerators.Sample
|
||||
}
|
||||
set
|
||||
{
|
||||
_notGenerate_Property_Int = value == "a" ? 1 : 2;
|
||||
_notGeneratePropertyInt = value == "a" ? 1 : 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Full Property
|
||||
private String _fullProperty_String = "FullProperty_String";
|
||||
private String _fullPropertyString = "FullPropertyString";
|
||||
[Export]
|
||||
public String FullProperty_String
|
||||
public String FullPropertyString
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fullProperty_String;
|
||||
return _fullPropertyString;
|
||||
}
|
||||
set
|
||||
{
|
||||
_fullProperty_String = value;
|
||||
_fullPropertyString = value;
|
||||
}
|
||||
}
|
||||
|
||||
private String _fullProperty_String_Complex = new string("FullProperty_String_Complex") + Convert.ToInt32("1");
|
||||
private String _fullPropertyStringComplex = new string("FullPropertyString_Complex") + Convert.ToInt32("1");
|
||||
[Export]
|
||||
public String FullProperty_String_Complex
|
||||
public String FullPropertyStringComplex
|
||||
{
|
||||
get
|
||||
{
|
||||
return _fullProperty_String_Complex;
|
||||
return _fullPropertyStringComplex;
|
||||
}
|
||||
set
|
||||
{
|
||||
_fullProperty_String_Complex = value;
|
||||
_fullPropertyStringComplex = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Lambda Property
|
||||
private String _lamdaProperty_String = "LamdaProperty_String";
|
||||
private String _lamdaPropertyString = "LamdaPropertyString";
|
||||
[Export]
|
||||
public String LamdaProperty_String
|
||||
public String LamdaPropertyString
|
||||
{
|
||||
get => _lamdaProperty_String;
|
||||
set => _lamdaProperty_String = value;
|
||||
get => _lamdaPropertyString;
|
||||
set => _lamdaPropertyString = value;
|
||||
}
|
||||
|
||||
// Auto Property
|
||||
[Export] private Boolean property_Boolean { get; set; } = true;
|
||||
[Export] private Char property_Char { get; set; } = 'f';
|
||||
[Export] private SByte property_SByte { get; set; } = 10;
|
||||
[Export] private Int16 property_Int16 { get; set; } = 10;
|
||||
[Export] private Int32 property_Int32 { get; set; } = 10;
|
||||
[Export] private Int64 property_Int64 { get; set; } = 10;
|
||||
[Export] private Byte property_Byte { get; set; } = 10;
|
||||
[Export] private UInt16 property_UInt16 { get; set; } = 10;
|
||||
[Export] private UInt32 property_UInt32 { get; set; } = 10;
|
||||
[Export] private UInt64 property_UInt64 { get; set; } = 10;
|
||||
[Export] private Single property_Single { get; set; } = 10;
|
||||
[Export] private Double property_Double { get; set; } = 10;
|
||||
[Export] private String property_String { get; set; } = "foo";
|
||||
[Export] private Boolean PropertyBoolean { get; set; } = true;
|
||||
[Export] private Char PropertyChar { get; set; } = 'f';
|
||||
[Export] private SByte PropertySByte { get; set; } = 10;
|
||||
[Export] private Int16 PropertyInt16 { get; set; } = 10;
|
||||
[Export] private Int32 PropertyInt32 { get; set; } = 10;
|
||||
[Export] private Int64 PropertyInt64 { get; set; } = 10;
|
||||
[Export] private Byte PropertyByte { get; set; } = 10;
|
||||
[Export] private UInt16 PropertyUInt16 { get; set; } = 10;
|
||||
[Export] private UInt32 PropertyUInt32 { get; set; } = 10;
|
||||
[Export] private UInt64 PropertyUInt64 { get; set; } = 10;
|
||||
[Export] private Single PropertySingle { get; set; } = 10;
|
||||
[Export] private Double PropertyDouble { get; set; } = 10;
|
||||
[Export] private String PropertyString { get; set; } = "foo";
|
||||
|
||||
// Godot structs
|
||||
[Export] private Vector2 property_Vector2 { get; set; } = new(10f, 10f);
|
||||
[Export] private Vector2I property_Vector2I { get; set; } = Vector2I.Up;
|
||||
[Export] private Rect2 property_Rect2 { get; set; } = new(new Vector2(10f, 10f), new Vector2(10f, 10f));
|
||||
[Export] private Rect2I property_Rect2I { get; set; } = new(new Vector2I(10, 10), new Vector2I(10, 10));
|
||||
[Export] private Transform2D property_Transform2D { get; set; } = Transform2D.Identity;
|
||||
[Export] private Vector3 property_Vector3 { get; set; } = new(10f, 10f, 10f);
|
||||
[Export] private Vector3I property_Vector3I { get; set; } = Vector3I.Back;
|
||||
[Export] private Basis property_Basis { get; set; } = new Basis(Quaternion.Identity);
|
||||
[Export] private Quaternion property_Quaternion { get; set; } = new Quaternion(Basis.Identity);
|
||||
[Export] private Transform3D property_Transform3D { get; set; } = Transform3D.Identity;
|
||||
[Export] private Vector4 property_Vector4 { get; set; } = new(10f, 10f, 10f, 10f);
|
||||
[Export] private Vector4I property_Vector4I { get; set; } = Vector4I.One;
|
||||
[Export] private Projection property_Projection { get; set; } = Projection.Identity;
|
||||
[Export] private Aabb property_Aabb { get; set; } = new Aabb(10f, 10f, 10f, new Vector3(1f, 1f, 1f));
|
||||
[Export] private Color property_Color { get; set; } = Colors.Aquamarine;
|
||||
[Export] private Plane property_Plane { get; set; } = Plane.PlaneXZ;
|
||||
[Export] private Callable property_Callable { get; set; } = new Callable(Engine.GetMainLoop(), "_process");
|
||||
[Export] private Signal property_Signal { get; set; } = new Signal(Engine.GetMainLoop(), "property_list_changed");
|
||||
[Export] private Vector2 PropertyVector2 { get; set; } = new(10f, 10f);
|
||||
[Export] private Vector2I PropertyVector2I { get; set; } = Vector2I.Up;
|
||||
[Export] private Rect2 PropertyRect2 { get; set; } = new(new Vector2(10f, 10f), new Vector2(10f, 10f));
|
||||
[Export] private Rect2I PropertyRect2I { get; set; } = new(new Vector2I(10, 10), new Vector2I(10, 10));
|
||||
[Export] private Transform2D PropertyTransform2D { get; set; } = Transform2D.Identity;
|
||||
[Export] private Vector3 PropertyVector3 { get; set; } = new(10f, 10f, 10f);
|
||||
[Export] private Vector3I PropertyVector3I { get; set; } = Vector3I.Back;
|
||||
[Export] private Basis PropertyBasis { get; set; } = new Basis(Quaternion.Identity);
|
||||
[Export] private Quaternion PropertyQuaternion { get; set; } = new Quaternion(Basis.Identity);
|
||||
[Export] private Transform3D PropertyTransform3D { get; set; } = Transform3D.Identity;
|
||||
[Export] private Vector4 PropertyVector4 { get; set; } = new(10f, 10f, 10f, 10f);
|
||||
[Export] private Vector4I PropertyVector4I { get; set; } = Vector4I.One;
|
||||
[Export] private Projection PropertyProjection { get; set; } = Projection.Identity;
|
||||
[Export] private Aabb PropertyAabb { get; set; } = new Aabb(10f, 10f, 10f, new Vector3(1f, 1f, 1f));
|
||||
[Export] private Color PropertyColor { get; set; } = Colors.Aquamarine;
|
||||
[Export] private Plane PropertyPlane { get; set; } = Plane.PlaneXZ;
|
||||
[Export] private Callable PropertyCallable { get; set; } = new Callable(Engine.GetMainLoop(), "_process");
|
||||
[Export] private Signal PropertySignal { get; set; } = new Signal(Engine.GetMainLoop(), "Propertylist_changed");
|
||||
|
||||
// Enums
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
enum MyEnum
|
||||
public enum MyEnum
|
||||
{
|
||||
A,
|
||||
B,
|
||||
C
|
||||
}
|
||||
|
||||
[Export] private MyEnum property_Enum { get; set; } = MyEnum.C;
|
||||
[Export] private MyEnum PropertyEnum { get; set; } = MyEnum.C;
|
||||
|
||||
[Flags]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Local")]
|
||||
enum MyFlagsEnum
|
||||
public enum MyFlagsEnum
|
||||
{
|
||||
A,
|
||||
B,
|
||||
C
|
||||
}
|
||||
|
||||
[Export] private MyFlagsEnum property_FlagsEnum { get; set; } = MyFlagsEnum.C;
|
||||
[Export] private MyFlagsEnum PropertyFlagsEnum { get; set; } = MyFlagsEnum.C;
|
||||
|
||||
// Arrays
|
||||
[Export] private Byte[] property_ByteArray { get; set; } = { 0, 1, 2, 3, 4, 5, 6 };
|
||||
[Export] private Int32[] property_Int32Array { get; set; } = { 0, 1, 2, 3, 4, 5, 6 };
|
||||
[Export] private Int64[] property_Int64Array { get; set; } = { 0, 1, 2, 3, 4, 5, 6 };
|
||||
[Export] private Single[] property_SingleArray { get; set; } = { 0f, 1f, 2f, 3f, 4f, 5f, 6f };
|
||||
[Export] private Double[] property_DoubleArray { get; set; } = { 0d, 1d, 2d, 3d, 4d, 5d, 6d };
|
||||
[Export] private String[] property_StringArray { get; set; } = { "foo", "bar" };
|
||||
[Export(PropertyHint.Enum, "A,B,C")] private String[] property_StringArrayEnum { get; set; } = { "foo", "bar" };
|
||||
[Export] private Vector2[] property_Vector2Array { get; set; } = { Vector2.Up, Vector2.Down, Vector2.Left, Vector2.Right };
|
||||
[Export] private Vector3[] property_Vector3Array { get; set; } = { Vector3.Up, Vector3.Down, Vector3.Left, Vector3.Right };
|
||||
[Export] private Color[] property_ColorArray { get; set; } = { Colors.Aqua, Colors.Aquamarine, Colors.Azure, Colors.Beige };
|
||||
[Export] private GodotObject[] property_GodotObjectOrDerivedArray { get; set; } = { null };
|
||||
[Export] private StringName[] field_StringNameArray { get; set; } = { "foo", "bar" };
|
||||
[Export] private NodePath[] field_NodePathArray { get; set; } = { "foo", "bar" };
|
||||
[Export] private Rid[] field_RidArray { get; set; } = { default, default, default };
|
||||
[Export] private Byte[] PropertyByteArray { get; set; } = { 0, 1, 2, 3, 4, 5, 6 };
|
||||
[Export] private Int32[] PropertyInt32Array { get; set; } = { 0, 1, 2, 3, 4, 5, 6 };
|
||||
[Export] private Int64[] PropertyInt64Array { get; set; } = { 0, 1, 2, 3, 4, 5, 6 };
|
||||
[Export] private Single[] PropertySingleArray { get; set; } = { 0f, 1f, 2f, 3f, 4f, 5f, 6f };
|
||||
[Export] private Double[] PropertyDoubleArray { get; set; } = { 0d, 1d, 2d, 3d, 4d, 5d, 6d };
|
||||
[Export] private String[] PropertyStringArray { get; set; } = { "foo", "bar" };
|
||||
[Export(PropertyHint.Enum, "A,B,C")] private String[] PropertyStringArrayEnum { get; set; } = { "foo", "bar" };
|
||||
[Export] private Vector2[] PropertyVector2Array { get; set; } = { Vector2.Up, Vector2.Down, Vector2.Left, Vector2.Right };
|
||||
[Export] private Vector3[] PropertyVector3Array { get; set; } = { Vector3.Up, Vector3.Down, Vector3.Left, Vector3.Right };
|
||||
[Export] private Color[] PropertyColorArray { get; set; } = { Colors.Aqua, Colors.Aquamarine, Colors.Azure, Colors.Beige };
|
||||
[Export] private GodotObject[] PropertyGodotObjectOrDerivedArray { get; set; } = { null };
|
||||
[Export] private StringName[] PropertyStringNameArray { get; set; } = { "foo", "bar" };
|
||||
[Export] private NodePath[] PropertyNodePathArray { get; set; } = { "foo", "bar" };
|
||||
[Export] private Rid[] PropertyRidArray { get; set; } = { default, default, default };
|
||||
|
||||
// Variant
|
||||
[Export] private Variant property_Variant { get; set; } = "foo";
|
||||
[Export] private Variant PropertyVariant { get; set; } = "foo";
|
||||
|
||||
// Classes
|
||||
[Export] private GodotObject property_GodotObjectOrDerived { get; set; }
|
||||
[Export] private Godot.Texture property_GodotResourceTexture { get; set; }
|
||||
[Export] private StringName property_StringName { get; set; } = new StringName("foo");
|
||||
[Export] private NodePath property_NodePath { get; set; } = new NodePath("foo");
|
||||
[Export] private Rid property_Rid { get; set; }
|
||||
[Export] private GodotObject PropertyGodotObjectOrDerived { get; set; }
|
||||
[Export] private Godot.Texture PropertyGodotResourceTexture { get; set; }
|
||||
[Export] private StringName PropertyStringName { get; set; } = new StringName("foo");
|
||||
[Export] private NodePath PropertyNodePath { get; set; } = new NodePath("foo");
|
||||
[Export] private Rid PropertyRid { get; set; }
|
||||
|
||||
[Export]
|
||||
private Godot.Collections.Dictionary property_GodotDictionary { get; set; } =
|
||||
private Godot.Collections.Dictionary PropertyGodotDictionary { get; set; } =
|
||||
new() { { "foo", 10 }, { Vector2.Up, Colors.Chocolate } };
|
||||
|
||||
[Export]
|
||||
private Godot.Collections.Array property_GodotArray { get; set; } =
|
||||
private Godot.Collections.Array PropertyGodotArray { get; set; } =
|
||||
new() { "foo", 10, Vector2.Up, Colors.Chocolate };
|
||||
|
||||
[Export]
|
||||
private Godot.Collections.Dictionary<string, bool> property_GodotGenericDictionary { get; set; } =
|
||||
private Godot.Collections.Dictionary<string, bool> PropertyGodotGenericDictionary { get; set; } =
|
||||
new() { { "foo", true }, { "bar", false } };
|
||||
|
||||
[Export]
|
||||
private Godot.Collections.Array<int> property_GodotGenericArray { get; set; } =
|
||||
private Godot.Collections.Array<int> PropertyGodotGenericArray { get; set; } =
|
||||
new() { 0, 1, 2, 3, 4, 5, 6 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
namespace Godot.SourceGenerators.Sample
|
||||
{
|
||||
partial class Foo : GodotObject
|
||||
public partial class Foo : GodotObject
|
||||
{
|
||||
}
|
||||
|
||||
// Foo again in the same file
|
||||
partial class Foo
|
||||
public partial class Foo
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Godot.SourceGenerators.Sample
|
||||
{
|
||||
// Generic again but without generic parameters
|
||||
partial class Generic : GodotObject
|
||||
public partial class Generic : GodotObject
|
||||
{
|
||||
private int _field;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Godot.SourceGenerators.Sample
|
||||
{
|
||||
partial class Generic1T<T> : GodotObject
|
||||
public partial class Generic1T<T> : GodotObject
|
||||
{
|
||||
private int _field;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Godot.SourceGenerators.Sample
|
||||
{
|
||||
// Generic again but different generic parameters
|
||||
partial class Generic2T<T, R> : GodotObject
|
||||
public partial class Generic2T<T, R> : GodotObject
|
||||
{
|
||||
private int _field;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@ namespace Godot.SourceGenerators.Sample
|
||||
public partial class ExportedFields : GodotObject
|
||||
{
|
||||
// Note we use Array and not System.Array. This tests the generated namespace qualification.
|
||||
[Export] private Int64[] field_empty_Int64Array = Array.Empty<Int64>();
|
||||
[Export] private Int64[] _fieldEmptyInt64Array = Array.Empty<Int64>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ public partial class NestedClass : GodotObject
|
||||
[Signal]
|
||||
public delegate void MySignalEventHandler(string str, int num);
|
||||
|
||||
[Export] private String field_String = "foo";
|
||||
[Export] private String property_String { get; set; } = "foo";
|
||||
[Export] private String _fieldString = "foo";
|
||||
[Export] private String PropertyString { get; set; } = "foo";
|
||||
|
||||
private void Method()
|
||||
{
|
||||
|
||||
@@ -2,9 +2,9 @@ namespace Godot.SourceGenerators.Sample
|
||||
{
|
||||
public partial class AllReadOnly : GodotObject
|
||||
{
|
||||
public readonly string readonly_field = "foo";
|
||||
public string readonly_auto_property { get; } = "foo";
|
||||
public string readonly_property { get => "foo"; }
|
||||
public string initonly_auto_property { get; init; }
|
||||
public readonly string ReadonlyField = "foo";
|
||||
public string ReadonlyAutoProperty { get; } = "foo";
|
||||
public string ReadonlyProperty { get => "foo"; }
|
||||
public string InitonlyAutoProperty { get; init; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Godot.SourceGenerators.Sample
|
||||
{
|
||||
public partial class AllWriteOnly : GodotObject
|
||||
{
|
||||
bool writeonly_backing_field = false;
|
||||
public bool writeonly_property { set => writeonly_backing_field = value; }
|
||||
private bool _writeOnlyBackingField = false;
|
||||
public bool WriteOnlyProperty { set => _writeOnlyBackingField = value; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ namespace Godot.SourceGenerators.Sample
|
||||
{
|
||||
public partial class MixedReadonlyWriteOnly : GodotObject
|
||||
{
|
||||
public readonly string readonly_field = "foo";
|
||||
public string readonly_auto_property { get; } = "foo";
|
||||
public string readonly_property { get => "foo"; }
|
||||
public string initonly_auto_property { get; init; }
|
||||
public readonly string ReadOnlyField = "foo";
|
||||
public string ReadOnlyAutoProperty { get; } = "foo";
|
||||
public string ReadOnlyProperty { get => "foo"; }
|
||||
public string InitOnlyAutoProperty { get; init; }
|
||||
|
||||
bool writeonly_backing_field = false;
|
||||
public bool writeonly_property { set => writeonly_backing_field = value; }
|
||||
private bool _writeOnlyBackingField = false;
|
||||
public bool WriteOnlyProperty { set => _writeOnlyBackingField = value; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Godot.SourceGenerators.Sample
|
||||
}
|
||||
}
|
||||
|
||||
partial struct OuterClass
|
||||
public partial struct OuterClass
|
||||
{
|
||||
public partial class NesterClass : RefCounted
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user