本文整理汇总了C#中Microsoft.CodeAnalysis.CommonMessageProvider类的典型用法代码示例。如果您正苦于以下问题:C# CommonMessageProvider类的具体用法?C# CommonMessageProvider怎么用?C# CommonMessageProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommonMessageProvider类属于Microsoft.CodeAnalysis命名空间,在下文中一共展示了CommonMessageProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DiagnosticInfo
// Only the compiler creates instances.
internal DiagnosticInfo(CommonMessageProvider messageProvider, int errorCode, params object[] arguments)
: this(messageProvider, errorCode)
{
AssertMessageSerializable(arguments);
_arguments = arguments;
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:8,代码来源:DiagnosticInfo.cs
示例2: CreateDescriptor
private static DiagnosticDescriptor CreateDescriptor(int errorCode, DiagnosticSeverity defaultSeverity, CommonMessageProvider messageProvider)
{
var id = messageProvider.GetIdForErrorCode(errorCode);
var title = messageProvider.GetTitle(errorCode);
var description = messageProvider.GetDescription(errorCode);
var messageFormat = messageProvider.GetMessageFormat(errorCode);
var helpLink = messageProvider.GetHelpLink(errorCode);
var category = messageProvider.GetCategory(errorCode);
var customTags = GetCustomTags(defaultSeverity);
return new DiagnosticDescriptor(id, title, messageFormat, category, defaultSeverity,
isEnabledByDefault: true, description: description, helpLinkUri: helpLink, customTags: customTags);
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:12,代码来源:DiagnosticInfo.cs
示例3: CommonSyntaxAndDeclarationManager
public CommonSyntaxAndDeclarationManager(
ImmutableArray<SyntaxTree> externalSyntaxTrees,
string scriptClassName,
SourceReferenceResolver resolver,
CommonMessageProvider messageProvider,
bool isSubmission)
{
this.ExternalSyntaxTrees = externalSyntaxTrees;
this.ScriptClassName = scriptClassName ?? "";
this.Resolver = resolver;
this.MessageProvider = messageProvider;
this.IsSubmission = isSubmission;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:13,代码来源:CommonSyntaxAndDeclarationManager.cs
示例4: Create
internal static StrongNameKeys Create(ImmutableArray<byte> publicKey, CommonMessageProvider messageProvider)
{
Debug.Assert(!publicKey.IsDefaultOrEmpty);
if (MetadataHelpers.IsValidPublicKey(publicKey))
{
return new StrongNameKeys(default(ImmutableArray<byte>), publicKey, null, null);
}
else
{
return new StrongNameKeys(messageProvider.CreateDiagnostic(messageProvider.ERR_BadCompilationOptionValue, Location.None,
nameof(CompilationOptions.CryptoPublicKey), BitConverter.ToString(publicKey.ToArray())));
}
}
开发者ID:daking2014,项目名称:roslyn,代码行数:14,代码来源:StrongNameKeys.cs
示例5: Create
internal static StrongNameKeys Create(StrongNameProvider providerOpt, string keyFilePath, string keyContainerName, CommonMessageProvider messageProvider)
{
if (string.IsNullOrEmpty(keyFilePath) && string.IsNullOrEmpty(keyContainerName))
{
return None;
}
if (providerOpt == null)
{
var diagnostic = GetError(keyFilePath, keyContainerName, new CodeAnalysisResourcesLocalizableErrorArgument(nameof(CodeAnalysisResources.AssemblySigningNotSupported)), messageProvider);
return new StrongNameKeys(diagnostic);
}
return providerOpt.CreateKeys(keyFilePath, keyContainerName, messageProvider);
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:15,代码来源:StrongNameKeys.cs
示例6: DiagnosticInfo
// Only the compiler creates instances.
internal DiagnosticInfo(CommonMessageProvider messageProvider, int errorCode, params object[] arguments)
: this(messageProvider, errorCode)
{
Debug.Assert(Array.TrueForAll(arguments, arg => arg != null && (arg is IMessageSerializable || arg.GetType().IsSerializable)));
this.arguments = arguments;
#if false
if (arguments != null)
{
foreach (var arg in arguments)
{
Debug.Assert(arg != null, "Diagnostic argument is null");
Debug.Assert(!arg.GetType().IsEnum, "Enum used as diagnostic argument");
}
}
#endif
}
开发者ID:riversky,项目名称:roslyn,代码行数:18,代码来源:DiagnosticInfo.cs
示例7: WritePeToStream
public static bool WritePeToStream(
EmitContext context,
CommonMessageProvider messageProvider,
Func<Stream> getPeStream,
PdbWriter nativePdbWriterOpt,
string pdbPathOpt,
bool allowMissingMethodBodies,
bool deterministic,
CancellationToken cancellationToken)
{
// If PDB writer is given, we have to have PDB path.
Debug.Assert(nativePdbWriterOpt == null || pdbPathOpt != null);
var peWriter = new PeWriter(context.Module, pdbPathOpt, deterministic);
var mdWriter = FullMetadataWriter.Create(context, messageProvider, allowMissingMethodBodies, deterministic, cancellationToken);
return peWriter.WritePeToStream(mdWriter, getPeStream, nativePdbWriterOpt);
}
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:18,代码来源:PeWriter.cs
示例8: WritePeToStream
public static void WritePeToStream(
EmitContext context,
CommonMessageProvider messageProvider,
Stream peStream,
PdbWriter nativePdbWriterOpt,
bool allowMissingMethodBodies,
bool deterministic,
CancellationToken cancellationToken)
{
var peWriter = new PeWriter(context.Module, nativePdbWriterOpt, deterministic);
var mdWriter = FullMetadataWriter.Create(context, messageProvider, allowMissingMethodBodies, deterministic, cancellationToken);
if (nativePdbWriterOpt != null)
{
nativePdbWriterOpt.SetMetadataEmitter(mdWriter);
}
uint entryPointToken;
peWriter.WritePeToStream(mdWriter, peStream, nativePdbWriterOpt, out entryPointToken);
if (nativePdbWriterOpt != null)
{
if (entryPointToken != 0)
{
nativePdbWriterOpt.SetEntryPoint(entryPointToken);
}
var assembly = context.Module.AsAssembly;
if (assembly != null && assembly.Kind == ModuleKind.WindowsRuntimeMetadata)
{
// Dev12: If compiling to winmdobj, we need to add to PDB source spans of
// all types and members for better error reporting by WinMDExp.
nativePdbWriterOpt.WriteDefinitionLocations(context.Module.GetSymbolToLocationMap());
}
}
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:37,代码来源:PeWriter.cs
示例9: GetError
internal static Diagnostic GetError(string keyFilePath, string keyContainerName, object message, CommonMessageProvider messageProvider)
{
if (keyContainerName != null)
{
return GetContainerError(messageProvider, keyContainerName, message);
}
else
{
return GetKeyFileError(messageProvider, keyFilePath, message);
}
}
开发者ID:daking2014,项目名称:roslyn,代码行数:11,代码来源:StrongNameKeys.cs
示例10: ResolveRelativePath
private static string ResolveRelativePath(CommonMessageProvider messageProvider, string path, string baseDirectory, IList<DiagnosticInfo> errors)
{
string fullPath = FileUtilities.ResolveRelativePath(path, baseDirectory);
if (fullPath == null)
{
errors.Add(new DiagnosticInfo(messageProvider, messageProvider.FTL_InputFileNameTooLong, path));
}
return fullPath;
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:10,代码来源:CommonCompiler.cs
示例11: OpenStream
private static Stream OpenStream(CommonMessageProvider messageProvider, string path, string baseDirectory, int errorCode, IList<DiagnosticInfo> errors)
{
if (path == null)
{
return null;
}
string fullPath = ResolveRelativePath(messageProvider, path, baseDirectory, errors);
if (fullPath == null)
{
return null;
}
try
{
return PortableShim.FileStream.Create(fullPath, PortableShim.FileMode.Open, PortableShim.FileAccess.Read);
}
catch (Exception ex)
{
errors.Add(new DiagnosticInfo(messageProvider, errorCode, fullPath, ex.Message));
}
return null;
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:24,代码来源:CommonCompiler.cs
示例12: OpenManifestStream
private static Stream OpenManifestStream(CommonMessageProvider messageProvider, OutputKind outputKind, CommandLineArguments arguments, List<DiagnosticInfo> errorList)
{
return outputKind.IsNetModule()
? null
: OpenStream(messageProvider, arguments.Win32Manifest, arguments.BaseDirectory, messageProvider.ERR_CantOpenWin32Manifest, errorList);
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:6,代码来源:CommonCompiler.cs
示例13: CommandLineParser
internal CommandLineParser(CommonMessageProvider messageProvider, bool isInteractive)
{
Debug.Assert(messageProvider != null);
this.messageProvider = messageProvider;
this.isInteractive = isInteractive;
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:6,代码来源:CommonCommandLineParser.cs
示例14: ExceptionToDiagnostic
internal static Diagnostic ExceptionToDiagnostic(Exception e, CommonMessageProvider messageProvider, Location location, string display, MetadataImageKind kind)
{
if (e is BadImageFormatException)
{
int errorCode = (kind == MetadataImageKind.Assembly) ? messageProvider.ERR_InvalidAssemblyMetadata : messageProvider.ERR_InvalidModuleMetadata;
return messageProvider.CreateDiagnostic(errorCode, location, display, e.Message);
}
var fileNotFound = e as FileNotFoundException;
if (fileNotFound != null)
{
return messageProvider.CreateDiagnostic(messageProvider.ERR_MetadataFileNotFound, location, fileNotFound.FileName ?? string.Empty);
}
else
{
int errorCode = (kind == MetadataImageKind.Assembly) ? messageProvider.ERR_ErrorOpeningAssemblyFile : messageProvider.ERR_ErrorOpeningModuleFile;
return messageProvider.CreateDiagnostic(errorCode, location, display, e.Message);
}
}
开发者ID:swaroop-sridhar,项目名称:roslyn,代码行数:19,代码来源:PortableExecutableReference.cs
示例15: GetDescriptor
internal static DiagnosticDescriptor GetDescriptor(int errorCode, CommonMessageProvider messageProvider)
{
var defaultSeverity = messageProvider.GetSeverity(errorCode);
return GetOrCreateDescriptor(errorCode, defaultSeverity, messageProvider);
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:5,代码来源:DiagnosticInfo.cs
示例16: ToFileReadDiagnostics
internal static DiagnosticInfo ToFileReadDiagnostics(CommonMessageProvider messageProvider, Exception e, string filePath)
{
DiagnosticInfo diagnosticInfo;
if (e is FileNotFoundException || e.GetType().Name == "DirectoryNotFoundException")
{
diagnosticInfo = new DiagnosticInfo(messageProvider, messageProvider.ERR_FileNotFound, filePath);
}
else if (e is InvalidDataException)
{
diagnosticInfo = new DiagnosticInfo(messageProvider, messageProvider.ERR_BinaryFile, filePath);
}
else
{
diagnosticInfo = new DiagnosticInfo(messageProvider, messageProvider.ERR_NoSourceFile, filePath, e.Message);
}
return diagnosticInfo;
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:19,代码来源:CommonCompiler.cs
示例17: ResolveAnalyzersFromArguments
internal ImmutableArray<DiagnosticAnalyzer> ResolveAnalyzersFromArguments(
string language,
List<DiagnosticInfo> diagnostics,
CommonMessageProvider messageProvider,
IAnalyzerAssemblyLoader analyzerLoader)
{
var analyzerBuilder = ImmutableArray.CreateBuilder<DiagnosticAnalyzer>();
EventHandler<AnalyzerLoadFailureEventArgs> errorHandler = (o, e) =>
{
var analyzerReference = o as AnalyzerFileReference;
DiagnosticInfo diagnostic;
switch (e.ErrorCode)
{
case AnalyzerLoadFailureEventArgs.FailureErrorCode.UnableToLoadAnalyzer:
diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_UnableToLoadAnalyzer, analyzerReference.FullPath, e.Message);
break;
case AnalyzerLoadFailureEventArgs.FailureErrorCode.UnableToCreateAnalyzer:
diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_AnalyzerCannotBeCreated, e.TypeName, analyzerReference.FullPath, e.Message);
break;
case AnalyzerLoadFailureEventArgs.FailureErrorCode.NoAnalyzers:
diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_NoAnalyzerInAssembly, analyzerReference.FullPath);
break;
case AnalyzerLoadFailureEventArgs.FailureErrorCode.None:
default:
return;
}
// Filter this diagnostic based on the compilation options so that /nowarn and /warnaserror etc. take effect.
diagnostic = messageProvider.FilterDiagnosticInfo(diagnostic, this.CompilationOptions);
if (diagnostic != null)
{
diagnostics.Add(diagnostic);
}
};
var resolvedReferences = ArrayBuilder<AnalyzerFileReference>.GetInstance();
foreach (var reference in AnalyzerReferences)
{
var resolvedReference = ResolveAnalyzerReference(reference, analyzerLoader);
if (resolvedReference != null)
{
resolvedReferences.Add(resolvedReference);
// register the reference to the analyzer loader:
analyzerLoader.AddDependencyLocation(resolvedReference.FullPath);
}
else
{
diagnostics.Add(new DiagnosticInfo(messageProvider, messageProvider.ERR_MetadataFileNotFound, reference.FilePath));
}
}
// All analyzer references are registered now, we can start loading them:
foreach (var resolvedReference in resolvedReferences)
{
resolvedReference.AnalyzerLoadFailed += errorHandler;
resolvedReference.AddAnalyzers(analyzerBuilder, language);
resolvedReference.AnalyzerLoadFailed -= errorHandler;
}
resolvedReferences.Free();
return analyzerBuilder.ToImmutable();
}
开发者ID:abock,项目名称:roslyn,代码行数:66,代码来源:CommonCommandLineArguments.cs
示例18: 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
示例19: 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
示例20: GetContainerError
internal static Diagnostic GetContainerError(CommonMessageProvider messageProvider, string name, object message)
{
return messageProvider.CreateDiagnostic(messageProvider.ERR_PublicKeyContainerFailure, Location.None, name, message);
}
开发者ID:daking2014,项目名称:roslyn,代码行数:4,代码来源:StrongNameKeys.cs
注:本文中的Microsoft.CodeAnalysis.CommonMessageProvider类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论