ExportedFields.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics.CodeAnalysis;
  4. #pragma warning disable CS0169
  5. #pragma warning disable CS0414
  6. namespace Godot.SourceGenerators.Sample
  7. {
  8. [SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")]
  9. [SuppressMessage("ReSharper", "RedundantNameQualifier")]
  10. [SuppressMessage("ReSharper", "ArrangeObjectCreationWhenTypeEvident")]
  11. [SuppressMessage("ReSharper", "InconsistentNaming")]
  12. public partial class ExportedFields : GodotObject
  13. {
  14. [Export] private Boolean field_Boolean = true;
  15. [Export] private Char field_Char = 'f';
  16. [Export] private SByte field_SByte = 10;
  17. [Export] private Int16 field_Int16 = 10;
  18. [Export] private Int32 field_Int32 = 10;
  19. [Export] private Int64 field_Int64 = 10;
  20. [Export] private Byte field_Byte = 10;
  21. [Export] private UInt16 field_UInt16 = 10;
  22. [Export] private UInt32 field_UInt32 = 10;
  23. [Export] private UInt64 field_UInt64 = 10;
  24. [Export] private Single field_Single = 10;
  25. [Export] private Double field_Double = 10;
  26. [Export] private String field_String = "foo";
  27. // Godot structs
  28. [Export] private Vector2 field_Vector2 = new(10f, 10f);
  29. [Export] private Vector2I field_Vector2I = Vector2I.Up;
  30. [Export] private Rect2 field_Rect2 = new(new Vector2(10f, 10f), new Vector2(10f, 10f));
  31. [Export] private Rect2I field_Rect2I = new(new Vector2I(10, 10), new Vector2I(10, 10));
  32. [Export] private Transform2D field_Transform2D = Transform2D.Identity;
  33. [Export] private Vector3 field_Vector3 = new(10f, 10f, 10f);
  34. [Export] private Vector3I field_Vector3I = Vector3I.Back;
  35. [Export] private Basis field_Basis = new Basis(Quaternion.Identity);
  36. [Export] private Quaternion field_Quaternion = new Quaternion(Basis.Identity);
  37. [Export] private Transform3D field_Transform3D = Transform3D.Identity;
  38. [Export] private Vector4 field_Vector4 = new(10f, 10f, 10f, 10f);
  39. [Export] private Vector4I field_Vector4I = Vector4I.One;
  40. [Export] private Projection field_Projection = Projection.Identity;
  41. [Export] private Aabb field_Aabb = new Aabb(10f, 10f, 10f, new Vector3(1f, 1f, 1f));
  42. [Export] private Color field_Color = Colors.Aquamarine;
  43. [Export] private Plane field_Plane = Plane.PlaneXZ;
  44. [Export] private Callable field_Callable = new Callable(Engine.GetMainLoop(), "_process");
  45. [Export] private Signal field_Signal = new Signal(Engine.GetMainLoop(), "property_list_changed");
  46. // Enums
  47. [SuppressMessage("ReSharper", "UnusedMember.Local")]
  48. enum MyEnum
  49. {
  50. A,
  51. B,
  52. C
  53. }
  54. [Export] private MyEnum field_Enum = MyEnum.C;
  55. [Flags]
  56. [SuppressMessage("ReSharper", "UnusedMember.Local")]
  57. enum MyFlagsEnum
  58. {
  59. A,
  60. B,
  61. C
  62. }
  63. [Export] private MyFlagsEnum field_FlagsEnum = MyFlagsEnum.C;
  64. // Arrays
  65. [Export] private Byte[] field_ByteArray = { 0, 1, 2, 3, 4, 5, 6 };
  66. [Export] private Int32[] field_Int32Array = { 0, 1, 2, 3, 4, 5, 6 };
  67. [Export] private Int64[] field_Int64Array = { 0, 1, 2, 3, 4, 5, 6 };
  68. [Export] private Single[] field_SingleArray = { 0f, 1f, 2f, 3f, 4f, 5f, 6f };
  69. [Export] private Double[] field_DoubleArray = { 0d, 1d, 2d, 3d, 4d, 5d, 6d };
  70. [Export] private String[] field_StringArray = { "foo", "bar" };
  71. [Export(PropertyHint.Enum, "A,B,C")] private String[] field_StringArrayEnum = { "foo", "bar" };
  72. [Export] private Vector2[] field_Vector2Array = { Vector2.Up, Vector2.Down, Vector2.Left, Vector2.Right };
  73. [Export] private Vector3[] field_Vector3Array = { Vector3.Up, Vector3.Down, Vector3.Left, Vector3.Right };
  74. [Export] private Color[] field_ColorArray = { Colors.Aqua, Colors.Aquamarine, Colors.Azure, Colors.Beige };
  75. [Export] private GodotObject[] field_GodotObjectOrDerivedArray = { null };
  76. [Export] private StringName[] field_StringNameArray = { "foo", "bar" };
  77. [Export] private NodePath[] field_NodePathArray = { "foo", "bar" };
  78. [Export] private Rid[] field_RidArray = { default, default, default };
  79. // Note we use Array and not System.Array. This tests the generated namespace qualification.
  80. [Export] private Int32[] field_empty_Int32Array = Array.Empty<Int32>();
  81. // Note we use List and not System.Collections.Generic.
  82. [Export] private int[] field_array_from_list = new List<int>(Array.Empty<int>()).ToArray();
  83. // Variant
  84. [Export] private Variant field_Variant = "foo";
  85. // Classes
  86. [Export] private GodotObject field_GodotObjectOrDerived;
  87. [Export] private Godot.Texture field_GodotResourceTexture;
  88. [Export] private StringName field_StringName = new StringName("foo");
  89. [Export] private NodePath field_NodePath = new NodePath("foo");
  90. [Export] private Rid field_Rid;
  91. [Export]
  92. private Godot.Collections.Dictionary field_GodotDictionary =
  93. new() { { "foo", 10 }, { Vector2.Up, Colors.Chocolate } };
  94. [Export]
  95. private Godot.Collections.Array field_GodotArray =
  96. new() { "foo", 10, Vector2.Up, Colors.Chocolate };
  97. [Export]
  98. private Godot.Collections.Dictionary<string, bool> field_GodotGenericDictionary =
  99. new() { { "foo", true }, { "bar", false } };
  100. [Export]
  101. private Godot.Collections.Array<int> field_GodotGenericArray =
  102. new() { 0, 1, 2, 3, 4, 5, 6 };
  103. }
  104. }