Skip to content

Commit 570c0b2

Browse files
committed
lock AssignTargetAssembly
1 parent df7fd34 commit 570c0b2

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

src/Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project>
33
<PropertyGroup>
4-
<Version>29.0.0-beta.1</Version>
4+
<Version>29.0.0-beta.2</Version>
55
<NoWarn>CA1822;CS1591;CS0649;xUnit1026;xUnit1013;CS1573;VerifyTestsProjectDir;VerifySetParameters;PolyFillTargetsForNuget;xUnit1051</NoWarn>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<LangVersion>preview</LangVersion>

src/Verify/VerifierSettings_TargetAssembly.cs

+21-11
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,35 @@ public static Assembly Assembly
2525
}
2626
}
2727

28+
static Lock locker = new();
29+
2830
public static void AssignTargetAssembly(Assembly assembly)
2931
{
3032
if (VerifierSettings.assembly is not null)
3133
{
3234
return;
3335
}
3436

35-
VerifierSettings.assembly = assembly;
36-
Namer.UseAssembly(assembly);
37-
IoHelpers.MapPathsForCallingAssembly(assembly);
38-
ProjectDir = AttributeReader.GetProjectDirectory(assembly);
39-
AttributeReader.TryGetSolutionDirectory(assembly, out var solutionDir);
40-
SolutionDir = solutionDir;
41-
if (AttributeReader.TryGetTargetFrameworks(assembly, out var targetFrameworks))
37+
lock (locker)
4238
{
43-
TargetsMultipleFramework = targetFrameworks.Contains(';');
44-
}
39+
if (VerifierSettings.assembly is not null)
40+
{
41+
return;
42+
}
4543

46-
SolutionDir = solutionDir;
47-
ApplyScrubbers.UseAssembly(solutionDir, ProjectDir);
44+
VerifierSettings.assembly = assembly;
45+
Namer.UseAssembly(assembly);
46+
IoHelpers.MapPathsForCallingAssembly(assembly);
47+
ProjectDir = AttributeReader.GetProjectDirectory(assembly);
48+
AttributeReader.TryGetSolutionDirectory(assembly, out var solutionDir);
49+
SolutionDir = solutionDir;
50+
if (AttributeReader.TryGetTargetFrameworks(assembly, out var targetFrameworks))
51+
{
52+
TargetsMultipleFramework = targetFrameworks.Contains(';');
53+
}
54+
55+
SolutionDir = solutionDir;
56+
ApplyScrubbers.UseAssembly(solutionDir, ProjectDir);
57+
}
4858
}
4959
}

0 commit comments

Comments
 (0)