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 _fieldBoolean = true;
  15. [Export] private Char _fieldChar = 'f';
  16. [Export] private SByte _fieldSByte = 10;
  17. [Export] private Int16 _fieldInt16 = 10;
  18. [Export] private Int32 _fieldInt32 = 10;
  19. [Export] private Int64 _fieldInt64 = 10;
  20. [Export] private Byte _fieldByte = 10;
  21. [Export] private UInt16 _fieldUInt16 = 10;
  22. [Export] private UInt32 _fieldUInt32 = 10;
  23. [Export] private UInt64 _fieldUInt64 = 10;
  24. [Export] private Single _fieldSingle = 10;
  25. [Export] private Double _fieldDouble = 10;
  26. [Export] private String _fieldString = "foo";
  27. // Godot structs
  28. [Export] private Vector2 _fieldVector2 = new(10f, 10f);
  29. [Export] private Vector2I _fieldVector2I = Vector2I.Up;
  30. [Export] private Rect2 _fieldRect2 = new(new Vector2(10f, 10f), new Vector2(10f, 10f));
  31. [Export] private Rect2I _fieldRect2I = new(new Vector2I(10, 10), new Vector2I(10, 10));
  32. [Export] private Transform2D _fieldTransform2D = Transform2D.Identity;
  33. [Export] private Vector3 _fieldVector3 = new(10f, 10f, 10f);
  34. [Export] private Vector3I _fieldVector3I = Vector3I.Back;
  35. [Export] private Basis _fieldBasis = new Basis(Quaternion.Identity);
  36. [Export] private Quaternion _fieldQuaternion = new Quaternion(Basis.Identity);
  37. [Export] private Transform3D _fieldTransform3D = Transform3D.Identity;
  38. [Export] private Vector4 _fieldVector4 = new(10f, 10f, 10f, 10f);
  39. [Export] private Vector4I _fieldVector4I = Vector4I.One;
  40. [Export] private Projection _fieldProjection = Projection.Identity;
  41. [Export] private Aabb _fieldAabb = new Aabb(10f, 10f, 10f, new Vector3(1f, 1f, 1f));
  42. [Export] private Color _fieldColor = Colors.Aquamarine;
  43. [Export] private Plane _fieldPlane = Plane.PlaneXZ;
  44. [Export] private Callable _fieldCallable = new Callable(Engine.GetMainLoop(), "_process");
  45. [Export] private Signal _fieldSignal = new Signal(Engine.GetMainLoop(), "property_list_changed");
  46. // Enums
  47. [SuppressMessage("ReSharper", "UnusedMember.Local")]
  48. public enum MyEnum
  49. {
  50. A,
  51. B,
  52. C
  53. }
  54. [Export] private MyEnum _fieldEnum = MyEnum.C;
  55. [Flags]
  56. [SuppressMessage("ReSharper", "UnusedMember.Local")]
  57. public enum MyFlagsEnum
  58. {
  59. A,
  60. B,
  61. C
  62. }
  63. [Export] private MyFlagsEnum _fieldFlagsEnum = MyFlagsEnum.C;
  64. // Arrays
  65. [Export] private Byte[] _fieldByteArray = { 0, 1, 2, 3, 4, 5, 6 };
  66. [Export] private Int32[] _fieldInt32Array = { 0, 1, 2, 3, 4, 5, 6 };
  67. [Export] private Int64[] _fieldInt64Array = { 0, 1, 2, 3, 4, 5, 6 };
  68. [Export] private Single[] _fieldSingleArray = { 0f, 1f, 2f, 3f, 4f, 5f, 6f };
  69. [Export] private Double[] _fieldDoubleArray = { 0d, 1d, 2d, 3d, 4d, 5d, 6d };
  70. [Export] private String[] _fieldStringArray = { "foo", "bar" };
  71. [Export(PropertyHint.Enum, "A,B,C")] private String[] _fieldStringArrayEnum = { "foo", "bar" };
  72. [Export] private Vector2[] _fieldVector2Array = { Vector2.Up, Vector2.Down, Vector2.Left, Vector2.Right };
  73. [Export] private Vector3[] _fieldVector3Array = { Vector3.Up, Vector3.Down, Vector3.Left, Vector3.Right };
  74. [Export] private Color[] _fieldColorArray = { Colors.Aqua, Colors.Aquamarine, Colors.Azure, Colors.Beige };
  75. [Export] private GodotObject[] _fieldGodotObjectOrDerivedArray = { null };
  76. [Export] private StringName[] _fieldStringNameArray = { "foo", "bar" };
  77. [Export] private NodePath[] _fieldNodePathArray = { "foo", "bar" };
  78. [Export] private Rid[] _fieldRidArray = { default, default, default };
  79. // Note we use Array and not System.Array. This tests the generated namespace qualification.
  80. [Export] private Int32[] _fieldEmptyInt32Array = Array.Empty<Int32>();
  81. // Note we use List and not System.Collections.Generic.
  82. [Export] private int[] _fieldArrayFromList = new List<int>(Array.Empty<int>()).ToArray();
  83. // Variant
  84. [Export] private Variant _fieldVariant = "foo";
  85. // Classes
  86. [Export] private GodotObject _fieldGodotObjectOrDerived;
  87. [Export] private Godot.Texture _fieldGodotResourceTexture;
  88. [Export] private StringName _fieldStringName = new StringName("foo");
  89. [Export] private NodePath _fieldNodePath = new NodePath("foo");
  90. [Export] private Rid _fieldRid;
  91. [Export]
  92. private Godot.Collections.Dictionary _fieldGodotDictionary =
  93. new() { { "foo", 10 }, { Vector2.Up, Colors.Chocolate } };
  94. [Export]
  95. private Godot.Collections.Array _fieldGodotArray =
  96. new() { "foo", 10, Vector2.Up, Colors.Chocolate };
  97. [Export]
  98. private Godot.Collections.Dictionary<string, bool> _fieldGodotGenericDictionary =
  99. new() { { "foo", true }, { "bar", false } };
  100. [Export]
  101. private Godot.Collections.Array<int> _fieldGodotGenericArray =
  102. new() { 0, 1, 2, 3, 4, 5, 6 };
  103. }
  104. }