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.
Fixes #7842
Context
Both "MSBuild inline tasks" and "MSBuild inline tasks with RoslynCodeTaskFactory" documentation pages contain a note:
When this situation is detected, there is an error, but the error message is not helpful and doesn't explain the real issue.
PR #2363 added a throw of an exception when
TaskType
is not set. This is not a recent change but unfortunately, it appears to have impacted the messaging for the mismatchedTaskName
and class name error.Changes Made
CodeTaskFactory.CouldNotFindTaskInAssembly
error is logged (not thrown). This log message is rolled up to aMSB4036
error.ITaskFactory
instances, but the test was modified to include checking ifITaskFactory.Initialize()
returnedtrue
. WhenInitialize()
fails and returnsfalse
, the parentGetTaskFactory()
method will returnfalse
. WhenInitialize()
returnsfalse
,GetTaskFactory()
should not perform other work. Within anelse
block whereInitialize()
is called, a check ofTaskFactoryParameters
is now qualified to only be performed whenITaskFactory.Initialize()
returnstrue
trim_trailing_whitespace = false
. The unit test file contains expected source code output that contains trailing whitespace. The auto-formatting will break the unit tests.CodeLanguageFromTaskBody()
to test thatLanguage
will default to C#.CSharpClass()
andCSharpClassSourceCodeFromFile()
to provide coverage ofType="Class"
.MismatchedTaskNameAndTaskClassName()
to test the error messaging changeTesting
Tested on Windows 11 and macOS 12.
Tested by running the full set of unit tests.
Tested by running a test solution + project.
Notes
In the original issue there is a further problem with the code where the output parameter is missing in the class source code. The error messaging for this situation could also be improved but is not addressed in this PR.