Exemplo n.º 1
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lv.SelectedIndices.Count <= 0)
            {
                return;
            }
            int          i = lv.SelectedIndices[0];
            ListViewItem v = lv.Items[i];

            if (ef == null)
            {
                return;
            }

            if (v.Tag == null)
            {
                return;
            }
            if (v.Tag.GetType() == typeof(Microsoft.Build.Framework.BuildErrorEventArgs))
            {
                Microsoft.Build.Framework.BuildErrorEventArgs b = v.Tag as Microsoft.Build.Framework.BuildErrorEventArgs;

                string project = b.ProjectFile;
                string file    = Path.GetDirectoryName(b.ProjectFile) + "\\" + b.File;
                int    c       = b.LineNumber;
                int    p       = b.ColumnNumber;
                int    es      = b.EndLineNumber;
                int    ep      = b.EndColumnNumber;

                ef.OpenFileLine(file, c.ToString(), p);
            }
            else if (v.Tag.GetType() == typeof(Microsoft.Build.Framework.BuildWarningEventArgs))
            {
                Microsoft.Build.Framework.BuildWarningEventArgs b = v.Tag as Microsoft.Build.Framework.BuildWarningEventArgs;

                string project = b.ProjectFile;
                string file    = Path.GetDirectoryName(b.ProjectFile) + "\\" + b.File;
                int    c       = b.LineNumber;
                int    p       = b.ColumnNumber;
                int    es      = b.EndLineNumber;
                int    ep      = b.EndColumnNumber;

                ef.OpenFileLine(file, c.ToString(), p);
            }
            else if (v.Tag.GetType() == typeof(ViolationEventArgs))
            {
                ViolationEventArgs b = v.Tag as ViolationEventArgs;

                string project = b.SourceCode.Path;
                string file    = Path.GetDirectoryName(project) + "\\" + b.SourceCode.Name;
                int    c       = b.LineNumber;
                int    p       = b.LineNumber;

                //ef.BeginInvoke(new Action(() => { ef.OpenFileLineHighlight(file, c.ToString(), p); }));

                AsyncCallback callBack = new AsyncCallback(ProcessInformation);
                GotoWarning   g        = Warning;
                g.BeginInvoke(file, c.ToString(), p, callBack, "null");
            }
        }
Exemplo n.º 2
0
        private void OnError(object sender, Microsoft.Build.Framework.BuildErrorEventArgs args)
        {
            var msBuildDiagnostic = MSBuildDiagnostic.CreateFrom(args);

            _logger.LogError(msBuildDiagnostic.Message);
            _diagnostics.Add(msBuildDiagnostic);
        }
        public static MSBuildDiagnostic CreateFrom(Microsoft.Build.Framework.BuildErrorEventArgs args)
        {
            string diagnosticText = null;

            // https://github.com/dotnet/msbuild/blob/v16.8.3/src/Tasks/Resources/Strings.resx#L2155-L2158
            // for MSB3644, we should print a different message on Unix because the default one is Windows-specific
            if (args.Code.Equals("MSB3644", StringComparison.OrdinalIgnoreCase))
            {
                // https://github.com/dotnet/msbuild/issues/5820
                // older versions of MSBuild incorrectly treat 'net5.0'/'net6.0' moniker as ".NETFramework,Version=v5.0/6.0"
                // this creates a confusing error message which we convert into a more helpful one
                if (args.Message.Contains(".NETFramework,Version=v5.0"))
                {
                    diagnosticText = Platform.Current.OperatingSystem == Utilities.OperatingSystem.Windows
                    ? ErrorMessages.ReferenceAssembliesNotFoundNet50Windows : ErrorMessages.ReferenceAssembliesNotFoundNet50Unix;
                }
                else if (args.Message.Contains(".NETFramework,Version=v6.0"))
                {
                    diagnosticText = Platform.Current.OperatingSystem == Utilities.OperatingSystem.Windows
                    ? ErrorMessages.ReferenceAssembliesNotFoundNet60Windows : ErrorMessages.ReferenceAssembliesNotFoundNet60Unix;
                }
                else
                {
                    diagnosticText = Platform.Current.OperatingSystem != Utilities.OperatingSystem.Windows
                        ? ErrorMessages.ReferenceAssembliesNotFoundUnix : args.Message;
                }
            }

            return(new MSBuildDiagnostic(MSBuildDiagnosticSeverity.Error,
                                         diagnosticText ?? args.Message, args.File, args.ProjectFile, args.Subcategory, args.Code,
                                         args.LineNumber, args.ColumnNumber, args.EndLineNumber, args.EndColumnNumber));
        }
        void eventSource_ErrorRaised(object sender, Microsoft.Build.Framework.BuildErrorEventArgs e)
        {
            string dir = System.IO.Directory.GetCurrentDirectory();

            string line = String.Format("{0}({1},{2}): error {3}: {4} ", System.IO.Path.Combine(dir, e.File), e.LineNumber, e.ColumnNumber, e.Code, e.Message);

            Console.WriteLine(line);
        }
Exemplo n.º 5
0
            private void OnErrorRaised(object sender, MSB.Framework.BuildErrorEventArgs e)
            {
                if (_hasError)
                {
                    _writer.WriteLine();
                }

                _writer.Write($"{e.File}: ({e.LineNumber}, {e.ColumnNumber}): {e.Message}");
                _hasError = true;
            }
Exemplo n.º 6
0
        private void EventSource_ErrorRaised(object sender, Microsoft.Build.Framework.BuildErrorEventArgs e)
        {
            var sb = new StringBuilder();

            sb.Append($"Error {e.Code}");
            sb.AppendLine(e.Message);
            sb.AppendLine($"Project: {e.ProjectFile}");
            sb.AppendLine($"Line {e.LineNumber} Column {e.ColumnNumber} in file {e.File}");
            sb.Append($"{new string('*', 50)}");
            Logger.Error(sb.ToString());
        }
        public static MSBuildDiagnostic CreateFrom(Microsoft.Build.Framework.BuildErrorEventArgs args)
        {
            // https://github.com/dotnet/msbuild/blob/v16.8.3/src/Tasks/Resources/Strings.resx#L2155-L2158
            // for MSB3644, we should print a different message on Unix because the default one is Windows-specific
            var diagnosticText = args.Code.Equals("MSB3644", StringComparison.OrdinalIgnoreCase) &&
                                 Platform.Current.OperatingSystem != Utilities.OperatingSystem.Windows
                ? ErrorMessages.ReferenceAssembliesNotFoundUnix : args.Message;

            return(new MSBuildDiagnostic(MSBuildDiagnosticSeverity.Error,
                                         diagnosticText, args.File, args.ProjectFile, args.Subcategory, args.Code,
                                         args.LineNumber, args.ColumnNumber, args.EndLineNumber, args.EndColumnNumber));
        }
Exemplo n.º 8
0
 private void OnError(object sender, Microsoft.Build.Framework.BuildErrorEventArgs args)
 {
     _logger.LogError(args.Message);
     _diagnostics.Add(new MSBuildDiagnosticsMessage()
     {
         LogLevel    = "Error",
         FileName    = args.File,
         Text        = args.Message,
         StartLine   = args.LineNumber,
         StartColumn = args.ColumnNumber,
         EndLine     = args.EndLineNumber,
         EndColumn   = args.EndColumnNumber
     });
 }
Exemplo n.º 9
0
 private void OnErrorRaised(object sender, MSB.Framework.BuildErrorEventArgs e)
 {
     RoslynDebug.AssertNotNull(_projectFilePath);
     _log?.Add(
         new MSBuildDiagnosticLogItem(
             WorkspaceDiagnosticKind.Failure,
             _projectFilePath,
             e.Message,
             e.File,
             e.LineNumber,
             e.ColumnNumber
             )
         );
 }
Exemplo n.º 10
0
 public void ErrorHandler(object sender, Microsoft.Build.Framework.BuildErrorEventArgs e)
 {
 }
Exemplo n.º 11
0
 void eventSource_ErrorRaised(object sender, Microsoft.Build.Framework.BuildErrorEventArgs e)
 {
     logger.Debug("buildlog: {1}: {2} in {3} at {4}", e.Timestamp, e.SenderName, e.Message, e.File, e.LineNumber);
     log.AppendFormat("\t[{0}] {1}: {2} in {3} at {4}", e.Timestamp, e.SenderName, e.Message, e.File, e.LineNumber);
 }
Exemplo n.º 12
0
 void eventSource_ErrorRaised(object sender, Microsoft.Build.Framework.BuildErrorEventArgs e)
 {
     Console.ForegroundColor = ConsoleColor.DarkRed;
     Console.WriteLine(e.Message);
     Console.ResetColor();
 }
Exemplo n.º 13
0
        private void OnError(object sender, Microsoft.Build.Framework.BuildErrorEventArgs args)
        {
            _logger.LogError(args.Message);

            AddDiagnostic("Error", args.File, args.Message, args.LineNumber, args.ColumnNumber, args.EndLineNumber, args.EndColumnNumber);
        }
Exemplo n.º 14
0
 public static MSBuildDiagnostic CreateFrom(Microsoft.Build.Framework.BuildErrorEventArgs args)
 => new MSBuildDiagnostic(MSBuildDiagnosticSeverity.Error,
                          args.Message, args.File, args.ProjectFile, args.Subcategory, args.Code,
                          args.LineNumber, args.ColumnNumber, args.EndLineNumber, args.EndColumnNumber);
 private void eventSource_ErrorRaised(object sender, Microsoft.Build.Framework.BuildErrorEventArgs e)
 {
     OutputString(EventArgsFormatter.FormatEventMessage(e, false, true));
 }
Exemplo n.º 16
0
 public virtual string FormatErrorEvent(Microsoft.Build.Framework.BuildErrorEventArgs args)
 {
     throw null;
 }
Exemplo n.º 17
0
        private void Dg_SelectionChanged(object sender, EventArgs e)
        {
            if (dg.SelectedRows.Count <= 0)
            {
                return;
            }
            int i = dg.SelectedRows[0].Index;

            DataGridViewRow v = dg.Rows[i];

            if (ef == null)
            {
                return;
            }

            if (v.Tag == null)
            {
                return;
            }
            if (v.Tag.GetType() == typeof(Microsoft.Build.Framework.BuildErrorEventArgs))
            {
                Microsoft.Build.Framework.BuildErrorEventArgs b = v.Tag as Microsoft.Build.Framework.BuildErrorEventArgs;

                string project = b.ProjectFile;
                string file    = Path.GetDirectoryName(b.ProjectFile) + "\\" + b.File;
                int    c       = b.LineNumber;
                int    p       = b.ColumnNumber;
                int    es      = b.EndLineNumber;
                int    ep      = b.EndColumnNumber;

                AsyncCallback     callBack = new AsyncCallback(ProcessInformation);
                workerDisplayLine wde      = DisplayLine;
                wde.BeginInvoke(file, c, p, 100, callBack, "null");

                // ef.OpenFileLine(file, c.ToString(), p);
            }
            else if (v.Tag.GetType() == typeof(Microsoft.Build.Framework.BuildWarningEventArgs))
            {
                Microsoft.Build.Framework.BuildWarningEventArgs b = v.Tag as Microsoft.Build.Framework.BuildWarningEventArgs;

                string project = b.ProjectFile;
                string file    = Path.GetDirectoryName(b.ProjectFile) + "\\" + b.File;
                int    c       = b.LineNumber;
                int    p       = b.ColumnNumber;
                int    es      = b.EndLineNumber;
                int    ep      = b.EndColumnNumber;

                AsyncCallback     callBack = new AsyncCallback(ProcessInformation);
                workerDisplayLine wde      = DisplayLine;
                wde.BeginInvoke(file, c, p, 100, callBack, "null");

                //ef.OpenFileLine(file, c.ToString(), p);
            }
            else //if (v.Tag.GetType() == typeof(Diagnostic))
            {
                Diagnostic b = v.Tag as Diagnostic;

                if (b != null)
                {
                    //string project = b.vp.FileName;
                    if (b.Location == Microsoft.CodeAnalysis.Location.None)
                    {
                        return;
                    }
                    if (b.Location.SourceTree == null)
                    {
                        return;
                    }
                    string file = b.Location.SourceTree.FilePath;

                    Microsoft.CodeAnalysis.FileLinePositionSpan c = b.Location.GetLineSpan();
                    int ps = c.StartLinePosition.Line;
                    int cs = 0;
                    int es = c.StartLinePosition.Character;

                    int start  = b.Location.SourceSpan.Start;
                    int length = b.Location.SourceSpan.Length;

                    AsyncCallback     callBack = new AsyncCallback(ProcessInformation);
                    workerDisplayLine wde      = DisplayLine;
                    wde.BeginInvoke(file, start, length, 100, callBack, "null");

                    //ef.OpenFileLine(file, c.ToString(), p);
                }
            }
        }