Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
95d0e62
chore: Read the sources a compiled assembly was built from out of its…
hatayama Oct 11, 2026
c813735
chore: Log where the hot reload source snapshot capture spends its ti…
hatayama Oct 11, 2026
5fd6da3
perf: Hot reload's source snapshot capture rewrites only the sources …
hatayama Oct 11, 2026
974a2b5
perf: Skip the hot reload source snapshot capture when the hot-reload…
hatayama Oct 11, 2026
58f1026
chore: Prepare compile status and pause points for a background sourc…
hatayama Oct 11, 2026
574b1b7
chore: Read the defines and metadata references a compiled assembly's…
hatayama Oct 11, 2026
ef1e125
chore: Save hot reload's compilation assembly list for the next domai…
hatayama Oct 11, 2026
f79a2a0
perf: Hot reload's source snapshot capture no longer asks the Package…
hatayama Oct 11, 2026
a12c987
Merge main's squash of #3278 into the integration branch, keeping thi…
hatayama Oct 11, 2026
2f72bb1
perf: Hot reload's source snapshot capture lists assemblies from the …
hatayama Oct 11, 2026
39aa56d
perf: Hot reload's source snapshot capture after a compile no longer …
hatayama Oct 11, 2026
9be23be
perf: Hot reload rebuilds its compilation assembly list off the main …
hatayama Oct 11, 2026
b754119
perf: Hot reload's warm-ups no longer ask Unity for the assembly list…
hatayama Oct 11, 2026
26e3942
fix: Hot reload no longer asks for a compile that cannot help when an…
hatayama Oct 12, 2026
94dd31a
fix: Hot reload notices edits to files without a method body in assem…
hatayama Oct 12, 2026
935ead9
chore: Hot reload's startup log separates rebuilding the compilation …
hatayama Oct 12, 2026
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
37 changes: 37 additions & 0 deletions Assets/Tests/Editor/CompileStatusBridgeCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void BuildResponse_WhenUnityIsIdleAndResultMatches_ReturnsReadyResult()
isCompiling: false,
isUpdating: false,
isDomainReloadInProgress: false,
isSnapshotCaptureHolding: false,
_compileSessionLifecycleService,
_compileResultSessionRepository,
_pendingCompileSessionRepository);
Expand All @@ -77,6 +78,7 @@ public void BuildResponse_WhenUnityIsStillCompiling_ReturnsNotReadyWithStoredRes
isCompiling: true,
isUpdating: false,
isDomainReloadInProgress: false,
isSnapshotCaptureHolding: false,
_compileSessionLifecycleService,
_compileResultSessionRepository,
_pendingCompileSessionRepository);
Expand All @@ -101,6 +103,7 @@ public void BuildResponse_WhenRequestIdDiffers_DoesNotReturnStaleResult()
isCompiling: false,
isUpdating: false,
isDomainReloadInProgress: false,
isSnapshotCaptureHolding: false,
_compileSessionLifecycleService,
_compileResultSessionRepository,
_pendingCompileSessionRepository);
Expand All @@ -124,6 +127,7 @@ public void BuildResponse_WhenUnityIsIdleAndPendingRequestHasNoReloadSignal_Wait
isCompiling: false,
isUpdating: false,
isDomainReloadInProgress: false,
isSnapshotCaptureHolding: false,
_compileSessionLifecycleService,
_compileResultSessionRepository,
_pendingCompileSessionRepository);
Expand Down Expand Up @@ -152,6 +156,7 @@ public void BuildResponse_WhenUnityIsIdleAndPendingRequestObservedReload_Returns
isCompiling: false,
isUpdating: false,
isDomainReloadInProgress: false,
isSnapshotCaptureHolding: false,
_compileSessionLifecycleService,
_compileResultSessionRepository,
_pendingCompileSessionRepository);
Expand Down Expand Up @@ -182,6 +187,37 @@ public void BuildResponse_WhenUnityIsBusyAndPendingRequestHasNoResult_WaitsForRe
isCompiling: true,
isUpdating: false,
isDomainReloadInProgress: false,
isSnapshotCaptureHolding: false,
_compileSessionLifecycleService,
_compileResultSessionRepository,
_pendingCompileSessionRepository);

Assert.That(response.Ready, Is.False);
Assert.That(response.HasResult, Is.False);
Assert.That(response.Result, Is.Null);
Assert.That(
UnityCliLoopEditorSessionStateTestFactory.GetSinglePendingCompileRequest(
_pendingCompileSessionRepository).HasRequest,
Is.True);
}

[Test]
public void BuildResponse_WhileTheSnapshotCaptureHolds_IsNotReadyAndDoesNotRecoverAPendingResult()
{
// Verifies an idle Unity still withholds the compile completion, and leaves the pending
// request for a later poll, while the hot reload source snapshot capture is running.
_compileSessionLifecycleService.MarkPendingCompileRequest(
"compile_test_request",
forceRecompile: false,
markedAtUtc: System.DateTime.UtcNow);
_pendingCompileSessionRepository.MarkPendingCompileRequestReloadObserved();

GetCompileStatusResponse response = CompileStatusBridgeCommand.BuildResponse(
"compile_test_request",
isCompiling: false,
isUpdating: false,
isDomainReloadInProgress: false,
isSnapshotCaptureHolding: true,
_compileSessionLifecycleService,
_compileResultSessionRepository,
_pendingCompileSessionRepository);
Expand Down Expand Up @@ -210,6 +246,7 @@ public void BuildResponse_WhenForceCompilePendingRequestHasNoResult_ReturnsExpla
isCompiling: false,
isUpdating: false,
isDomainReloadInProgress: false,
isSnapshotCaptureHolding: false,
_compileSessionLifecycleService,
_compileResultSessionRepository,
_pendingCompileSessionRepository);
Expand Down
67 changes: 67 additions & 0 deletions Assets/Tests/Editor/HotReload/CecilPdbRewrite.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;
using System.IO;

using Mono.Cecil;
using Mono.Cecil.Cil;

using NUnit.Framework;

using io.github.hatayama.UnityCliLoop.FirstPartyTools;

namespace io.github.hatayama.UnityCliLoop.Tests.Editor.HotReload
{
/// <summary>
/// Writes a copy of a compiled assembly of this project the way an IL post-processor does, for
/// tests that need a PDB which lost the documents no sequence point refers to.
/// </summary>
internal static class CecilPdbRewrite
{
// Writes the rewritten copy into a new temporary directory and returns the dll's path; the
// caller deletes the directory. Fails the test unless the copy kept the compiler's source
// count and lost a document, which every case that uses it relies on.
internal static string RewriteIntoNewDirectoryLosingDocuments(string projectRoot, string assemblyName)
{
string directory = Path.Combine(Path.GetTempPath(), "uloop-cecil-pdb-rewrite-" + Guid.NewGuid().ToString("N"));
string dllPath = Path.Combine(directory, HotReloadConstants.ScriptAssembliesRelativeDirectory, assemblyName + ".dll");
Directory.CreateDirectory(Path.GetDirectoryName(dllPath));
Rewrite(projectRoot, assemblyName, directory, dllPath);
HotReloadPdbCompilationInfo rewritten = HotReloadPdbCompilationInfo.Read(Path.ChangeExtension(dllPath, ".pdb"));
Assert.That(rewritten.SourceFileCount, Is.Not.Null, "Precondition: the rewritten PDB must keep the compiler's source count.");
Assert.That(rewritten.DocumentCount, Is.LessThan(rewritten.SourceFileCount.Value), "Precondition: the rewrite must drop some document.");
return dllPath;
}

// The temporary directory RewriteIntoNewDirectoryLosingDocuments created for the dll.
internal static string RootOf(string dllPath)
{
return Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(dllPath)));
}

// Reads the assembly with its symbols and writes both again, as an IL post-processor does.
// Cecil keeps only the documents a method refers to. workDirectory receives the copy that is
// read, so the compiled files are never opened for writing.
internal static void Rewrite(string projectRoot, string assemblyName, string workDirectory, string outputDllPath)
{
CompiledAssemblyLayout real = CompiledAssemblyLayout.Resolve(projectRoot);
string sourceDll = Path.Combine(workDirectory, "Source", assemblyName + ".dll");
Directory.CreateDirectory(Path.GetDirectoryName(sourceDll));
File.Copy(real.DllPath(assemblyName), sourceDll);
File.Copy(real.PdbPath(assemblyName), Path.ChangeExtension(sourceDll, ".pdb"));
using (DefaultAssemblyResolver resolver = new DefaultAssemblyResolver())
{
resolver.AddSearchDirectory(real.CompiledAssembliesDirectory);
resolver.AddSearchDirectory(Path.GetDirectoryName(typeof(object).Assembly.Location));
using (ModuleDefinition module = ModuleDefinition.ReadModule(
sourceDll,
new ReaderParameters { ReadSymbols = true, AssemblyResolver = resolver }))
{
module.Write(outputDllPath, new WriterParameters
{
WriteSymbols = true,
SymbolWriterProvider = new PortablePdbWriterProvider(),
});
}
}
}
}
}
11 changes: 11 additions & 0 deletions Assets/Tests/Editor/HotReload/CecilPdbRewrite.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading