diff options
author | Paul Joannon <hello@pauljoannon.com> | 2024-02-07 20:52:58 +0100 |
---|---|---|
committer | Paul Joannon <hello@pauljoannon.com> | 2024-02-07 21:26:32 +0100 |
commit | 9d283063a0c52f489baf0f0c8eff96dbed22cb36 (patch) | |
tree | 32564a13dd1070a726e2db73923c493cf5c634f9 /modules/mono/editor | |
parent | 36e943b6b20cb7a8a89bc30489c4a81c3e149d74 (diff) | |
download | redot-engine-9d283063a0c52f489baf0f0c8eff96dbed22cb36.tar.gz |
Fix C# "out of sync" notice with external editors
Change what triggers our re-evaluation of the last valid build datetime stored internally.
Move that datetime in `BuildManager`.
Diffstat (limited to 'modules/mono/editor')
5 files changed, 29 insertions, 23 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs index 7cf98b8f1f..6e99483a1c 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs @@ -24,6 +24,20 @@ namespace GodotTools.Build public static event Action<string> StdOutputReceived; public static event Action<string> StdErrorReceived; + public static DateTime LastValidBuildDateTime { get; private set; } + + static BuildManager() + { + UpdateLastValidBuildDateTime(); + } + + public static void UpdateLastValidBuildDateTime() + { + var dllName = $"{GodotSharpDirs.ProjectAssemblyName}.dll"; + var path = Path.Combine(GodotSharpDirs.ProjectBaseOutputPath, "Debug", dllName); + LastValidBuildDateTime = File.GetLastWriteTime(path); + } + private static void RemoveOldIssuesFile(BuildInfo buildInfo) { string issuesFile = GetIssuesFilePath(buildInfo); diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs b/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs index bae87dd1dd..9a02c9ca88 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs @@ -89,7 +89,10 @@ namespace GodotTools.Build GodotSharpEditor.Instance.GetNode<HotReloadAssemblyWatcher>("HotReloadAssemblyWatcher").RestartTimer(); if (Internal.IsAssembliesReloadingNeeded()) + { + BuildManager.UpdateLastValidBuildDateTime(); Internal.ReloadAssemblies(softReload: false); + } } private void RebuildProject() @@ -107,7 +110,10 @@ namespace GodotTools.Build GodotSharpEditor.Instance.GetNode<HotReloadAssemblyWatcher>("HotReloadAssemblyWatcher").RestartTimer(); if (Internal.IsAssembliesReloadingNeeded()) + { + BuildManager.UpdateLastValidBuildDateTime(); Internal.ReloadAssemblies(softReload: false); + } } private void CleanProject() diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index 5408b9b13e..44422eb862 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -54,8 +54,6 @@ namespace GodotTools public bool SkipBuildBeforePlaying { get; set; } = false; - public DateTime LastValidBuildDateTime { get; private set; } - [UsedImplicitly] private bool CreateProjectSolutionIfNeeded() { @@ -441,21 +439,6 @@ namespace GodotTools } } - private void UpdateLastValidBuildDateTime() - { - var dllName = $"{GodotSharpDirs.ProjectAssemblyName}.dll"; - var path = Path.Combine(GodotSharpDirs.ProjectBaseOutputPath, "Debug", dllName); - LastValidBuildDateTime = File.GetLastWriteTime(path); - } - - private void BuildFinished(BuildResult buildResult) - { - if (buildResult == BuildResult.Success) - { - UpdateLastValidBuildDateTime(); - } - } - private void BuildStateChanged() { if (_bottomPanelBtn != null) @@ -466,8 +449,6 @@ namespace GodotTools { base._EnablePlugin(); - UpdateLastValidBuildDateTime(); - ProjectSettings.SettingsChanged += GodotSharpDirs.DetermineProjectLocation; if (Instance != null) @@ -640,7 +621,6 @@ namespace GodotTools var inspectorPlugin = new InspectorPlugin(); AddInspectorPlugin(inspectorPlugin); _inspectorPluginWeak = WeakRef(inspectorPlugin); - BuildManager.BuildFinished += BuildFinished; BuildManager.Initialize(); RiderPathManager.Initialize(); @@ -657,7 +637,6 @@ namespace GodotTools // Custom signals aren't automatically disconnected currently. MSBuildPanel.BuildStateChanged -= BuildStateChanged; - BuildManager.BuildFinished -= BuildFinished; } public override void _ExitTree() diff --git a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs index eb42f01b3a..66717d8636 100644 --- a/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs +++ b/modules/mono/editor/GodotTools/GodotTools/HotReloadAssemblyWatcher.cs @@ -1,7 +1,7 @@ using Godot; +using GodotTools.Build; using GodotTools.Internals; using JetBrains.Annotations; -using static GodotTools.Internals.Globals; namespace GodotTools { @@ -16,14 +16,20 @@ namespace GodotTools RestartTimer(); if (Internal.IsAssembliesReloadingNeeded()) + { + BuildManager.UpdateLastValidBuildDateTime(); Internal.ReloadAssemblies(softReload: false); + } } } private void TimerTimeout() { if (Internal.IsAssembliesReloadingNeeded()) + { + BuildManager.UpdateLastValidBuildDateTime(); Internal.ReloadAssemblies(softReload: false); + } } [UsedImplicitly] diff --git a/modules/mono/editor/GodotTools/GodotTools/Inspector/InspectorPlugin.cs b/modules/mono/editor/GodotTools/GodotTools/Inspector/InspectorPlugin.cs index 8282ca6ea6..323a0fb380 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Inspector/InspectorPlugin.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Inspector/InspectorPlugin.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Godot; +using GodotTools.Build; using GodotTools.Utils; namespace GodotTools.Inspector @@ -24,7 +25,7 @@ namespace GodotTools.Inspector { if (script is not CSharpScript) continue; - if (File.GetLastWriteTime(script.ResourcePath) > GodotSharpEditor.Instance.LastValidBuildDateTime) + if (File.GetLastWriteTime(script.ResourcePath) > BuildManager.LastValidBuildDateTime) { AddCustomControl(new InspectorOutOfSyncWarning()); break; |