当前位置: 首页>>代码示例>>C#>>正文


C# MetadataReference.Concat方法代码示例

本文整理汇总了C#中MetadataReference.Concat方法的典型用法代码示例。如果您正苦于以下问题:C# MetadataReference.Concat方法的具体用法?C# MetadataReference.Concat怎么用?C# MetadataReference.Concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MetadataReference的用法示例。


在下文中一共展示了MetadataReference.Concat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PortableLibrary

        public void PortableLibrary()
        {
            var mscorlibPP7 = new MetadataImageReference(ProprietaryTestResources.NetFX.ReferenceAssemblies_PortableProfile7.mscorlib, display: "mscorlib, PP7");
            var systemRuntimePP7 = new MetadataImageReference(ProprietaryTestResources.NetFX.ReferenceAssemblies_PortableProfile7.System_Runtime, display: "System.Runtime, PP7");

            var plSource = @"public class C {}";
            var pl = CreateCompilation(plSource, new[] { mscorlibPP7, systemRuntimePP7 });

            var dir = Temp.CreateDirectory();
            var mscorlibFile = dir.CreateFile("mscorlib.dll").WriteAllBytes(ProprietaryTestResources.NetFX.ReferenceAssemblies_V45.mscorlib);
            
            var mainRefs = new MetadataReference[] 
            {
                new CSharpCompilationReference(pl), 
                new MetadataFileReference(mscorlibFile.Path, MetadataReferenceProperties.Assembly)
            };

            var mainSource = @"public class D : C { }";
           
            // w/o facades:

            var main = CreateCompilation(mainSource, mainRefs);
            main.VerifyDiagnostics(
                // (1,18): error CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
                Diagnostic(ErrorCode.ERR_NoTypeDef, "C").WithArguments("System.Object", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"));

            // empty facades directory:

            main.VerifyDiagnostics(
                // (1,18): error CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
                Diagnostic(ErrorCode.ERR_NoTypeDef, "C").WithArguments("System.Object", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"));

            // System.Runtime facade present:
            var facades = dir.CreateDirectory("Facades");
            var systemRuntimeFacade = facades.CreateFile("System.Runtime.dll").WriteAllBytes(ProprietaryTestResources.NetFX.ReferenceAssemblies_V45_Facades.System_Runtime);

            main = CreateCompilation(mainSource, mainRefs);
            main.VerifyDiagnostics();

            var expectedReferences = new string[] 
            { 
                "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", 
                pl.AssemblyName + ", Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", 
                "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            };

            AssertEx.Equal(expectedReferences, main.ReferencedAssemblyNames.Select(n => n.GetDisplayName()));
            AssertEx.Equal(expectedReferences, main.GetBoundReferenceManager().ReferencedAssembliesMap.Values.Select(ra => ra.Symbol.Identity.GetDisplayName()));


            // facade explicitly specified:

            main = CreateCompilation(mainSource, mainRefs.Concat(new[] { new MetadataFileReference(systemRuntimeFacade.Path, MetadataReferenceProperties.Assembly) }));
            main.VerifyDiagnostics();
        }
开发者ID:nagyist,项目名称:roslyn,代码行数:55,代码来源:ReferenceManagerTests.cs

示例2: PortableLibrary

        public void PortableLibrary()
        {
            var mscorlibPP7 = AssemblyMetadata.CreateFromImage(ProprietaryTestResources.NetFX.ReferenceAssemblies_PortableProfile7.mscorlib).GetReference(display: "mscorlib, PP7");
            var systemRuntimePP7 = AssemblyMetadata.CreateFromImage(ProprietaryTestResources.NetFX.ReferenceAssemblies_PortableProfile7.System_Runtime).GetReference(display: "System.Runtime, PP7");
            var systemRuntimeFacade = AssemblyMetadata.CreateFromImage(ProprietaryTestResources.NetFX.ReferenceAssemblies_V45_Facades.System_Runtime).GetReference(display: "System.Runtime, facade");

            var plSource = @"public class C {}";
            var pl = CreateCompilation(plSource, new[] { mscorlibPP7, systemRuntimePP7 });

            var mainRefs = new MetadataReference[]
            {
                new CSharpCompilationReference(pl),
                MetadataReference.CreateFromImage(ProprietaryTestResources.NetFX.ReferenceAssemblies_V45.mscorlib)
            };

            var mainSource = @"public class D : C { }";

            // w/o facades:

            var main = CreateCompilation(mainSource, mainRefs, options: TestOptions.ReleaseDll);

            main.VerifyDiagnostics(
                // (1,18): error CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
                Diagnostic(ErrorCode.ERR_NoTypeDef, "C").WithArguments("System.Object", "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"));

            // facade specified:

            main = CreateCompilation(mainSource, mainRefs.Concat(new[] { systemRuntimeFacade }));
            main.VerifyDiagnostics();
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:30,代码来源:ReferenceManagerTests.cs

示例3: GetSymbolsForReferences

 internal static AssemblySymbol[] GetSymbolsForReferences(MetadataReference[] mrefs, Compilation[] compilations)
 {
     return GetSymbolsForReferences(
         mrefs: mrefs.Concat(compilations.Select(c => c.ToMetadataReference())).ToArray());
 }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:5,代码来源:MetadataTestHelpers.cs


注:本文中的MetadataReference.Concat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。