Skip to content

Commit c9e111b

Browse files
committed
Support running tests when mscorlib contains ValueTuple
1 parent 000b45d commit c9e111b

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/MetadataReferences.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,25 @@ internal static class MetadataReferences
2626

2727
static MetadataReferences()
2828
{
29-
Assembly systemRuntime = AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(x => x.GetName().Name == "System.Runtime");
30-
if (systemRuntime != null)
29+
if (typeof(string).Assembly.GetType("System.ValueTuple", false) != null)
3130
{
32-
SystemRuntimeReference = MetadataReference.CreateFromFile(systemRuntime.Location);
31+
// mscorlib contains ValueTuple, so no need to add a separate reference
32+
SystemRuntimeReference = null;
33+
SystemValueTupleReference = null;
3334
}
34-
35-
Assembly systemValueTuple = AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(x => x.GetName().Name == "System.ValueTuple");
36-
if (systemValueTuple != null)
35+
else
3736
{
38-
SystemValueTupleReference = MetadataReference.CreateFromFile(systemValueTuple.Location);
37+
Assembly systemRuntime = AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(x => x.GetName().Name == "System.Runtime");
38+
if (systemRuntime != null)
39+
{
40+
SystemRuntimeReference = MetadataReference.CreateFromFile(systemRuntime.Location);
41+
}
42+
43+
Assembly systemValueTuple = AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(x => x.GetName().Name == "System.ValueTuple");
44+
if (systemValueTuple != null)
45+
{
46+
SystemValueTupleReference = MetadataReference.CreateFromFile(systemValueTuple.Location);
47+
}
3948
}
4049
}
4150
}

0 commit comments

Comments
 (0)