public void MetadataImageReference_Module_WithXxx() { var doc = new TestDocumentationProvider(); var module = ModuleMetadata.CreateFromImage(TestResources.SymbolsTests.General.C1); var r = new MetadataImageReference(module, fullPath: @"c:\temp", display: "hello", documentation: doc); Assert.Same(doc, r.DocumentationProvider); Assert.Same(doc, r.DocumentationProvider); Assert.NotNull(r.GetMetadata()); Assert.Equal(false, r.Properties.EmbedInteropTypes); Assert.Equal(MetadataImageKind.Module, r.Properties.Kind); Assert.True(r.Properties.Aliases.IsDefault); Assert.Equal(@"c:\temp", r.FullPath); var r1 = r.WithAliases(default(ImmutableArray <string>)); Assert.Same(r, r1); var r2 = r.WithEmbedInteropTypes(false); Assert.Same(r, r2); var r3 = r.WithDocumentationProvider(doc); Assert.Same(r, r3); Assert.Throws <ArgumentException>(() => r.WithAliases(new[] { "bar" })); Assert.Throws <ArgumentException>(() => r.WithEmbedInteropTypes(true)); }
public void Module_WithXxx() { var doc = new TestDocumentationProvider(); var module = ModuleMetadata.CreateFromImage(TestResources.General.C1); var r = module.GetReference(filePath: @"c:\temp", display: "hello", documentation: doc); Assert.Same(doc, r.DocumentationProvider); Assert.Same(doc, r.DocumentationProvider); Assert.NotNull(r.GetMetadataNoCopy()); Assert.False(r.Properties.EmbedInteropTypes); Assert.Equal(MetadataImageKind.Module, r.Properties.Kind); Assert.True(r.Properties.Aliases.IsEmpty); Assert.Equal(@"c:\temp", r.FilePath); var r1 = r.WithAliases(default(ImmutableArray <string>)); Assert.Same(r, r1); Assert.Equal(@"c:\temp", r1.FilePath); var r2 = r.WithEmbedInteropTypes(false); Assert.Same(r, r2); Assert.Equal(@"c:\temp", r2.FilePath); var r3 = r.WithProperties(new MetadataReferenceProperties(MetadataImageKind.Module)); Assert.Same(r, r3); var r4 = r.WithProperties(new MetadataReferenceProperties(MetadataImageKind.Assembly)); Assert.Equal(MetadataImageKind.Assembly, r4.Properties.Kind); Assert.Throws <ArgumentException>(() => r.WithAliases(new[] { "bar" })); Assert.Throws <ArgumentException>(() => r.WithEmbedInteropTypes(true)); }
public void DocCommentProvider() { var docProvider = new TestDocumentationProvider(); var corlib = AssemblyMetadata .CreateFromImage(ResourcesNet451.mscorlib) .GetReference(display: "corlib", documentation: docProvider); var comp = (Compilation)CS.CSharpCompilation.Create( "goo", syntaxTrees: new[] { CS.SyntaxFactory.ParseSyntaxTree("class C : System.Collections.ArrayList { }") }, references: new[] { corlib } ); var c = (ITypeSymbol)comp.GlobalNamespace.GetMembers("C").Single(); var list = c.BaseType; var summary = list.GetDocumentationCommentXml(); Assert.Equal( "<member name='T:System.Collections.ArrayList'><summary>T:System.Collections.ArrayList</summary></member>", summary ); }
public void MetadataImageReference_Module_WithXxx() { var doc = new TestDocumentationProvider(); var module = ModuleMetadata.CreateFromImage(TestResources.SymbolsTests.General.C1); var r = new MetadataImageReference(module, filePath: @"c:\temp", display: "hello", documentation: doc); Assert.Same(doc, r.DocumentationProvider); Assert.Same(doc, r.DocumentationProvider); Assert.NotNull(r.GetMetadata()); Assert.Equal(false, r.Properties.EmbedInteropTypes); Assert.Equal(MetadataImageKind.Module, r.Properties.Kind); Assert.True(r.Properties.Aliases.IsDefault); Assert.Equal(@"c:\temp", r.FilePath); var r1 = r.WithAliases(default(ImmutableArray<string>)); Assert.Same(r, r1); var r2 = r.WithEmbedInteropTypes(false); Assert.Same(r, r2); var r3 = r.WithDocumentationProvider(doc); Assert.Same(r, r3); Assert.Throws<ArgumentException>(() => r.WithAliases(new[] { "bar" })); Assert.Throws<ArgumentException>(() => r.WithEmbedInteropTypes(true)); }
public void MetadataImageReference_Assembly_WithXxx() { var doc = new TestDocumentationProvider(); var assembly = AssemblyMetadata.CreateFromImage(TestResources.SymbolsTests.General.C1); var r = new MetadataImageReference( assembly, documentation: doc, aliases: ImmutableArray.Create("a"), embedInteropTypes: true, fullPath: @"c:\temp", display: "hello"); Assert.Same(doc, r.DocumentationProvider); Assert.Same(doc, r.DocumentationProvider); Assert.NotNull(r.GetMetadata()); Assert.Equal(true, r.Properties.EmbedInteropTypes); Assert.Equal(MetadataImageKind.Assembly, r.Properties.Kind); AssertEx.Equal(new[] { "a" }, r.Properties.Aliases); Assert.Equal(@"c:\temp", r.FullPath); var r2 = r.WithEmbedInteropTypes(true); Assert.Equal(r, r2); var r3 = r.WithAliases(ImmutableArray.Create("b", "c")); Assert.Same(r.DocumentationProvider, r3.DocumentationProvider); Assert.Same(r.GetMetadata(), r3.GetMetadata()); Assert.Equal(r.Properties.EmbedInteropTypes, r3.Properties.EmbedInteropTypes); Assert.Equal(r.Properties.Kind, r3.Properties.Kind); AssertEx.Equal(new[] { "b", "c" }, r3.Properties.Aliases); Assert.Equal(r.FullPath, r3.FullPath); var r4 = r.WithEmbedInteropTypes(false); Assert.Same(r.DocumentationProvider, r4.DocumentationProvider); Assert.Same(r.GetMetadata(), r4.GetMetadata()); Assert.Equal(false, r4.Properties.EmbedInteropTypes); Assert.Equal(r.Properties.Kind, r4.Properties.Kind); AssertEx.Equal(r.Properties.Aliases, r4.Properties.Aliases); Assert.Equal(r.FullPath, r4.FullPath); Assert.Throws <ArgumentNullException>(() => r.WithDocumentationProvider(null)); Assert.Same(r, r.WithDocumentationProvider(r.DocumentationProvider)); var doc2 = new TestDocumentationProvider(); var r5 = r.WithDocumentationProvider(doc2); Assert.Same(doc2, r5.DocumentationProvider); Assert.Same(r.GetMetadata(), r5.GetMetadata()); Assert.Equal(r.Properties.EmbedInteropTypes, r5.Properties.EmbedInteropTypes); Assert.Equal(r.Properties.Kind, r5.Properties.Kind); AssertEx.Equal(r.Properties.Aliases, r5.Properties.Aliases); Assert.Equal(r.FullPath, r5.FullPath); }
public void Assembly_WithXxx() { var doc = new TestDocumentationProvider(); var assembly = AssemblyMetadata.CreateFromImage(TestResources.General.C1); var r = assembly.GetReference( documentation: doc, aliases: ImmutableArray.Create("a"), embedInteropTypes: true, filePath: @"c:\temp", display: "hello"); Assert.Same(doc, r.DocumentationProvider); Assert.Same(doc, r.DocumentationProvider); Assert.NotNull(r.GetMetadataNoCopy()); Assert.True(r.Properties.EmbedInteropTypes); Assert.Equal(MetadataImageKind.Assembly, r.Properties.Kind); AssertEx.Equal(new[] { "a" }, r.Properties.Aliases); Assert.Equal(@"c:\temp", r.FilePath); var r2 = r.WithEmbedInteropTypes(true); Assert.Equal(r, r2); Assert.Equal(@"c:\temp", r2.FilePath); var r3 = r.WithAliases(ImmutableArray.Create("b", "c")); Assert.Same(r.DocumentationProvider, r3.DocumentationProvider); Assert.Same(r.GetMetadataNoCopy(), r3.GetMetadataNoCopy()); Assert.Equal(r.Properties.EmbedInteropTypes, r3.Properties.EmbedInteropTypes); Assert.Equal(r.Properties.Kind, r3.Properties.Kind); AssertEx.Equal(new[] { "b", "c" }, r3.Properties.Aliases); Assert.Equal(r.FilePath, r3.FilePath); var r4 = r.WithEmbedInteropTypes(false); Assert.Same(r.DocumentationProvider, r4.DocumentationProvider); Assert.Same(r.GetMetadataNoCopy(), r4.GetMetadataNoCopy()); Assert.False(r4.Properties.EmbedInteropTypes); Assert.Equal(r.Properties.Kind, r4.Properties.Kind); AssertEx.Equal(r.Properties.Aliases, r4.Properties.Aliases); Assert.Equal(r.FilePath, r4.FilePath); var r5 = r.WithProperties(new MetadataReferenceProperties(MetadataImageKind.Module)); Assert.Equal(MetadataImageKind.Module, r5.Properties.Kind); Assert.True(r5.Properties.Aliases.IsEmpty); Assert.False(r5.Properties.EmbedInteropTypes); var r6 = r.WithProperties(new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray.Create("x"), embedInteropTypes: true)); Assert.Equal(MetadataImageKind.Assembly, r6.Properties.Kind); AssertEx.Equal(new[] { "x" }, r6.Properties.Aliases); Assert.True(r6.Properties.EmbedInteropTypes); }
public void CreateFromAssembly_WithPropertiesAndDocumentation() { var doc = new TestDocumentationProvider(); var assembly = typeof(object).Assembly; var r = (PortableExecutableReference)MetadataReference.CreateFromAssemblyInternal(assembly, new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray.Create("a", "b"), embedInteropTypes: true), documentation: doc); Assert.Equal(assembly.Location, r.FilePath); Assert.Equal(assembly.Location, r.Display); Assert.Equal(MetadataImageKind.Assembly, r.Properties.Kind); Assert.True(r.Properties.EmbedInteropTypes); AssertEx.Equal(ImmutableArray.Create("a", "b"), r.Properties.Aliases); Assert.Same(doc, r.DocumentationProvider); }
public void DocCommentProvider() { var docProvider = new TestDocumentationProvider(); var corlib = new MetadataImageReference( ProprietaryTestResources.NetFX.v4_0_30319.mscorlib.AsImmutableOrNull(), display: "corlib", documentation: docProvider); var comp = CS.CSharpCompilation.Create("foo", syntaxTrees: new[] { CS.SyntaxFactory.ParseSyntaxTree("class C : System.Collections.ArrayList { }") }, references: new[] { corlib }); var c = (ITypeSymbol)comp.GlobalNamespace.GetMembers("C").Single(); var list = c.BaseType; var summary = list.GetDocumentationCommentXml(); Assert.Equal("<member name='T:System.Collections.ArrayList'><summary>T:System.Collections.ArrayList</summary></member>", summary); }
public void DocCommentProvider() { var docProvider = new TestDocumentationProvider(); var corlib = AssemblyMetadata.CreateFromImage(ProprietaryTestResources.NetFX.v4_0_30319.mscorlib). GetReference(display: "corlib", documentation: docProvider); var comp = CS.CSharpCompilation.Create("foo", syntaxTrees: new[] { CS.SyntaxFactory.ParseSyntaxTree("class C : System.Collections.ArrayList { }") }, references: new[] { corlib }); var c = (ITypeSymbol)comp.GlobalNamespace.GetMembers("C").Single(); var list = c.BaseType; var summary = list.GetDocumentationCommentXml(); Assert.Equal("<member name='T:System.Collections.ArrayList'><summary>T:System.Collections.ArrayList</summary></member>", summary); }
public void Assembly_WithXxx() { var doc = new TestDocumentationProvider(); var assembly = AssemblyMetadata.CreateFromImage(TestResources.SymbolsTests.General.C1); var r = assembly.GetReference( documentation: doc, aliases: ImmutableArray.Create("a"), embedInteropTypes: true, filePath: @"c:\temp", display: "hello"); Assert.Same(doc, r.DocumentationProvider); Assert.Same(doc, r.DocumentationProvider); Assert.NotNull(r.GetMetadata()); Assert.Equal(true, r.Properties.EmbedInteropTypes); Assert.Equal(MetadataImageKind.Assembly, r.Properties.Kind); AssertEx.Equal(new[] { "a" }, r.Properties.Aliases); Assert.Equal(@"c:\temp", r.FilePath); var r2 = r.WithEmbedInteropTypes(true); Assert.Equal(r, r2); Assert.Equal(@"c:\temp", r2.FilePath); var r3 = r.WithAliases(ImmutableArray.Create("b", "c")); Assert.Same(r.DocumentationProvider, r3.DocumentationProvider); Assert.Same(r.GetMetadata(), r3.GetMetadata()); Assert.Equal(r.Properties.EmbedInteropTypes, r3.Properties.EmbedInteropTypes); Assert.Equal(r.Properties.Kind, r3.Properties.Kind); AssertEx.Equal(new[] { "b", "c" }, r3.Properties.Aliases); Assert.Equal(r.FilePath, r3.FilePath); var r4 = r.WithEmbedInteropTypes(false); Assert.Same(r.DocumentationProvider, r4.DocumentationProvider); Assert.Same(r.GetMetadata(), r4.GetMetadata()); Assert.Equal(false, r4.Properties.EmbedInteropTypes); Assert.Equal(r.Properties.Kind, r4.Properties.Kind); AssertEx.Equal(r.Properties.Aliases, r4.Properties.Aliases); Assert.Equal(r.FilePath, r4.FilePath); var r5 = r.WithProperties(new MetadataReferenceProperties(MetadataImageKind.Module)); Assert.Equal(MetadataImageKind.Module, r5.Properties.Kind); Assert.True(r5.Properties.Aliases.IsEmpty); Assert.False(r5.Properties.EmbedInteropTypes); var r6 = r.WithProperties(new MetadataReferenceProperties(MetadataImageKind.Assembly, ImmutableArray.Create("x"), embedInteropTypes: true)); Assert.Equal(MetadataImageKind.Assembly, r6.Properties.Kind); AssertEx.Equal(new[] { "x" }, r6.Properties.Aliases); Assert.True(r6.Properties.EmbedInteropTypes); }
public void MetadataImageReference_Assembly_WithXxx() { var doc = new TestDocumentationProvider(); var assembly = AssemblyMetadata.CreateFromImage(TestResources.SymbolsTests.General.C1); var r = new MetadataImageReference( assembly, documentation: doc, aliases: ImmutableArray.Create("a"), embedInteropTypes: true, filePath: @"c:\temp", display: "hello"); Assert.Same(doc, r.DocumentationProvider); Assert.Same(doc, r.DocumentationProvider); Assert.NotNull(r.GetMetadata()); Assert.Equal(true, r.Properties.EmbedInteropTypes); Assert.Equal(MetadataImageKind.Assembly, r.Properties.Kind); AssertEx.Equal(new[] { "a" }, r.Properties.Aliases); Assert.Equal(@"c:\temp", r.FilePath); var r2 = r.WithEmbedInteropTypes(true); Assert.Equal(r, r2); var r3 = r.WithAliases(ImmutableArray.Create("b", "c")); Assert.Same(r.DocumentationProvider, r3.DocumentationProvider); Assert.Same(r.GetMetadata(), r3.GetMetadata()); Assert.Equal(r.Properties.EmbedInteropTypes, r3.Properties.EmbedInteropTypes); Assert.Equal(r.Properties.Kind, r3.Properties.Kind); AssertEx.Equal(new[] { "b", "c" }, r3.Properties.Aliases); Assert.Equal(r.FilePath, r3.FilePath); var r4 = r.WithEmbedInteropTypes(false); Assert.Same(r.DocumentationProvider, r4.DocumentationProvider); Assert.Same(r.GetMetadata(), r4.GetMetadata()); Assert.Equal(false, r4.Properties.EmbedInteropTypes); Assert.Equal(r.Properties.Kind, r4.Properties.Kind); AssertEx.Equal(r.Properties.Aliases, r4.Properties.Aliases); Assert.Equal(r.FilePath, r4.FilePath); Assert.Throws<ArgumentNullException>(() => r.WithDocumentationProvider(null)); Assert.Same(r, r.WithDocumentationProvider(r.DocumentationProvider)); var doc2 = new TestDocumentationProvider(); var r5 = r.WithDocumentationProvider(doc2); Assert.Same(doc2, r5.DocumentationProvider); Assert.Same(r.GetMetadata(), r5.GetMetadata()); Assert.Equal(r.Properties.EmbedInteropTypes, r5.Properties.EmbedInteropTypes); Assert.Equal(r.Properties.Kind, r5.Properties.Kind); AssertEx.Equal(r.Properties.Aliases, r5.Properties.Aliases); Assert.Equal(r.FilePath, r5.FilePath); }