当前位置: 首页>>代码示例>>C#>>正文


C# DiagnosticInfo.ToString方法代码示例

本文整理汇总了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));
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:4,代码来源:CommonCompiler.cs

示例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;
            }
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:22,代码来源:CommonCompiler.cs

示例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;
            }
        }
开发者ID:riversky,项目名称:roslyn,代码行数:27,代码来源:CommonCompiler.cs

示例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;
            }
        }
开发者ID:riversky,项目名称:roslyn,代码行数:26,代码来源:CommonCompiler.cs

示例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;
            }
        }
开发者ID:riversky,项目名称:roslyn,代码行数:18,代码来源:CommonCompiler.cs

示例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;
        }
开发者ID:riversky,项目名称:roslyn,代码行数:20,代码来源:CommonCompiler.cs

示例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;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:26,代码来源:CommonCompiler.cs


注:本文中的Microsoft.CodeAnalysis.DiagnosticInfo.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。