本文整理汇总了C#中Microsoft.CodeAnalysis.MetadataReferenceResolver类的典型用法代码示例。如果您正苦于以下问题:C# MetadataReferenceResolver类的具体用法?C# MetadataReferenceResolver怎么用?C# MetadataReferenceResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetadataReferenceResolver类属于Microsoft.CodeAnalysis命名空间,在下文中一共展示了MetadataReferenceResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ResolveMetadataReferences
/// <summary>
/// Resolves metadata references stored in command line arguments and reports errors for those that can't be resolved.
/// </summary>
internal List<MetadataReference> ResolveMetadataReferences(
List<DiagnosticInfo> diagnostics,
TouchedFileLogger touchedFiles,
out MetadataReferenceResolver referenceDirectiveResolver)
{
var commandLineReferenceResolver = GetCommandLineMetadataReferenceResolver(touchedFiles);
List<MetadataReference> resolved = new List<MetadataReference>();
Arguments.ResolveMetadataReferences(commandLineReferenceResolver, diagnostics, this.MessageProvider, resolved);
if (Arguments.IsScriptRunner)
{
referenceDirectiveResolver = commandLineReferenceResolver;
}
else
{
// when compiling into an assembly (csc/vbc) we only allow #r that match references given on command line:
referenceDirectiveResolver = new ExistingReferencesResolver(commandLineReferenceResolver, resolved.ToImmutableArray());
}
return resolved;
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:25,代码来源:CommonCompiler.cs
示例2: CompilationOptions
// Expects correct arguments.
internal CompilationOptions(
OutputKind outputKind,
bool reportSuppressedDiagnostics,
string moduleName,
string mainTypeName,
string scriptClassName,
string cryptoKeyContainer,
string cryptoKeyFile,
ImmutableArray<byte> cryptoPublicKey,
bool? delaySign,
OptimizationLevel optimizationLevel,
bool checkOverflow,
Platform platform,
ReportDiagnostic generalDiagnosticOption,
int warningLevel,
ImmutableDictionary<string, ReportDiagnostic> specificDiagnosticOptions,
bool concurrentBuild,
bool extendedCustomDebugInformation,
bool debugPlusMode,
XmlReferenceResolver xmlReferenceResolver,
SourceReferenceResolver sourceReferenceResolver,
MetadataReferenceResolver metadataReferenceResolver,
AssemblyIdentityComparer assemblyIdentityComparer,
StrongNameProvider strongNameProvider,
MetadataImportOptions metadataImportOptions)
{
this.OutputKind = outputKind;
this.ModuleName = moduleName;
this.MainTypeName = mainTypeName;
this.ScriptClassName = scriptClassName ?? WellKnownMemberNames.DefaultScriptClassName;
this.CryptoKeyContainer = cryptoKeyContainer;
this.CryptoKeyFile = cryptoKeyFile;
this.CryptoPublicKey = cryptoPublicKey.NullToEmpty();
this.DelaySign = delaySign;
this.CheckOverflow = checkOverflow;
this.Platform = platform;
this.GeneralDiagnosticOption = generalDiagnosticOption;
this.WarningLevel = warningLevel;
this.SpecificDiagnosticOptions = specificDiagnosticOptions;
this.ReportSuppressedDiagnostics = reportSuppressedDiagnostics;
this.OptimizationLevel = optimizationLevel;
this.ConcurrentBuild = concurrentBuild;
this.ExtendedCustomDebugInformation = extendedCustomDebugInformation;
this.DebugPlusMode = debugPlusMode;
this.XmlReferenceResolver = xmlReferenceResolver;
this.SourceReferenceResolver = sourceReferenceResolver;
this.MetadataReferenceResolver = metadataReferenceResolver;
this.StrongNameProvider = strongNameProvider;
this.AssemblyIdentityComparer = assemblyIdentityComparer ?? AssemblyIdentityComparer.Default;
this.MetadataImportOptions = metadataImportOptions;
_lazyErrors = new Lazy<ImmutableArray<Diagnostic>>(() =>
{
var builder = ArrayBuilder<Diagnostic>.GetInstance();
ValidateOptions(builder);
return builder.ToImmutableAndFree();
});
}
开发者ID:nemec,项目名称:roslyn,代码行数:59,代码来源:CompilationOptions.cs
示例3: ResolveMetadataReferences
internal virtual bool ResolveMetadataReferences(MetadataReferenceResolver metadataResolver, List<DiagnosticInfo> diagnosticsOpt, CommonMessageProvider messageProviderOpt, List<MetadataReference> resolved)
{
bool result = true;
foreach (CommandLineReference cmdReference in MetadataReferences)
{
var references = ResolveMetadataReference(cmdReference, metadataResolver, diagnosticsOpt, messageProviderOpt);
if (!references.IsDefaultOrEmpty)
{
resolved.AddRange(references);
}
else
{
result = false;
if (diagnosticsOpt == null)
{
// no diagnostic, so leaved unresolved reference in list
resolved.Add(new UnresolvedMetadataReference(cmdReference.Reference, cmdReference.Properties));
}
}
}
return result;
}
开发者ID:abock,项目名称:roslyn,代码行数:24,代码来源:CommonCommandLineArguments.cs
示例4: ResolveMetadataReference
internal static ImmutableArray<PortableExecutableReference> ResolveMetadataReference(CommandLineReference cmdReference, MetadataReferenceResolver metadataResolver, List<DiagnosticInfo> diagnosticsOpt, CommonMessageProvider messageProviderOpt)
{
Debug.Assert(metadataResolver != null);
Debug.Assert((diagnosticsOpt == null) == (messageProviderOpt == null));
ImmutableArray<PortableExecutableReference> references;
try
{
references = metadataResolver.ResolveReference(cmdReference.Reference, baseFilePath: null, properties: cmdReference.Properties);
}
catch (Exception e) when (diagnosticsOpt != null && (e is BadImageFormatException || e is IOException))
{
var diagnostic = PortableExecutableReference.ExceptionToDiagnostic(e, messageProviderOpt, Location.None, cmdReference.Reference, cmdReference.Properties.Kind);
diagnosticsOpt.Add(((DiagnosticWithInfo)diagnostic).Info);
return ImmutableArray<PortableExecutableReference>.Empty;
}
if (references.IsDefaultOrEmpty && diagnosticsOpt != null)
{
diagnosticsOpt.Add(new DiagnosticInfo(messageProviderOpt, messageProviderOpt.ERR_MetadataFileNotFound, cmdReference.Reference));
return ImmutableArray<PortableExecutableReference>.Empty;
}
return references;
}
开发者ID:abock,项目名称:roslyn,代码行数:25,代码来源:CommonCommandLineArguments.cs
示例5: CreateAssemblyFromIdentity
PEAssemblySymbol CreateAssemblyFromIdentity(MetadataReferenceResolver resolver, AssemblyIdentity identity, string basePath, List<PEModuleSymbol> modules)
{
PEAssemblySymbol ass;
if (!_assembliesMap.TryGetValue(identity, out ass))
{
// temporary: lookup ignoring minor version number
foreach (var pair in _assembliesMap)
{
if (pair.Key.Name.Equals(identity.Name, StringComparison.OrdinalIgnoreCase) && pair.Key.Version.Major == identity.Version.Major)
{
_assembliesMap[identity] = pair.Value;
return pair.Value;
}
}
//
string keytoken = string.Join("", identity.PublicKeyToken.Select(b => b.ToString("x2")));
var pes = resolver.ResolveReference(identity.Name + ".dll", basePath, MetadataReferenceProperties.Assembly)
.Concat(resolver.ResolveReference($"{identity.Name}/v4.0_{identity.Version}__{keytoken}/{identity.Name}.dll", basePath, MetadataReferenceProperties.Assembly));
var pe = pes.FirstOrDefault();
if (pe != null)
{
_assembliesMap[identity] = ass = PEAssemblySymbol.Create(pe);
ass.SetCorLibrary(_lazyCorLibrary);
modules.AddRange(ass.Modules.Cast<PEModuleSymbol>());
}
else
{
throw new DllNotFoundException(identity.GetDisplayName());
}
}
return ass;
}
开发者ID:iolevel,项目名称:peachpie,代码行数:35,代码来源:ReferenceManager.cs
示例6: ResolveMetadataReferences
/// <summary>
/// Resolves metadata references stored in <see cref="MetadataReferences"/> using given file resolver and metadata provider.
/// If a non-null diagnostic bag <paramref name="diagnosticsOpt"/> is provided, it catches exceptions that may be generated while reading the metadata file and
/// reports appropriate diagnostics.
/// Otherwise, if <paramref name="diagnosticsOpt"/> is null, the exceptions are unhandled.
/// </summary>
internal IEnumerable<MetadataReference> ResolveMetadataReferences(MetadataReferenceResolver metadataResolver, MetadataReferenceProvider metadataProvider, List<DiagnosticInfo> diagnosticsOpt, CommonMessageProvider messageProviderOpt)
{
Debug.Assert(metadataResolver != null);
Debug.Assert(metadataProvider != null);
foreach (CommandLineReference cmdReference in MetadataReferences)
{
yield return ResolveMetadataReference(cmdReference, metadataResolver, metadataProvider, diagnosticsOpt, messageProviderOpt) ??
new UnresolvedMetadataReference(cmdReference.Reference, cmdReference.Properties);
}
}
开发者ID:riversky,项目名称:roslyn,代码行数:17,代码来源:CommonCommandLineArguments.cs
示例7: ResolveMetadataReferences
/// <summary>
/// Resolves metadata references stored in command line arguments and reports errors for those that can't be resolved.
/// </summary>
internal List<MetadataReference> ResolveMetadataReferences(
MetadataReferenceResolver externalReferenceResolver,
MetadataReferenceProvider metadataProvider,
List<DiagnosticInfo> diagnostics,
AssemblyIdentityComparer assemblyIdentityComparer,
TouchedFileLogger touchedFiles,
out MetadataReferenceResolver referenceDirectiveResolver)
{
using (Logger.LogBlock(FunctionId.Common_CommandLineCompiler_ResolveMetadataReferences))
{
List<MetadataReference> resolved = new List<MetadataReference>();
ResolveMetadataReferencesFromArguments(externalReferenceResolver, metadataProvider, diagnostics, resolved);
if (Arguments.IsInteractive)
{
referenceDirectiveResolver = externalReferenceResolver;
}
else
{
// when compiling into an assembly (csc/vbc) we only allow #r that match references given on command line:
referenceDirectiveResolver = new ExistingReferencesResolver(
resolved.Where(r => r.Properties.Kind == MetadataImageKind.Assembly).OfType<MetadataFileReference>().AsImmutable(),
Arguments.ReferencePaths,
Arguments.BaseDirectory,
assemblyIdentityComparer,
touchedFiles);
}
return resolved;
}
}
开发者ID:riversky,项目名称:roslyn,代码行数:34,代码来源:CommonCompiler.cs
示例8: SetReferencesOfReferencedModules
void SetReferencesOfReferencedModules(MetadataReferenceResolver resolver, List<PEModuleSymbol> modules)
{
for (int i = 0; i < modules.Count; i++)
{
var refs = modules[i].Module.ReferencedAssemblies;
var symbols = new AssemblySymbol[refs.Length];
for (int j = 0; j < refs.Length; j++)
{
var symbol = CreateAssemblyFromIdentity(resolver, refs[j], null, modules);
symbols[j] = symbol;
}
//
modules[i].SetReferences(new ModuleReferences<AssemblySymbol>(refs, symbols.AsImmutable(), ImmutableArray<UnifiedAssembly<AssemblySymbol>>.Empty));
}
}
开发者ID:iolevel,项目名称:peachpie,代码行数:17,代码来源:ReferenceManager.cs
示例9: ResolveMetadataReferencesFromArguments
/// <summary>
/// Returns false if there were unresolved references in arguments, true otherwise.
/// </summary>
protected virtual bool ResolveMetadataReferencesFromArguments(MetadataReferenceResolver externalReferenceResolver, MetadataReferenceProvider metadataProvider, List<DiagnosticInfo> diagnostics, List<MetadataReference> resolved)
{
bool result = true;
foreach (var reference in Arguments.ResolveMetadataReferences(externalReferenceResolver, metadataProvider, diagnostics, MessageProvider))
{
if (!reference.IsUnresolved)
{
resolved.Add(reference);
}
else
{
result = false;
Debug.Assert(diagnostics.Any());
}
}
return result;
}
开发者ID:riversky,项目名称:roslyn,代码行数:22,代码来源:CommonCompiler.cs
示例10: ResolveMetadataReference
// TODO: change to private protected when available
internal static MetadataReference ResolveMetadataReference(CommandLineReference cmdReference, MetadataReferenceResolver metadataResolver, MetadataReferenceProvider metadataProvider, List<DiagnosticInfo> diagnosticsOpt, CommonMessageProvider messageProviderOpt)
{
Debug.Assert(metadataResolver != null);
Debug.Assert(metadataProvider != null);
Debug.Assert((diagnosticsOpt == null) == (messageProviderOpt == null));
string resolvedPath = metadataResolver.ResolveReference(cmdReference.Reference, baseFilePath: null);
if (resolvedPath == null)
{
if (diagnosticsOpt != null)
{
diagnosticsOpt.Add(new DiagnosticInfo(messageProviderOpt, messageProviderOpt.ERR_MetadataFileNotFound, cmdReference.Reference));
}
return null;
}
try
{
return metadataProvider.GetReference(resolvedPath, cmdReference.Properties);
}
catch (Exception e) if (diagnosticsOpt != null && (e is BadImageFormatException || e is IOException))
{
var diagnostic = PortableExecutableReference.ExceptionToDiagnostic(e, messageProviderOpt, Location.None, cmdReference.Reference, cmdReference.Properties.Kind);
diagnosticsOpt.Add(((DiagnosticWithInfo)diagnostic).Info);
return null;
}
}
#endregion
#region Analyzer References
/// <summary>
/// Resolves analyzer references stored in <see cref="AnalyzerReferences"/> using given file resolver.
/// </summary>
/// <returns>Yields resolved <see cref="AnalyzerFileReference"/> or <see cref="UnresolvedAnalyzerReference"/>.</returns>
public IEnumerable<AnalyzerReference> ResolveAnalyzerReferences()
{
foreach (CommandLineAnalyzerReference cmdLineReference in AnalyzerReferences)
{
yield return ResolveAnalyzerReference(cmdLineReference)
?? (AnalyzerReference)new UnresolvedAnalyzerReference(cmdLineReference.FilePath);
}
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:46,代码来源:CommonCommandLineArguments.cs
示例11: MetadataResolver
public MetadataResolver(MetadataReferenceResolver previousResolver)
{
this.previousResolver = previousResolver;
}
开发者ID:southpolenator,项目名称:WinDbgCs,代码行数:4,代码来源:ScriptExecution.cs
示例12: WithMetadataReferenceResolver
public CompilationOptions WithMetadataReferenceResolver(MetadataReferenceResolver resolver)
{
return CommonWithMetadataReferenceResolver(resolver);
}
开发者ID:nemec,项目名称:roslyn,代码行数:4,代码来源:CompilationOptions.cs
示例13: CompilationOptions
// Expects correct arguments.
internal CompilationOptions(
OutputKind outputKind,
string moduleName,
string mainTypeName,
string scriptClassName,
string cryptoKeyContainer,
string cryptoKeyFile,
bool? delaySign,
OptimizationLevel optimizationLevel,
bool checkOverflow,
int fileAlignment,
ulong baseAddress,
Platform platform,
ReportDiagnostic generalDiagnosticOption,
int warningLevel,
ImmutableDictionary<string, ReportDiagnostic> specificDiagnosticOptions,
bool highEntropyVirtualAddressSpace,
SubsystemVersion subsystemVersion,
bool concurrentBuild,
XmlReferenceResolver xmlReferenceResolver,
SourceReferenceResolver sourceReferenceResolver,
MetadataReferenceResolver metadataReferenceResolver,
MetadataReferenceProvider metadataReferenceProvider,
AssemblyIdentityComparer assemblyIdentityComparer,
StrongNameProvider strongNameProvider,
MetadataImportOptions metadataImportOptions,
ImmutableArray<string> features)
{
this.OutputKind = outputKind;
this.ModuleName = moduleName;
this.MainTypeName = mainTypeName;
this.ScriptClassName = scriptClassName;
this.CryptoKeyContainer = cryptoKeyContainer;
this.CryptoKeyFile = cryptoKeyFile;
this.DelaySign = delaySign;
this.CheckOverflow = checkOverflow;
this.FileAlignment = fileAlignment;
this.BaseAddress = baseAddress;
this.Platform = platform;
this.GeneralDiagnosticOption = generalDiagnosticOption;
this.WarningLevel = warningLevel;
this.SpecificDiagnosticOptions = specificDiagnosticOptions;
this.HighEntropyVirtualAddressSpace = highEntropyVirtualAddressSpace;
this.OptimizationLevel = optimizationLevel;
this.ConcurrentBuild = concurrentBuild;
this.SubsystemVersion = subsystemVersion;
this.XmlReferenceResolver = xmlReferenceResolver;
this.SourceReferenceResolver = sourceReferenceResolver;
this.MetadataReferenceResolver = metadataReferenceResolver;
this.MetadataReferenceProvider = metadataReferenceProvider;
this.StrongNameProvider = strongNameProvider;
this.AssemblyIdentityComparer = assemblyIdentityComparer ?? AssemblyIdentityComparer.Default;
this.MetadataImportOptions = metadataImportOptions;
this.Features = features;
this.lazyErrors = new Lazy<ImmutableArray<Diagnostic>>(() =>
{
var builder = ArrayBuilder<Diagnostic>.GetInstance();
ValidateOptions(builder);
return builder.ToImmutableAndFree();
});
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:63,代码来源:CompilationOptions.cs
示例14: CommonWithMetadataReferenceResolver
protected abstract CompilationOptions CommonWithMetadataReferenceResolver(MetadataReferenceResolver resolver);
开发者ID:nemec,项目名称:roslyn,代码行数:1,代码来源:CompilationOptions.cs
示例15: CompilationOptions
// Expects correct arguments.
internal CompilationOptions(
OutputKind outputKind,
string moduleName,
string mainTypeName,
string scriptClassName,
string cryptoKeyContainer,
string cryptoKeyFile,
bool? delaySign,
bool optimize,
bool checkOverflow,
int fileAlignment,
ulong baseAddress,
Platform platform,
ReportDiagnostic generalDiagnosticOption,
int warningLevel,
IEnumerable<KeyValuePair<string, ReportDiagnostic>> specificDiagnosticOptions,
bool highEntropyVirtualAddressSpace,
DebugInformationKind debugInformationKind,
SubsystemVersion subsystemVersion,
bool concurrentBuild,
XmlReferenceResolver xmlReferenceResolver,
SourceReferenceResolver sourceReferenceResolver,
MetadataReferenceResolver metadataReferenceResolver,
MetadataReferenceProvider metadataReferenceProvider,
AssemblyIdentityComparer assemblyIdentityComparer,
StrongNameProvider strongNameProvider,
MetadataImportOptions metadataImportOptions)
{
Initialize(
outputKind, moduleName, mainTypeName, scriptClassName, cryptoKeyContainer, cryptoKeyFile, delaySign, optimize, checkOverflow, fileAlignment,
baseAddress, platform, generalDiagnosticOption, warningLevel, specificDiagnosticOptions, highEntropyVirtualAddressSpace, debugInformationKind,
subsystemVersion, concurrentBuild, xmlReferenceResolver, sourceReferenceResolver, metadataReferenceResolver, metadataReferenceProvider, assemblyIdentityComparer, strongNameProvider,
metadataImportOptions);
}
开发者ID:riversky,项目名称:roslyn,代码行数:35,代码来源:CompilationOptions.cs
注:本文中的Microsoft.CodeAnalysis.MetadataReferenceResolver类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论