本文整理汇总了C#中Microsoft.CodeAnalysis.DiagnosticInfo类的典型用法代码示例。如果您正苦于以下问题:C# DiagnosticInfo类的具体用法?C# DiagnosticInfo怎么用?C# DiagnosticInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DiagnosticInfo类属于Microsoft.CodeAnalysis命名空间,在下文中一共展示了DiagnosticInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DiagnosticWithInfo
internal DiagnosticWithInfo(DiagnosticInfo info, Location location)
{
Debug.Assert(info != null);
Debug.Assert(location != null);
_info = info;
_location = location;
}
示例2: GreenNode
protected GreenNode(ushort kind, DiagnosticInfo[] diagnostics)
{
_kind = kind;
if (diagnostics?.Length > 0)
{
this.flags |= NodeFlags.ContainsDiagnostics;
s_diagnosticsTable.Add(this, diagnostics);
}
}
示例3: DiagnosticInfo
private DiagnosticInfo(DiagnosticInfo original, DiagnosticSeverity overridenSeverity)
{
_messageProvider = original.MessageProvider;
_errorCode = original._errorCode;
_defaultSeverity = original.DefaultSeverity;
_arguments = original._arguments;
_effectiveSeverity = overridenSeverity;
}
示例4: CreateTypeArguments
public static ImmutableArray<TypeWithModifiers> CreateTypeArguments(ImmutableArray<TypeParameterSymbol> typeParameters, int n, DiagnosticInfo errorInfo)
{
var result = ArrayBuilder<TypeWithModifiers>.GetInstance();
for (int i = 0; i < n; i++)
{
string name = (i < typeParameters.Length) ? typeParameters[i].Name : string.Empty;
result.Add(new TypeWithModifiers(new UnboundArgumentErrorTypeSymbol(name, errorInfo)));
}
return result.ToImmutableAndFree();
}
示例5: ResolveAnalyzersFromArguments
internal ImmutableArray<DiagnosticAnalyzer> ResolveAnalyzersFromArguments(string language, List<DiagnosticInfo> diagnostics, CommonMessageProvider messageProvider, TouchedFileLogger touchedFiles, Func<string, Assembly> getAssembly)
{
var builder = ImmutableArray.CreateBuilder<DiagnosticAnalyzer>();
EventHandler<AnalyzerLoadFailureEventArgs> errorHandler = (o, e) =>
{
var analyzerReference = o as AnalyzerFileReference;
DiagnosticInfo diagnostic = null;
switch (e.ErrorCode)
{
case AnalyzerLoadFailureEventArgs.FailureErrorCode.UnableToLoadAnalyzer:
diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_UnableToLoadAnalyzer, analyzerReference.FullPath, e.Exception.Message);
break;
case AnalyzerLoadFailureEventArgs.FailureErrorCode.UnableToCreateAnalyzer:
diagnostic = new DiagnosticInfo(messageProvider, messageProvider.WRN_AnalyzerCannotBeCreated, e.TypeName, analyzerReference.FullPath, e.Exception.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);
}
};
foreach (var reference in AnalyzerReferences)
{
var resolvedReference = ResolveAnalyzerReference(reference, getAssembly);
if (resolvedReference != null)
{
resolvedReference.AnalyzerLoadFailed += errorHandler;
resolvedReference.AddAnalyzers(builder, language);
resolvedReference.AnalyzerLoadFailed -= errorHandler;
}
else
{
diagnostics.Add(new DiagnosticInfo(messageProvider, messageProvider.ERR_MetadataFileNotFound, reference.FilePath));
}
}
return builder.ToImmutable();
}
示例6: EnsureTypeParametersAreLoaded
private ImmutableArray<TypeParameterSymbol> EnsureTypeParametersAreLoaded(ref DiagnosticInfo diagnosticInfo)
{
var typeParams = _lazyTypeParameters;
if (!typeParams.IsDefault)
{
return typeParams;
}
return InterlockedOperations.Initialize(ref _lazyTypeParameters, LoadTypeParameters(ref diagnosticInfo));
}
示例7: Run
/// <summary>
/// csc.exe and vbc.exe entry point.
/// </summary>
public virtual int Run(TextWriter consoleOutput, CancellationToken cancellationToken = default(CancellationToken))
{
var saveUICulture = CultureInfo.CurrentUICulture;
ErrorLogger errorLogger = null;
try
{
// Messages from exceptions can be used as arguments for errors and they are often localized.
// Ensure they are localized to the right language.
var culture = this.Culture;
if (culture != null)
{
PortableShim.Misc.SetCurrentUICulture(culture);
}
if (Arguments.ErrorLogPath != null)
{
errorLogger = GetErrorLogger(consoleOutput, cancellationToken);
if (errorLogger == null)
{
return Failed;
}
}
return RunCore(consoleOutput, errorLogger, cancellationToken);
}
catch (OperationCanceledException)
{
var errorCode = MessageProvider.ERR_CompileCancelled;
if (errorCode > 0)
{
var diag = new DiagnosticInfo(MessageProvider, errorCode);
ReportErrors(new[] { diag }, consoleOutput, errorLogger);
}
return Failed;
}
finally
{
PortableShim.Misc.SetCurrentUICulture(saveUICulture);
errorLogger?.Dispose();
}
}
示例8: 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;
}
示例9: GetDiagnosticReport
/// <summary>
/// Produces the filtering action for the diagnostic based on the options passed in.
/// </summary>
/// <returns>
/// A new <see cref="DiagnosticInfo"/> with new effective severity based on the options or null if the
/// diagnostic has been suppressed.
/// </returns>
public abstract ReportDiagnostic GetDiagnosticReport(DiagnosticInfo diagnosticInfo, CompilationOptions options);
示例10: DiagnosticInfoWithOverridenSeverity
// Only the compiler creates instances.
internal DiagnosticInfoWithOverridenSeverity(DiagnosticInfo original, DiagnosticSeverity overriddenSeverity) :
base (original.messageProvider, original.isWarningAsError, original.errorCode, original.Arguments)
{
this.overriddenSeverity = overriddenSeverity;
}
示例11: UnboundArgumentErrorTypeSymbol
private UnboundArgumentErrorTypeSymbol(string name, DiagnosticInfo errorInfo)
{
_name = name;
_errorInfo = errorInfo;
}
示例12: CreateTempFile
private FileStream CreateTempFile(TextWriter consoleOutput, out string fileName)
{
// now catching in response to watson bucket 148019219
try
{
fileName = GetTempFileName();
var result = FileOpen(fileName, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None);
if (OnCreateTempFile != null)
{
OnCreateTempFile(fileName, result);
}
return result;
}
catch (IOException ex)
{
if (consoleOutput != null)
{
DiagnosticInfo diagnosticInfo = new DiagnosticInfo(MessageProvider, (int)MessageProvider.ERR_FailedToCreateTempFile, ex.Message);
consoleOutput.WriteLine(diagnosticInfo.ToString(Culture));
}
}
fileName = null;
return null;
}
示例13: SetDiagnostics
internal abstract GreenNode SetDiagnostics(DiagnosticInfo[] diagnostics);
示例14: LoadTypeParameters
private ImmutableArray<TypeParameterSymbol> LoadTypeParameters(ref DiagnosticInfo diagnosticInfo)
{
try
{
var moduleSymbol = _containingType.ContainingPEModule;
var gpHandles = moduleSymbol.Module.GetGenericParametersForMethodOrThrow(_handle);
if (gpHandles.Count == 0)
{
return ImmutableArray<TypeParameterSymbol>.Empty;
}
else
{
var ownedParams = ImmutableArray.CreateBuilder<TypeParameterSymbol>(gpHandles.Count);
for (int i = 0; i < gpHandles.Count; i++)
{
ownedParams.Add(new PETypeParameterSymbol(moduleSymbol, this, (ushort)i, gpHandles[i]));
}
return ownedParams.ToImmutable();
}
}
catch (BadImageFormatException)
{
//diagnosticInfo = new CSDiagnosticInfo(ErrorCode.ERR_BindToBogus, this); // TODO: ErrorCode
return ImmutableArray<TypeParameterSymbol>.Empty;
}
}
示例15: DiagnosticWithInfo
protected DiagnosticWithInfo(SerializationInfo info, StreamingContext context)
{
this.info = (DiagnosticInfo)info.GetValue("info", typeof(DiagnosticInfo));
this.location = (Location)info.GetValue("location", typeof(Location));
}