本文整理汇总了C#中Microsoft.CodeAnalysis.CommonMessageProvider类的典型用法代码示例。如果您正苦于以下问题:C# CommonMessageProvider类的具体用法?C# CommonMessageProvider怎么用?C# CommonMessageProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommonMessageProvider类属于Microsoft.CodeAnalysis命名空间,在下文中一共展示了CommonMessageProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DiagnosticInfo
// Only the compiler creates instances.
internal DiagnosticInfo(CommonMessageProvider messageProvider, int errorCode, params object[] arguments)
: this(messageProvider, errorCode)
{
AssertMessageSerializable(arguments);
_arguments = arguments;
}
示例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);
}
示例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;
}
示例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())));
}
}
示例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);
}
示例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
}
示例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);
}
示例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());
}
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例13: CommandLineParser
internal CommandLineParser(CommonMessageProvider messageProvider, bool isInteractive)
{
Debug.Assert(messageProvider != null);
this.messageProvider = messageProvider;
this.isInteractive = isInteractive;
}
示例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);
}
}
示例15: GetDescriptor
internal static DiagnosticDescriptor GetDescriptor(int errorCode, CommonMessageProvider messageProvider)
{
var defaultSeverity = messageProvider.GetSeverity(errorCode);
return GetOrCreateDescriptor(errorCode, defaultSeverity, messageProvider);
}