diff options
Diffstat (limited to 'modules/mono')
-rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs | 2 | ||||
-rw-r--r-- | modules/mono/glue/Managed/Files/StringExtensions.cs | 38 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono.cpp | 14 |
3 files changed, 35 insertions, 19 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs index b17a3f4491..dd1b58b34b 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Export/ExportPlugin.cs @@ -39,7 +39,7 @@ namespace GodotTools.Export private void AddFile(string srcPath, string dstPath, bool remap = false) { - AddFile(dstPath, File.ReadAllBytes(srcPath), remap); + AddFile(dstPath.Replace("\\", "/"), File.ReadAllBytes(srcPath), remap); } public override void _ExportFile(string path, string type, string[] features) diff --git a/modules/mono/glue/Managed/Files/StringExtensions.cs b/modules/mono/glue/Managed/Files/StringExtensions.cs index 079e9912d6..b926037e5a 100644 --- a/modules/mono/glue/Managed/Files/StringExtensions.cs +++ b/modules/mono/glue/Managed/Files/StringExtensions.cs @@ -18,7 +18,7 @@ namespace Godot int pos = 0; int slices = 1; - while ((pos = instance.Find(splitter, true, pos)) >= 0) + while ((pos = instance.Find(splitter, pos, caseSensitive: true)) >= 0) { slices++; pos += splitter.Length; @@ -229,7 +229,7 @@ namespace Godot // </summary> public static int CasecmpTo(this string instance, string to) { - return instance.CompareTo(to, true); + return instance.CompareTo(to, caseSensitive: true); } // <summary> @@ -322,25 +322,29 @@ namespace Godot return instance.Substring(pos + 1); } - // <summary> - // Find the first occurrence of a substring, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed. - // </summary> - public static int Find(this string instance, string what, bool caseSensitive = true, int from = 0) + /// <summary>Find the first occurrence of a substring. Optionally, the search starting position can be passed.</summary> + /// <returns>The starting position of the substring, or -1 if not found.</returns> + public static int Find(this string instance, string what, int from = 0, bool caseSensitive = true) { return instance.IndexOf(what, from, caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); } - // <summary> - // Find the last occurrence of a substring, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed. - // </summary> - public static int FindLast(this string instance, string what, bool caseSensitive = true, int from = 0) + /// <summary>Find the last occurrence of a substring.</summary> + /// <returns>The starting position of the substring, or -1 if not found.</returns> + public static int FindLast(this string instance, string what, bool caseSensitive = true) + { + return instance.FindLast(what, instance.Length - 1, caseSensitive); + } + + /// <summary>Find the last occurrence of a substring specifying the search starting position.</summary> + /// <returns>The starting position of the substring, or -1 if not found.</returns> + public static int FindLast(this string instance, string what, int from, bool caseSensitive = true) { return instance.LastIndexOf(what, from, caseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase); } - // <summary> - // Find the first occurrence of a substring but search as case-insensitive, return the starting position of the substring or -1 if not found. Optionally, the initial search index can be passed. - // </summary> + /// <summary>Find the first occurrence of a substring but search as case-insensitive. Optionally, the search starting position can be passed.</summary> + /// <returns>The starting position of the substring, or -1 if not found.</returns> public static int FindN(this string instance, string what, int from = 0) { return instance.IndexOf(what, from, StringComparison.OrdinalIgnoreCase); @@ -502,7 +506,7 @@ namespace Godot // </summary> public static bool IsSubsequenceOfI(this string instance, string text) { - return instance.IsSubsequenceOf(text, false); + return instance.IsSubsequenceOf(text, caseSensitive: false); } // <summary> @@ -662,7 +666,7 @@ namespace Godot // </summary> public static bool MatchN(this string instance, string expr) { - return instance.ExprMatch(expr, false); + return instance.ExprMatch(expr, caseSensitive: false); } // <summary> @@ -692,7 +696,7 @@ namespace Godot // </summary> public static int NocasecmpTo(this string instance, string to) { - return instance.CompareTo(to, false); + return instance.CompareTo(to, caseSensitive: false); } // <summary> @@ -928,7 +932,7 @@ namespace Godot while (true) { - int end = instance.Find(divisor, true, from); + int end = instance.Find(divisor, from, caseSensitive: true); if (end < 0) end = len; if (allowEmpty || end > from) diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 33ba877352..29274be559 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -102,6 +102,18 @@ void gd_mono_profiler_init() { bool profiler_enabled = GLOBAL_DEF("mono/profiler/enabled", false); if (profiler_enabled) { mono_profiler_load(profiler_args.utf8()); + return; + } + + const String env_var_name = "MONO_ENV_OPTIONS"; + if (OS::get_singleton()->has_environment(env_var_name)) { + const auto mono_env_ops = OS::get_singleton()->get_environment(env_var_name); + // Usually MONO_ENV_OPTIONS looks like: --profile=jb:prof=timeline,ctl=remote,host=127.0.0.1:55467 + const String prefix = "--profile="; + if (mono_env_ops.begins_with(prefix)) { + const auto ops = mono_env_ops.substr(prefix.length(), mono_env_ops.length()); + mono_profiler_load(ops.utf8()); + } } } @@ -356,7 +368,7 @@ void GDMono::initialize() { } #endif -#if !defined(WINDOWS_ENABLED) && !defined(NO_MONO_THREADS_SUSPEND_WORKAROUND) +#if !defined(NO_MONO_THREADS_SUSPEND_WORKAROUND) // FIXME: Temporary workaround. See: https://github.com/godotengine/godot/issues/29812 if (!OS::get_singleton()->has_environment("MONO_THREADS_SUSPEND")) { OS::get_singleton()->set_environment("MONO_THREADS_SUSPEND", "preemptive"); |