Conversation
|
Mightn't the error description contain parentheses? If so, using LastIndexOf would grab it instead. |
|
@adambiser Yeah that's correct. Fixed. |
|
I think we need to find a way to test the change. |
|
@AlekseyTs I agree, but I'm unfortunately unaware of how to test this. |
| /// <param name="singleLine">The line to parse</param> | ||
| /// <param name="messageImportance">The MessageImportance to use when reporting the error.</param> | ||
| internal void ParseVBErrorOrWarning(string singleLine, MessageImportance messageImportance) | ||
| private void ParseVBErrorOrWarning(string singleLine, MessageImportance messageImportance) |
There was a problem hiding this comment.
Agree in general that it's hard to test the various Tasks because it becomes more of an integration test with MSBuild. In this particular case though we're effectively altering how VB error messages are parsed in the task. I think we could factor this method a bit, by either adding a static method or by just newing up the Task in test and setting the properies, and use that to validate this change works (and stays correct going forward).
|
There is a pull request on Youssef1313:patch-7 that has tests and fixes the issue. The fix here does not parse what comes from vbc correctly (should be a space between the end parenthesis and the colon). It has been waiting for a couple of weeks. Should I close it and start a separate pull request for this issue? |
|
It's possible that @Youssef1313 didn't know the request was there? |
|
Possibly, but I thought that sending a pull request also sent a notification. |
On forks, I believe notifications are actually off by default. |
|
OK. I had forked from his fork so I thought he would get notification of the pull request to his repo. |
Verifies the text used for Microsoft.Build.Tasks.CodeAnalysis.UnitTests.CheckErrorAndWarningParsing.
ErrorLoggerEngine was added to capture the parse results as produced by Microsoft.Build.Shared.EventArgsFormatting.
Youssef1313
left a comment
There was a problem hiding this comment.
Thanks @adambiser. That really helped a lot. And sorry for the delay, I didn't get notified of your PR on my fork.
| public void LogCustomEvent(CustomBuildEventArgs eventArgs) | ||
| { | ||
| } | ||
|
|
||
| public void LogMessageEvent(BuildMessageEventArgs eventArgs) | ||
| { | ||
| } |
There was a problem hiding this comment.
Should throw NotImplementedException instead?
There was a problem hiding this comment.
And thank you, too. I had assumed you would get a notification since I had forked from you instead of the main project. Figured other things were filling your time, as is easy to happen nowadays. But now I know.
As for NotImplementedException, I don't think so. I added the class solely to get to the warning and error output, though I guess given the class's limited usage, throwing NotImplementedException in both probably won't affect things.
I also was unaware of how to test this and ended up with two. Not sure whether they will approve of the tests or not though.
| _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)."); |
There was a problem hiding this comment.
Using reflection here concerns me greatly. @rainersigwald, do you have suggestions for a better way to accomplish this?
There was a problem hiding this comment.
For context, we're trying to test our parsing of msbuild error message output in Vbc.exe
There was a problem hiding this comment.
Sorry, missed this. I agree that this feels icky but I'm afraid I don't have a better idea at the moment.
|
@jaredpar, if you have some time can you take a look at this PR? |
jcouv
left a comment
There was a problem hiding this comment.
LGTM (iteration 6). Thanks for figuring out a way to unittest the change.
|
@jaredpar @RikkiGibson Something strange is happening with CI. The Spanish legs fail after retry, but when I try to get details I get "Build not found" (and no details). Any clues? |
|
The build might be too old to retry. I suggest merging master into the PR branch. |
|
The unit tests fail in Spanish because it's checking for the English error message text. But in Spanish it should check for I guess it needs <ConditionalFact(GetType(IsEnglishLocal))> to be skipped for the Spanish checks? |
|
Thanks @adambiser! |
|
Sorry for the delay here. The last commit should hopefully pass CI. |
* upstream/main: (1035 commits) Add missing header Mark IVSTypeScriptFormattingServiceImplementation as optional, but require it in the constructor Fix Go To Base for a symbol with a single metadata location (dotnet#58965) [EnC] Store entire spans instead of line deltas (dotnet#58831) Delete CodeAnalysisRules.ruleset (dotnet#58968) Allow xml docs to still be created when 'emit metadata only' is on. (dotnet#57667) Fix ParseVBErrorOrWarning (dotnet#47833) Update parameter nullability to match implementation Ensure CSharpUseParameterNullCheckingDiagnosticAnalyzer works with nullable parameters Add tests for issues fixed by previous PR (dotnet#58764) Update src/Features/CSharp/Portable/Completion/CompletionProviders/ExplicitInterfaceMemberCompletionProvider.CompletionSymbolDisplay.cs Disallow null checking discard parameters (dotnet#58952) Add extension method Escape type arguments Few fixes Update tests. Add Analyzers layer to CODEOWNERS Add formatting analyzer test for param nullchecking (dotnet#58936) Move reading HideAdvancedMembers option up (dotnet#58747) List patterns: Slice value is assumed to be never null (dotnet#57457) ...
Fixes #47790
Not sure how/where to write tests for this. I was also unable to test this locally due to getting some unrelated exception (#47562 (comment)).