summaryrefslogtreecommitdiffstats
path: root/modules/mono
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mono')
-rw-r--r--modules/mono/csharp_script.cpp4
-rw-r--r--modules/mono/csharp_script.h1
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedComplexStrings.cs26
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ScriptPropertyDefValGeneratorTests.cs9
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/ExportedComplexStrings_ScriptPropertyDefVal.generated.cs29
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportedComplexStrings.cs23
-rw-r--r--modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs19
-rw-r--r--modules/mono/editor/bindings_generator.cpp25
-rw-r--r--modules/mono/editor/script_templates/SCsub2
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs2
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj2
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj2
12 files changed, 135 insertions, 9 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 9ccaa27e84..93fb5f1dc6 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -405,6 +405,10 @@ bool CSharpLanguage::supports_builtin_mode() const {
return false;
}
+ScriptLanguage::ScriptNameCasing CSharpLanguage::preferred_file_name_casing() const {
+ return SCRIPT_NAME_CASING_PASCAL_CASE;
+}
+
#ifdef TOOLS_ENABLED
struct VariantCsName {
Variant::Type variant_type;
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h
index 99e6ebf2e3..7821420620 100644
--- a/modules/mono/csharp_script.h
+++ b/modules/mono/csharp_script.h
@@ -518,6 +518,7 @@ public:
virtual String _get_indentation() const;
/* TODO? */ void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const override {}
/* TODO */ void add_global_constant(const StringName &p_variable, const Variant &p_value) override {}
+ virtual ScriptNameCasing preferred_file_name_casing() const override;
/* SCRIPT GLOBAL CLASS FUNCTIONS */
virtual bool handles_global_class_type(const String &p_type) const override;
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedComplexStrings.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedComplexStrings.cs
new file mode 100644
index 0000000000..907257b125
--- /dev/null
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/ExportedComplexStrings.cs
@@ -0,0 +1,26 @@
+using Godot;
+
+namespace Godot.SourceGenerators.Sample
+{
+ public partial class ExportedComplexStrings : Node
+ {
+ [Export]
+ private string _fieldInterpolated1 = $"The quick brown fox jumps over ({Engine.GetVersionInfo()})";
+
+ [Export]
+ private string _fieldInterpolated2 = $"The quick brown fox jumps over ({Engine.GetVersionInfo()["major"],0:G}) the lazy dog.";
+
+ [Export]
+ private string _fieldInterpolated3 = $"{((int)Engine.GetVersionInfo()["major"]) * -1 * -1:G} the lazy dog.";
+
+ [Export]
+ private string _fieldInterpolated4 = $"{":::fff,,}<,<}},,}]"}";
+
+ [Export]
+ public string PropertyInterpolated1
+ {
+ get;
+ private set;
+ } = $"The quick brown fox jumps over {GD.VarToStr($"the lazy {Engine.GetVersionInfo()} do")}g.";
+ }
+}
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ScriptPropertyDefValGeneratorTests.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ScriptPropertyDefValGeneratorTests.cs
index ae5fb86d77..7711bce1c7 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ScriptPropertyDefValGeneratorTests.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ScriptPropertyDefValGeneratorTests.cs
@@ -21,4 +21,13 @@ public class ScriptPropertyDefValGeneratorTests
"ExportedProperties_ScriptPropertyDefVal.generated.cs"
);
}
+
+ [Fact]
+ public async void ExportedComplexStrings()
+ {
+ await CSharpSourceGeneratorVerifier<ScriptPropertyDefValGenerator>.Verify(
+ "ExportedComplexStrings.cs",
+ "ExportedComplexStrings_ScriptPropertyDefVal.generated.cs"
+ );
+ }
}
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/ExportedComplexStrings_ScriptPropertyDefVal.generated.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/ExportedComplexStrings_ScriptPropertyDefVal.generated.cs
new file mode 100644
index 0000000000..69e85b4467
--- /dev/null
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/ExportedComplexStrings_ScriptPropertyDefVal.generated.cs
@@ -0,0 +1,29 @@
+partial class ExportedComplexStrings
+{
+#pragma warning disable CS0109 // Disable warning about redundant 'new' keyword
+#if TOOLS
+ /// <summary>
+ /// Get the default values for all properties declared in this class.
+ /// This method is used by Godot to determine the value that will be
+ /// used by the inspector when resetting properties.
+ /// Do not call this method.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
+ internal new static global::System.Collections.Generic.Dictionary<global::Godot.StringName, global::Godot.Variant> GetGodotPropertyDefaultValues()
+ {
+ var values = new global::System.Collections.Generic.Dictionary<global::Godot.StringName, global::Godot.Variant>(5);
+ string __PropertyInterpolated1_default_value = $"The quick brown fox jumps over {(global::Godot.GD.VarToStr($"the lazy {(global::Godot.Engine.GetVersionInfo())} do"))}g.";
+ values.Add(PropertyName.PropertyInterpolated1, global::Godot.Variant.From<string>(__PropertyInterpolated1_default_value));
+ string ___fieldInterpolated1_default_value = $"The quick brown fox jumps over ({(global::Godot.Engine.GetVersionInfo())})";
+ values.Add(PropertyName._fieldInterpolated1, global::Godot.Variant.From<string>(___fieldInterpolated1_default_value));
+ string ___fieldInterpolated2_default_value = $"The quick brown fox jumps over ({(global::Godot.Engine.GetVersionInfo()["major"]),0:G}) the lazy dog.";
+ values.Add(PropertyName._fieldInterpolated2, global::Godot.Variant.From<string>(___fieldInterpolated2_default_value));
+ string ___fieldInterpolated3_default_value = $"{(((int)global::Godot.Engine.GetVersionInfo()["major"]) * -1 * -1):G} the lazy dog.";
+ values.Add(PropertyName._fieldInterpolated3, global::Godot.Variant.From<string>(___fieldInterpolated3_default_value));
+ string ___fieldInterpolated4_default_value = $"{(":::fff,,}<,<}},,}]")}";
+ values.Add(PropertyName._fieldInterpolated4, global::Godot.Variant.From<string>(___fieldInterpolated4_default_value));
+ return values;
+ }
+#endif // TOOLS
+#pragma warning restore CS0109
+}
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportedComplexStrings.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportedComplexStrings.cs
new file mode 100644
index 0000000000..06a34bdc4a
--- /dev/null
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportedComplexStrings.cs
@@ -0,0 +1,23 @@
+using Godot;
+
+public partial class ExportedComplexStrings : Node
+{
+ [Export]
+ private string _fieldInterpolated1 = $"The quick brown fox jumps over ({Engine.GetVersionInfo()})";
+
+ [Export]
+ private string _fieldInterpolated2 = $"The quick brown fox jumps over ({Engine.GetVersionInfo()["major"],0:G}) the lazy dog.";
+
+ [Export]
+ private string _fieldInterpolated3 = $"{((int)Engine.GetVersionInfo()["major"]) * -1 * -1:G} the lazy dog.";
+
+ [Export]
+ private string _fieldInterpolated4 = $"{":::fff,,}<,<}},,}]"}";
+
+ [Export]
+ public string PropertyInterpolated1
+ {
+ get;
+ private set;
+ } = $"The quick brown fox jumps over {GD.VarToStr($"the lazy {Engine.GetVersionInfo()} do")}g.";
+}
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs
index 9784bd0b78..957d5789df 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ExtensionMethods.cs
@@ -208,7 +208,17 @@ namespace Godot.SourceGenerators
if (child.IsNode)
{
- FullQualifiedSyntax(child.AsNode()!, sm, sb, isFirstNode: innerIsFirstNode);
+ var childNode = child.AsNode()!;
+
+ if (node is InterpolationSyntax && childNode is ExpressionSyntax)
+ {
+ ParenEnclosedFullQualifiedSyntax(childNode, sm, sb, isFirstNode: innerIsFirstNode);
+ }
+ else
+ {
+ FullQualifiedSyntax(childNode, sm, sb, isFirstNode: innerIsFirstNode);
+ }
+
innerIsFirstNode = false;
}
else
@@ -221,6 +231,13 @@ namespace Godot.SourceGenerators
sb.Append(child.GetTrailingTrivia());
}
}
+
+ static void ParenEnclosedFullQualifiedSyntax(SyntaxNode node, SemanticModel sm, StringBuilder sb, bool isFirstNode)
+ {
+ sb.Append(SyntaxFactory.Token(SyntaxKind.OpenParenToken));
+ FullQualifiedSyntax(node, sm, sb, isFirstNode);
+ sb.Append(SyntaxFactory.Token(SyntaxKind.CloseParenToken));
+ }
}
public static string SanitizeQualifiedNameForUniqueHint(this string qualifiedName)
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 0a9162bd28..5cb177676c 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -121,6 +121,10 @@ StringBuilder &operator<<(StringBuilder &r_sb, const char *p_cstring) {
// This must be kept in sync with `ignored_types` in csharp_script.cpp
const Vector<String> ignored_types = {};
+// Special [code] keywords to wrap with <see langword="code"/> instead of <c>code</c>.
+// Don't check against all C# reserved words, as many cases are GDScript-specific.
+const Vector<String> langword_check = { "true", "false", "null" };
+
void BindingsGenerator::TypeInterface::postsetup_enum_type(BindingsGenerator::TypeInterface &r_enum_itype) {
// C interface for enums is the same as that of 'uint32_t'. Remember to apply
// any of the changes done here to the 'uint32_t' type interface as well.
@@ -670,11 +674,24 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
pos = brk_end + 1;
tag_stack.push_front(tag);
} else if (tag == "code" || tag.begins_with("code ")) {
- xml_output.append("<c>");
+ int end = bbcode.find("[", brk_end);
+ if (end == -1) {
+ end = bbcode.length();
+ }
+ String code = bbcode.substr(brk_end + 1, end - brk_end - 1);
+ if (langword_check.has(code)) {
+ xml_output.append("<see langword=\"");
+ xml_output.append(code);
+ xml_output.append("\"/>");
- code_tag = true;
- pos = brk_end + 1;
- tag_stack.push_front("code");
+ pos = brk_end + code.length() + 8;
+ } else {
+ xml_output.append("<c>");
+
+ code_tag = true;
+ pos = brk_end + 1;
+ tag_stack.push_front("code");
+ }
} else if (tag == "codeblock" || tag.begins_with("codeblock ")) {
xml_output.append("<code>");
diff --git a/modules/mono/editor/script_templates/SCsub b/modules/mono/editor/script_templates/SCsub
index 39f6cb5c01..01c293c25d 100644
--- a/modules/mono/editor/script_templates/SCsub
+++ b/modules/mono/editor/script_templates/SCsub
@@ -5,7 +5,7 @@ Import("env")
import editor.template_builders as build_template_cs
env["BUILDERS"]["MakeCSharpTemplateBuilder"] = Builder(
- action=env.Run(build_template_cs.make_templates, "Generating C# templates header."),
+ action=env.Run(build_template_cs.make_templates),
suffix=".h",
src_suffix=".cs",
)
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs
index 72a3fe3ed0..a1f1ade9b8 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs
@@ -336,7 +336,7 @@ namespace Godot
/// by the specified ratio (on the range of 0 to 1).
/// </summary>
/// <param name="amount">The ratio to lighten by.</param>
- /// <returns>The darkened color.</returns>
+ /// <returns>The lightened color.</returns>
public readonly Color Lightened(float amount)
{
Color res = this;
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj
index db16b1fe1d..d54942e654 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj
+++ b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj
@@ -142,5 +142,5 @@
We can't use wildcards as there may be undesired old files still hanging around.
Fortunately code completion, go to definition and such still work.
-->
- <Import Project="Generated\GeneratedIncludes.props" />
+ <Import Condition=" '$(GodotSkipGenerated)' == '' " Project="Generated\GeneratedIncludes.props" />
</Project>
diff --git a/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj b/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj
index 31e20e4ecd..c32cbcd3d1 100644
--- a/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj
+++ b/modules/mono/glue/GodotSharp/GodotSharpEditor/GodotSharpEditor.csproj
@@ -44,5 +44,5 @@
We can't use wildcards as there may be undesired old files still hanging around.
Fortunately code completion, go to definition and such still work.
-->
- <Import Project="Generated\GeneratedIncludes.props" />
+ <Import Condition=" '$(GodotSkipGenerated)' == '' " Project="Generated\GeneratedIncludes.props" />
</Project>