diff options
author | Ignacio Roldán Etcheverry <ignalfonsore@gmail.com> | 2022-05-28 04:56:46 +0200 |
---|---|---|
committer | Ignacio Roldán Etcheverry <ignalfonsore@gmail.com> | 2022-08-22 03:36:51 +0200 |
commit | e235cef09f71d0cd752ba4931640be24dcb551ab (patch) | |
tree | bb347c5defc17beb54490d48a91edef9da2b0d1d /modules/mono/editor/GodotTools | |
parent | d78e0a842638df9c98a8f7637b125d36e488a367 (diff) |
C#: Re-implement assembly reloading with ALCs
Diffstat (limited to 'modules/mono/editor/GodotTools')
3 files changed, 30 insertions, 10 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs index 18073d6492..f8a810fd44 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildInfo.cs @@ -11,16 +11,16 @@ namespace GodotTools.Build [Serializable] public sealed partial class BuildInfo : RefCounted // TODO Remove RefCounted once we have proper serialization { - public string Solution { get; } - public string Configuration { get; } - public string? RuntimeIdentifier { get; } - public string? PublishOutputDir { get; } - public bool Restore { get; } - public bool Rebuild { get; } - public bool OnlyClean { get; } + public string Solution { get; private set; } + public string Configuration { get; private set; } + public string? RuntimeIdentifier { get; private set; } + public string? PublishOutputDir { get; private set; } + public bool Restore { get; private set; } + public bool Rebuild { get; private set; } + public bool OnlyClean { get; private set; } // TODO Use List once we have proper serialization - public Array<string> CustomProperties { get; } = new Array<string>(); + public Array<string> CustomProperties { get; private set; } = new Array<string>(); public string LogsDirPath => Path.Combine(GodotSharpDirs.BuildLogsDirs, $"{Solution.MD5Text()}_{Configuration}"); @@ -56,6 +56,13 @@ namespace GodotTools.Build } } + // Needed for instantiation from Godot, after reloading assemblies + private BuildInfo() + { + Solution = string.Empty; + Configuration = string.Empty; + } + public BuildInfo(string solution, string configuration, bool restore, bool rebuild, bool onlyClean) { Solution = solution; diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs index f7b8c6bffd..bac5464fd6 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildOutputView.cs @@ -58,7 +58,7 @@ namespace GodotTools.Build } // TODO Use List once we have proper serialization. - private readonly Array<BuildIssue> _issues = new Array<BuildIssue>(); + private Array<BuildIssue> _issues = new Array<BuildIssue>(); private ItemList _issuesList; private PopupMenu _issuesListContextMenu; private TextEdit _buildLog; @@ -133,7 +133,9 @@ namespace GodotTools.Build if (string.IsNullOrEmpty(issue.ProjectFile) && string.IsNullOrEmpty(issue.File)) return; - string projectDir = issue.ProjectFile.Length > 0 ? issue.ProjectFile.GetBaseDir() : _buildInfo.Solution.GetBaseDir(); + string projectDir = issue.ProjectFile.Length > 0 ? + issue.ProjectFile.GetBaseDir() : + _buildInfo.Solution.GetBaseDir(); string file = Path.Combine(projectDir.SimplifyGodotPath(), issue.File.SimplifyGodotPath()); @@ -412,6 +414,16 @@ namespace GodotTools.Build { // In case it didn't update yet. We don't want to have to serialize any pending output. UpdateBuildLogText(); + + // NOTE: + // Currently, GodotTools is loaded in its own load context. This load context is not reloaded, but the script still are. + // Until that changes, we need workarounds like this one because events keep strong references to disposed objects. + BuildManager.BuildLaunchFailed -= BuildLaunchFailed; + BuildManager.BuildStarted -= BuildStarted; + BuildManager.BuildFinished -= BuildFinished; + // StdOutput/Error can be received from different threads, so we need to use CallDeferred + BuildManager.StdOutputReceived -= StdOutputReceived; + BuildManager.StdErrorReceived -= StdErrorReceived; } public void OnAfterDeserialize() diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj index 2765391a27..f5734e6e69 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj +++ b/modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj @@ -9,6 +9,7 @@ <GodotSourceRootPath>$(SolutionDir)/../../../../</GodotSourceRootPath> <GodotOutputDataDir>$(GodotSourceRootPath)/bin/GodotSharp</GodotOutputDataDir> <GodotApiAssembliesDir>$(GodotOutputDataDir)/Api/$(GodotApiConfiguration)</GodotApiAssembliesDir> + <ProduceReferenceAssembly>false</ProduceReferenceAssembly> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> </PropertyGroup> <!-- Needed for our source generators to work despite this not being a Godot game project --> |