Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C# "out of sync" notice with external editors #88076

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ public static class BuildManager
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ public void BuildProject()
GodotSharpEditor.Instance.GetNode<HotReloadAssemblyWatcher>("HotReloadAssemblyWatcher").RestartTimer();

if (Internal.IsAssembliesReloadingNeeded())
{
BuildManager.UpdateLastValidBuildDateTime();
Internal.ReloadAssemblies(softReload: false);
}
}

private void RebuildProject()
Expand All @@ -107,7 +110,10 @@ private void RebuildProject()
GodotSharpEditor.Instance.GetNode<HotReloadAssemblyWatcher>("HotReloadAssemblyWatcher").RestartTimer();

if (Internal.IsAssembliesReloadingNeeded())
{
BuildManager.UpdateLastValidBuildDateTime();
Internal.ReloadAssemblies(softReload: false);
}
}

private void CleanProject()
Expand Down
21 changes: 0 additions & 21 deletions modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ public static class Settings

public bool SkipBuildBeforePlaying { get; set; } = false;

public DateTime LastValidBuildDateTime { get; private set; }

[UsedImplicitly]
private bool CreateProjectSolutionIfNeeded()
{
Expand Down Expand Up @@ -441,21 +439,6 @@ private void ApplyNecessaryChangesToSolution()
}
}

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)
Expand All @@ -466,8 +449,6 @@ public override void _EnablePlugin()
{
base._EnablePlugin();

UpdateLastValidBuildDateTime();

ProjectSettings.SettingsChanged += GodotSharpDirs.DetermineProjectLocation;

if (Instance != null)
Expand Down Expand Up @@ -640,7 +621,6 @@ public override void _EnablePlugin()
var inspectorPlugin = new InspectorPlugin();
AddInspectorPlugin(inspectorPlugin);
_inspectorPluginWeak = WeakRef(inspectorPlugin);
BuildManager.BuildFinished += BuildFinished;

BuildManager.Initialize();
RiderPathManager.Initialize();
Expand All @@ -657,7 +637,6 @@ public override void _DisablePlugin()

// Custom signals aren't automatically disconnected currently.
MSBuildPanel.BuildStateChanged -= BuildStateChanged;
BuildManager.BuildFinished -= BuildFinished;
}

public override void _ExitTree()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Godot;
using GodotTools.Build;
using GodotTools.Internals;
using JetBrains.Annotations;
using static GodotTools.Internals.Globals;

namespace GodotTools
{
Expand All @@ -16,14 +16,20 @@ public override void _Notification(int what)
RestartTimer();

if (Internal.IsAssembliesReloadingNeeded())
{
BuildManager.UpdateLastValidBuildDateTime();
Internal.ReloadAssemblies(softReload: false);
}
}
}

private void TimerTimeout()
{
if (Internal.IsAssembliesReloadingNeeded())
{
BuildManager.UpdateLastValidBuildDateTime();
Internal.ReloadAssemblies(softReload: false);
}
}

[UsedImplicitly]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Godot;
using GodotTools.Build;
using GodotTools.Utils;

namespace GodotTools.Inspector
Expand All @@ -24,7 +25,7 @@ public override void _ParseBegin(GodotObject godotObject)
{
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;
Expand Down
Loading