本文整理汇总了C#中Microsoft.CodeAnalysis.DiagnosticInfo类的典型用法代码示例。如果您正苦于以下问题:C# DiagnosticInfo类的具体用法?C# DiagnosticInfo怎么用?C# DiagnosticInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DiagnosticInfo类属于Microsoft.CodeAnalysis命名空间,在下文中一共展示了DiagnosticInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DiagnosticWithInfo
internal DiagnosticWithInfo(DiagnosticInfo info, Location location)
{
Debug.Assert(info != null);
Debug.Assert(location != null);
_info = info;
_location = location;
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:7,代码来源:DiagnosticWithInfo.cs
示例2: GreenNode
protected GreenNode(ushort kind, DiagnosticInfo[] diagnostics)
{
_kind = kind;
if (diagnostics?.Length > 0)
{
this.flags |= NodeFlags.ContainsDiagnostics;
s_diagnosticsTable.Add(this, diagnostics);
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:9,代码来源:GreenNode.cs
示例3: DiagnosticInfo
private DiagnosticInfo(DiagnosticInfo original, DiagnosticSeverity overridenSeverity)
{
_messageProvider = original.MessageProvider;
_errorCode = original._errorCode;
_defaultSeverity = original.DefaultSeverity;
_arguments = original._arguments;
_effectiveSeverity = overridenSeverity;
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:9,代码来源:DiagnosticInfo.cs
示例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();
}
开发者ID:iolevel,项目名称:peachpie,代码行数:10,代码来源:UnboundGenericType.cs
示例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();
}
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:50,代码来源:CommonCommandLineArguments.cs
示例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));
}
开发者ID:iolevel,项目名称:peachpie,代码行数:10,代码来源:PEMethodSymbol.cs
示例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();
}
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:46,代码来源:CommonCompiler.cs
示例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;
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:19,代码来源:CommonCompiler.cs
示例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);
开发者ID:nemec,项目名称:roslyn,代码行数:8,代码来源:CommonMessageProvider.cs
示例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;
}
开发者ID:nagyist,项目名称:roslyn,代码行数:6,代码来源:DiagnosticInfo.DiagnosticInfoWithOverridenSeverity.cs
示例11: UnboundArgumentErrorTypeSymbol
private UnboundArgumentErrorTypeSymbol(string name, DiagnosticInfo errorInfo)
{
_name = name;
_errorInfo = errorInfo;
}
开发者ID:iolevel,项目名称:peachpie,代码行数:5,代码来源:UnboundGenericType.cs
示例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;
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:26,代码来源:CommonCompiler.cs
示例13: SetDiagnostics
internal abstract GreenNode SetDiagnostics(DiagnosticInfo[] diagnostics);
开发者ID:XieShuquan,项目名称:roslyn,代码行数:1,代码来源:GreenNode.cs
示例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;
}
}
开发者ID:iolevel,项目名称:peachpie,代码行数:28,代码来源:PEMethodSymbol.cs
示例15: DiagnosticWithInfo
protected DiagnosticWithInfo(SerializationInfo info, StreamingContext context)
{
this.info = (DiagnosticInfo)info.GetValue("info", typeof(DiagnosticInfo));
this.location = (Location)info.GetValue("location", typeof(Location));
}
开发者ID:riversky,项目名称:roslyn,代码行数:5,代码来源:DiagnosticWithInfo.cs
示例16: CreateTempFile
private string CreateTempFile(TextWriter consoleOutput)
{
string result = null;
// now catching in response to watson bucket 148019219
try
{
result = PathGetTempFileName();
}
catch (IOException ex)
{
if (consoleOutput != null)
{
DiagnosticInfo diagnosticInfo = new DiagnosticInfo(MessageProvider, (int)MessageProvider.ERR_FailedToCreateTempFile, ex.Message);
consoleOutput.WriteLine(diagnosticInfo.ToString(Culture));
}
}
return result;
}
开发者ID:riversky,项目名称:roslyn,代码行数:20,代码来源:CommonCompiler.cs
示例17: OpenFile
private FileStream OpenFile(string filePath, TextWriter consoleOutput, FileMode mode = FileMode.Open, FileAccess access = FileAccess.ReadWrite, FileShare share = FileShare.None)
{
try
{
return FileOpen(filePath, mode, access, share);
}
catch (Exception e)
{
if (consoleOutput != null)
{
// TODO: distinct error message?
DiagnosticInfo diagnosticInfo = new DiagnosticInfo(MessageProvider, (int)MessageProvider.ERR_OutputWriteFailed, filePath, e.Message);
consoleOutput.WriteLine(diagnosticInfo.ToString(Culture));
}
return null;
}
}
开发者ID:riversky,项目名称:roslyn,代码行数:18,代码来源:CommonCompiler.cs
示例18: GetDiagnosticReport
public override ReportDiagnostic GetDiagnosticReport(DiagnosticInfo diagnosticInfo, CompilationOptions options)
{
throw new NotImplementedException();
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:4,代码来源:TestMessageProvider.cs
示例19: TryDeleteFile
private bool TryDeleteFile(string filePath, TextWriter consoleOutput)
{
try
{
if (File.Exists(filePath))
{
FileDelete(filePath);
}
return true;
}
catch (Exception e)
{
// Treat all possible exceptions uniformly, so we report
// "Could not write to output file"/"can't open '***' for writing"
// for all as in the native CS/VB compiler.
if (consoleOutput != null)
{
DiagnosticInfo diagnosticInfo = new DiagnosticInfo(MessageProvider, (int)MessageProvider.ERR_OutputWriteFailed, filePath, e.Message);
consoleOutput.WriteLine(diagnosticInfo.ToString(Culture));
}
return false;
}
}
开发者ID:riversky,项目名称:roslyn,代码行数:26,代码来源:CommonCompiler.cs
示例20: 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
注:本文中的Microsoft.CodeAnalysis.DiagnosticInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论