本文整理汇总了C#中Microsoft.CodeAnalysis.CommonMessageProvider.CreateDiagnostic方法的典型用法代码示例。如果您正苦于以下问题:C# CommonMessageProvider.CreateDiagnostic方法的具体用法?C# CommonMessageProvider.CreateDiagnostic怎么用?C# CommonMessageProvider.CreateDiagnostic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CommonMessageProvider
的用法示例。
在下文中一共展示了CommonMessageProvider.CreateDiagnostic方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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())));
}
}
示例2: 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);
}
}
示例3: GetKeyFileError
internal static Diagnostic GetKeyFileError(CommonMessageProvider messageProvider, string path, object message)
{
return messageProvider.CreateDiagnostic(messageProvider.ERR_PublicKeyFileFailure, Location.None, path, message);
}
示例4: GetContainerError
internal static Diagnostic GetContainerError(CommonMessageProvider messageProvider, string name, object message)
{
return messageProvider.CreateDiagnostic(messageProvider.ERR_PublicKeyContainerFailure, Location.None, name, message);
}
示例5: ValidateOptions
internal void ValidateOptions(ArrayBuilder<Diagnostic> builder, CommonMessageProvider messageProvider)
{
if (!CryptoPublicKey.IsEmpty)
{
if (CryptoKeyFile != null)
{
builder.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_MutuallyExclusiveOptions,
Location.None, nameof(CryptoPublicKey), nameof(CryptoKeyFile)));
}
if (CryptoKeyContainer != null)
{
builder.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_MutuallyExclusiveOptions,
Location.None, nameof(CryptoPublicKey), nameof(CryptoKeyContainer)));
}
}
if (PublicSign)
{
if (CryptoKeyFile != null && !PathUtilities.IsAbsolute(CryptoKeyFile))
{
// TODO(https://github.com/dotnet/roslyn/issues/9153):
// Produce better diagnostic message for passing a key file with a relative path
builder.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_BadCompilationOptionValue,
Location.None, nameof(CryptoKeyFile), CryptoKeyFile));
}
if (CryptoKeyContainer != null)
{
builder.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_MutuallyExclusiveOptions,
Location.None, nameof(PublicSign), nameof(CryptoKeyContainer)));
}
if (DelaySign == true)
{
builder.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_MutuallyExclusiveOptions,
Location.None, nameof(PublicSign), nameof(DelaySign)));
}
}
}
示例6: ValidateOptions
internal void ValidateOptions(ArrayBuilder<Diagnostic> builder, CommonMessageProvider messageProvider)
{
if (!CryptoPublicKey.IsEmpty)
{
if (CryptoKeyFile != null)
{
builder.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_MutuallyExclusiveOptions,
Location.None, nameof(CryptoPublicKey), nameof(CryptoKeyFile)));
}
if (CryptoKeyContainer != null)
{
builder.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_MutuallyExclusiveOptions,
Location.None, nameof(CryptoPublicKey), nameof(CryptoKeyContainer)));
}
}
if (PublicSign)
{
if (CryptoKeyFile != null && !PathUtilities.IsAbsolute(CryptoKeyFile))
{
builder.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_OptionMustBeAbsolutePath,
Location.None, nameof(CryptoKeyFile)));
}
if (CryptoKeyContainer != null)
{
builder.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_MutuallyExclusiveOptions,
Location.None, nameof(PublicSign), nameof(CryptoKeyContainer)));
}
if (DelaySign == true)
{
builder.Add(messageProvider.CreateDiagnostic(messageProvider.ERR_MutuallyExclusiveOptions,
Location.None, nameof(PublicSign), nameof(DelaySign)));
}
}
}