SimpleStubs icon indicating copy to clipboard operation
SimpleStubs copied to clipboard

Intellisense fails in VS 2019 for generated stubs

Open billyzkid opened this issue 6 years ago • 3 comments

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:

  1. Close VS 2019
  2. Open the SimpleStubs.targets file included with the installed NuGet package, e.g. %USERPROFILE%\.nuget\packages\simplestubs\2.4.8.2\build\SimpleStubs.targets
  3. Move this ItemGroup block above/outside the Target block and save the updated file:
<ItemGroup>
  <Compile Include="$(SimpleStubsCodeGenOutput)" />
</ItemGroup>
  1. Open the solution in VS 2019
  2. 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 avatar Jan 30 '20 18:01 billyzkid

@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?

nehmebilal avatar Feb 01 '20 09:02 nehmebilal

Unfortunately, I need special permission from my employer to make open source contributions.

billyzkid avatar Feb 02 '20 04:02 billyzkid

@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.

nehmebilal avatar Aug 09 '20 05:08 nehmebilal