diff --git a/modules/mono/build_scripts/build_assemblies.py b/modules/mono/build_scripts/build_assemblies.py index 9f88b0575ed9..bdb0ce892139 100755 --- a/modules/mono/build_scripts/build_assemblies.py +++ b/modules/mono/build_scripts/build_assemblies.py @@ -229,7 +229,7 @@ def build_godot_api(msbuild_tool, module_dir, output_dir, push_nupkgs_local, pre core_src_dir = os.path.abspath(os.path.join(sln, os.pardir, "GodotSharp", "bin", build_config)) editor_src_dir = os.path.abspath(os.path.join(sln, os.pardir, "GodotSharpEditor", "bin", build_config)) - plugins_src_dir = os.path.abspath(os.path.join(sln, os.pardir, "GodotPlugins", "bin", build_config, "net6.0")) + plugins_src_dir = os.path.abspath(os.path.join(sln, os.pardir, "GodotPlugins", "bin", build_config, "net8.0")) if not os.path.isdir(editor_api_dir): assert not os.path.isfile(editor_api_dir) diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj index fc887313d5e8..bbb180914cce 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Sample/Godot.SourceGenerators.Sample.csproj @@ -1,8 +1,8 @@  - net6.0 - 11 + net8.0 + 12 diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpAnalyzerVerifier.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpAnalyzerVerifier.cs index 253889296b17..09d8faa35f1c 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpAnalyzerVerifier.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpAnalyzerVerifier.cs @@ -21,7 +21,7 @@ public class Test : CSharpAnalyzerTest { public Test() { - ReferenceAssemblies = ReferenceAssemblies.Net.Net60; + ReferenceAssemblies = Constants.Net80; SolutionTransforms.Add((Solution solution, ProjectId projectId) => { diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpCodeFixVerifier.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpCodeFixVerifier.cs index 51e215a17b22..c00ac45b89c6 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpCodeFixVerifier.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpCodeFixVerifier.cs @@ -4,7 +4,6 @@ using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Testing.Verifiers; namespace Godot.SourceGenerators.Tests; @@ -17,7 +16,7 @@ public class Test : CSharpCodeFixTest { public Test() { - ReferenceAssemblies = ReferenceAssemblies.Net.Net60; + ReferenceAssemblies = Constants.Net80; SolutionTransforms.Add((Solution solution, ProjectId projectId) => { Project project = solution.GetProject(projectId)! diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpSourceGeneratorVerifier.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpSourceGeneratorVerifier.cs index 84e319352d9e..975f9f4e3f59 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpSourceGeneratorVerifier.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/CSharpSourceGeneratorVerifier.cs @@ -18,7 +18,7 @@ public class Test : CSharpSourceGeneratorTest { public Test() { - ReferenceAssemblies = ReferenceAssemblies.Net.Net60; + ReferenceAssemblies = Constants.Net80; SolutionTransforms.Add((Solution solution, ProjectId projectId) => { diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Constants.cs b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Constants.cs index 783b1e429872..bfd8fc736928 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Constants.cs +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Constants.cs @@ -1,5 +1,6 @@ using System.IO; using System.Reflection; +using Microsoft.CodeAnalysis.Testing; namespace Godot.SourceGenerators.Tests; @@ -7,6 +8,13 @@ public static class Constants { public static Assembly GodotSharpAssembly => typeof(GodotObject).Assembly; + // Can't find what needs updating to be able to access ReferenceAssemblies.Net.Net80, so we're making our own one. + public static ReferenceAssemblies Net80 => new ReferenceAssemblies( + "net8.0", + new PackageIdentity("Microsoft.NETCore.App.Ref", "8.0.0"), + Path.Combine("ref", "net8.0") + ); + public static string ExecutingAssemblyPath { get; } public static string SourceFolderPath { get; } public static string GeneratedSourceFolderPath { get; } diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Godot.SourceGenerators.Tests.csproj b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Godot.SourceGenerators.Tests.csproj index 31a255dcdfcd..676facf90d1f 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Godot.SourceGenerators.Tests.csproj +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/Godot.SourceGenerators.Tests.csproj @@ -1,9 +1,8 @@  - net6.0 - - 11 + net8.0 + 12 enable false diff --git a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj index 8e407da7a6a7..e8302f41375c 100644 --- a/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj +++ b/modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators/Godot.SourceGenerators.csproj @@ -3,6 +3,7 @@ netstandard2.0 10 enable + true Core C# source generator for Godot projects. diff --git a/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj b/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj index f692f26a8b00..833f6b269a6a 100644 --- a/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj +++ b/modules/mono/editor/GodotTools/GodotTools.Core/GodotTools.Core.csproj @@ -1,8 +1,10 @@  + {639E48BD-44E5-4091-8EDD-22D36DC0768D} - net6.0 - 10 + net8.0 + 12 enable + diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/GodotTools.ProjectEditor.csproj b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/GodotTools.ProjectEditor.csproj index 5547ffcf192d..b08efd0964cc 100644 --- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/GodotTools.ProjectEditor.csproj +++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/GodotTools.ProjectEditor.csproj @@ -1,17 +1,21 @@  + {A8CDAD94-C6D4-4B19-A7E7-76C53CC92984} - net6.0 - 10 + net8.0 + 12 enable + + + diff --git a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs index 04ea46e9ef3b..dd74a0d52339 100644 --- a/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs +++ b/modules/mono/editor/GodotTools/GodotTools.ProjectEditor/ProjectGenerator.cs @@ -22,13 +22,7 @@ public static ProjectRootElement GenGameProject(string name) root.Sdk = GodotSdkAttrValue; var mainGroup = root.AddPropertyGroup(); - mainGroup.AddProperty("TargetFramework", "net6.0"); - - var net7 = mainGroup.AddProperty("TargetFramework", "net7.0"); - net7.Condition = " '$(GodotTargetPlatform)' == 'android' "; - - var net8 = mainGroup.AddProperty("TargetFramework", "net8.0"); - net8.Condition = " '$(GodotTargetPlatform)' == 'ios' "; + mainGroup.AddProperty("TargetFramework", "net8.0"); mainGroup.AddProperty("EnableDynamicLoading", "true"); diff --git a/modules/mono/editor/GodotTools/GodotTools.Shared/GodotTools.Shared.csproj b/modules/mono/editor/GodotTools/GodotTools.Shared/GodotTools.Shared.csproj index 7c19fabaf6eb..a281853f682c 100644 --- a/modules/mono/editor/GodotTools/GodotTools.Shared/GodotTools.Shared.csproj +++ b/modules/mono/editor/GodotTools/GodotTools.Shared/GodotTools.Shared.csproj @@ -1,8 +1,12 @@  - - net6.0 - - false - - + + + net8.0 + 12 + + false + + + + diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj index 96d2c5c75f22..c82da741bd11 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj +++ b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj @@ -1,9 +1,10 @@  + {27B00618-A6F2-4828-B922-05CAEB08C286} - net6.0 + net8.0 + 12 true - 10 enable Debug @@ -13,13 +14,16 @@ false true + true + + @@ -27,6 +31,7 @@ False + @@ -41,14 +46,17 @@ False + + + diff --git a/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Godot.SourceGenerators.Internal.csproj b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Godot.SourceGenerators.Internal.csproj index 81add0e44f12..ee607ff279e2 100644 --- a/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Godot.SourceGenerators.Internal.csproj +++ b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/Godot.SourceGenerators.Internal.csproj @@ -1,11 +1,15 @@  + netstandard2.0 10 enable + true + - - + + + diff --git a/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/UnmanagedCallbacksGenerator.cs b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/UnmanagedCallbacksGenerator.cs index 08e293afcc27..80d6160f3d67 100644 --- a/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/UnmanagedCallbacksGenerator.cs +++ b/modules/mono/glue/GodotSharp/Godot.SourceGenerators.Internal/UnmanagedCallbacksGenerator.cs @@ -172,7 +172,7 @@ void AppendPartialContainingTypeDeclarations(INamedTypeSymbol? containingType) { var parameter = callback.Parameters[i]; - AppendRefKind(source, parameter.RefKind); + AppendRefKind(source, parameter.RefKind, parameter.ScopedKind); source.Append(' '); source.Append(parameter.Type.FullQualifiedNameIncludeGlobal()); source.Append(' '); @@ -208,7 +208,7 @@ void AppendPartialContainingTypeDeclarations(INamedTypeSymbol? containingType) { // If it's a by-ref param and we can't get the pointer // just pass it by-ref and let it be pinned. - AppendRefKind(methodCallArguments, parameter.RefKind) + AppendRefKind(methodCallArguments, parameter.RefKind, parameter.ScopedKind) .Append(' ') .Append(parameter.Name); } @@ -346,7 +346,7 @@ void AppendPartialContainingTypeDeclarations(INamedTypeSymbol? containingType) { // If it's a by-ref param and we can't get the pointer // just pass it by-ref and let it be pinned. - AppendRefKind(source, parameter.RefKind) + AppendRefKind(source, parameter.RefKind, parameter.ScopedKind) .Append(' ') .Append(parameter.Type.FullQualifiedNameIncludeGlobal()); } @@ -392,14 +392,18 @@ private static bool IsGodotInteropStruct(ITypeSymbol type) => private static bool IsByRefParameter(IParameterSymbol parameter) => parameter.RefKind is RefKind.In or RefKind.Out or RefKind.Ref; - private static StringBuilder AppendRefKind(StringBuilder source, RefKind refKind) => - refKind switch + private static StringBuilder AppendRefKind(StringBuilder source, RefKind refKind, ScopedKind scopedKind) + { + return (refKind, scopedKind) switch { - RefKind.In => source.Append("in"), - RefKind.Out => source.Append("out"), - RefKind.Ref => source.Append("ref"), + (RefKind.Out, _) => source.Append("out"), + (RefKind.In, ScopedKind.ScopedRef) => source.Append("scoped in"), + (RefKind.In, _) => source.Append("in"), + (RefKind.Ref, ScopedKind.ScopedRef) => source.Append("scoped ref"), + (RefKind.Ref, _) => source.Append("ref"), _ => source, }; + } private static void AppendPointerType(StringBuilder source, ITypeSymbol type) { diff --git a/modules/mono/glue/GodotSharp/GodotPlugins/GodotPlugins.csproj b/modules/mono/glue/GodotSharp/GodotPlugins/GodotPlugins.csproj index 1e60743fb1ef..6d557c1eacf3 100644 --- a/modules/mono/glue/GodotSharp/GodotPlugins/GodotPlugins.csproj +++ b/modules/mono/glue/GodotSharp/GodotPlugins/GodotPlugins.csproj @@ -1,8 +1,8 @@  - net6.0 - 10 + net8.0 + 12 enable true diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs index c4bfed854291..9879a781043d 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Array.cs @@ -50,8 +50,7 @@ public Array() /// A new Godot Array. public Array(IEnumerable collection) : this() { - if (collection == null) - throw new ArgumentNullException(nameof(collection)); + ArgumentNullException.ThrowIfNull(collection); foreach (Variant element in collection) Add(element); @@ -67,8 +66,7 @@ public Array(IEnumerable collection) : this() /// A new Godot Array. public Array(Variant[] array) { - if (array == null) - throw new ArgumentNullException(nameof(array)); + ArgumentNullException.ThrowIfNull(array); NativeValue = (godot_array.movable)NativeFuncs.godotsharp_array_new(); _weakReferenceToSelf = DisposablesTracker.RegisterDisposable(this); @@ -1056,7 +1054,7 @@ public sealed class Array<[MustBeVariant] T> : IEnumerable, IGenericGodotArray { - private static godot_variant ToVariantFunc(in Array godotArray) => + private static godot_variant ToVariantFunc(scoped in Array godotArray) => VariantUtils.CreateFromArray(godotArray); private static Array FromVariantFunc(in godot_variant variant) => @@ -1080,8 +1078,8 @@ private void SetTypedForUnderlyingArray() static unsafe Array() { - VariantUtils.GenericConversion>.ToVariantCb = &ToVariantFunc; - VariantUtils.GenericConversion>.FromVariantCb = &FromVariantFunc; + VariantUtils.GenericConversion>.ToVariantCb = ToVariantFunc; + VariantUtils.GenericConversion>.FromVariantCb = FromVariantFunc; } private readonly Array _underlyingArray; @@ -1114,8 +1112,7 @@ public Array() /// A new Godot Array. public Array(IEnumerable collection) { - if (collection == null) - throw new ArgumentNullException(nameof(collection)); + ArgumentNullException.ThrowIfNull(collection); _underlyingArray = new Array(); SetTypedForUnderlyingArray(); @@ -1134,8 +1131,7 @@ public Array(IEnumerable collection) /// A new Godot Array. public Array(T[] array) { - if (array == null) - throw new ArgumentNullException(nameof(array)); + ArgumentNullException.ThrowIfNull(array); _underlyingArray = new Array(); SetTypedForUnderlyingArray(); @@ -1154,8 +1150,7 @@ public Array(T[] array) /// A new Godot Array. public Array(Array array) { - if (array == null) - throw new ArgumentNullException(nameof(array)); + ArgumentNullException.ThrowIfNull(array); _underlyingArray = array; } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs index 93a3f52f7db6..7019ea2932eb 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs @@ -90,8 +90,7 @@ internal static void FrameCallback() } [UnmanagedCallersOnly] - internal static unsafe IntPtr CreateManagedForGodotObjectBinding(godot_string_name* nativeTypeName, - IntPtr godotObject) + internal static unsafe IntPtr CreateManagedForGodotObjectBinding(godot_string_name* nativeTypeName, IntPtr godotObject) { try { @@ -143,7 +142,7 @@ internal static unsafe godot_bool CreateManagedForGodotObjectScriptInstance(IntP } } - var obj = (GodotObject)FormatterServices.GetUninitializedObject(scriptType); + var obj = (GodotObject)RuntimeHelpers.GetUninitializedObject(scriptType); var parameters = ctor.GetParameters(); int paramCount = parameters.Length; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/DebuggingUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/DebuggingUtils.cs index 0d96a9a5c184..0c83fd58aa1e 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/DebuggingUtils.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/DebuggingUtils.cs @@ -87,8 +87,8 @@ public readonly unsafe godot_stack_info* Elements public void Resize(int size) { - if (size < 0) - throw new ArgumentOutOfRangeException(nameof(size)); + ArgumentOutOfRangeException.ThrowIfNegative(size); + var err = NativeFuncs.godotsharp_stack_info_vector_resize(ref this, size); if (err != Error.Ok) throw new InvalidOperationException("Failed to resize vector. Error code is: " + err.ToString()); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs index ad313dbbf03f..dcb94f05fdf4 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Dictionary.cs @@ -492,7 +492,7 @@ public class Dictionary<[MustBeVariant] TKey, [MustBeVariant] TValue> : IReadOnlyDictionary, IGenericGodotDictionary { - private static godot_variant ToVariantFunc(in Dictionary godotDictionary) => + private static godot_variant ToVariantFunc(scoped in Dictionary godotDictionary) => VariantUtils.CreateFromDictionary(godotDictionary); private static Dictionary FromVariantFunc(in godot_variant variant) => @@ -521,8 +521,8 @@ private void SetTypedForUnderlyingDictionary() static unsafe Dictionary() { - VariantUtils.GenericConversion>.ToVariantCb = &ToVariantFunc; - VariantUtils.GenericConversion>.FromVariantCb = &FromVariantFunc; + VariantUtils.GenericConversion>.ToVariantCb = ToVariantFunc; + VariantUtils.GenericConversion>.FromVariantCb = FromVariantFunc; } private readonly Dictionary _underlyingDict; @@ -555,8 +555,7 @@ public Dictionary() /// A new Godot Dictionary. public Dictionary(IDictionary dictionary) { - if (dictionary == null) - throw new ArgumentNullException(nameof(dictionary)); + ArgumentNullException.ThrowIfNull(dictionary); _underlyingDict = new Dictionary(); SetTypedForUnderlyingDictionary(); @@ -575,8 +574,7 @@ public Dictionary(IDictionary dictionary) /// A new Godot Dictionary. public Dictionary(Dictionary dictionary) { - if (dictionary == null) - throw new ArgumentNullException(nameof(dictionary)); + ArgumentNullException.ThrowIfNull(dictionary); _underlyingDict = dictionary; } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.base.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.base.cs index 00eb64dd170c..08aea77e84c7 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.base.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotObject.base.cs @@ -90,8 +90,7 @@ internal static IntPtr GetPtr(GodotObject? instance) // NativePtr is assigned, that would result in UB or crashes when calling // native functions that receive the pointer, which can happen because the // debugger calls ToString() and tries to get the value of properties. - if (instance._disposed || instance.NativePtr == IntPtr.Zero) - throw new ObjectDisposedException(instance.GetType().FullName); + ObjectDisposedException.ThrowIf(instance._disposed || instance.NativePtr == IntPtr.Zero, instance); return instance.NativePtr; } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotTaskScheduler.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotTaskScheduler.cs index f6c36455b277..f84bf9de7c08 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotTaskScheduler.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GodotTaskScheduler.cs @@ -88,7 +88,7 @@ private void ExecuteQueuedTasks() lock (_tasks) { - if (_tasks.Any()) + if (_tasks.Count > 0) { task = _tasks.First.Value; _tasks.RemoveFirst(); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropStructs.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropStructs.cs index 555aebcd8313..dda776fee5f5 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropStructs.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/InteropStructs.cs @@ -174,6 +174,7 @@ public ref struct godot_variant => (godot_variant*)Unsafe.AsPointer(ref Unsafe.AsRef(in _typeField)); // Variant.Type is generated as an enum of type long, so we can't use for the field as it must only take 32-bits. + // The native enum actually has no fixed underlying type, so it is only at least 6 bits long. private int _typeField; // There's padding here @@ -481,8 +482,10 @@ public void Dispose() Type = Variant.Type.Nil; } +#pragma warning disable CS8981 // The type name only contains lower-cased ascii characters [StructLayout(LayoutKind.Explicit)] internal struct movable +#pragma warning restore CS8981 { // Variant.Type is generated as an enum of type long, so we can't use for the field as it must only take 32-bits. [FieldOffset(0)] private int _typeField; @@ -588,8 +591,10 @@ public override int GetHashCode() return _data.GetHashCode(); } +#pragma warning disable CS8981 // The type name only contains lower-cased ascii characters [StructLayout(LayoutKind.Sequential)] internal struct movable +#pragma warning restore CS8981 { private IntPtr _data; @@ -634,8 +639,10 @@ public readonly bool IsEmpty get => _data == IntPtr.Zero; } +#pragma warning disable CS8981 // The type name only contains lower-cased ascii characters [StructLayout(LayoutKind.Sequential)] internal struct movable +#pragma warning restore CS8981 { private IntPtr _data; @@ -809,8 +816,10 @@ public unsafe void Dispose() _p = null; } +#pragma warning disable CS8981 // The type name only contains lower-cased ascii characters [StructLayout(LayoutKind.Sequential)] internal struct movable +#pragma warning restore CS8981 { private unsafe ArrayPrivate* _p; @@ -876,8 +885,10 @@ public unsafe void Dispose() _p = null; } +#pragma warning disable CS8981 // The type name only contains lower-cased ascii characters [StructLayout(LayoutKind.Sequential)] internal struct movable +#pragma warning restore CS8981 { private unsafe DictionaryPrivate* _p; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/Marshaling.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/Marshaling.cs index 54efaad3c84c..69ea567c9900 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/Marshaling.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/Marshaling.cs @@ -268,7 +268,7 @@ public static unsafe string ConvertStringToManaged(in godot_string p_string) // Callable - public static godot_callable ConvertCallableToNative(in Callable p_managed_callable) + public static godot_callable ConvertCallableToNative(scoped in Callable p_managed_callable) { if (p_managed_callable.Delegate != null) { @@ -333,7 +333,7 @@ public static Callable ConvertCallableToManaged(in godot_callable p_callable) // Signal - public static godot_signal ConvertSignalToNative(in Signal p_managed_signal) + public static godot_signal ConvertSignalToNative(scoped in Signal p_managed_signal) { ulong ownerId = p_managed_signal.Owner.GetInstanceId(); godot_string_name name; @@ -432,12 +432,12 @@ public static unsafe byte[] ConvertNativePackedByteArrayToSystemArray(in godot_p return array; } - public static godot_packed_byte_array ConvertSystemArrayToNativePackedByteArray(Span p_array) + public static godot_packed_byte_array ConvertSystemArrayToNativePackedByteArray(scoped Span p_array) { return ConvertSystemArrayToNativePackedByteArray((ReadOnlySpan)p_array); } - public static unsafe godot_packed_byte_array ConvertSystemArrayToNativePackedByteArray(ReadOnlySpan p_array) + public static unsafe godot_packed_byte_array ConvertSystemArrayToNativePackedByteArray(scoped ReadOnlySpan p_array) { if (p_array.IsEmpty) return new godot_packed_byte_array(); @@ -460,12 +460,12 @@ public static unsafe int[] ConvertNativePackedInt32ArrayToSystemArray(godot_pack return array; } - public static godot_packed_int32_array ConvertSystemArrayToNativePackedInt32Array(Span p_array) + public static godot_packed_int32_array ConvertSystemArrayToNativePackedInt32Array(scoped Span p_array) { return ConvertSystemArrayToNativePackedInt32Array((ReadOnlySpan)p_array); } - public static unsafe godot_packed_int32_array ConvertSystemArrayToNativePackedInt32Array(ReadOnlySpan p_array) + public static unsafe godot_packed_int32_array ConvertSystemArrayToNativePackedInt32Array(scoped ReadOnlySpan p_array) { if (p_array.IsEmpty) return new godot_packed_int32_array(); @@ -488,12 +488,12 @@ public static unsafe long[] ConvertNativePackedInt64ArrayToSystemArray(godot_pac return array; } - public static godot_packed_int64_array ConvertSystemArrayToNativePackedInt64Array(Span p_array) + public static godot_packed_int64_array ConvertSystemArrayToNativePackedInt64Array(scoped Span p_array) { return ConvertSystemArrayToNativePackedInt64Array((ReadOnlySpan)p_array); } - public static unsafe godot_packed_int64_array ConvertSystemArrayToNativePackedInt64Array(ReadOnlySpan p_array) + public static unsafe godot_packed_int64_array ConvertSystemArrayToNativePackedInt64Array(scoped ReadOnlySpan p_array) { if (p_array.IsEmpty) return new godot_packed_int64_array(); @@ -516,13 +516,12 @@ public static unsafe float[] ConvertNativePackedFloat32ArrayToSystemArray(godot_ return array; } - public static godot_packed_float32_array ConvertSystemArrayToNativePackedFloat32Array(Span p_array) + public static godot_packed_float32_array ConvertSystemArrayToNativePackedFloat32Array(scoped Span p_array) { return ConvertSystemArrayToNativePackedFloat32Array((ReadOnlySpan)p_array); } - public static unsafe godot_packed_float32_array ConvertSystemArrayToNativePackedFloat32Array( - ReadOnlySpan p_array) + public static unsafe godot_packed_float32_array ConvertSystemArrayToNativePackedFloat32Array(scoped ReadOnlySpan p_array) { if (p_array.IsEmpty) return new godot_packed_float32_array(); @@ -545,13 +544,12 @@ public static unsafe double[] ConvertNativePackedFloat64ArrayToSystemArray(godot return array; } - public static godot_packed_float64_array ConvertSystemArrayToNativePackedFloat64Array(Span p_array) + public static godot_packed_float64_array ConvertSystemArrayToNativePackedFloat64Array(scoped Span p_array) { return ConvertSystemArrayToNativePackedFloat64Array((ReadOnlySpan)p_array); } - public static unsafe godot_packed_float64_array ConvertSystemArrayToNativePackedFloat64Array( - ReadOnlySpan p_array) + public static unsafe godot_packed_float64_array ConvertSystemArrayToNativePackedFloat64Array(scoped ReadOnlySpan p_array) { if (p_array.IsEmpty) return new godot_packed_float64_array(); @@ -573,12 +571,12 @@ public static unsafe string[] ConvertNativePackedStringArrayToSystemArray(godot_ return array; } - public static godot_packed_string_array ConvertSystemArrayToNativePackedStringArray(Span p_array) + public static godot_packed_string_array ConvertSystemArrayToNativePackedStringArray(scoped Span p_array) { return ConvertSystemArrayToNativePackedStringArray((ReadOnlySpan)p_array); } - public static godot_packed_string_array ConvertSystemArrayToNativePackedStringArray(ReadOnlySpan p_array) + public static godot_packed_string_array ConvertSystemArrayToNativePackedStringArray(scoped ReadOnlySpan p_array) { godot_packed_string_array dest = new godot_packed_string_array(); @@ -612,13 +610,12 @@ public static unsafe Vector2[] ConvertNativePackedVector2ArrayToSystemArray(godo return array; } - public static godot_packed_vector2_array ConvertSystemArrayToNativePackedVector2Array(Span p_array) + public static godot_packed_vector2_array ConvertSystemArrayToNativePackedVector2Array(scoped Span p_array) { return ConvertSystemArrayToNativePackedVector2Array((ReadOnlySpan)p_array); } - public static unsafe godot_packed_vector2_array ConvertSystemArrayToNativePackedVector2Array( - ReadOnlySpan p_array) + public static unsafe godot_packed_vector2_array ConvertSystemArrayToNativePackedVector2Array(scoped ReadOnlySpan p_array) { if (p_array.IsEmpty) return new godot_packed_vector2_array(); @@ -641,13 +638,12 @@ public static unsafe Vector3[] ConvertNativePackedVector3ArrayToSystemArray(godo return array; } - public static godot_packed_vector3_array ConvertSystemArrayToNativePackedVector3Array(Span p_array) + public static godot_packed_vector3_array ConvertSystemArrayToNativePackedVector3Array(scoped Span p_array) { return ConvertSystemArrayToNativePackedVector3Array((ReadOnlySpan)p_array); } - public static unsafe godot_packed_vector3_array ConvertSystemArrayToNativePackedVector3Array( - ReadOnlySpan p_array) + public static unsafe godot_packed_vector3_array ConvertSystemArrayToNativePackedVector3Array(scoped ReadOnlySpan p_array) { if (p_array.IsEmpty) return new godot_packed_vector3_array(); @@ -670,13 +666,12 @@ public static unsafe Vector4[] ConvertNativePackedVector4ArrayToSystemArray(godo return array; } - public static godot_packed_vector4_array ConvertSystemArrayToNativePackedVector4Array(Span p_array) + public static godot_packed_vector4_array ConvertSystemArrayToNativePackedVector4Array(scoped Span p_array) { return ConvertSystemArrayToNativePackedVector4Array((ReadOnlySpan)p_array); } - public static unsafe godot_packed_vector4_array ConvertSystemArrayToNativePackedVector4Array( - ReadOnlySpan p_array) + public static unsafe godot_packed_vector4_array ConvertSystemArrayToNativePackedVector4Array(scoped ReadOnlySpan p_array) { if (p_array.IsEmpty) return new godot_packed_vector4_array(); @@ -699,12 +694,12 @@ public static unsafe Color[] ConvertNativePackedColorArrayToSystemArray(godot_pa return array; } - public static godot_packed_color_array ConvertSystemArrayToNativePackedColorArray(Span p_array) + public static godot_packed_color_array ConvertSystemArrayToNativePackedColorArray(scoped Span p_array) { return ConvertSystemArrayToNativePackedColorArray((ReadOnlySpan)p_array); } - public static unsafe godot_packed_color_array ConvertSystemArrayToNativePackedColorArray(ReadOnlySpan p_array) + public static unsafe godot_packed_color_array ConvertSystemArrayToNativePackedColorArray(scoped ReadOnlySpan p_array) { if (p_array.IsEmpty) return new godot_packed_color_array(); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs index 47998c8017cf..021a701521ec 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.cs @@ -101,10 +101,10 @@ internal static partial IntPtr godotsharp_internal_unmanaged_instance_binding_cr internal static partial void godotsharp_internal_reload_registered_script(IntPtr scriptPtr); - internal static partial void godotsharp_array_filter_godot_objects_by_native(in godot_string_name p_native_name, - in godot_array p_input, out godot_array r_output); + internal static partial void godotsharp_array_filter_godot_objects_by_native(scoped in godot_string_name p_native_name, + scoped in godot_array p_input, out godot_array r_output); - internal static partial void godotsharp_array_filter_godot_objects_by_non_native(in godot_array p_input, + internal static partial void godotsharp_array_filter_godot_objects_by_non_native(scoped in godot_array p_input, out godot_array r_output); public static partial void godotsharp_ref_new_from_ref_counted_ptr(out godot_ref r_dest, @@ -113,15 +113,15 @@ public static partial void godotsharp_ref_new_from_ref_counted_ptr(out godot_ref public static partial void godotsharp_ref_destroy(ref godot_ref p_instance); public static partial void godotsharp_string_name_new_from_string(out godot_string_name r_dest, - in godot_string p_name); + scoped in godot_string p_name); public static partial void godotsharp_node_path_new_from_string(out godot_node_path r_dest, - in godot_string p_name); + scoped in godot_string p_name); public static partial void - godotsharp_string_name_as_string(out godot_string r_dest, in godot_string_name p_name); + godotsharp_string_name_as_string(out godot_string r_dest, scoped in godot_string_name p_name); - public static partial void godotsharp_node_path_as_string(out godot_string r_dest, in godot_node_path p_np); + public static partial void godotsharp_node_path_as_string(out godot_string r_dest, scoped in godot_node_path p_np); public static partial godot_packed_byte_array godotsharp_packed_byte_array_new_mem_copy(byte* p_src, int p_length); @@ -156,10 +156,10 @@ public static partial void godotsharp_packed_string_array_add(ref godot_packed_s public static partial void godotsharp_callable_new_with_delegate(IntPtr p_delegate_handle, IntPtr p_trampoline, IntPtr p_object, out godot_callable r_callable); - internal static partial godot_bool godotsharp_callable_get_data_for_marshalling(in godot_callable p_callable, + internal static partial godot_bool godotsharp_callable_get_data_for_marshalling(scoped in godot_callable p_callable, out IntPtr r_delegate_handle, out IntPtr r_trampoline, out IntPtr r_object, out godot_string_name r_name); - internal static partial godot_variant godotsharp_callable_call(in godot_callable p_callable, + internal static partial godot_variant godotsharp_callable_call(scoped in godot_callable p_callable, godot_variant** p_args, int p_arg_count, out godot_variant_call_error p_call_error); internal static partial void godotsharp_callable_call_deferred(in godot_callable p_callable, @@ -180,140 +180,135 @@ public static partial godot_variant godotsharp_method_bind_call(IntPtr p_method_ // variant.h public static partial void - godotsharp_variant_new_string_name(out godot_variant r_dest, in godot_string_name p_s); + godotsharp_variant_new_string_name(out godot_variant r_dest, scoped in godot_string_name p_s); - public static partial void godotsharp_variant_new_copy(out godot_variant r_dest, in godot_variant p_src); + public static partial void godotsharp_variant_new_copy(out godot_variant r_dest, scoped in godot_variant p_src); - public static partial void godotsharp_variant_new_node_path(out godot_variant r_dest, in godot_node_path p_np); + public static partial void godotsharp_variant_new_node_path(out godot_variant r_dest, scoped in godot_node_path p_np); public static partial void godotsharp_variant_new_object(out godot_variant r_dest, IntPtr p_obj); - public static partial void godotsharp_variant_new_transform2d(out godot_variant r_dest, in Transform2D p_t2d); + public static partial void godotsharp_variant_new_transform2d(out godot_variant r_dest, scoped in Transform2D p_t2d); - public static partial void godotsharp_variant_new_basis(out godot_variant r_dest, in Basis p_basis); + public static partial void godotsharp_variant_new_basis(out godot_variant r_dest, scoped in Basis p_basis); - public static partial void godotsharp_variant_new_transform3d(out godot_variant r_dest, in Transform3D p_trans); + public static partial void godotsharp_variant_new_transform3d(out godot_variant r_dest, scoped in Transform3D p_trans); - public static partial void godotsharp_variant_new_projection(out godot_variant r_dest, in Projection p_proj); + public static partial void godotsharp_variant_new_projection(out godot_variant r_dest, scoped in Projection p_proj); - public static partial void godotsharp_variant_new_aabb(out godot_variant r_dest, in Aabb p_aabb); + public static partial void godotsharp_variant_new_aabb(out godot_variant r_dest, scoped in Aabb p_aabb); public static partial void godotsharp_variant_new_dictionary(out godot_variant r_dest, - in godot_dictionary p_dict); + scoped in godot_dictionary p_dict); - public static partial void godotsharp_variant_new_array(out godot_variant r_dest, in godot_array p_arr); + public static partial void godotsharp_variant_new_array(out godot_variant r_dest, scoped in godot_array p_arr); public static partial void godotsharp_variant_new_packed_byte_array(out godot_variant r_dest, - in godot_packed_byte_array p_pba); + scoped in godot_packed_byte_array p_pba); public static partial void godotsharp_variant_new_packed_int32_array(out godot_variant r_dest, - in godot_packed_int32_array p_pia); + scoped in godot_packed_int32_array p_pia); public static partial void godotsharp_variant_new_packed_int64_array(out godot_variant r_dest, - in godot_packed_int64_array p_pia); + scoped in godot_packed_int64_array p_pia); public static partial void godotsharp_variant_new_packed_float32_array(out godot_variant r_dest, - in godot_packed_float32_array p_pra); + scoped in godot_packed_float32_array p_pra); public static partial void godotsharp_variant_new_packed_float64_array(out godot_variant r_dest, - in godot_packed_float64_array p_pra); + scoped in godot_packed_float64_array p_pra); public static partial void godotsharp_variant_new_packed_string_array(out godot_variant r_dest, - in godot_packed_string_array p_psa); + scoped in godot_packed_string_array p_psa); public static partial void godotsharp_variant_new_packed_vector2_array(out godot_variant r_dest, - in godot_packed_vector2_array p_pv2a); + scoped in godot_packed_vector2_array p_pv2a); public static partial void godotsharp_variant_new_packed_vector3_array(out godot_variant r_dest, - in godot_packed_vector3_array p_pv3a); + scoped in godot_packed_vector3_array p_pv3a); public static partial void godotsharp_variant_new_packed_vector4_array(out godot_variant r_dest, - in godot_packed_vector4_array p_pv4a); + scoped in godot_packed_vector4_array p_pv4a); public static partial void godotsharp_variant_new_packed_color_array(out godot_variant r_dest, - in godot_packed_color_array p_pca); + scoped in godot_packed_color_array p_pca); - public static partial godot_bool godotsharp_variant_as_bool(in godot_variant p_self); + public static partial godot_bool godotsharp_variant_as_bool(scoped in godot_variant p_self); - public static partial Int64 godotsharp_variant_as_int(in godot_variant p_self); + public static partial Int64 godotsharp_variant_as_int(scoped in godot_variant p_self); - public static partial double godotsharp_variant_as_float(in godot_variant p_self); + public static partial double godotsharp_variant_as_float(scoped in godot_variant p_self); - public static partial godot_string godotsharp_variant_as_string(in godot_variant p_self); + public static partial godot_string godotsharp_variant_as_string(scoped in godot_variant p_self); - public static partial Vector2 godotsharp_variant_as_vector2(in godot_variant p_self); + public static partial Vector2 godotsharp_variant_as_vector2(scoped in godot_variant p_self); - public static partial Vector2I godotsharp_variant_as_vector2i(in godot_variant p_self); + public static partial Vector2I godotsharp_variant_as_vector2i(scoped in godot_variant p_self); - public static partial Rect2 godotsharp_variant_as_rect2(in godot_variant p_self); + public static partial Rect2 godotsharp_variant_as_rect2(scoped in godot_variant p_self); - public static partial Rect2I godotsharp_variant_as_rect2i(in godot_variant p_self); + public static partial Rect2I godotsharp_variant_as_rect2i(scoped in godot_variant p_self); - public static partial Vector3 godotsharp_variant_as_vector3(in godot_variant p_self); + public static partial Vector3 godotsharp_variant_as_vector3(scoped in godot_variant p_self); - public static partial Vector3I godotsharp_variant_as_vector3i(in godot_variant p_self); + public static partial Vector3I godotsharp_variant_as_vector3i(scoped in godot_variant p_self); - public static partial Transform2D godotsharp_variant_as_transform2d(in godot_variant p_self); + public static partial Transform2D godotsharp_variant_as_transform2d(scoped in godot_variant p_self); - public static partial Vector4 godotsharp_variant_as_vector4(in godot_variant p_self); + public static partial Vector4 godotsharp_variant_as_vector4(scoped in godot_variant p_self); - public static partial Vector4I godotsharp_variant_as_vector4i(in godot_variant p_self); + public static partial Vector4I godotsharp_variant_as_vector4i(scoped in godot_variant p_self); - public static partial Plane godotsharp_variant_as_plane(in godot_variant p_self); + public static partial Plane godotsharp_variant_as_plane(scoped in godot_variant p_self); - public static partial Quaternion godotsharp_variant_as_quaternion(in godot_variant p_self); + public static partial Quaternion godotsharp_variant_as_quaternion(scoped in godot_variant p_self); - public static partial Aabb godotsharp_variant_as_aabb(in godot_variant p_self); + public static partial Aabb godotsharp_variant_as_aabb(scoped in godot_variant p_self); - public static partial Basis godotsharp_variant_as_basis(in godot_variant p_self); + public static partial Basis godotsharp_variant_as_basis(scoped in godot_variant p_self); - public static partial Transform3D godotsharp_variant_as_transform3d(in godot_variant p_self); + public static partial Transform3D godotsharp_variant_as_transform3d(scoped in godot_variant p_self); - public static partial Projection godotsharp_variant_as_projection(in godot_variant p_self); + public static partial Projection godotsharp_variant_as_projection(scoped in godot_variant p_self); - public static partial Color godotsharp_variant_as_color(in godot_variant p_self); + public static partial Color godotsharp_variant_as_color(scoped in godot_variant p_self); - public static partial godot_string_name godotsharp_variant_as_string_name(in godot_variant p_self); + public static partial godot_string_name godotsharp_variant_as_string_name(scoped in godot_variant p_self); - public static partial godot_node_path godotsharp_variant_as_node_path(in godot_variant p_self); + public static partial godot_node_path godotsharp_variant_as_node_path(scoped in godot_variant p_self); - public static partial Rid godotsharp_variant_as_rid(in godot_variant p_self); + public static partial Rid godotsharp_variant_as_rid(scoped in godot_variant p_self); - public static partial godot_callable godotsharp_variant_as_callable(in godot_variant p_self); + public static partial godot_callable godotsharp_variant_as_callable(scoped in godot_variant p_self); - public static partial godot_signal godotsharp_variant_as_signal(in godot_variant p_self); + public static partial godot_signal godotsharp_variant_as_signal(scoped in godot_variant p_self); - public static partial godot_dictionary godotsharp_variant_as_dictionary(in godot_variant p_self); + public static partial godot_dictionary godotsharp_variant_as_dictionary(scoped in godot_variant p_self); - public static partial godot_array godotsharp_variant_as_array(in godot_variant p_self); + public static partial godot_array godotsharp_variant_as_array(scoped in godot_variant p_self); - public static partial godot_packed_byte_array godotsharp_variant_as_packed_byte_array(in godot_variant p_self); + public static partial godot_packed_byte_array godotsharp_variant_as_packed_byte_array(scoped in godot_variant p_self); - public static partial godot_packed_int32_array godotsharp_variant_as_packed_int32_array(in godot_variant p_self); + public static partial godot_packed_int32_array godotsharp_variant_as_packed_int32_array(scoped in godot_variant p_self); - public static partial godot_packed_int64_array godotsharp_variant_as_packed_int64_array(in godot_variant p_self); + public static partial godot_packed_int64_array godotsharp_variant_as_packed_int64_array(scoped in godot_variant p_self); - public static partial godot_packed_float32_array godotsharp_variant_as_packed_float32_array( - in godot_variant p_self); + public static partial godot_packed_float32_array godotsharp_variant_as_packed_float32_array(scoped in godot_variant p_self); - public static partial godot_packed_float64_array godotsharp_variant_as_packed_float64_array( - in godot_variant p_self); + public static partial godot_packed_float64_array godotsharp_variant_as_packed_float64_array(scoped in godot_variant p_self); - public static partial godot_packed_string_array godotsharp_variant_as_packed_string_array( - in godot_variant p_self); + public static partial godot_packed_string_array godotsharp_variant_as_packed_string_array(scoped in godot_variant p_self); - public static partial godot_packed_vector2_array godotsharp_variant_as_packed_vector2_array( - in godot_variant p_self); + public static partial godot_packed_vector2_array godotsharp_variant_as_packed_vector2_array(scoped in godot_variant p_self); - public static partial godot_packed_vector3_array godotsharp_variant_as_packed_vector3_array( - in godot_variant p_self); + public static partial godot_packed_vector3_array godotsharp_variant_as_packed_vector3_array(scoped in godot_variant p_self); public static partial godot_packed_vector4_array godotsharp_variant_as_packed_vector4_array( in godot_variant p_self); - public static partial godot_packed_color_array godotsharp_variant_as_packed_color_array(in godot_variant p_self); + public static partial godot_packed_color_array godotsharp_variant_as_packed_color_array(scoped in godot_variant p_self); - public static partial godot_bool godotsharp_variant_equals(in godot_variant p_a, in godot_variant p_b); + public static partial godot_bool godotsharp_variant_equals(scoped in godot_variant p_a, scoped in godot_variant p_b); // string.h @@ -322,17 +317,17 @@ public static partial godot_packed_vector4_array godotsharp_variant_as_packed_ve // string_name.h public static partial void godotsharp_string_name_new_copy(out godot_string_name r_dest, - in godot_string_name p_src); + scoped in godot_string_name p_src); // node_path.h - public static partial void godotsharp_node_path_new_copy(out godot_node_path r_dest, in godot_node_path p_src); + public static partial void godotsharp_node_path_new_copy(out godot_node_path r_dest, scoped in godot_node_path p_src); // array.h public static partial void godotsharp_array_new(out godot_array r_dest); - public static partial void godotsharp_array_new_copy(out godot_array r_dest, in godot_array p_src); + public static partial void godotsharp_array_new_copy(out godot_array r_dest, scoped in godot_array p_src); public static partial godot_variant* godotsharp_array_ptrw(ref godot_array p_self); @@ -341,7 +336,7 @@ public static partial void godotsharp_string_name_new_copy(out godot_string_name public static partial void godotsharp_dictionary_new(out godot_dictionary r_dest); public static partial void godotsharp_dictionary_new_copy(out godot_dictionary r_dest, - in godot_dictionary p_src); + scoped in godot_dictionary p_src); // destroy functions @@ -389,8 +384,7 @@ public static partial void godotsharp_dictionary_new_copy(out godot_dictionary r public static partial int godotsharp_array_binary_search(ref godot_array p_self, int p_index, int p_count, in godot_variant p_value); - public static partial void - godotsharp_array_duplicate(ref godot_array p_self, godot_bool p_deep, out godot_array r_dest); + public static partial void godotsharp_array_duplicate(scoped ref godot_array p_self, godot_bool p_deep, out godot_array r_dest); public static partial void godotsharp_array_fill(ref godot_array p_self, in godot_variant p_value); @@ -410,11 +404,11 @@ public static partial void godotsharp_array_set_typed( public static partial godot_bool godotsharp_array_is_typed(ref godot_array p_self); - public static partial void godotsharp_array_max(ref godot_array p_self, out godot_variant r_value); + public static partial void godotsharp_array_max(scoped ref godot_array p_self, out godot_variant r_value); - public static partial void godotsharp_array_min(ref godot_array p_self, out godot_variant r_value); + public static partial void godotsharp_array_min(scoped ref godot_array p_self, out godot_variant r_value); - public static partial void godotsharp_array_pick_random(ref godot_array p_self, out godot_variant r_value); + public static partial void godotsharp_array_pick_random(scoped ref godot_array p_self, out godot_variant r_value); public static partial godot_bool godotsharp_array_recursive_equal(ref godot_array p_self, in godot_array p_other); @@ -426,7 +420,7 @@ public static partial void godotsharp_array_set_typed( public static partial void godotsharp_array_shuffle(ref godot_array p_self); - public static partial void godotsharp_array_slice(ref godot_array p_self, int p_start, int p_end, + public static partial void godotsharp_array_slice(scoped ref godot_array p_self, int p_start, int p_end, int p_step, godot_bool p_deep, out godot_array r_dest); public static partial void godotsharp_array_sort(ref godot_array p_self); @@ -435,20 +429,20 @@ public static partial void godotsharp_array_slice(ref godot_array p_self, int p_ // Dictionary - public static partial godot_bool godotsharp_dictionary_try_get_value(ref godot_dictionary p_self, - in godot_variant p_key, + public static partial godot_bool godotsharp_dictionary_try_get_value(scoped ref godot_dictionary p_self, + scoped in godot_variant p_key, out godot_variant r_value); public static partial void godotsharp_dictionary_set_value(ref godot_dictionary p_self, in godot_variant p_key, in godot_variant p_value); - public static partial void godotsharp_dictionary_keys(ref godot_dictionary p_self, out godot_array r_dest); + public static partial void godotsharp_dictionary_keys(scoped ref godot_dictionary p_self, out godot_array r_dest); - public static partial void godotsharp_dictionary_values(ref godot_dictionary p_self, out godot_array r_dest); + public static partial void godotsharp_dictionary_values(scoped ref godot_dictionary p_self, out godot_array r_dest); public static partial int godotsharp_dictionary_count(ref godot_dictionary p_self); - public static partial void godotsharp_dictionary_key_value_pair_at(ref godot_dictionary p_self, int p_index, + public static partial void godotsharp_dictionary_key_value_pair_at(scoped ref godot_dictionary p_self, int p_index, out godot_variant r_key, out godot_variant r_value); public static partial void godotsharp_dictionary_add(ref godot_dictionary p_self, in godot_variant p_key, @@ -459,7 +453,7 @@ public static partial void godotsharp_dictionary_add(ref godot_dictionary p_self public static partial godot_bool godotsharp_dictionary_contains_key(ref godot_dictionary p_self, in godot_variant p_key); - public static partial void godotsharp_dictionary_duplicate(ref godot_dictionary p_self, godot_bool p_deep, + public static partial void godotsharp_dictionary_duplicate(scoped ref godot_dictionary p_self, godot_bool p_deep, out godot_dictionary r_dest); public static partial void godotsharp_dictionary_merge(ref godot_dictionary p_self, in godot_dictionary p_dictionary, godot_bool p_overwrite); @@ -496,20 +490,20 @@ public static partial void godotsharp_dictionary_set_typed( public static partial void godotsharp_dictionary_get_typed_value_script(ref godot_dictionary p_self, out godot_variant r_dest); - public static partial void godotsharp_dictionary_to_string(ref godot_dictionary p_self, out godot_string r_str); + public static partial void godotsharp_dictionary_to_string(scoped ref godot_dictionary p_self, out godot_string r_str); // StringExtensions - public static partial void godotsharp_string_simplify_path(in godot_string p_self, + public static partial void godotsharp_string_simplify_path(scoped in godot_string p_self, out godot_string r_simplified_path); - public static partial void godotsharp_string_to_camel_case(in godot_string p_self, + public static partial void godotsharp_string_to_camel_case(scoped in godot_string p_self, out godot_string r_camel_case); - public static partial void godotsharp_string_to_pascal_case(in godot_string p_self, + public static partial void godotsharp_string_to_pascal_case(scoped in godot_string p_self, out godot_string r_pascal_case); - public static partial void godotsharp_string_to_snake_case(in godot_string p_self, + public static partial void godotsharp_string_to_snake_case(scoped in godot_string p_self, out godot_string r_snake_case); // NodePath @@ -517,18 +511,18 @@ public static partial void godotsharp_string_to_snake_case(in godot_string p_sel public static partial void godotsharp_node_path_get_as_property_path(in godot_node_path p_self, ref godot_node_path r_dest); - public static partial void godotsharp_node_path_get_concatenated_names(in godot_node_path p_self, + public static partial void godotsharp_node_path_get_concatenated_names(scoped in godot_node_path p_self, out godot_string r_names); - public static partial void godotsharp_node_path_get_concatenated_subnames(in godot_node_path p_self, + public static partial void godotsharp_node_path_get_concatenated_subnames(scoped in godot_node_path p_self, out godot_string r_subnames); - public static partial void godotsharp_node_path_get_name(in godot_node_path p_self, int p_idx, + public static partial void godotsharp_node_path_get_name(scoped in godot_node_path p_self, int p_idx, out godot_string r_name); public static partial int godotsharp_node_path_get_name_count(in godot_node_path p_self); - public static partial void godotsharp_node_path_get_subname(in godot_node_path p_self, int p_idx, + public static partial void godotsharp_node_path_get_subname(scoped in godot_node_path p_self, int p_idx, out godot_string r_subname); public static partial int godotsharp_node_path_get_subname_count(in godot_node_path p_self); @@ -541,11 +535,11 @@ public static partial void godotsharp_node_path_get_subname(in godot_node_path p // GD, etc - internal static partial void godotsharp_bytes_to_var(in godot_packed_byte_array p_bytes, + internal static partial void godotsharp_bytes_to_var(scoped in godot_packed_byte_array p_bytes, godot_bool p_allow_objects, out godot_variant r_ret); - internal static partial void godotsharp_convert(in godot_variant p_what, int p_type, + internal static partial void godotsharp_convert(scoped in godot_variant p_what, int p_type, out godot_variant r_ret); internal static partial int godotsharp_hash(in godot_variant p_var); @@ -582,12 +576,12 @@ internal static partial void godotsharp_convert(in godot_variant p_what, int p_t internal static partial void godotsharp_weakref(IntPtr p_obj, out godot_ref r_weak_ref); - internal static partial void godotsharp_str_to_var(in godot_string p_str, out godot_variant r_ret); + internal static partial void godotsharp_str_to_var(scoped in godot_string p_str, out godot_variant r_ret); - internal static partial void godotsharp_var_to_bytes(in godot_variant p_what, godot_bool p_full_objects, + internal static partial void godotsharp_var_to_bytes(scoped in godot_variant p_what, godot_bool p_full_objects, out godot_packed_byte_array r_bytes); - internal static partial void godotsharp_var_to_str(in godot_variant p_var, out godot_string r_ret); + internal static partial void godotsharp_var_to_str(scoped in godot_variant p_var, out godot_string r_ret); internal static partial void godotsharp_err_print_error(in godot_string p_function, in godot_string p_file, int p_line, in godot_string p_error, in godot_string p_message = default, godot_bool p_editor_notify = godot_bool.False, godot_error_handler_type p_type = godot_error_handler_type.ERR_HANDLER_ERROR); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs index 9f237e4d00cb..b885893de028 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/NativeFuncs.extended.cs @@ -6,7 +6,7 @@ namespace Godot.NativeInterop { public static partial class NativeFuncs { - public static godot_variant godotsharp_variant_new_copy(in godot_variant src) + public static godot_variant godotsharp_variant_new_copy(scoped in godot_variant src) { switch (src.Type) { @@ -48,7 +48,7 @@ public static godot_variant godotsharp_variant_new_copy(in godot_variant src) return ret; } - public static godot_string_name godotsharp_string_name_new_copy(in godot_string_name src) + public static godot_string_name godotsharp_string_name_new_copy(scoped in godot_string_name src) { if (src.IsEmpty) return default; @@ -56,7 +56,7 @@ public static godot_string_name godotsharp_string_name_new_copy(in godot_string_ return ret; } - public static godot_node_path godotsharp_node_path_new_copy(in godot_node_path src) + public static godot_node_path godotsharp_node_path_new_copy(scoped in godot_node_path src) { if (src.IsEmpty) return default; @@ -70,7 +70,7 @@ public static godot_array godotsharp_array_new() return ret; } - public static godot_array godotsharp_array_new_copy(in godot_array src) + public static godot_array godotsharp_array_new_copy(scoped in godot_array src) { godotsharp_array_new_copy(out godot_array ret, src); return ret; @@ -82,7 +82,7 @@ public static godot_dictionary godotsharp_dictionary_new() return ret; } - public static godot_dictionary godotsharp_dictionary_new_copy(in godot_dictionary src) + public static godot_dictionary godotsharp_dictionary_new_copy(scoped in godot_dictionary src) { godotsharp_dictionary_new_copy(out godot_dictionary ret, src); return ret; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs index 222ded689563..a48e60a30f60 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.cs @@ -117,137 +117,137 @@ public static godot_variant CreateFromStringTakingOwnershipOfDisposableValue(god public static godot_variant CreateFromString(string? from) => CreateFromStringTakingOwnershipOfDisposableValue(Marshaling.ConvertStringToNative(from)); - public static godot_variant CreateFromPackedByteArray(in godot_packed_byte_array from) + public static godot_variant CreateFromPackedByteArray(scoped in godot_packed_byte_array from) { NativeFuncs.godotsharp_variant_new_packed_byte_array(out godot_variant ret, from); return ret; } - public static godot_variant CreateFromPackedInt32Array(in godot_packed_int32_array from) + public static godot_variant CreateFromPackedInt32Array(scoped in godot_packed_int32_array from) { NativeFuncs.godotsharp_variant_new_packed_int32_array(out godot_variant ret, from); return ret; } - public static godot_variant CreateFromPackedInt64Array(in godot_packed_int64_array from) + public static godot_variant CreateFromPackedInt64Array(scoped in godot_packed_int64_array from) { NativeFuncs.godotsharp_variant_new_packed_int64_array(out godot_variant ret, from); return ret; } - public static godot_variant CreateFromPackedFloat32Array(in godot_packed_float32_array from) + public static godot_variant CreateFromPackedFloat32Array(scoped in godot_packed_float32_array from) { NativeFuncs.godotsharp_variant_new_packed_float32_array(out godot_variant ret, from); return ret; } - public static godot_variant CreateFromPackedFloat64Array(in godot_packed_float64_array from) + public static godot_variant CreateFromPackedFloat64Array(scoped in godot_packed_float64_array from) { NativeFuncs.godotsharp_variant_new_packed_float64_array(out godot_variant ret, from); return ret; } - public static godot_variant CreateFromPackedStringArray(in godot_packed_string_array from) + public static godot_variant CreateFromPackedStringArray(scoped in godot_packed_string_array from) { NativeFuncs.godotsharp_variant_new_packed_string_array(out godot_variant ret, from); return ret; } - public static godot_variant CreateFromPackedVector2Array(in godot_packed_vector2_array from) + public static godot_variant CreateFromPackedVector2Array(scoped in godot_packed_vector2_array from) { NativeFuncs.godotsharp_variant_new_packed_vector2_array(out godot_variant ret, from); return ret; } - public static godot_variant CreateFromPackedVector3Array(in godot_packed_vector3_array from) + public static godot_variant CreateFromPackedVector3Array(scoped in godot_packed_vector3_array from) { NativeFuncs.godotsharp_variant_new_packed_vector3_array(out godot_variant ret, from); return ret; } - public static godot_variant CreateFromPackedVector4Array(in godot_packed_vector4_array from) + public static godot_variant CreateFromPackedVector4Array(scoped in godot_packed_vector4_array from) { NativeFuncs.godotsharp_variant_new_packed_vector4_array(out godot_variant ret, from); return ret; } - public static godot_variant CreateFromPackedColorArray(in godot_packed_color_array from) + public static godot_variant CreateFromPackedColorArray(scoped in godot_packed_color_array from) { NativeFuncs.godotsharp_variant_new_packed_color_array(out godot_variant ret, from); return ret; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static godot_variant CreateFromPackedByteArray(Span from) + public static godot_variant CreateFromPackedByteArray(scoped Span from) { using var nativePackedArray = Marshaling.ConvertSystemArrayToNativePackedByteArray(from); return CreateFromPackedByteArray(nativePackedArray); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static godot_variant CreateFromPackedInt32Array(Span from) + public static godot_variant CreateFromPackedInt32Array(scoped Span from) { using var nativePackedArray = Marshaling.ConvertSystemArrayToNativePackedInt32Array(from); return CreateFromPackedInt32Array(nativePackedArray); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static godot_variant CreateFromPackedInt64Array(Span from) + public static godot_variant CreateFromPackedInt64Array(scoped Span from) { using var nativePackedArray = Marshaling.ConvertSystemArrayToNativePackedInt64Array(from); return CreateFromPackedInt64Array(nativePackedArray); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static godot_variant CreateFromPackedFloat32Array(Span from) + public static godot_variant CreateFromPackedFloat32Array(scoped Span from) { using var nativePackedArray = Marshaling.ConvertSystemArrayToNativePackedFloat32Array(from); return CreateFromPackedFloat32Array(nativePackedArray); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static godot_variant CreateFromPackedFloat64Array(Span from) + public static godot_variant CreateFromPackedFloat64Array(scoped Span from) { using var nativePackedArray = Marshaling.ConvertSystemArrayToNativePackedFloat64Array(from); return CreateFromPackedFloat64Array(nativePackedArray); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static godot_variant CreateFromPackedStringArray(Span from) + public static godot_variant CreateFromPackedStringArray(scoped Span from) { using var nativePackedArray = Marshaling.ConvertSystemArrayToNativePackedStringArray(from); return CreateFromPackedStringArray(nativePackedArray); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static godot_variant CreateFromPackedVector2Array(Span from) + public static godot_variant CreateFromPackedVector2Array(scoped Span from) { using var nativePackedArray = Marshaling.ConvertSystemArrayToNativePackedVector2Array(from); return CreateFromPackedVector2Array(nativePackedArray); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static godot_variant CreateFromPackedVector3Array(Span from) + public static godot_variant CreateFromPackedVector3Array(scoped Span from) { using var nativePackedArray = Marshaling.ConvertSystemArrayToNativePackedVector3Array(from); return CreateFromPackedVector3Array(nativePackedArray); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static godot_variant CreateFromPackedVector4Array(Span from) + public static godot_variant CreateFromPackedVector4Array(scoped Span from) { using var nativePackedArray = Marshaling.ConvertSystemArrayToNativePackedVector4Array(from); return CreateFromPackedVector4Array(nativePackedArray); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static godot_variant CreateFromPackedColorArray(Span from) + public static godot_variant CreateFromPackedColorArray(scoped Span from) { using var nativePackedArray = Marshaling.ConvertSystemArrayToNativePackedColorArray(from); return CreateFromPackedColorArray(nativePackedArray); } - public static godot_variant CreateFromSystemArrayOfStringName(Span from) + public static godot_variant CreateFromSystemArrayOfStringName(scoped Span from) { if (from == null) return default; @@ -255,7 +255,7 @@ public static godot_variant CreateFromSystemArrayOfStringName(Span f return CreateFromArray((godot_array)fromGodot.NativeValue); } - public static godot_variant CreateFromSystemArrayOfNodePath(Span from) + public static godot_variant CreateFromSystemArrayOfNodePath(scoped Span from) { if (from == null) return default; @@ -263,7 +263,7 @@ public static godot_variant CreateFromSystemArrayOfNodePath(Span from) return CreateFromArray((godot_array)fromGodot.NativeValue); } - public static godot_variant CreateFromSystemArrayOfRid(Span from) + public static godot_variant CreateFromSystemArrayOfRid(scoped Span from) { if (from == null) return default; @@ -279,7 +279,7 @@ public static godot_variant CreateFromSystemArrayOfGodotObject(GodotObject[]? fr return CreateFromArray((godot_array)fromGodot.NativeValue); } - public static godot_variant CreateFromArray(godot_array from) + public static godot_variant CreateFromArray(scoped in godot_array from) { NativeFuncs.godotsharp_variant_new_array(out godot_variant ret, from); return ret; @@ -293,7 +293,7 @@ public static godot_variant CreateFromArray(Collections.Array? from) public static godot_variant CreateFromArray<[MustBeVariant] T>(Array? from) => from != null ? CreateFromArray((godot_array)((Collections.Array)from).NativeValue) : default; - public static godot_variant CreateFromDictionary(godot_dictionary from) + public static godot_variant CreateFromDictionary(scoped in godot_dictionary from) { NativeFuncs.godotsharp_variant_new_dictionary(out godot_variant ret, from); return ret; @@ -307,7 +307,7 @@ public static godot_variant CreateFromDictionary(Dictionary? from) public static godot_variant CreateFromDictionary<[MustBeVariant] TKey, [MustBeVariant] TValue>(Dictionary? from) => from != null ? CreateFromDictionary((godot_dictionary)((Dictionary)from).NativeValue) : default; - public static godot_variant CreateFromStringName(godot_string_name from) + public static godot_variant CreateFromStringName(scoped in godot_string_name from) { NativeFuncs.godotsharp_variant_new_string_name(out godot_variant ret, from); return ret; @@ -317,7 +317,7 @@ public static godot_variant CreateFromStringName(godot_string_name from) public static godot_variant CreateFromStringName(StringName? from) => from != null ? CreateFromStringName((godot_string_name)from.NativeValue) : default; - public static godot_variant CreateFromNodePath(godot_node_path from) + public static godot_variant CreateFromNodePath(scoped in godot_node_path from) { NativeFuncs.godotsharp_variant_new_node_path(out godot_variant ret, from); return ret; @@ -510,7 +510,7 @@ public static string ConvertToString(in godot_variant p_var) } } - public static godot_string_name ConvertToNativeStringName(in godot_variant p_var) + public static godot_string_name ConvertToNativeStringName(scoped in godot_variant p_var) => p_var.Type == Variant.Type.StringName ? NativeFuncs.godotsharp_string_name_new_copy(p_var.StringName) : NativeFuncs.godotsharp_variant_as_string_name(p_var); @@ -519,7 +519,7 @@ public static godot_string_name ConvertToNativeStringName(in godot_variant p_var public static StringName ConvertToStringName(in godot_variant p_var) => StringName.CreateTakingOwnershipOfDisposableValue(ConvertToNativeStringName(p_var)); - public static godot_node_path ConvertToNativeNodePath(in godot_variant p_var) + public static godot_node_path ConvertToNativeNodePath(scoped in godot_variant p_var) => p_var.Type == Variant.Type.NodePath ? NativeFuncs.godotsharp_node_path_new_copy(p_var.NodePath) : NativeFuncs.godotsharp_variant_as_node_path(p_var); @@ -529,7 +529,7 @@ public static NodePath ConvertToNodePath(in godot_variant p_var) => NodePath.CreateTakingOwnershipOfDisposableValue(ConvertToNativeNodePath(p_var)); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static godot_callable ConvertToNativeCallable(in godot_variant p_var) + public static godot_callable ConvertToNativeCallable(scoped in godot_variant p_var) => NativeFuncs.godotsharp_variant_as_callable(p_var); [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -540,7 +540,7 @@ public static Callable ConvertToCallable(in godot_variant p_var) } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static godot_signal ConvertToNativeSignal(in godot_variant p_var) + public static godot_signal ConvertToNativeSignal(scoped in godot_variant p_var) => NativeFuncs.godotsharp_variant_as_signal(p_var); [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -550,7 +550,7 @@ public static Signal ConvertToSignal(in godot_variant p_var) return Marshaling.ConvertSignalToManaged(signal); } - public static godot_array ConvertToNativeArray(in godot_variant p_var) + public static godot_array ConvertToNativeArray(scoped in godot_variant p_var) => p_var.Type == Variant.Type.Array ? NativeFuncs.godotsharp_array_new_copy(p_var.Array) : NativeFuncs.godotsharp_variant_as_array(p_var); @@ -563,7 +563,7 @@ public static Collections.Array ConvertToArray(in godot_variant p_var) public static Array ConvertToArray<[MustBeVariant] T>(in godot_variant p_var) => Array.CreateTakingOwnershipOfDisposableValue(ConvertToNativeArray(p_var)); - public static godot_dictionary ConvertToNativeDictionary(in godot_variant p_var) + public static godot_dictionary ConvertToNativeDictionary(scoped in godot_variant p_var) => p_var.Type == Variant.Type.Dictionary ? NativeFuncs.godotsharp_dictionary_new_copy(p_var.Dictionary) : NativeFuncs.godotsharp_variant_as_dictionary(p_var); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs index 2897cc4199e6..d8c8ea568fd6 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/VariantUtils.generic.cs @@ -7,22 +7,23 @@ namespace Godot.NativeInterop; public partial class VariantUtils { - private static Exception UnsupportedType() => new InvalidOperationException( + private static InvalidOperationException UnsupportedType() => new InvalidOperationException( $"The type is not supported for conversion to/from Variant: '{typeof(T).FullName}'"); internal static class GenericConversion { - public static unsafe godot_variant ToVariant(in T from) => - ToVariantCb != null ? ToVariantCb(from) : throw UnsupportedType(); + internal delegate godot_variant ToVariantConverter(scoped in T from); + internal delegate T FromVariantConverter(in godot_variant from); + + public static unsafe godot_variant ToVariant(scoped in T from) => + ToVariantCb != null ? ToVariantCb(from) : throw UnsupportedType(); public static unsafe T FromVariant(in godot_variant variant) => FromVariantCb != null ? FromVariantCb(variant) : throw UnsupportedType(); - // ReSharper disable once StaticMemberInGenericType - internal static unsafe delegate* ToVariantCb; + internal static ToVariantConverter? ToVariantCb; - // ReSharper disable once StaticMemberInGenericType - internal static unsafe delegate* FromVariantCb; + internal static FromVariantConverter? FromVariantCb; static GenericConversion() { @@ -31,10 +32,10 @@ static GenericConversion() } [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static godot_variant CreateFrom<[MustBeVariant] T>(in T from) + public static godot_variant CreateFrom<[MustBeVariant] T>(scoped in T from) { [MethodImpl(MethodImplOptions.AggressiveInlining)] - static TTo UnsafeAs(in T f) => Unsafe.As(ref Unsafe.AsRef(f)); + static TTo UnsafeAs(in T f) => Unsafe.As(ref Unsafe.AsRef(in f)); // `typeof(T) == typeof(X)` is optimized away. We cannot cache `typeof(T)` in a local variable, as it's not optimized when done like that. @@ -227,7 +228,7 @@ public static godot_variant CreateFrom<[MustBeVariant] T>(in T from) public static T ConvertTo<[MustBeVariant] T>(in godot_variant variant) { [MethodImpl(MethodImplOptions.AggressiveInlining)] - static T UnsafeAsT(TFrom f) => Unsafe.As(ref Unsafe.AsRef(f)); + static T UnsafeAsT(TFrom f) => Unsafe.As(ref Unsafe.AsRef(in f)); if (typeof(T) == typeof(bool)) return UnsafeAsT(ConvertToBool(variant)); diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs index ad75195f0fae..c79c45fa08ca 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/StringExtensions.cs @@ -1581,7 +1581,7 @@ public static float[] SplitFloats(this string instance, string divisor, bool all if (end < 0) end = len; if (allowEmpty || end > from) - ret.Add(float.Parse(instance.Substring(from), CultureInfo.InvariantCulture)); + ret.Add(float.Parse(instance.AsSpan(from), CultureInfo.InvariantCulture)); if (end == len) break; diff --git a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj index 5aa68559d80f..ab9c5fe18a28 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj +++ b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj @@ -1,17 +1,19 @@  + {AEBF0036-DA76-4341-B651-A3F2856AB2FA} + net8.0 + 12 bin/$(Configuration) false Godot - net6.0 $(OutputPath)/$(AssemblyName).xml false true - 10 Recommended + Godot C# Core API. Godot Engine contributors @@ -28,23 +30,28 @@ true snupkg + SdkPackageVersions.props + $(DefineConstants);GODOT REAL_T_IS_DOUBLE;$(DefineConstants) + + + @@ -135,10 +142,12 @@ + +