public void ErrorInfo_01() { var error = new MissingMetadataTypeSymbol.Nested(new UnsupportedMetadataTypeSymbol(), "Test", 0, false); var info = error.ErrorInfo; Assert.Equal(ErrorCode.ERR_BogusType, (ErrorCode)info.Code); Assert.Null(error.ContainingModule); Assert.Null(error.ContainingAssembly); Assert.NotNull(error.ContainingSymbol); }
public void Equality() { var assemblies = MetadataTestHelpers.GetSymbolsForReferences(new[] { TestReferences.SymbolsTests.MissingTypes.MissingTypesEquality1, TestReferences.SymbolsTests.MissingTypes.MissingTypesEquality2, TestReferences.SymbolsTests.MDTestLib1, TestReferences.SymbolsTests.MDTestLib2 }); var asm1 = assemblies[0]; var asm1classC = asm1.GlobalNamespace.GetTypeMembers("C").Single(); var asm1m1 = asm1classC.GetMembers("M1").OfType <MethodSymbol>().Single(); var asm1m2 = asm1classC.GetMembers("M2").OfType <MethodSymbol>().Single(); var asm1m3 = asm1classC.GetMembers("M3").OfType <MethodSymbol>().Single(); var asm1m4 = asm1classC.GetMembers("M4").OfType <MethodSymbol>().Single(); var asm1m5 = asm1classC.GetMembers("M5").OfType <MethodSymbol>().Single(); var asm1m6 = asm1classC.GetMembers("M6").OfType <MethodSymbol>().Single(); var asm1m7 = asm1classC.GetMembers("M7").OfType <MethodSymbol>().Single(); var asm1m8 = asm1classC.GetMembers("M8").OfType <MethodSymbol>().Single(); Assert.NotEqual(asm1m2.ReturnType, asm1m1.ReturnType); Assert.NotEqual(asm1m3.ReturnType, asm1m1.ReturnType); Assert.NotEqual(asm1m4.ReturnType, asm1m1.ReturnType); Assert.NotEqual(asm1m5.ReturnType, asm1m4.ReturnType); Assert.NotEqual(asm1m6.ReturnType, asm1m4.ReturnType); Assert.Equal(asm1m7.ReturnType, asm1m1.ReturnType); Assert.Equal(asm1m8.ReturnType, asm1m4.ReturnType); var asm2 = assemblies[1]; var asm2classC = asm2.GlobalNamespace.GetTypeMembers("C").Single(); var asm2m1 = asm2classC.GetMembers("M1").OfType <MethodSymbol>().Single(); var asm2m4 = asm2classC.GetMembers("M4").OfType <MethodSymbol>().Single(); Assert.Equal(asm2m1.ReturnType, asm1m1.ReturnType); Assert.NotSame(asm1m4.ReturnType, asm2m4.ReturnType); Assert.Equal(asm2m4.ReturnType, asm1m4.ReturnType); Assert.Equal(asm1.GetSpecialType(SpecialType.System_Boolean), asm1.GetSpecialType(SpecialType.System_Boolean)); Assert.Equal(asm1.GetSpecialType(SpecialType.System_Boolean), asm2.GetSpecialType(SpecialType.System_Boolean)); MissingMetadataTypeSymbol[] missingTypes1 = new MissingMetadataTypeSymbol[15]; MissingMetadataTypeSymbol[] missingTypes2 = new MissingMetadataTypeSymbol[15]; var defaultName = new AssemblyIdentity("missing"); missingTypes1[0] = new MissingMetadataTypeSymbol.TopLevel(new MissingAssemblySymbol(defaultName).Modules[0], "", "test1", 0, true); missingTypes1[1] = new MissingMetadataTypeSymbol.TopLevel(new MissingAssemblySymbol(defaultName).Modules[0], "", "test1", 1, true); missingTypes1[2] = new MissingMetadataTypeSymbol.TopLevel(new MissingAssemblySymbol(defaultName).Modules[0], "", "test2", 0, true); missingTypes1[3] = new MissingMetadataTypeSymbol.TopLevel(new MissingAssemblySymbol(new AssemblyIdentity("asm1")).Modules[0], "", "test1", 0, true); missingTypes1[4] = new MissingMetadataTypeSymbol.TopLevel(new MissingAssemblySymbol(new AssemblyIdentity("asm1")).Modules[0], "", "test1", 1, true); missingTypes1[5] = new MissingMetadataTypeSymbol.TopLevel(new MissingAssemblySymbol(new AssemblyIdentity("asm1")).Modules[0], "", "test2", 0, true); missingTypes1[6] = new MissingMetadataTypeSymbol.TopLevel(new MissingAssemblySymbol(new AssemblyIdentity("asm2")).Modules[0], "", "test1", 0, true); missingTypes1[7] = new MissingMetadataTypeSymbol.TopLevel(asm1.Modules[0], "", "test1", 0, true); missingTypes1[8] = new MissingMetadataTypeSymbol.TopLevel(asm1.Modules[0], "", "test1", 1, true); missingTypes1[9] = new MissingMetadataTypeSymbol.TopLevel(asm1.Modules[0], "", "test2", 0, true); missingTypes1[10] = new MissingMetadataTypeSymbol.TopLevel(asm2.Modules[0], "", "test1", 0, true); missingTypes1[11] = new MissingMetadataTypeSymbol.Nested(asm1classC, "test1", 0, true); missingTypes1[12] = new MissingMetadataTypeSymbol.Nested(asm1classC, "test1", 1, true); missingTypes1[13] = new MissingMetadataTypeSymbol.Nested(asm1classC, "test2", 0, true); missingTypes1[14] = new MissingMetadataTypeSymbol.Nested(asm2classC, "test1", 0, true); missingTypes2[0] = new MissingMetadataTypeSymbol.TopLevel(new MissingAssemblySymbol(defaultName).Modules[0], "", "test1", 0, true); missingTypes2[1] = new MissingMetadataTypeSymbol.TopLevel(new MissingAssemblySymbol(defaultName).Modules[0], "", "test1", 1, true); missingTypes2[2] = new MissingMetadataTypeSymbol.TopLevel(new MissingAssemblySymbol(defaultName).Modules[0], "", "test2", 0, true); missingTypes2[3] = new MissingMetadataTypeSymbol.TopLevel(new MissingAssemblySymbol(new AssemblyIdentity("asm1")).Modules[0], "", "test1", 0, true); missingTypes2[4] = new MissingMetadataTypeSymbol.TopLevel(new MissingAssemblySymbol(new AssemblyIdentity("asm1")).Modules[0], "", "test1", 1, true); missingTypes2[5] = new MissingMetadataTypeSymbol.TopLevel(new MissingAssemblySymbol(new AssemblyIdentity("asm1")).Modules[0], "", "test2", 0, true); missingTypes2[6] = new MissingMetadataTypeSymbol.TopLevel(new MissingAssemblySymbol(new AssemblyIdentity("asm2")).Modules[0], "", "test1", 0, true); missingTypes2[7] = new MissingMetadataTypeSymbol.TopLevel(asm1.Modules[0], "", "test1", 0, true); missingTypes2[8] = new MissingMetadataTypeSymbol.TopLevel(asm1.Modules[0], "", "test1", 1, true); missingTypes2[9] = new MissingMetadataTypeSymbol.TopLevel(asm1.Modules[0], "", "test2", 0, true); missingTypes2[10] = new MissingMetadataTypeSymbol.TopLevel(asm2.Modules[0], "", "test1", 0, true); missingTypes2[11] = new MissingMetadataTypeSymbol.Nested(asm1classC, "test1", 0, true); missingTypes2[12] = new MissingMetadataTypeSymbol.Nested(asm1classC, "test1", 1, true); missingTypes2[13] = new MissingMetadataTypeSymbol.Nested(asm1classC, "test2", 0, true); missingTypes2[14] = new MissingMetadataTypeSymbol.Nested(asm2classC, "test1", 0, true); for (int i = 0; i < missingTypes1.Length; i++) { for (int j = 0; j < missingTypes2.Length; j++) { if (i == j) { Assert.Equal(missingTypes2[j], missingTypes1[i]); Assert.Equal(missingTypes1[i], missingTypes2[j]); } else { Assert.NotEqual(missingTypes2[j], missingTypes1[i]); Assert.NotEqual(missingTypes1[i], missingTypes2[j]); } } } var missingAssembly = new MissingAssemblySymbol(new AssemblyIdentity("asm1")); Assert.True(missingAssembly.Equals(missingAssembly)); Assert.NotEqual(new object(), missingAssembly); Assert.False(missingAssembly.Equals(null)); }