Intellisense fails in VS 2019 for generated stubs
SimpleStubs has an issue where Intellisense fails to work for the generated stubs in VS 2019. The issue occurs in VS 2019 v16.x, including the latest update (v16.4.4).
This was observed in a UWP Unit Test app that references SimpleStubs v2.4.8.2 and a UWP/C# class library containing the stubbed interfaces. The solution builds without errors, the stubs are generated successfully, and the unit tests run, but the text editor shows the dreaded "red squiggles". This same setup worked fine in VS 2017.
Here are the workaround steps:
- Close VS 2019
- Open the SimpleStubs.targets file included with the installed NuGet package, e.g.
%USERPROFILE%\.nuget\packages\simplestubs\2.4.8.2\build\SimpleStubs.targets - Move this
ItemGroupblock above/outside theTargetblock and save the updated file:
<ItemGroup>
<Compile Include="$(SimpleStubsCodeGenOutput)" />
</ItemGroup>
- Open the solution in VS 2019
- Rebuild the solution
After following the steps above, the issue is resolved in VS 2019. Note the updated SimpleStubs.targets file does not appear to impact VS 2017 which continues to work.
@billyzkid does that mean we could update the targets file accordingly and ship it with newer NuGets? If so, would you be able to submit a PR?
Unfortunately, I need special permission from my employer to make open source contributions.
@billyzkid by opening this ticket, you are making an opensource contribution. I suggest to check with your employer but a simple fix is not considered a significant opensource contribution that employers would hold you from making.