From 1982773eafe496460e3d8e73f0f14ec3ac802ccf Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Tue, 28 Jul 2026 20:58:48 +0200 Subject: [PATCH] Assemble the ID string probe once, outside the source tree Each fixture test assembled Documentation/IdStringProbe.il separately, and ilasm writes its output next to the input: on Windows the second test failed with a sharing violation (0x80070020) because the first test's PEFile still had the previous output open. The probe is now assembled once per test run from a temp copy of the .il, so the tests share one PEFile and nothing is written into the source tree, which also makes the per-directory .gitignore unnecessary. Assisted-by: Claude:claude-fable-5:Claude Code --- .../Documentation/.gitignore | 2 -- .../Documentation/IdStringProviderTests.cs | 27 ++++++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) delete mode 100644 ICSharpCode.Decompiler.Tests/Documentation/.gitignore diff --git a/ICSharpCode.Decompiler.Tests/Documentation/.gitignore b/ICSharpCode.Decompiler.Tests/Documentation/.gitignore deleted file mode 100644 index f0f1af068..000000000 --- a/ICSharpCode.Decompiler.Tests/Documentation/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/IdStringProbe.dll -/IdStringProbe.pdb diff --git a/ICSharpCode.Decompiler.Tests/Documentation/IdStringProviderTests.cs b/ICSharpCode.Decompiler.Tests/Documentation/IdStringProviderTests.cs index 8eb14bac8..ff059de21 100644 --- a/ICSharpCode.Decompiler.Tests/Documentation/IdStringProviderTests.cs +++ b/ICSharpCode.Decompiler.Tests/Documentation/IdStringProviderTests.cs @@ -2191,11 +2191,30 @@ namespace ModreqParams // and IdStringProbe.xml the unmodified xml doc file MSVC generated for it; every // member key MSVC wrote must be reachable through the ID string candidates. - static async Task AssembleIdStringProbe() + // Assembled once per test run: ilasm writes its output next to the input, so the + // .il is copied to a unique temp path first (no output in the source tree), and + // the result is shared because re-assembling to the same path would fail on + // Windows with a sharing violation while an earlier test's PEFile holds the + // previous output open. + static readonly Lazy> idStringProbeAssembly = new(async () => { + string sourcePath = Path.Combine(Tester.TesterPath, "../../../../Documentation/IdStringProbe.il"); + string tempPath = Path.Combine(Path.GetTempPath(), + "IdStringProbe_" + Guid.NewGuid().ToString("N") + ".il"); + File.Copy(sourcePath, tempPath); + try + { + string dll = await Tester.AssembleIL(tempPath, AssemblerOptions.Library); + return new PEFile(dll); + } + finally + { + File.Delete(tempPath); + } + }); + + static Task AssembleIdStringProbe() { - string dir = Path.Combine(Tester.TesterPath, "../../../../Documentation"); - string dll = await Tester.AssembleIL(Path.Combine(dir, "IdStringProbe.il"), AssemblerOptions.Library); - return new PEFile(dll); + return idStringProbeAssembly.Value; } static HashSet CollectIdStringCandidates(PEFile pe)