diff options
Diffstat (limited to 'modules/mono')
-rw-r--r-- | modules/mono/build_scripts/mono_configure.py | 2 | ||||
-rw-r--r-- | modules/mono/csharp_script.cpp | 85 | ||||
-rw-r--r-- | modules/mono/csharp_script.h | 12 | ||||
-rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs | 7 | ||||
-rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/BuildManager.cs | 23 | ||||
-rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs | 109 | ||||
-rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs | 28 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs | 4 | ||||
-rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs | 2 | ||||
-rw-r--r-- | modules/mono/icons/CSharpScript.svg (renamed from modules/mono/icons/icon_c_sharp_script.svg) | 0 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono.cpp | 5 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_internals.cpp | 7 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_utils.cpp | 12 | ||||
-rw-r--r-- | modules/mono/utils/mutex_utils.h | 67 |
14 files changed, 163 insertions, 200 deletions
diff --git a/modules/mono/build_scripts/mono_configure.py b/modules/mono/build_scripts/mono_configure.py index 033c467da9..9a6198f13a 100644 --- a/modules/mono/build_scripts/mono_configure.py +++ b/modules/mono/build_scripts/mono_configure.py @@ -163,7 +163,7 @@ def configure(env, env_mono): copy_file(mono_bin_path, '#bin', mono_dll_name + '.dll') else: - is_apple = (sys.platform == 'darwin' or "osxcross" in env) + is_apple = env['platform'] in ['osx', 'iphone'] sharedlib_ext = '.dylib' if is_apple else '.so' diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 5c1c098e3e..02ff6bcf13 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -33,8 +33,11 @@ #include <mono/metadata/threads.h> #include <stdint.h> +#include "core/debugger/engine_debugger.h" +#include "core/debugger/script_debugger.h" #include "core/io/json.h" #include "core/os/file_access.h" +#include "core/os/mutex.h" #include "core/os/os.h" #include "core/os/thread.h" #include "core/project_settings.h" @@ -58,7 +61,6 @@ #include "mono_gd/gd_mono_utils.h" #include "signal_awaiter_utils.h" #include "utils/macros.h" -#include "utils/mutex_utils.h" #include "utils/string_utils.h" #include "utils/thread_local.h" @@ -633,7 +635,7 @@ Vector<ScriptLanguage::StackInfo> CSharpLanguage::stack_trace_get_info(MonoObjec void CSharpLanguage::post_unsafe_reference(Object *p_obj) { #ifdef DEBUG_ENABLED - SCOPED_MUTEX_LOCK(unsafe_object_references_lock); + MutexLock lock(unsafe_object_references_lock); ObjectID id = p_obj->get_instance_id(); unsafe_object_references[id]++; #endif @@ -641,7 +643,7 @@ void CSharpLanguage::post_unsafe_reference(Object *p_obj) { void CSharpLanguage::pre_unsafe_unreference(Object *p_obj) { #ifdef DEBUG_ENABLED - SCOPED_MUTEX_LOCK(unsafe_object_references_lock); + MutexLock lock(unsafe_object_references_lock); ObjectID id = p_obj->get_instance_id(); Map<ObjectID, int>::Element *elem = unsafe_object_references.find(id); ERR_FAIL_NULL(elem); @@ -764,7 +766,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) { List<Ref<CSharpScript> > scripts; { - SCOPED_MUTEX_LOCK(script_instances_mutex); + MutexLock lock(script_instances_mutex); for (SelfList<CSharpScript> *elem = script_list.first(); elem; elem = elem->next()) { // Cast to CSharpScript to avoid being erased by accident @@ -1134,11 +1136,11 @@ void CSharpLanguage::thread_exit() { bool CSharpLanguage::debug_break_parse(const String &p_file, int p_line, const String &p_error) { // Not a parser error in our case, but it's still used for other type of errors - if (ScriptDebugger::get_singleton() && Thread::get_caller_id() == Thread::get_main_id()) { + if (EngineDebugger::is_active() && Thread::get_caller_id() == Thread::get_main_id()) { _debug_parse_err_line = p_line; _debug_parse_err_file = p_file; _debug_error = p_error; - ScriptDebugger::get_singleton()->debug(this, false, true); + EngineDebugger::get_script_debugger()->debug(this, false, true); return true; } else { return false; @@ -1147,11 +1149,11 @@ bool CSharpLanguage::debug_break_parse(const String &p_file, int p_line, const S bool CSharpLanguage::debug_break(const String &p_error, bool p_allow_continue) { - if (ScriptDebugger::get_singleton() && Thread::get_caller_id() == Thread::get_main_id()) { + if (EngineDebugger::is_active() && Thread::get_caller_id() == Thread::get_main_id()) { _debug_parse_err_line = -1; _debug_parse_err_file = ""; _debug_error = p_error; - ScriptDebugger::get_singleton()->debug(this, p_allow_continue); + EngineDebugger::get_script_debugger()->debug(this, p_allow_continue); return true; } else { return false; @@ -1204,7 +1206,7 @@ void CSharpLanguage::set_language_index(int p_idx) { void CSharpLanguage::release_script_gchandle(Ref<MonoGCHandle> &p_gchandle) { if (!p_gchandle->is_released()) { // Do not lock unnecessarily - SCOPED_MUTEX_LOCK(get_singleton()->script_gchandle_release_mutex); + MutexLock lock(get_singleton()->script_gchandle_release_mutex); p_gchandle->release(); } } @@ -1214,7 +1216,7 @@ void CSharpLanguage::release_script_gchandle(MonoObject *p_expected_obj, Ref<Mon uint32_t pinned_gchandle = MonoGCHandle::new_strong_handle_pinned(p_expected_obj); // We might lock after this, so pin it if (!p_gchandle->is_released()) { // Do not lock unnecessarily - SCOPED_MUTEX_LOCK(get_singleton()->script_gchandle_release_mutex); + MutexLock lock(get_singleton()->script_gchandle_release_mutex); MonoObject *target = p_gchandle->get_target(); @@ -1239,24 +1241,6 @@ CSharpLanguage::CSharpLanguage() { gdmono = NULL; -#ifdef NO_THREADS - script_instances_mutex = NULL; - script_gchandle_release_mutex = NULL; - language_bind_mutex = NULL; -#else - script_instances_mutex = Mutex::create(); - script_gchandle_release_mutex = Mutex::create(); - language_bind_mutex = Mutex::create(); -#endif - -#ifdef DEBUG_ENABLED -#ifdef NO_THREADS - unsafe_object_references_lock = NULL; -#else - unsafe_object_references_lock = Mutex::create(); -#endif -#endif - lang_idx = -1; scripts_metadata_invalidated = true; @@ -1269,29 +1253,6 @@ CSharpLanguage::CSharpLanguage() { CSharpLanguage::~CSharpLanguage() { finish(); - - if (script_instances_mutex) { - memdelete(script_instances_mutex); - script_instances_mutex = NULL; - } - - if (language_bind_mutex) { - memdelete(language_bind_mutex); - language_bind_mutex = NULL; - } - - if (script_gchandle_release_mutex) { - memdelete(script_gchandle_release_mutex); - script_gchandle_release_mutex = NULL; - } - -#ifdef DEBUG_ENABLED - if (unsafe_object_references_lock) { - memdelete(unsafe_object_references_lock); - unsafe_object_references_lock = NULL; - } -#endif - singleton = NULL; } @@ -1346,7 +1307,7 @@ bool CSharpLanguage::setup_csharp_script_binding(CSharpScriptBinding &r_script_b void *CSharpLanguage::alloc_instance_binding_data(Object *p_object) { - SCOPED_MUTEX_LOCK(language_bind_mutex); + MutexLock lock(language_bind_mutex); Map<Object *, CSharpScriptBinding>::Element *match = script_bindings.find(p_object); if (match) @@ -1381,7 +1342,7 @@ void CSharpLanguage::free_instance_binding_data(void *p_data) { GD_MONO_ASSERT_THREAD_ATTACHED; { - SCOPED_MUTEX_LOCK(language_bind_mutex); + MutexLock lock(language_bind_mutex); Map<Object *, CSharpScriptBinding>::Element *data = (Map<Object *, CSharpScriptBinding>::Element *)p_data; @@ -2187,7 +2148,7 @@ CSharpInstance::~CSharpInstance() { CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->get(); if (!script_binding.inited) { - SCOPED_MUTEX_LOCK(CSharpLanguage::get_singleton()->get_language_bind_mutex()); + MutexLock lock(CSharpLanguage::get_singleton()->get_language_bind_mutex()); if (!script_binding.inited) { // Other thread may have set it up // Already had a binding that needs to be setup @@ -2203,7 +2164,7 @@ CSharpInstance::~CSharpInstance() { } if (script.is_valid() && owner) { - SCOPED_MUTEX_LOCK(CSharpLanguage::get_singleton()->script_instances_mutex); + MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex); #ifdef DEBUG_ENABLED // CSharpInstance must not be created unless it's going to be added to the list for sure @@ -2979,7 +2940,7 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg instance->_reference_owner_unsafe(); // Here, after assigning the gchandle (for the refcount_incremented callback) { - SCOPED_MUTEX_LOCK(CSharpLanguage::get_singleton()->script_instances_mutex); + MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex); instances.insert(instance->owner); } @@ -3039,7 +3000,7 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) { if (native) { String native_name = NATIVE_GDMONOCLASS_NAME(native); if (!ClassDB::is_parent_class(p_this->get_class_name(), native_name)) { - if (ScriptDebugger::get_singleton()) { + if (EngineDebugger::is_active()) { CSharpLanguage::get_singleton()->debug_break_parse(get_path(), 0, "Script inherits from native type '" + native_name + "', so it can't be instanced in object of type: '" + p_this->get_class() + "'"); } ERR_FAIL_V_MSG(NULL, "Script inherits from native type '" + native_name + @@ -3067,7 +3028,7 @@ PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_t bool CSharpScript::instance_has(const Object *p_this) const { - SCOPED_MUTEX_LOCK(CSharpLanguage::get_singleton()->script_instances_mutex); + MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex); return instances.has((Object *)p_this); } @@ -3140,7 +3101,7 @@ Error CSharpScript::reload(bool p_keep_state) { bool has_instances; { - SCOPED_MUTEX_LOCK(CSharpLanguage::get_singleton()->script_instances_mutex); + MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex); has_instances = instances.size(); } @@ -3476,7 +3437,7 @@ CSharpScript::CSharpScript() : #ifdef DEBUG_ENABLED { - SCOPED_MUTEX_LOCK(CSharpLanguage::get_singleton()->script_instances_mutex); + MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex); CSharpLanguage::get_singleton()->script_list.add(&this->script_list); } #endif @@ -3485,14 +3446,14 @@ CSharpScript::CSharpScript() : CSharpScript::~CSharpScript() { #ifdef DEBUG_ENABLED - SCOPED_MUTEX_LOCK(CSharpLanguage::get_singleton()->script_instances_mutex); + MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex); CSharpLanguage::get_singleton()->script_list.remove(&this->script_list); #endif } /*************** RESOURCE ***************/ -RES ResourceFormatLoaderCSharpScript::load(const String &p_path, const String &p_original_path, Error *r_error) { +RES ResourceFormatLoaderCSharpScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) { if (r_error) *r_error = ERR_FILE_CANT_OPEN; diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index 627218eaf5..18c53aab52 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -325,16 +325,16 @@ class CSharpLanguage : public ScriptLanguage { GDMono *gdmono; SelfList<CSharpScript>::List script_list; - Mutex *script_instances_mutex; - Mutex *script_gchandle_release_mutex; - Mutex *language_bind_mutex; + Mutex script_instances_mutex; + Mutex script_gchandle_release_mutex; + Mutex language_bind_mutex; Map<Object *, CSharpScriptBinding> script_bindings; #ifdef DEBUG_ENABLED // List of unsafe object references Map<ObjectID, int> unsafe_object_references; - Mutex *unsafe_object_references_lock; + Mutex unsafe_object_references_lock; #endif struct StringNameCache { @@ -376,7 +376,7 @@ class CSharpLanguage : public ScriptLanguage { public: StringNameCache string_names; - Mutex *get_language_bind_mutex() { return language_bind_mutex; } + const Mutex &get_language_bind_mutex() { return language_bind_mutex; } _FORCE_INLINE_ int get_language_index() { return lang_idx; } void set_language_index(int p_idx); @@ -497,7 +497,7 @@ public: class ResourceFormatLoaderCSharpScript : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs b/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs index c3db52aa9e..af8d070cbd 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/MsBuildFinder.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using Godot; +using GodotTools.Ides.Rider; using GodotTools.Internals; using Directory = System.IO.Directory; using Environment = System.Environment; @@ -54,6 +55,12 @@ namespace GodotTools.Build return msbuildPath; } + case BuildManager.BuildTool.JetBrainsMsBuild: + var editorPath = (string)editorSettings.GetSetting(RiderPathManager.EditorPathSettingName); + if (!File.Exists(editorPath)) + throw new FileNotFoundException($"Cannot find Rider executable. Tried with path: {editorPath}"); + var riderDir = new FileInfo(editorPath).Directory.Parent; + return Path.Combine(riderDir.FullName, @"tools\MSBuild\Current\Bin\MSBuild.exe"); default: throw new IndexOutOfRangeException("Invalid build tool in editor settings"); } diff --git a/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs b/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs index fa6bf4dafd..69a8c9cf4a 100644 --- a/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/BuildManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using GodotTools.Build; +using GodotTools.Ides.Rider; using GodotTools.Internals; using GodotTools.Utils; using static GodotTools.Internals.Globals; @@ -16,6 +17,7 @@ namespace GodotTools public const string PropNameMsbuildMono = "MSBuild (Mono)"; public const string PropNameMsbuildVs = "MSBuild (VS Build Tools)"; + public const string PropNameMsbuildJetBrains = "MSBuild (JetBrains Rider)"; public const string MsBuildIssuesFileName = "msbuild_issues.csv"; public const string MsBuildLogFileName = "msbuild_log.txt"; @@ -23,7 +25,8 @@ namespace GodotTools public enum BuildTool { MsBuildMono, - MsBuildVs + MsBuildVs, + JetBrainsMsBuild } private static void RemoveOldIssuesFile(BuildInfo buildInfo) @@ -181,7 +184,7 @@ namespace GodotTools var buildInfo = new BuildInfo(GodotSharpDirs.ProjectSlnPath, config); // Add Godot defines - string constants = buildTool == BuildTool.MsBuildVs ? "GodotDefineConstants=\"" : "GodotDefineConstants=\\\""; + string constants = buildTool != BuildTool.MsBuildMono ? "GodotDefineConstants=\"" : "GodotDefineConstants=\\\""; foreach (var godotDefine in godotDefines) constants += $"GODOT_{godotDefine.ToUpper().Replace("-", "_").Replace(" ", "_").Replace(";", "_")};"; @@ -189,7 +192,7 @@ namespace GodotTools if (Internal.GodotIsRealTDouble()) constants += "GODOT_REAL_T_IS_DOUBLE;"; - constants += buildTool == BuildTool.MsBuildVs ? "\"" : "\\\""; + constants += buildTool != BuildTool.MsBuildMono ? "\"" : "\\\""; buildInfo.CustomProperties.Add(constants); @@ -245,18 +248,22 @@ namespace GodotTools public static void Initialize() { // Build tool settings - - EditorDef("mono/builds/build_tool", OS.IsWindows ? BuildTool.MsBuildVs : BuildTool.MsBuildMono); - var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings(); - + var msbuild = BuildTool.MsBuildMono; + if (OS.IsWindows) + msbuild = RiderPathManager.IsRider((string) editorSettings.GetSetting(RiderPathManager.EditorPathSettingName)) + ? BuildTool.JetBrainsMsBuild + : BuildTool.MsBuildVs; + + EditorDef("mono/builds/build_tool", msbuild); + editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary { ["type"] = Godot.Variant.Type.Int, ["name"] = "mono/builds/build_tool", ["hint"] = Godot.PropertyHint.Enum, ["hint_string"] = OS.IsWindows ? - $"{PropNameMsbuildMono},{PropNameMsbuildVs}" : + $"{PropNameMsbuildMono},{PropNameMsbuildVs},{PropNameMsbuildJetBrains}" : $"{PropNameMsbuildMono}" }); diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs index 9038333d38..77740f0e53 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathLocator.cs @@ -11,6 +11,10 @@ using Environment = System.Environment; using File = System.IO.File; using Path = System.IO.Path; using OS = GodotTools.Utils.OS; +// ReSharper disable UnassignedField.Local +// ReSharper disable InconsistentNaming +// ReSharper disable UnassignedField.Global +// ReSharper disable MemberHidesStaticFromOuterClass namespace GodotTools.Ides.Rider { @@ -131,28 +135,45 @@ namespace GodotTools.Ides.Rider if (OS.IsWindows) { var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); - return Path.Combine(localAppData, @"JetBrains\Toolbox\apps\Rider"); + return GetToolboxRiderRootPath(localAppData); } if (OS.IsOSX) { var home = Environment.GetEnvironmentVariable("HOME"); - if (!string.IsNullOrEmpty(home)) - { - return Path.Combine(home, @"Library/Application Support/JetBrains/Toolbox/apps/Rider"); - } + if (string.IsNullOrEmpty(home)) + return string.Empty; + var localAppData = Path.Combine(home, @"Library/Application Support"); + return GetToolboxRiderRootPath(localAppData); } if (OS.IsUnixLike()) { var home = Environment.GetEnvironmentVariable("HOME"); - if (!string.IsNullOrEmpty(home)) - { - return Path.Combine(home, @".local/share/JetBrains/Toolbox/apps/Rider"); - } + if (string.IsNullOrEmpty(home)) + return string.Empty; + var localAppData = Path.Combine(home, @".local/share"); + return GetToolboxRiderRootPath(localAppData); } - throw new Exception("Unexpected OS."); + return string.Empty; + } + + + private static string GetToolboxRiderRootPath(string localAppData) + { + var toolboxPath = Path.Combine(localAppData, @"JetBrains\Toolbox"); + var settingsJson = Path.Combine(toolboxPath, ".settings.json"); + + if (File.Exists(settingsJson)) + { + var path = SettingsJson.GetInstallLocationFromJson(File.ReadAllText(settingsJson)); + if (!string.IsNullOrEmpty(path)) + toolboxPath = path; + } + + var toolboxRiderRootPath = Path.Combine(toolboxPath, @"apps\Rider"); + return toolboxRiderRootPath; } internal static ProductInfo GetBuildVersion(string path) @@ -197,20 +218,29 @@ namespace GodotTools.Ides.Rider private static void CollectPathsFromRegistry(string registryKey, List<string> installPaths) { + using (var key = Registry.CurrentUser.OpenSubKey(registryKey)) + { + CollectPathsFromRegistry(installPaths, key); + } using (var key = Registry.LocalMachine.OpenSubKey(registryKey)) { - if (key == null) return; - foreach (var subkeyName in key.GetSubKeyNames().Where(a => a.Contains("Rider"))) + CollectPathsFromRegistry(installPaths, key); + } + } + + private static void CollectPathsFromRegistry(List<string> installPaths, RegistryKey key) + { + if (key == null) return; + foreach (var subkeyName in key.GetSubKeyNames().Where(a => a.Contains("Rider"))) + { + using (var subkey = key.OpenSubKey(subkeyName)) { - using (var subkey = key.OpenSubKey(subkeyName)) - { - var folderObject = subkey?.GetValue("InstallLocation"); - if (folderObject == null) continue; - var folder = folderObject.ToString(); - var possiblePath = Path.Combine(folder, @"bin\rider64.exe"); - if (File.Exists(possiblePath)) - installPaths.Add(possiblePath); - } + var folderObject = subkey?.GetValue("InstallLocation"); + if (folderObject == null) continue; + var folder = folderObject.ToString(); + var possiblePath = Path.Combine(folder, @"bin\rider64.exe"); + if (File.Exists(possiblePath)) + installPaths.Add(possiblePath); } } } @@ -226,8 +256,8 @@ namespace GodotTools.Ides.Rider { try { - // use history.json - last entry stands for the active build https://jetbrains.slack.com/archives/C07KNP99D/p1547807024066500?thread_ts=1547731708.057700&cid=C07KNP99D - var historyFile = Path.Combine(channelDir, ".history.json"); + // use history.json - last entry stands for the active build https://jetbrains.slack.com/archives/C07KNP99D/p1547807024066500?thread_ts=1547731708.057700&cid=C07KNP99D + var historyFile = Path.Combine(channelDir, ".history.json"); if (File.Exists(historyFile)) { var json = File.ReadAllText(historyFile); @@ -255,14 +285,14 @@ namespace GodotTools.Ides.Rider } } - // changes in toolbox json files format may brake the logic above, so return all found Rider installations - return Directory.GetDirectories(channelDir) - .SelectMany(buildDir => GetExecutablePaths(dirName, searchPattern, isMac, buildDir)); + // changes in toolbox json files format may brake the logic above, so return all found Rider installations + return Directory.GetDirectories(channelDir) + .SelectMany(buildDir => GetExecutablePaths(dirName, searchPattern, isMac, buildDir)); } catch (Exception e) { - // do not write to Debug.Log, just log it. - Logger.Warn($"Failed to get RiderPath from {channelDir}", e); + // do not write to Debug.Log, just log it. + Logger.Warn($"Failed to get RiderPath from {channelDir}", e); } return new string[0]; @@ -289,6 +319,27 @@ namespace GodotTools.Ides.Rider #pragma warning disable 0649 [Serializable] + class SettingsJson + { + public string install_location; + + [CanBeNull] + public static string GetInstallLocationFromJson(string json) + { + try + { + return JsonConvert.DeserializeObject<SettingsJson>(json).install_location; + } + catch (Exception) + { + Logger.Warn($"Failed to get install_location from json {json}"); + } + + return null; + } + } + + [Serializable] class ToolboxHistory { public List<ItemNode> history; @@ -372,7 +423,6 @@ namespace GodotTools.Ides.Rider [Serializable] class ActiveApplication { - // ReSharper disable once InconsistentNaming public List<string> builds; } @@ -380,6 +430,7 @@ namespace GodotTools.Ides.Rider public struct RiderInfo { + // ReSharper disable once NotAccessedField.Global public bool IsToolbox; public string Presentation; public Version BuildNumber; diff --git a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs index 558a242bf9..ee5677a6a8 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Ides/Rider/RiderPathManager.cs @@ -9,13 +9,13 @@ namespace GodotTools.Ides.Rider { public static class RiderPathManager { - private static readonly string editorPathSettingName = "mono/editor/editor_path_optional"; + public static readonly string EditorPathSettingName = "mono/editor/editor_path_optional"; private static string GetRiderPathFromSettings() { var editorSettings = GodotSharpEditor.Instance.GetEditorInterface().GetEditorSettings(); - if (editorSettings.HasSetting(editorPathSettingName)) - return (string)editorSettings.GetSetting(editorPathSettingName); + if (editorSettings.HasSetting(EditorPathSettingName)) + return (string)editorSettings.GetSetting(EditorPathSettingName); return null; } @@ -25,22 +25,22 @@ namespace GodotTools.Ides.Rider var editor = (ExternalEditorId)editorSettings.GetSetting("mono/editor/external_editor"); if (editor == ExternalEditorId.Rider) { - if (!editorSettings.HasSetting(editorPathSettingName)) + if (!editorSettings.HasSetting(EditorPathSettingName)) { - Globals.EditorDef(editorPathSettingName, "Optional"); + Globals.EditorDef(EditorPathSettingName, "Optional"); editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary { ["type"] = Variant.Type.String, - ["name"] = editorPathSettingName, + ["name"] = EditorPathSettingName, ["hint"] = PropertyHint.File, ["hint_string"] = "" }); } - var riderPath = (string)editorSettings.GetSetting(editorPathSettingName); + var riderPath = (string)editorSettings.GetSetting(EditorPathSettingName); if (IsRiderAndExists(riderPath)) { - Globals.EditorDef(editorPathSettingName, riderPath); + Globals.EditorDef(EditorPathSettingName, riderPath); return; } @@ -50,17 +50,15 @@ namespace GodotTools.Ides.Rider return; var newPath = paths.Last().Path; - Globals.EditorDef(editorPathSettingName, newPath); - editorSettings.SetSetting(editorPathSettingName, newPath); + Globals.EditorDef(EditorPathSettingName, newPath); + editorSettings.SetSetting(EditorPathSettingName, newPath); } } - private static bool IsRider(string path) + public static bool IsRider(string path) { if (string.IsNullOrEmpty(path)) - { return false; - } var fileInfo = new FileInfo(path); var filename = fileInfo.Name.ToLowerInvariant(); @@ -81,8 +79,8 @@ namespace GodotTools.Ides.Rider return null; var newPath = paths.Last().Path; - editorSettings.SetSetting(editorPathSettingName, newPath); - Globals.EditorDef(editorPathSettingName, newPath); + editorSettings.SetSetting(EditorPathSettingName, newPath); + Globals.EditorDef(EditorPathSettingName, newPath); return newPath; } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs index 684d160b57..5f64c09a89 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Extensions/ResourceLoaderExtensions.cs @@ -2,9 +2,9 @@ namespace Godot { public static partial class ResourceLoader { - public static T Load<T>(string path) where T : class + public static T Load<T>(string path, string typeHint = null, bool noCache = false) where T : class { - return (T)(object)Load(path); + return (T)(object)Load(path, typeHint, noCache); } } } diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs index 19962d418a..2a9c2d73b1 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs @@ -83,7 +83,7 @@ namespace Godot public static void Print(params object[] what) { - godot_icall_GD_print(Array.ConvertAll(what, x => x.ToString())); + godot_icall_GD_print(Array.ConvertAll(what, x => x?.ToString())); } public static void PrintStack() diff --git a/modules/mono/icons/icon_c_sharp_script.svg b/modules/mono/icons/CSharpScript.svg index 69664ca553..69664ca553 100644 --- a/modules/mono/icons/icon_c_sharp_script.svg +++ b/modules/mono/icons/CSharpScript.svg diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 895393537f..eb4c263745 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -37,6 +37,7 @@ #include <mono/metadata/mono-gc.h> #include <mono/metadata/profiler.h> +#include "core/debugger/engine_debugger.h" #include "core/os/dir_access.h" #include "core/os/file_access.h" #include "core/os/os.h" @@ -1183,8 +1184,8 @@ void GDMono::unhandled_exception_hook(MonoObject *p_exc, void *) { #ifdef DEBUG_ENABLED GDMonoUtils::debug_send_unhandled_exception_error((MonoException *)p_exc); - if (ScriptDebugger::get_singleton()) - ScriptDebugger::get_singleton()->idle_poll(); + if (EngineDebugger::is_active()) + EngineDebugger::get_singleton()->poll_events(false); #endif exit(mono_environment_exitcode_get()); diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp index 74ffa90cb3..b179b484f3 100644 --- a/modules/mono/mono_gd/gd_mono_internals.cpp +++ b/modules/mono/mono_gd/gd_mono_internals.cpp @@ -38,6 +38,9 @@ #include "gd_mono_marshal.h" #include "gd_mono_utils.h" +#include "core/debugger/engine_debugger.h" +#include "core/debugger/script_debugger.h" + #include <mono/metadata/exception.h> namespace GDMonoInternals { @@ -120,8 +123,8 @@ void unhandled_exception(MonoException *p_exc) { } else { #ifdef DEBUG_ENABLED GDMonoUtils::debug_send_unhandled_exception_error((MonoException *)p_exc); - if (ScriptDebugger::get_singleton()) - ScriptDebugger::get_singleton()->idle_poll(); + if (EngineDebugger::is_active()) + EngineDebugger::get_singleton()->poll_events(false); #endif } } diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp index ae6625a6c6..bc290f3a7f 100644 --- a/modules/mono/mono_gd/gd_mono_utils.cpp +++ b/modules/mono/mono_gd/gd_mono_utils.cpp @@ -32,18 +32,20 @@ #include <mono/metadata/exception.h> +#include "core/debugger/engine_debugger.h" +#include "core/debugger/script_debugger.h" #include "core/os/dir_access.h" +#include "core/os/mutex.h" #include "core/os/os.h" #include "core/project_settings.h" #include "core/reference.h" #ifdef TOOLS_ENABLED -#include "editor/debugger/script_editor_debugger.h" +#include "editor/debugger/editor_debugger_node.h" #endif #include "../csharp_script.h" #include "../utils/macros.h" -#include "../utils/mutex_utils.h" #include "gd_mono.h" #include "gd_mono_cache.h" #include "gd_mono_class.h" @@ -74,7 +76,7 @@ MonoObject *unmanaged_get_managed(Object *unmanaged) { CSharpScriptBinding &script_binding = ((Map<Object *, CSharpScriptBinding>::Element *)data)->value(); if (!script_binding.inited) { - SCOPED_MUTEX_LOCK(CSharpLanguage::get_singleton()->get_language_bind_mutex()); + MutexLock lock(CSharpLanguage::get_singleton()->get_language_bind_mutex()); if (!script_binding.inited) { // Other thread may have set it up // Already had a binding that needs to be setup @@ -351,7 +353,7 @@ void debug_print_unhandled_exception(MonoException *p_exc) { void debug_send_unhandled_exception_error(MonoException *p_exc) { #ifdef DEBUG_ENABLED - if (!ScriptDebugger::get_singleton()) { + if (!EngineDebugger::is_active()) { #ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint()) { ERR_PRINT(GDMonoUtils::get_exception_name_and_message(p_exc)); @@ -410,7 +412,7 @@ void debug_send_unhandled_exception_error(MonoException *p_exc) { int line = si.size() ? si[0].line : __LINE__; String error_msg = "Unhandled exception"; - ScriptDebugger::get_singleton()->send_error(func, file, line, error_msg, exc_msg, ERR_HANDLER_ERROR, si); + EngineDebugger::get_script_debugger()->send_error(func, file, line, error_msg, exc_msg, ERR_HANDLER_ERROR, si); #endif } diff --git a/modules/mono/utils/mutex_utils.h b/modules/mono/utils/mutex_utils.h deleted file mode 100644 index bafd875395..0000000000 --- a/modules/mono/utils/mutex_utils.h +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************/ -/* mutex_utils.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef MUTEX_UTILS_H -#define MUTEX_UTILS_H - -#include "core/error_macros.h" -#include "core/os/mutex.h" - -#include "macros.h" - -class ScopedMutexLock { - Mutex *mutex; - -public: - ScopedMutexLock(Mutex *mutex) { - this->mutex = mutex; -#ifndef NO_THREADS -#ifdef DEBUG_ENABLED - CRASH_COND(!mutex); -#endif - this->mutex->lock(); -#endif - } - - ~ScopedMutexLock() { -#ifndef NO_THREADS -#ifdef DEBUG_ENABLED - CRASH_COND(!mutex); -#endif - mutex->unlock(); -#endif - } -}; - -#define SCOPED_MUTEX_LOCK(m_mutex) ScopedMutexLock GD_UNIQUE_NAME(__scoped_mutex_lock__)(m_mutex); - -// TODO: Add version that receives a lambda instead, once C++11 is allowed - -#endif // MUTEX_UTILS_H |