1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Fully qualify C# default values in exported fields.

This avoids issues when the default values rely on using
namespaces.
This commit is contained in:
R. Alex Hofer
2022-11-11 22:34:43 -05:00
parent c17f17eb98
commit 6ab93bd919
4 changed files with 83 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#pragma warning disable CS0169
@@ -83,6 +84,10 @@ namespace Godot.SourceGenerators.Sample
[Export] private StringName[] field_StringNameArray = { "foo", "bar" };
[Export] private NodePath[] field_NodePathArray = { "foo", "bar" };
[Export] private RID[] field_RIDArray = { 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>();
// Note we use List and not System.Collections.Generic.
[Export] private int[] field_array_from_list = new List<int>(Array.Empty<int>()).ToArray();
// Variant
[Export] private Variant field_Variant = "foo";

View File

@@ -0,0 +1,19 @@
using System;
using System.Diagnostics.CodeAnalysis;
#pragma warning disable CS0169
#pragma warning disable CS0414
namespace Godot.SourceGenerators.Sample
{
[SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")]
[SuppressMessage("ReSharper", "RedundantNameQualifier")]
[SuppressMessage("ReSharper", "ArrangeObjectCreationWhenTypeEvident")]
[SuppressMessage("ReSharper", "InconsistentNaming")]
// We split the definition of ExportedFields to verify properties work across multiple files.
public partial class ExportedFields : Godot.Object
{
// Note we use Array and not System.Array. This tests the generated namespace qualification.
[Export] private Int64[] field_empty_Int64Array = Array.Empty<Int64>();
}
}