summaryrefslogtreecommitdiff
path: root/modules/mono/editor/GodotTools
diff options
context:
space:
mode:
authorIgnacio Roldán Etcheverry <ignalfonsore@gmail.com>2021-12-28 23:25:16 +0100
committerIgnacio Roldán Etcheverry <ignalfonsore@gmail.com>2022-08-22 03:36:51 +0200
commite5e7a795b14487e7eb0cfb011a8e0518769ce533 (patch)
tree57a0322ef0c11d8944f9a95708d243dcc3e4c5a4 /modules/mono/editor/GodotTools
parent34db8d2c6c4d2c714772479145c235c9f4189bdb (diff)
C#: Code cleanup and greatly reduce use of C# pointers
Diffstat (limited to 'modules/mono/editor/GodotTools')
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.Shared/GenerateGodotNupkgsVersions.targets4
-rw-r--r--modules/mono/editor/GodotTools/GodotTools.Shared/GodotTools.Shared.csproj2
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs10
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Internals/EditorProgress.cs14
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs22
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Internals/GodotSharpDirs.cs14
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs10
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs6
8 files changed, 42 insertions, 40 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools.Shared/GenerateGodotNupkgsVersions.targets b/modules/mono/editor/GodotTools/GodotTools.Shared/GenerateGodotNupkgsVersions.targets
index aab2d73bdd..4baae77b34 100644
--- a/modules/mono/editor/GodotTools/GodotTools.Shared/GenerateGodotNupkgsVersions.targets
+++ b/modules/mono/editor/GodotTools/GodotTools.Shared/GenerateGodotNupkgsVersions.targets
@@ -8,8 +8,8 @@
</Target>
<Target Name="GenerateGodotNupkgsVersionsFile"
- DependsOnTargets="PrepareForBuild;_GenerateGodotNupkgsVersionsFile"
- BeforeTargets="BeforeCompile;CoreCompile">
+ DependsOnTargets="_GenerateGodotNupkgsVersionsFile"
+ BeforeTargets="PrepareForBuild;CompileDesignTime;BeforeCompile;CoreCompile">
<ItemGroup>
<Compile Include="$(GeneratedGodotNupkgsVersionsFile)" />
<FileWrites Include="$(GeneratedGodotNupkgsVersionsFile)" />
diff --git a/modules/mono/editor/GodotTools/GodotTools.Shared/GodotTools.Shared.csproj b/modules/mono/editor/GodotTools/GodotTools.Shared/GodotTools.Shared.csproj
index 4b058a5daa..7d8b83d5f0 100644
--- a/modules/mono/editor/GodotTools/GodotTools.Shared/GodotTools.Shared.csproj
+++ b/modules/mono/editor/GodotTools/GodotTools.Shared/GodotTools.Shared.csproj
@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
+ <!-- Specify compile items manually to avoid including dangling generated items. -->
+ <EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
<Import Project="GenerateGodotNupkgsVersions.targets" />
</Project>
diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
index 25c2e4ab59..d8ebe762e1 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs
@@ -233,11 +233,11 @@ namespace GodotTools.Export
}
}
- var initialAssemblies = assemblies.Duplicate();
- godot_dictionary initialAssembliesAux = ((Godot.Collections.Dictionary)initialAssemblies).NativeValue;
- using godot_string buildConfigAux = Marshaling.mono_string_to_godot(buildConfig);
- using godot_string bclDirAux = Marshaling.mono_string_to_godot(bclDir);
- godot_dictionary assembliesAux = ((Godot.Collections.Dictionary)assemblies).NativeValue;
+ // var initialAssemblies = assemblies.Duplicate();
+ // godot_dictionary initialAssembliesAux = ((Godot.Collections.Dictionary)initialAssemblies).NativeValue;
+ // using godot_string buildConfigAux = Marshaling.ConvertStringToNative(buildConfig);
+ // using godot_string bclDirAux = Marshaling.ConvertStringToNative(bclDir);
+ // godot_dictionary assembliesAux = ((Godot.Collections.Dictionary)assemblies).NativeValue;
// TODO
throw new NotImplementedException();
//internal_GetExportedAssemblyDependencies(initialAssembliesAux, buildConfigAux, bclDirAux, ref assembliesAux);
diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/EditorProgress.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/EditorProgress.cs
index 7d2eb2d869..8f39ad063e 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Internals/EditorProgress.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Internals/EditorProgress.cs
@@ -12,8 +12,8 @@ namespace GodotTools.Internals
public EditorProgress(string task, string label, int amount, bool canCancel = false)
{
Task = task;
- using godot_string taskIn = Marshaling.mono_string_to_godot(task);
- using godot_string labelIn = Marshaling.mono_string_to_godot(label);
+ using godot_string taskIn = Marshaling.ConvertStringToNative(task);
+ using godot_string labelIn = Marshaling.ConvertStringToNative(label);
Internal.godot_icall_EditorProgress_Create(taskIn, labelIn, amount, canCancel);
}
@@ -27,22 +27,22 @@ namespace GodotTools.Internals
public void Dispose()
{
- using godot_string taskIn = Marshaling.mono_string_to_godot(Task);
+ using godot_string taskIn = Marshaling.ConvertStringToNative(Task);
Internal.godot_icall_EditorProgress_Dispose(taskIn);
GC.SuppressFinalize(this);
}
public void Step(string state, int step = -1, bool forceRefresh = true)
{
- using godot_string taskIn = Marshaling.mono_string_to_godot(Task);
- using godot_string stateIn = Marshaling.mono_string_to_godot(state);
+ using godot_string taskIn = Marshaling.ConvertStringToNative(Task);
+ using godot_string stateIn = Marshaling.ConvertStringToNative(state);
Internal.godot_icall_EditorProgress_Step(taskIn, stateIn, step, forceRefresh);
}
public bool TryStep(string state, int step = -1, bool forceRefresh = true)
{
- using godot_string taskIn = Marshaling.mono_string_to_godot(Task);
- using godot_string stateIn = Marshaling.mono_string_to_godot(state);
+ using godot_string taskIn = Marshaling.ConvertStringToNative(Task);
+ using godot_string stateIn = Marshaling.ConvertStringToNative(state);
return Internal.godot_icall_EditorProgress_Step(taskIn, stateIn, step, forceRefresh);
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs
index 3b65263aa9..acb7cc3ab0 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Internals/Globals.cs
@@ -10,37 +10,37 @@ namespace GodotTools.Internals
public static unsafe object GlobalDef(string setting, object defaultValue, bool restartIfChanged = false)
{
- using godot_string settingIn = Marshaling.mono_string_to_godot(setting);
- using godot_variant defaultValueIn = Marshaling.mono_object_to_variant(defaultValue);
+ using godot_string settingIn = Marshaling.ConvertStringToNative(setting);
+ using godot_variant defaultValueIn = Marshaling.ConvertManagedObjectToVariant(defaultValue);
Internal.godot_icall_Globals_GlobalDef(settingIn, defaultValueIn, restartIfChanged, out godot_variant result);
using (result)
- return Marshaling.variant_to_mono_object(&result);
+ return Marshaling.ConvertVariantToManagedObject(result);
}
public static unsafe object EditorDef(string setting, object defaultValue, bool restartIfChanged = false)
{
- using godot_string settingIn = Marshaling.mono_string_to_godot(setting);
- using godot_variant defaultValueIn = Marshaling.mono_object_to_variant(defaultValue);
+ using godot_string settingIn = Marshaling.ConvertStringToNative(setting);
+ using godot_variant defaultValueIn = Marshaling.ConvertManagedObjectToVariant(defaultValue);
Internal.godot_icall_Globals_EditorDef(settingIn, defaultValueIn, restartIfChanged, out godot_variant result);
using (result)
- return Marshaling.variant_to_mono_object(&result);
+ return Marshaling.ConvertVariantToManagedObject(result);
}
- public static unsafe object EditorShortcut(string setting)
+ public static object EditorShortcut(string setting)
{
- using godot_string settingIn = Marshaling.mono_string_to_godot(setting);
+ using godot_string settingIn = Marshaling.ConvertStringToNative(setting);
Internal.godot_icall_Globals_EditorShortcut(settingIn, out godot_variant result);
using (result)
- return Marshaling.variant_to_mono_object(&result);
+ return Marshaling.ConvertVariantToManagedObject(result);
}
[SuppressMessage("ReSharper", "InconsistentNaming")]
public static string TTR(this string text)
{
- using godot_string textIn = Marshaling.mono_string_to_godot(text);
+ using godot_string textIn = Marshaling.ConvertStringToNative(text);
Internal.godot_icall_Globals_TTR(textIn, out godot_string dest);
using (dest)
- return Marshaling.mono_string_from_godot(dest);
+ return Marshaling.ConvertStringToManaged(dest);
}
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/GodotSharpDirs.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/GodotSharpDirs.cs
index 9011662248..eca7da07c8 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Internals/GodotSharpDirs.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Internals/GodotSharpDirs.cs
@@ -11,7 +11,7 @@ namespace GodotTools.Internals
{
Internal.godot_icall_GodotSharpDirs_ResMetadataDir(out godot_string dest);
using (dest)
- return Marshaling.mono_string_from_godot(dest);
+ return Marshaling.ConvertStringToManaged(dest);
}
}
@@ -21,7 +21,7 @@ namespace GodotTools.Internals
{
Internal.godot_icall_GodotSharpDirs_ResTempAssembliesBaseDir(out godot_string dest);
using (dest)
- return Marshaling.mono_string_from_godot(dest);
+ return Marshaling.ConvertStringToManaged(dest);
}
}
@@ -31,7 +31,7 @@ namespace GodotTools.Internals
{
Internal.godot_icall_GodotSharpDirs_MonoUserDir(out godot_string dest);
using (dest)
- return Marshaling.mono_string_from_godot(dest);
+ return Marshaling.ConvertStringToManaged(dest);
}
}
@@ -41,7 +41,7 @@ namespace GodotTools.Internals
{
Internal.godot_icall_GodotSharpDirs_BuildLogsDirs(out godot_string dest);
using (dest)
- return Marshaling.mono_string_from_godot(dest);
+ return Marshaling.ConvertStringToManaged(dest);
}
}
@@ -51,7 +51,7 @@ namespace GodotTools.Internals
{
Internal.godot_icall_GodotSharpDirs_ProjectSlnPath(out godot_string dest);
using (dest)
- return Marshaling.mono_string_from_godot(dest);
+ return Marshaling.ConvertStringToManaged(dest);
}
}
@@ -61,7 +61,7 @@ namespace GodotTools.Internals
{
Internal.godot_icall_GodotSharpDirs_ProjectCsProjPath(out godot_string dest);
using (dest)
- return Marshaling.mono_string_from_godot(dest);
+ return Marshaling.ConvertStringToManaged(dest);
}
}
@@ -71,7 +71,7 @@ namespace GodotTools.Internals
{
Internal.godot_icall_GodotSharpDirs_DataEditorToolsDir(out godot_string dest);
using (dest)
- return Marshaling.mono_string_from_godot(dest);
+ return Marshaling.ConvertStringToManaged(dest);
}
}
}
diff --git a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
index 8e4eb031db..7b39f8ecdb 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Internals/Internal.cs
@@ -18,7 +18,7 @@ namespace GodotTools.Internals
{
godot_icall_Internal_FullExportTemplatesDir(out godot_string dest);
using (dest)
- return Marshaling.mono_string_from_godot(dest);
+ return Marshaling.ConvertStringToManaged(dest);
}
}
@@ -26,7 +26,7 @@ namespace GodotTools.Internals
public static bool IsMacOSAppBundleInstalled(string bundleId)
{
- using godot_string bundleIdIn = Marshaling.mono_string_to_godot(bundleId);
+ using godot_string bundleIdIn = Marshaling.ConvertStringToNative(bundleId);
return godot_icall_Internal_IsMacOSAppBundleInstalled(bundleIdIn);
}
@@ -53,7 +53,7 @@ namespace GodotTools.Internals
{
godot_icall_Internal_MonoWindowsInstallRoot(out godot_string dest);
using (dest)
- return Marshaling.mono_string_from_godot(dest);
+ return Marshaling.ConvertStringToManaged(dest);
}
}
@@ -67,10 +67,10 @@ namespace GodotTools.Internals
public static unsafe string[] CodeCompletionRequest(CodeCompletionRequest.CompletionKind kind,
string scriptFile)
{
- using godot_string scriptFileIn = Marshaling.mono_string_to_godot(scriptFile);
+ using godot_string scriptFileIn = Marshaling.ConvertStringToNative(scriptFile);
godot_icall_Internal_CodeCompletionRequest((int)kind, scriptFileIn, out godot_packed_string_array res);
using (res)
- return Marshaling.PackedStringArray_to_mono_array(&res);
+ return Marshaling.ConvertNativePackedStringArrayToSystemArray(res);
}
#region Internal
diff --git a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
index d9b5942237..db77a71c2f 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
@@ -63,7 +63,7 @@ namespace GodotTools.Utils
Internal.godot_icall_Utils_OS_GetPlatformName(out godot_string dest);
using (dest)
{
- string platformName = Marshaling.mono_string_from_godot(dest);
+ string platformName = Marshaling.ConvertStringToManaged(dest);
return name.Equals(platformName, StringComparison.OrdinalIgnoreCase);
}
}
@@ -73,7 +73,7 @@ namespace GodotTools.Utils
Internal.godot_icall_Utils_OS_GetPlatformName(out godot_string dest);
using (dest)
{
- string platformName = Marshaling.mono_string_from_godot(dest);
+ string platformName = Marshaling.ConvertStringToManaged(dest);
return names.Any(p => p.Equals(platformName, StringComparison.OrdinalIgnoreCase));
}
}
@@ -185,7 +185,7 @@ namespace GodotTools.Utils
return searchDirs.Select(dir => Path.Combine(dir, name))
.FirstOrDefault(path =>
{
- using godot_string pathIn = Marshaling.mono_string_to_godot(path);
+ using godot_string pathIn = Marshaling.ConvertStringToNative(path);
return File.Exists(path) && Internal.godot_icall_Utils_OS_UnixFileHasExecutableAccess(pathIn);
});
}