Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tasks
Log.HasLoggedError
now respectsMSBuildWarningsAsErrors
#6174Tasks
Log.HasLoggedError
now respectsMSBuildWarningsAsErrors
#6174Changes from 11 commits
8ca466d
ff95db2
16cd7f0
2b61f12
07fbbb7
8da9849
8f58790
cf90ca0
fda18f5
4a93c5a
cdb831e
6cd3074
53c5b0e
4af8ce6
b396ed5
764df59
fdd2419
5d7b16a
83f1b66
63be126
28f55cb
787982a
d2c230c
7aa9763
febb509
0ccb51c
7670dea
9a485da
924423b
a969d83
b65e272
9856364
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this may not work with tasks that implement ITask directly. Can you please add another test just like this one but calling a task implementing ITask directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Going to brain dump this before making the test.
Someone implementing ITask wouldn't have access to a TaskLoggingHelper (like Task does) and thus have to log a warning through the
BuildEngine.LogWarningEvent
. The build engine would log it to the logging service as a warning and atLoggingService.RouteBuildEvent
it would be translated into an error.But I think the build would continue because it entirely depends on what the task returned right? So long as the task returns true despite logging an error, the build will complete.
Question, what context would someone implement itask vs inheriting from task?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't really know why people would do it, but according to this GH search they do it.
I think MSBuild might either warn or error that the ITask instance returned true but an error was logged. Not super sure about this though, so worth writing a test to pin the behaviour :)
On the other hand, since an ITask implementation cannot know whether any errors were logged (because it does not have access to
Log
), it can't really condition its return value. So maybe this whole scenario does not make sense and we can ignore it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that there's no need to check this on an ITask. Something interesting about the error task. It explicitly returns false otherwise the build would continue:
msbuild/src/Tasks/Error.cs
Line 47 in f0eebf2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It comes from an era where an error was an error, so returning false made sense :)
I'd wait until somebody reports an issue and then update both Error and Warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, why is that wrong? A task returns false if it logged an error. The Error task is designed to log an error, hence always returns "HasLoggedAnError."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have included it in the code sample, but the error task called
Log.LogError
and simply returns false, notLog.HasLoggedErrors
.Edit: So if the error task returned true, the build would continue despite it having logged an error. So we'd see the rest of the build but we'd get a
Build Failed
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right...it has always logged an error because it logs an error right before the return statement.
Right, and people who log errors tend to want execution to stop at that point. No point continuing if something went irredeemably wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need to make this a public API? Isn't it enough to just ensure that HasLoggedErrors works as expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'll remove public on warningsaserrors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So do we need IBuildEngine8 then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may have been confused by the original question. WarningsAsErrors needs to be visible to the tasklogginghelper so it can determine if it actually logged an error when it tries to log a warning. Without IBE8 having this hashset I'm not aware of a to get that info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interface members are public by default so if you remove the public keyword nothing will change, it will still be a public member on a public interface.
So I guess to answer Mihai's question we do need an
IBuildEngine8
and it does need to have theWarningsAsErrors
member, right? Just to confirm.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the value of the private part of the public/private split interfaces? I do like the final abstract class plan, but marcpopMSFT suggested we should wait for rainersigwald before making that kind of decision, so I shelved my planned implementation of that for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was assuming it somehow prevents fixing
TaskLoggingHelper.HasLoggedErrors
to return true when logging warnings-as-errors, but it turns out it's not needed. Why do tasks require a new API in addition to the existingTaskLoggingHelper.HasLoggedErrors
? In order to allow them to inhibit logging a warning if turns out to be an error? That does not sound like safe behaviour :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see, and you're right. I got so focused on the solution that I forgot about the motivating problem. That sounds reasonable to me, though—@benvillalobos, could this interface be internal? Maybe have IBuildEngine7 extend WarningsAsErrorsBuildEngine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where I'm at with IBuildEngine. IMO we take one more "this is the way we've done it" IBE PR and stop at IBE9 when we implement the abstract class. Otherwise why would we extend private IBE interfaces after we add the abstract class?
It sounds like it would be even messier to have a single private IBE8, all previous IBE's are public, then we make the abstract class and have no use for private IBE's.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mkay, took another look at the code. So TaskLoggingHelper gets an
IBuildEngine
, and that's how it interacts with theTaskHost:IBuildEngine{N}
which knows about warnings-as-errors from its TaskLoggingContext. Beyond keeping it public, any solution I can think of is pretty messy. So public it is then :)