-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Enhance msb4064 unexpected task attribute error #5945
Enhance msb4064 unexpected task attribute error #5945
Conversation
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 looks great, but I have a vague recollection that it isn't enough. I'll try to figure out why I think that and get back to you. Hopefully I can convince myself that past-me was just wrong!
@rainersigwald Perhaps what you feel that is missing here is a path (on local disk) to the assembly?
but when debugging it, this path has always been |
This seems pretty plausible! It would definitely be nice to have the path (I'd strongly prefer that over assembly identity) but I agree with your tradeoffs, and this is better than nothing. Is that path |
@rainersigwald Answering your question: no, the path isn't null when reproducing the error with the example you've provided me with. |
It looks like LoadedAssembly is null for the ValidateNonExistantParameter (sic) test. It looks artificial to me, but are there any circumstances when it would be executing a task without loading an assembly? If so, maybe add a second error possibility depending on whether that exists? |
Looking through the code, Regarding tests, you have to update the mocked types to have an assembly, probably over here: msbuild/src/Build.UnitTests/BackEnd/TaskExecutionHost_Tests.cs Lines 1159 to 1166 in 27981f1
Then you need to write two tests: one when the assembly is null, and one when the assembly is not null, and assert the proper error message in both. |
@BartoszKlonowski, status update? |
@Forgind Thanks for asking, and sorry for such a long delay... |
No worries! If you didn't want to work on it anymore, I was willing to try to get it ship-shape, since I think it's pretty close. End of this week (or end of next week) is fine. Thanks! |
This commit enhances the MSB4064 error with additional information and details such as: - assembly identity - it's full name containing the token ID, version and name.
The enhanced MSB4064 error message has previously been implemented without assembly location. It has been added by this commit. Note that assembly parameter used for the error message has been replaced with loadedAssembly parameter, due to having the null name property.
cd658dd
to
3ba346a
Compare
It turns out, that when executing the tests, the LoadedAssembly is null which breaks the run. To avoid such situation, checking for null has been implemented, so in case of no assembly loaded the type is checked and it's path and name is returned to the user/developer.
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.
LGTM! Thank you!
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.
Looks great! One small nit inline.
src/Build/Resources/Strings.resx
Outdated
@@ -1225,7 +1225,7 @@ | |||
<comment>{StrBegin="MSB4091: "}</comment> | |||
</data> | |||
<data name="UnexpectedTaskAttribute" xml:space="preserve"> | |||
<value>MSB4064: The "{0}" parameter is not supported by the "{1}" task. Verify the parameter exists on the task, and it is a settable public instance property.</value> | |||
<value>MSB4064: The "{0}" parameter is not supported by the "{1}" task loaded from assembly: {2} from the path: {3}. Verify that the parameter exists on the task, the UsingTask points to the correct assembly and it is a settable public instance property.</value> |
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.
super-nit: In many other error messages mentioning UsingTask
I see it wrapped in angle brackets making it clear that it refers to an XML element. Also, a comma before the last and
would be more consistent with the style of the rest of this file.
Thanks @BartoszKlonowski! |
This pull request fixes #3922.
The MSB4064 error has been provided with additional information about the assembly such as it's version, full name, etc.
Changes provided within this commit contains:
Results:
The example of MSB4064 printed is presented below: