Repository: godotengine/godot (language: cpp)

Issue:
Default export values are ignored if negative
### Tested versions

- Reproducible in 4.5.dev [215acd52e82f4c575abb715e25e54558deeef998]
- Not reproducible in 4.4.1 and earlier

### System information

Godot v4.5.dev.mono (215acd52e) - Linux Mint 22.1 (Xia) on X11 - X11 display driver, Single-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 (nvidia; 550.120) - 13th Gen Intel(R) Core(TM) i5-13600KF (20 threads)

### Issue description

When setting a default value to an export property, if the value is negative, the editor does not recognize the value as the default. Setting the value to `0` will not be saved to the `.tscn` since the editor still thinks it's the default value for the type.

![Image](https://github.com/user-attachments/assets/66e7fecb-c086-44b8-89a9-176bad5edd4f)

![Image](https://github.com/user-attachments/assets/a64167a0-7273-4884-8b16-4d789572ad57)

![Image](https://github.com/user-attachments/assets/f90f40fc-615c-4057-9b29-5713cf95ca07)

### Steps to reproduce

Create a Node with a script.
Add an export property of type `int` and set the default value to a negative number.
Add the node to scene.
Save and reopen the scene.

### Minimal reproduction project (MRP)

[ExportTest.zip](https://github.com/user-attachments/files/19725812/ExportTest.zip)


Discussion / hints:

Fix patch:
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/ExportedFields_ScriptPropertyDefVal.generated.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/ExportedFields_ScriptPropertyDefVal.generated.cs
index f201b7c8d8dd..4caf51dc5a01 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/ExportedFields_ScriptPropertyDefVal.generated.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/ExportedFields_ScriptPropertyDefVal.generated.cs
@@ -22,7 +22,7 @@ partial class ExportedFields
         values.Add(PropertyName.@_fieldInt16, global::Godot.Variant.From<short>(___fieldInt16_default_value));
         int ___fieldInt32_default_value = 10;
         values.Add(PropertyName.@_fieldInt32, global::Godot.Variant.From<int>(___fieldInt32_default_value));
-        long ___fieldInt64_default_value = 10;
+        long ___fieldInt64_default_value = -10_000;
         values.Add(PropertyName.@_fieldInt64, global::Godot.Variant.From<long>(___fieldInt64_default_value));
         byte ___fieldByte_default_value = 10;
         values.Add(PropertyName.@_fieldByte, global::Godot.Variant.From<byte>(___fieldByte_default_value));
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/ExportedProperties_ScriptPropertyDefVal.generated.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/ExportedProperties_ScriptPropertyDefVal.generated.cs
index ce154cad8e88..0bf0b0845a45 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/ExportedProperties_ScriptPropertyDefVal.generated.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/ExportedProperties_ScriptPropertyDefVal.generated.cs
@@ -36,7 +36,7 @@ partial class ExportedProperties
         values.Add(PropertyName.@PropertyInt16, global::Godot.Variant.From<short>(__PropertyInt16_default_value));
         int __PropertyInt32_default_value = 10;
         values.Add(PropertyName.@PropertyInt32, global::Godot.Variant.From<int>(__PropertyInt32_default_value));
-        long __PropertyInt64_default_value = 10;
+        long __PropertyInt64_default_value = -10_000;
         values.Add(PropertyName.@PropertyInt64, global::Godot.Variant.From<long>(__PropertyInt64_default_value));
         byte __PropertyByte_default_value = 10;
         values.Add(PropertyName.@PropertyByte, global::Godot.Variant.From<byte>(__PropertyByte_default_value));
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportedFields.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportedFields.cs
index 0938d10afe58..07ae5cb68427 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportedFields.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportedFields.cs
@@ -9,7 +9,7 @@ public partial class ExportedFields : GodotObject
     [Export] private SByte _fieldSByte = 10;
     [Export] private Int16 _fieldInt16 = 10;
     [Export] private Int32 _fieldInt32 = 10;
-    [Export] private Int64 _fieldInt64 = 10;
+    [Export] private Int64 _fieldInt64 = -10_000;
     [Export] private Byte _fieldByte = 10;
     [Export] private UInt16 _fieldUInt16 = 10;
     [Export] private UInt32 _fieldUInt32 = 10;
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportedProperties.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportedProperties.cs
index 9ae23066fc4b..d7fcdc6b1b58 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportedProperties.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/ExportedProperties.cs
@@ -97,7 +97,7 @@ public String LamdaPropertyString
     [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 Int64 PropertyInt64 { get; set; } = -10_000;
     [Export] private Byte PropertyByte { get; set; } = 10;
     [Export] private UInt16 PropertyUInt16 { get; set; } = 10;
     [Export] private UInt32 PropertyUInt32 { get; set; } = 10;
diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs
index fff32a108004..6c3824711f8c 100644
--- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs
+++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/ScriptPropertyDefValGenerator.cs
@@ -430,6 +430,13 @@ private static bool IsStaticallyResolvable(ExpressionSyntax expression, Semantic
                 return true;
             }
 
+            // Handle negative literals (e.g., `-10`)
+            if (expression is PrefixUnaryExpressionSyntax { Operand: LiteralExpressionSyntax } &&
+                expression.Kind() == SyntaxKind.UnaryMinusExpression)
+            {
+                return true;
+            }
+
             // Handle identifiers (e.g., variable names)
             if (expression is IdentifierNameSyntax identifier)
             {


Test patch: