C#: Code cleanup and greatly reduce use of C# pointers
This commit is contained in:
parent
34db8d2c6c
commit
e5e7a795b1
51 changed files with 2195 additions and 1347 deletions
|
|
@ -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)" />
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue