RoslynCodeTaskFactory: Log MSB3753 when task class does not implement ITask#13517
Conversation
There was a problem hiding this comment.
Pull request overview
Aligns RoslynCodeTaskFactory diagnostics with CodeTaskFactory by emitting MSB3753 when an inline task class doesn’t implement ITask, instead of failing later with a generic MSB4060.
Changes:
- Add a null-check in
RoslynCodeTaskFactory.CreateTask()and logCodeTaskFactory.NeedsITaskInterface(MSB3753) when the created instance can’t be cast toITask. - Add an end-to-end unit test validating the MSB3753 behavior for both in-proc and forced out-of-proc inline task factory paths.
- Add a new regression test covering successful execution when the temp directory path does not exist.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Tasks/RoslynCodeTaskFactory/RoslynCodeTaskFactory.cs | Adds MSB3753 logging when the compiled inline task type does not implement ITask. |
| src/Tasks.UnitTests/RoslynCodeTaskFactory_Tests.cs | Adds coverage for the new MSB3753 behavior and an additional temp-directory regression scenario. |
There was a problem hiding this comment.
Security Awareness — LGTM
No security regression. Activator.CreateInstance(TaskType) was already the existing instantiation path; the only addition is a null-guard with error logging. No changes to type loading policy, file operations, or path handling.
Note
🔒 Integrity filter blocked 1 item
The following item were blocked because they don't meet the GitHub integrity level.
- #13517
search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
To allow these resources, lower min-integrity in your GitHub frontmatter:
tools:
github:
min-integrity: approved # merged | approved | unapproved | noneGenerated by Expert Code Review (on open) for issue #13517 · ● 25M
Summary
RoslynCodeTaskFactory.CreateTask()silently returnednullwhen the inline task class did not implementITask, causing the engine to emit the generic MSB4060 error.CodeTaskFactoryalready checks for this and emits the more specific MSB3753 (CodeTaskFactory.NeedsITaskInterface).Changes
RoslynCodeTaskFactory.cs: Added null check afterActivator.CreateInstance(TaskType) as ITask— logs MSB3753 via the existing_loginstance (set duringInitialize), matchingCodeTaskFactorybehavior.RoslynCodeTaskFactory_Tests.cs: AddedClassDoesNotInheritFromITasktest covering both in-proc and out-of-proc (MSBUILDFORCEINLINETASKFACTORIESOUTOFPROC) paths.Context
I noticed this when trying to migrate usage of CodeTaskFactory to RoslynCodeTaskFactory and checking for coverage parity between these two factories as part of that.
The
CodeTaskFactoryequivalent test (CodeTaskFactoryTests.cs) already validates this behavior. This was an oversight inRoslynCodeTaskFactory— the two factories should produce the same diagnostic for this user error.