Browse Source

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
pull/3941/head
Siegfried Pammer 2 months ago committed by Siegfried Pammer
parent
commit
1982773eaf
  1. 2
      ICSharpCode.Decompiler.Tests/Documentation/.gitignore
  2. 27
      ICSharpCode.Decompiler.Tests/Documentation/IdStringProviderTests.cs

2
ICSharpCode.Decompiler.Tests/Documentation/.gitignore vendored

@ -1,2 +0,0 @@ @@ -1,2 +0,0 @@
/IdStringProbe.dll
/IdStringProbe.pdb

27
ICSharpCode.Decompiler.Tests/Documentation/IdStringProviderTests.cs

@ -2191,11 +2191,30 @@ namespace ModreqParams @@ -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<PEFile> 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<Task<PEFile>> 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<PEFile> 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<string> CollectIdStringCandidates(PEFile pe)

Loading…
Cancel
Save