public void MissingAssemblyResolution_BindingToImplicitReference2() { // 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 b3Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""3.0.0.0"")] public interface B { }", options: s_signedDll, assemblyName: "B").EmitToImageReference(); var b4Ref = CreateCompilationWithMscorlib(@"[assembly: System.Reflection.AssemblyVersion(""4.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", b3Ref }, { "B, 2.0.0.0", b4Ref }, }); var c = CreateCompilationWithMscorlib("public class C : A { }", new[] { aRef }, s_signedDll.WithMetadataReferenceResolver(resolverC)); c.VerifyEmitDiagnostics( // (1,14): warning CS1701: Assuming assembly reference // 'B, Version=2.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, "C").WithArguments( "B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "A", "B, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "B"), // (1,14): warning CS1701: Assuming assembly reference // 'B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2' used by 'D' 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, "C").WithArguments( "B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "D", "B, Version=3.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=3.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=3.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "B")); AssertEx.Equal(new[] { "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "A, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "D, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "B, Version=4.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "E, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "B, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2" }, c.GetBoundReferenceManager().ReferencedAssemblies.Select(a => a.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"); }
public void MissingAssemblyResolution_BindingToExplicitReference_WorseVersion() { // c - a -> d -> "b,v2" // e -> "b,v1" // - "b,v1" 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, b1Ref }, s_signedDll.WithMetadataReferenceResolver(resolverC)); c.VerifyEmitDiagnostics( // (1,14): error CS1705: Assembly // 'A' with identity 'A, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2' uses // 'B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2' which has a higher version than referenced assembly // 'B' with identity 'B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2' Diagnostic(ErrorCode.ERR_AssemblyMatchBadVersion, "C").WithArguments( "A", "A, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "B", "B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2"), // (1,14): error CS1705: Assembly // 'D' with identity 'D, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2' uses // 'B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2' which has a higher version than referenced assembly // 'B' with identity 'B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2' Diagnostic(ErrorCode.ERR_AssemblyMatchBadVersion, "C").WithArguments( "D", "D, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "B", "B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2")); resolverC.VerifyResolutionAttempts( "A -> D, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "A -> E, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2"); }
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"); }
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"); }
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(); }
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"); }
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"); }
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"); }
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(); }
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"); }
public void MissingAssemblyResolution_AliasesMerge() { // c - a -> "b, V1" resolved to "b, V3" with alias X // - d -> "b, V2" resolved to "b, V3" with alias Y 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("public class A : B { }", new[] { b1Ref }, assemblyName: "A").EmitToImageReference(); var dRef = CreateCompilationWithMscorlib("public class D : B { }", new[] { b2Ref }, assemblyName: "D").EmitToImageReference(); var b3RefX = b3Ref.WithAliases(ImmutableArray.Create("X")); var b3RefY = b3Ref.WithAliases(ImmutableArray.Create("Y")); var resolver = new TestMissingMetadataReferenceResolver(new Dictionary<string, MetadataReference> { { "B, 1.0.0.0", b3RefX }, { "B, 2.0.0.0", b3RefY }, }); var c = CreateCompilationWithMscorlib(@" extern alias X; extern alias Y; public class C : A { X::B F() => new Y::B(); } ", new[] { aRef, dRef }, TestOptions.ReleaseDll.WithMetadataReferenceResolver(resolver)); c.VerifyEmitDiagnostics( // (5,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", ((AssemblySymbol)c.GetAssemblyOrModuleSymbol(b3RefY)).Name); Assert.Null(c.GetAssemblyOrModuleSymbol(b3RefX)); resolver.VerifyResolutionAttempts( "D -> B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2", "A -> B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ce65828c82a341f2"); }
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"); }
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"); }
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>"); }
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>"); }
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 = CreateSubmission(@"public interface C : A, D { }", new[] { aRef, dRef }, TestOptions.ReleaseDll.WithMetadataReferenceResolver(resolver)); c.VerifyEmitDiagnostics(); resolver.VerifyResolutionAttempts( "D -> B, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null", "A -> B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); c.VerifyAssemblyVersionsAndAliases( "mscorlib, Version=4.0.0.0", "A, Version=0.0.0.0", "D, Version=0.0.0.0", "B, Version=4.0.0.0", "B, Version=3.0.0.0: <superseded>"); }