本文整理汇总了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();
}
示例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();
}
示例3: GetSymbolsForReferences
internal static AssemblySymbol[] GetSymbolsForReferences(MetadataReference[] mrefs, Compilation[] compilations)
{
return GetSymbolsForReferences(
mrefs: mrefs.Concat(compilations.Select(c => c.ToMetadataReference())).ToArray());
}