Commit e2ae904
authored
RoslynCodeTaskFactory: Log MSB3753 when task class does not implement ITask (#13517)
## Summary
`RoslynCodeTaskFactory.CreateTask()` silently returned `null` when the
inline task class did not implement `ITask`, causing the engine to emit
the generic MSB4060 error. `CodeTaskFactory` already checks for this and
emits the more specific MSB3753 (`CodeTaskFactory.NeedsITaskInterface`).
## Changes
- **`RoslynCodeTaskFactory.cs`**: Added null check after
`Activator.CreateInstance(TaskType) as ITask` — logs MSB3753 via the
existing `_log` instance (set during `Initialize`), matching
`CodeTaskFactory` behavior.
- **`RoslynCodeTaskFactory_Tests.cs`**: Added
`ClassDoesNotInheritFromITask` test 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 `CodeTaskFactory` equivalent test (`CodeTaskFactoryTests.cs`)
already validates this behavior. This was an oversight in
`RoslynCodeTaskFactory` — the two factories should produce the same
diagnostic for this user error.1 parent d1f8fe6 commit e2ae904
2 files changed
Lines changed: 60 additions & 2 deletions
File tree
- src
- Tasks.UnitTests
- Tasks/RoslynCodeTaskFactory
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
36 | 39 | | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
784 | 788 | | |
785 | 789 | | |
786 | 790 | | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
787 | 834 | | |
788 | 835 | | |
789 | 836 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
145 | 156 | | |
146 | 157 | | |
147 | 158 | | |
| |||
0 commit comments