本文整理汇总了C#中Microsoft.CodeAnalysis.DiagnosticInfo.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# DiagnosticInfo.ToString方法的具体用法?C# DiagnosticInfo.ToString怎么用?C# DiagnosticInfo.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.DiagnosticInfo
的用法示例。
在下文中一共展示了DiagnosticInfo.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintError
protected virtual void PrintError(DiagnosticInfo diagnostic, TextWriter consoleOutput)
{
consoleOutput.WriteLine(diagnostic.ToString(Culture));
}
示例2: OpenFile
private Stream OpenFile(string filePath, TextWriter consoleOutput, object mode = null, object access = null, object share = null)
{
mode = mode ?? PortableShim.FileMode.Open;
access = access ?? PortableShim.FileAccess.ReadWrite;
share = share ?? PortableShim.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;
}
}
示例3: TryMoveFile
private bool TryMoveFile(string sourcePath, string destinationPath, TextWriter consoleOutput)
{
try
{
FileMove(sourcePath, destinationPath);
return true;
}
catch (Exception e)
{
// There can be various exceptions caught here including:
// - DirectoryNotFoundException when a given path is not found
// - IOException when a device like a:\ is not ready
// - UnauthorizedAccessException when a given path is not accessible
// - NotSupportedException when a given path is in an invalid format
//
// Treat them uniformly, so we report "Cannot open 'filename' for writing" for all as in the native VB compiler.
if (consoleOutput != null)
{
DiagnosticInfo diagnosticInfo = new DiagnosticInfo(MessageProvider, (int)MessageProvider.ERR_CantOpenFileWrite, destinationPath, e.Message);
consoleOutput.WriteLine(diagnosticInfo.ToString(Culture));
}
return false;
}
}
示例4: 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;
}
}
示例5: 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;
}
}
示例6: 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;
}
示例7: 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;
}