本文整理汇总了C#中Roslyn.Test.Utilities.TestMissingMetadataReferenceResolver类的典型用法代码示例。如果您正苦于以下问题:C# TestMissingMetadataReferenceResolver类的具体用法?C# TestMissingMetadataReferenceResolver怎么用?C# TestMissingMetadataReferenceResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TestMissingMetadataReferenceResolver类属于Roslyn.Test.Utilities命名空间,在下文中一共展示了TestMissingMetadataReferenceResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MissingAssemblyResolution_Multiple
public void MissingAssemblyResolution_Multiple()
{
// c - a -> d
// - b -> d
var dRef = CreateCompilationWithMscorlib("public interface D { }", assemblyName: "D").EmitToImageReference();
var aRef = CreateCompilationWithMscorlib("public interface A : D { }", new[] { dRef }, assemblyName: "A").ToMetadataReference();
var bRef = CreateCompilationWithMscorlib("public interface B : D { }", new[] { dRef }, assemblyName: "B").ToMetadataReference();
var resolver = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>
{
{ "D", dRef }
});
var c = CreateCompilationWithMscorlib("public interface C : A, B { }", new[] { aRef, bRef },
TestOptions.ReleaseDll.WithMetadataReferenceResolver(resolver));
c.VerifyEmitDiagnostics();
Assert.Equal("D", ((AssemblySymbol)c.GetAssemblyOrModuleSymbol(dRef)).Name);
resolver.VerifyResolutionAttempts(
"B -> D, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
}
示例2: MissingAssemblyResolution_Modules
public void MissingAssemblyResolution_Modules()
{
// c - a - d
// - module(m) - b
// - module(n) - d
var bRef = CreateCompilationWithMscorlib("public interface B { }", assemblyName: "B").EmitToImageReference();
var dRef = CreateCompilationWithMscorlib("public interface D { }", assemblyName: "D").EmitToImageReference();
var mRef = CreateCompilationWithMscorlib("public interface M : B { }", new[] { bRef }, options: TestOptions.ReleaseModule.WithModuleName("M.netmodule")).EmitToImageReference();
var nRef = CreateCompilationWithMscorlib("public interface N : D { }", new[] { dRef }, options: TestOptions.ReleaseModule.WithModuleName("N.netmodule")).EmitToImageReference();
var aRef = CreateCompilationWithMscorlib("public interface A : D { }", new[] { dRef }, assemblyName: "A").EmitToImageReference();
var resolver = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>
{
{ "B", bRef },
{ "D", dRef },
});
var c = CreateCompilationWithMscorlib("public interface C : A { }", new[] { aRef, mRef, nRef },
TestOptions.ReleaseDll.WithMetadataReferenceResolver(resolver));
c.VerifyEmitDiagnostics();
Assert.Equal("B", ((AssemblySymbol)c.GetAssemblyOrModuleSymbol(bRef)).Name);
Assert.Equal("D", ((AssemblySymbol)c.GetAssemblyOrModuleSymbol(dRef)).Name);
// We don't resolve one assembly reference identity twice, even if the requesting definition is different.
resolver.VerifyResolutionAttempts(
"A -> D, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"M.netmodule -> B, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
}
示例3: MissingAssemblyResolution_None
public void MissingAssemblyResolution_None()
{
// c - a -> d
// - d
var dRef = CreateCompilationWithMscorlib("public interface D { }", assemblyName: "D").EmitToImageReference();
var aRef = CreateCompilationWithMscorlib("public interface A : D { }", new[] { dRef }, assemblyName: "A").ToMetadataReference();
var resolver = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>());
var c = CreateCompilationWithMscorlib("public interface C : A { }", new[] { aRef, dRef },
TestOptions.ReleaseDll.WithMetadataReferenceResolver(resolver));
c.VerifyDiagnostics();
resolver.VerifyResolutionAttempts();
}
示例4: MissingAssemblyResolution_MissingDueToResolutionMismatch
public void MissingAssemblyResolution_MissingDueToResolutionMismatch()
{
// c - a -> b
var bRef = CreateCompilationWithMscorlib("public interface D { }", assemblyName: "B").EmitToImageReference();
var aRef = CreateCompilationWithMscorlib("public interface A : D { }", new[] { bRef }, assemblyName: "A").ToMetadataReference();
var eRef = CreateCompilationWithMscorlib("public interface E { }", assemblyName: "E").ToMetadataReference();
var resolver = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>
{
{ "B, 1.0.0.0", eRef },
});
var c = CreateCompilationWithMscorlib(@"public interface C : A { }", new[] { aRef },
TestOptions.ReleaseDll.WithMetadataReferenceResolver(resolver));
c.VerifyDiagnostics(
// (1,18): error CS0012: The type 'D' is defined in an assembly that is not referenced. You must add a reference to assembly 'B, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Diagnostic(ErrorCode.ERR_NoTypeDef, "C").WithArguments("D", "B, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"));
resolver.VerifyResolutionAttempts(
"A -> B, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
}
示例5: MissingAssemblyResolution_BindingToImplicitReference1
public void MissingAssemblyResolution_BindingToImplicitReference1()
{
// c - a -> d -> "b,v2"
// e -> "b,v1"
// "b,v1"
// "b,v2"
var b1Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public interface B { }", options: s_signedDll, assemblyName: "B").EmitToImageReference();
var b2Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public interface B { }", options: s_signedDll, assemblyName: "B").EmitToImageReference();
var dRef = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public interface D : B { }", new[] { b2Ref }, options: s_signedDll, assemblyName: "D").EmitToImageReference();
var eRef = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public interface E : B { }", new[] { b1Ref }, options: s_signedDll, assemblyName: "E").EmitToImageReference();
var aRef = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public interface A : D, E { }", new[] { dRef, eRef, b1Ref, b2Ref },
s_signedDll, assemblyName: "A").EmitToImageReference();
var resolverC = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>
{
{ "D, 1.0.0.0", dRef },
{ "E, 1.0.0.0", eRef },
{ "B, 1.0.0.0", b1Ref },
{ "B, 2.0.0.0", b2Ref },
});
var c = CreateSubmission("public class C : A { }", new[] { aRef },
TestOptions.ReleaseDll.WithMetadataReferenceResolver(resolverC));
c.VerifyEmitDiagnostics();
resolverC.VerifyResolutionAttempts(
"A -> D, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2",
"A -> B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2",
"A -> E, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2",
"A -> B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2");
c.VerifyAssemblyVersionsAndAliases(
"mscorlib, Version=4.0.0.0",
"A, Version=1.0.0.0",
"D, Version=1.0.0.0",
"B, Version=2.0.0.0",
"E, Version=1.0.0.0",
"B, Version=1.0.0.0: <superseded>");
}
示例6: MissingAssemblyResolution_WeakIdentities2
public void MissingAssemblyResolution_WeakIdentities2()
{
// c - a -> "b,v1,PKT=null"
// - d -> "b,v2,PKT=null"
var b1Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public interface B { }", assemblyName: "B").EmitToImageReference();
var b2Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public interface B { }", assemblyName: "B").EmitToImageReference();
var b3Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""3.0.0.0"")] public interface B { }", assemblyName: "B").EmitToImageReference();
var b4Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""4.0.0.0"")] public interface B { }", assemblyName: "B").EmitToImageReference();
var aRef = CreateCompilationWithMscorlib(@"public interface A : B { }", new[] { b1Ref }, assemblyName: "A").EmitToImageReference();
var dRef = CreateCompilationWithMscorlib(@"public interface D : B { }", new[] { b2Ref }, assemblyName: "D").EmitToImageReference();
var resolver = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>
{
{ "B, 1.0.0.0", b3Ref },
{ "B, 2.0.0.0", b4Ref },
});
var c = CreateCompilationWithMscorlib(@"public interface C : A, D { }", new[] { aRef, dRef },
TestOptions.ReleaseDll.WithMetadataReferenceResolver(resolver));
c.VerifyEmitDiagnostics(
// error CS1704: An assembly with the same simple name 'B' has already been imported. Try removing one of the references (e.g. 'B') or sign them to enable side-by-side.
Diagnostic(ErrorCode.ERR_DuplicateImportSimple).WithArguments("B", "B"));
resolver.VerifyResolutionAttempts(
"D -> B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null",
"A -> B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null");
}
示例7: MissingAssemblyResolution1
public void MissingAssemblyResolution1()
{
// c - a -> b
var bRef = CreateCompilationWithMscorlib("public class B { }", assemblyName: "B").EmitToImageReference();
var aRef = CreateCompilationWithMscorlib("public class A : B { }", new[] { bRef }, assemblyName: "A").EmitToImageReference();
var resolver = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>
{
{ "B", bRef }
});
var c = CreateCompilationWithMscorlib("public class C : A { }", new[] { aRef }, TestOptions.ReleaseDll.WithMetadataReferenceResolver(resolver));
c.VerifyEmitDiagnostics();
Assert.Equal("B", ((AssemblySymbol)c.GetAssemblyOrModuleSymbol(bRef)).Name);
resolver.VerifyResolutionAttempts(
"A -> B, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
}
示例8: MissingAssemblyResolution_BindingToImplicitReference1
public void MissingAssemblyResolution_BindingToImplicitReference1()
{
// c - a -> d -> "b,v2"
// e -> "b,v1"
// "b,v1"
// "b,v2"
var b1Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public interface B { }", options: s_signedDll, assemblyName: "B").EmitToImageReference();
var b2Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public interface B { }", options: s_signedDll, assemblyName: "B").EmitToImageReference();
var dRef = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public interface D : B { }", new[] { b2Ref }, options: s_signedDll, assemblyName: "D").EmitToImageReference();
var eRef = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public interface E : B { }", new[] { b1Ref }, options: s_signedDll, assemblyName: "E").EmitToImageReference();
var aRef = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public interface A : D, E { }", new[] { dRef, eRef, b1Ref, b2Ref },
s_signedDll, assemblyName: "A").EmitToImageReference();
var resolverC = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>
{
{ "D, 1.0.0.0", dRef },
{ "E, 1.0.0.0", eRef },
{ "B, 1.0.0.0", b1Ref },
{ "B, 2.0.0.0", b2Ref },
});
var c = CreateCompilationWithMscorlib("public class C : A { }", new[] { aRef },
s_signedDll.WithMetadataReferenceResolver(resolverC));
c.VerifyEmitDiagnostics();
Assert.Equal(4, resolverC.ResolutionAttempts.Count);
Assert.Equal(
"B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2",
((AssemblySymbol)c.GetAssemblyOrModuleSymbol(b1Ref)).Identity.GetDisplayName());
Assert.Equal(
"B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2",
((AssemblySymbol)c.GetAssemblyOrModuleSymbol(b2Ref)).Identity.GetDisplayName());
resolverC.VerifyResolutionAttempts(
"A -> D, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2",
"A -> B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2",
"A -> E, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2",
"A -> B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2");
}
示例9: MissingAssemblyResolution_Modules
public void MissingAssemblyResolution_Modules()
{
// c - a - d
// - module(m) - b
// - module(n) - d
var bRef = CreateCompilationWithMscorlib("public interface B { }", assemblyName: "B").EmitToImageReference();
var dRef = CreateCompilationWithMscorlib("public interface D { }", assemblyName: "D").EmitToImageReference();
var mRef = CreateCompilationWithMscorlib("public interface M : B { }", new[] { bRef }, options: TestOptions.ReleaseModule.WithModuleName("M.netmodule")).EmitToImageReference();
var nRef = CreateCompilationWithMscorlib("public interface N : D { }", new[] { dRef }, options: TestOptions.ReleaseModule.WithModuleName("N.netmodule")).EmitToImageReference();
var aRef = CreateCompilationWithMscorlib("public interface A : D { }", new[] { dRef }, assemblyName: "A").EmitToImageReference();
var resolver = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>
{
{ "B", bRef },
{ "D", dRef },
});
var c = CreateCompilationWithMscorlib("public interface C : A { }", new[] { aRef, mRef, nRef },
TestOptions.ReleaseDll.WithMetadataReferenceResolver(resolver));
c.VerifyEmitDiagnostics();
Assert.Equal("B", ((AssemblySymbol)c.GetAssemblyOrModuleSymbol(bRef)).Name);
Assert.Equal("D", ((AssemblySymbol)c.GetAssemblyOrModuleSymbol(dRef)).Name);
}
示例10: MissingAssemblyResolution_BindingToExplicitReference_BetterVersion
public void MissingAssemblyResolution_BindingToExplicitReference_BetterVersion()
{
// c - a -> d -> "b,v2"
// e -> "b,v1"
// - "b,v2"
var b1Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public interface B { }", options: s_signedDll, assemblyName: "B").EmitToImageReference();
var b2Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public interface B { }", options: s_signedDll, assemblyName: "B").EmitToImageReference();
var dRef = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public interface D : B { }", new[] { b2Ref }, options: s_signedDll, assemblyName: "D").EmitToImageReference();
var eRef = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public interface E : B { }", new[] { b1Ref }, options: s_signedDll, assemblyName: "E").EmitToImageReference();
var resolverA = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>
{
{ "B, 2.0.0.0", b2Ref },
{ "B, 1.0.0.0", b1Ref },
});
var aRef = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public interface A : D, E { }", new[] { dRef, eRef },
s_signedDll.WithMetadataReferenceResolver(resolverA), assemblyName: "A").EmitToImageReference();
Assert.Equal(2, resolverA.ResolutionAttempts.Count);
var resolverC = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>
{
{ "D, 1.0.0.0", dRef },
{ "E, 1.0.0.0", eRef },
});
var c = CreateCompilationWithMscorlib("public class C : A { }", new[] { aRef, b2Ref },
s_signedDll.WithMetadataReferenceResolver(resolverC));
c.VerifyEmitDiagnostics(
// (1,14): warning CS1701: Assuming assembly reference
// 'B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2' used by
// 'A' matches identity 'B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2' of 'B', you may need to supply runtime policy
Diagnostic(ErrorCode.WRN_UnifyReferenceMajMin, "C").WithArguments(
"B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "A",
"B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "B"),
// (1,14): warning CS1701: Assuming assembly reference
// 'B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2' used by 'E' matches identity
// 'B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2' of 'B', you may need to supply runtime policy
Diagnostic(ErrorCode.WRN_UnifyReferenceMajMin, "C").WithArguments(
"B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "E",
"B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "B"));
Assert.Equal(2, resolverC.ResolutionAttempts.Count);
}
示例11: MissingAssemblyResolution_ActualMissing
public void MissingAssemblyResolution_ActualMissing()
{
// c - a -> d
var dRef = CreateCompilationWithMscorlib("public interface D { }", assemblyName: "D").EmitToImageReference();
var aRef = CreateCompilationWithMscorlib("public interface A : D { }", new[] { dRef }, assemblyName: "A").ToMetadataReference();
var resolver = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>());
var c = CreateCompilationWithMscorlib("public interface C : A { }", new[] { aRef },
TestOptions.ReleaseDll.WithMetadataReferenceResolver(resolver));
c.VerifyDiagnostics(
// (1,18): error CS0012: The type 'D' is defined in an assembly that is not referenced. You must add a reference to assembly 'D, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Diagnostic(ErrorCode.ERR_NoTypeDef, "C").WithArguments("D", "D, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"));
Assert.Equal(1, resolver.ResolutionAttempts.Count);
}
示例12: MissingAssemblyResolution_Supersession_StrongNames
public void MissingAssemblyResolution_Supersession_StrongNames()
{
var options = TestOptions.ReleaseDll.WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.Default);
// c - a -> "C, v2"
// b -> "C, v1"
var aRef = CreateCompilationWithMscorlib(@"public interface A { C CA { get; } }", new[] { TestReferences.SymbolsTests.Versioning.C2 },
options: options, assemblyName: "A").EmitToImageReference();
var bRef = CreateCompilationWithMscorlib(@"public interface B { C CB { get; } }", new[] { TestReferences.SymbolsTests.Versioning.C1 },
options: options, assemblyName: "B").EmitToImageReference();
var resolverC = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>
{
{ "C, 1.0.0.0", TestReferences.SymbolsTests.Versioning.C1 },
{ "C, 2.0.0.0", TestReferences.SymbolsTests.Versioning.C2 },
});
var c = CreateSubmission("public interface D : A, B { C CC { get; } }", new[] { aRef, bRef },
options.WithMetadataReferenceResolver(resolverC));
c.VerifyEmitDiagnostics();
resolverC.VerifyResolutionAttempts(
"B -> C, Version=1.0.0.0, Culture=neutral, PublicKeyToken=374d0c2befcd8cc9",
"A -> C, Version=2.0.0.0, Culture=neutral, PublicKeyToken=374d0c2befcd8cc9");
c.VerifyAssemblyVersionsAndAliases(
"mscorlib, Version=4.0.0.0",
"A, Version=0.0.0.0",
"B, Version=0.0.0.0",
"C, Version=1.0.0.0: <superseded>",
"C, Version=2.0.0.0");
}
示例13: MissingAssemblyResolution_Supersession_FxUnification
public void MissingAssemblyResolution_Supersession_FxUnification()
{
var options = TestOptions.ReleaseDll.WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.Default);
// c - "mscorlib, v4"
// a -> "mscorlib, v2"
// "System, v2"
// b -> "mscorlib, v4"
// "System, v4"
var aRef = CreateCompilation(@"public interface A { System.Diagnostics.Process PA { get; } }", new[] { TestReferences.NetFx.v2_0_50727.mscorlib, TestReferences.NetFx.v2_0_50727.System },
options: options, assemblyName: "A").EmitToImageReference();
var bRef = CreateCompilation(@"public interface B { System.Diagnostics.Process PB { get; } }", new[] { MscorlibRef_v4_0_30316_17626, TestReferences.NetFx.v4_0_30319.System },
options: options, assemblyName: "B").EmitToImageReference();
var resolverC = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>
{
{ "System, 2.0.0.0", TestReferences.NetFx.v2_0_50727.System },
{ "System, 4.0.0.0", TestReferences.NetFx.v4_0_30319.System },
});
var c = CreateSubmissionWithExactReferences("public interface C : A, B { System.Diagnostics.Process PC { get; } }", new[] { MscorlibRef_v4_0_30316_17626, aRef, bRef },
options.WithMetadataReferenceResolver(resolverC));
c.VerifyEmitDiagnostics();
resolverC.VerifyResolutionAttempts(
"B -> System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"System.dll -> System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
"System.dll -> System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"A -> System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"System.dll -> System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
"System.dll -> System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
c.VerifyAssemblyVersionsAndAliases(
"mscorlib, Version=4.0.0.0",
"A, Version=0.0.0.0",
"B, Version=0.0.0.0",
"System, Version=4.0.0.0",
"System, Version=2.0.0.0: <superseded>");
}
示例14: MissingAssemblyResolution_BindingToForExplicitReference1
public void MissingAssemblyResolution_BindingToForExplicitReference1()
{
// c - a -> "b,v1"
// - "b,v3"
//
var b1Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class B { }", options: s_signedDll, assemblyName: "B").EmitToImageReference();
var b2Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""2.0.0.0"")] public class B { }", options: s_signedDll, assemblyName: "B").EmitToImageReference();
var b3Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""3.0.0.0"")] public class B { }", options: s_signedDll, assemblyName: "B").EmitToImageReference();
var aRef = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""1.0.0.0"")] public class A : B { }", new[] { b1Ref }, options: s_signedDll, assemblyName: "A").EmitToImageReference();
var resolver = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>
{
// the compiler asked for v1, but we have v2
{ "B, 1.0.0.0", b2Ref }
});
var c = CreateCompilationWithMscorlib("public class C : A { }", new[] { aRef, b3Ref },
s_signedDll.WithMetadataReferenceResolver(resolver));
c.VerifyEmitDiagnostics(
// (1,18): warning CS1701: Assuming assembly reference
// 'B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2' used by 'A' matches identity
// 'B, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2' of 'B', you may need to supply runtime policy
Diagnostic(ErrorCode.WRN_UnifyReferenceMajMin, "A").WithArguments(
"B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "A",
"B, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "B"));
Assert.Equal(
"B, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2",
((AssemblySymbol)c.GetAssemblyOrModuleSymbol(b3Ref)).Identity.GetDisplayName());
Assert.Null((AssemblySymbol)c.GetAssemblyOrModuleSymbol(b2Ref));
resolver.VerifyResolutionAttempts();
}
示例15: MissingAssemblyResolution_Aliases
public void MissingAssemblyResolution_Aliases()
{
// c - a -> b with alias X
var bRef = CreateCompilationWithMscorlib("public class B { }", assemblyName: "B").EmitToImageReference();
var aRef = CreateCompilationWithMscorlib("public class A : B { }", new[] { bRef }, assemblyName: "A").EmitToImageReference();
var resolver = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference>
{
{ "B", bRef.WithAliases(ImmutableArray.Create("X")) }
});
var c = CreateCompilationWithMscorlib(@"
extern alias X;
public class C : A
{
X::B F() => null;
}
", new[] { aRef }, TestOptions.ReleaseDll.WithMetadataReferenceResolver(resolver));
c.VerifyEmitDiagnostics();
resolver.VerifyResolutionAttempts(
"A -> B, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
}