提交 88fa1ea9 编写于 作者: A Andy Gocke 提交者: GitHub

Fix races and skip NoPia test on CoreClr (#20549)

Fixes #18985
上级 3f86d718
......@@ -6,6 +6,7 @@
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols.Metadata.PE
......@@ -733,7 +734,7 @@ public void GenericsClosedOverLocalTypes1()
Assert.IsType<NoPiaIllegalGenericInstantiationSymbol>(localTypes3.GetMembers("Test6").OfType<MethodSymbol>().Single().ReturnType);
}
[Fact]
[ConditionalFact(typeof(DesktopOnly))]
public void GenericsClosedOverLocalTypes2()
{
var mscorlibRef = TestReferences.NetFx.v4_0_21006.mscorlib;
......
......@@ -171,7 +171,7 @@ struct Name5 {}
}
[WorkItem(527531, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/527531")]
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/18985")]
[Fact]
public void InterfaceName()
{
var text = @"
......
......@@ -53,6 +53,19 @@ public virtual void Dispose()
#region Metadata References
/// <summary>
/// Helper for atomically acquiring and saving a metadata reference. Necessary
/// if the acquired reference will ever be used in object identity comparisons.
/// </summary>
private static MetadataReference GetOrCreateMetadataReference(ref MetadataReference field, Func<MetadataReference> getReference)
{
if (field == null)
{
Interlocked.CompareExchange(ref field, getReference(), null);
}
return field;
}
private static MetadataReference[] s_lazyDefaultVbReferences;
private static MetadataReference[] s_lazyLatestVbReferences;
......@@ -143,22 +156,10 @@ public static MetadataReference[] PortableRefsMinimal
private static MetadataReference s_systemCoreRef;
public static MetadataReference SystemCoreRef
{
get
{
if (s_systemCoreRef == null)
{
// We rely on reference equality in CreateSharedCompilation, so
// we must use a CompareExchange here.
Interlocked.CompareExchange(
ref s_systemCoreRef,
AssemblyMetadata.CreateFromImage(TestResources.NetFX.v4_0_30319.System_Core).GetReference(display: "System.Core.v4_0_30319.dll"),
null);
}
return s_systemCoreRef;
}
}
// We rely on reference equality in CreateSharedCompilation, so
// we must use a CompareExchange here.
=> GetOrCreateMetadataReference(ref s_systemCoreRef,
() => AssemblyMetadata.CreateFromImage(TestResources.NetFX.v4_0_30319.System_Core).GetReference(display: "System.Core.v4_0_30319.dll"));
private static MetadataReference s_systemCoreRef_v4_0_30319_17929;
public static MetadataReference SystemCoreRef_v4_0_30319_17929
......@@ -232,17 +233,10 @@ public static MetadataReference SystemDataRef
private static MetadataReference s_mscorlibRef;
public static MetadataReference MscorlibRef
{
get
{
if (s_mscorlibRef == null)
{
s_mscorlibRef = AssemblyMetadata.CreateFromImage(TestResources.NetFX.v4_0_30319.mscorlib).GetReference(display: "mscorlib.v4_0_30319.dll");
}
return s_mscorlibRef;
}
}
// We rely on reference equality in CreateSharedCompilation, so
// we must use a CompareExchange here.
=> GetOrCreateMetadataReference(ref s_mscorlibRef,
() => AssemblyMetadata.CreateFromImage(TestResources.NetFX.v4_0_30319.mscorlib).GetReference(display: "mscorlib.v4_0_30319.dll"));
private static MetadataReference s_mscorlibRefPortable;
public static MetadataReference MscorlibRefPortable
......@@ -415,22 +409,8 @@ public static MetadataReference SystemDynamicRuntimeRef
private static MetadataReference s_systemRef;
public static MetadataReference SystemRef
{
get
{
if (s_systemRef == null)
{
// We rely on reference equality in CreateSharedCompilation, so
// we must use a CompareExchange here.
Interlocked.CompareExchange(
ref s_systemRef,
AssemblyMetadata.CreateFromImage(TestResources.NetFX.v4_0_30319.System).GetReference(display: "System.v4_0_30319.dll"),
null);
}
return s_systemRef;
}
}
=> GetOrCreateMetadataReference(ref s_systemRef,
() => AssemblyMetadata.CreateFromImage(TestResources.NetFX.v4_0_30319.System).GetReference(display: "System.v4_0_30319.dll"));
private static MetadataReference s_systemRef_v46;
public static MetadataReference SystemRef_v46
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册