-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix ParseVBErrorOrWarning * Update Vbc.cs * internal -> private * Added test to verify error reporting from the VB compiler. Verifies the text used for Microsoft.Build.Tasks.CodeAnalysis.UnitTests.CheckErrorAndWarningParsing. * Added test to verify that column numbers insert correctly. ErrorLoggerEngine was added to capture the parse results as produced by Microsoft.Build.Shared.EventArgsFormatting. * Needs a space between the end parenthesis and the colon. * Update ErrorLoggerEngine.cs * Update Vbc.cs * Update VbcTests.cs * Make internal and fix spanish test failure * Address feedback Co-authored-by: Adam Biser <adambiser@gmail.com> Co-authored-by: Julien Couvreur <julien.couvreur@gmail.com>
- Loading branch information
1 parent
3fad507
commit 094bee3
Showing
6 changed files
with
140 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/Compilers/Core/MSBuildTaskTests/TestUtilities/ErrorLoggerEngine.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Reflection; | ||
using System.Text; | ||
using Microsoft.Build.Framework; | ||
|
||
namespace Microsoft.CodeAnalysis.BuildTasks.UnitTests | ||
{ | ||
/// <summary> | ||
/// An engine to output event messages as MSBuild does to test Vbc.ParseVBErrorOrWarning. | ||
/// </summary> | ||
internal sealed class ErrorLoggingEngine : IBuildEngine | ||
{ | ||
private StringBuilder _log = new StringBuilder(); | ||
public MessageImportance MinimumMessageImportance = MessageImportance.Low; | ||
private readonly MethodInfo _formatErrorMethod; | ||
private readonly MethodInfo _formatWarningMethod; | ||
|
||
public ErrorLoggingEngine() | ||
{ | ||
// Use the formatting from Microsoft.Build.Shared.EventArgsFormatting. | ||
var assembly = Assembly.LoadFrom("Microsoft.Build.dll"); | ||
var formattingClass = assembly.GetType("Microsoft.Build.Shared.EventArgsFormatting") ?? throw new Exception("Could not find EventArgsFormatting type"); | ||
_formatErrorMethod = formattingClass.GetMethod("FormatEventMessage", BindingFlags.Static | BindingFlags.NonPublic, null, CallingConventions.Any, | ||
new Type[] { typeof(BuildErrorEventArgs) }, null) ?? throw new Exception("Could not find FormatEventMessage(BuildErrorEventArgs)."); | ||
_formatWarningMethod = formattingClass.GetMethod("FormatEventMessage", BindingFlags.Static | BindingFlags.NonPublic, null, CallingConventions.Any, | ||
new Type[] { typeof(BuildWarningEventArgs) }, null) ?? throw new Exception("Could not find FormatEventMessage(BuildWarningEventArgs)."); | ||
} | ||
|
||
internal string Log | ||
{ | ||
set { _log = new StringBuilder(value); } | ||
get { return _log.ToString(); } | ||
} | ||
|
||
public void LogErrorEvent(BuildErrorEventArgs eventArgs) | ||
{ | ||
_log.Append(_formatErrorMethod.Invoke(null, new object[] { eventArgs })); | ||
_log.AppendLine(); | ||
} | ||
|
||
public void LogWarningEvent(BuildWarningEventArgs eventArgs) | ||
{ | ||
_log.Append(_formatWarningMethod.Invoke(null, new object[] { eventArgs })); | ||
_log.AppendLine(); | ||
} | ||
|
||
public void LogCustomEvent(CustomBuildEventArgs eventArgs) | ||
{ | ||
} | ||
|
||
public void LogMessageEvent(BuildMessageEventArgs eventArgs) | ||
{ | ||
} | ||
|
||
public string ProjectFileOfTaskNode => ""; | ||
public int ColumnNumberOfTaskNode => 0; | ||
public int LineNumberOfTaskNode => 0; | ||
public bool ContinueOnError => true; | ||
|
||
public bool BuildProjectFile(string projectFileName, string[] targetNames, IDictionary globalProperties, IDictionary targetOutputs) | ||
=> throw new NotImplementedException(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters