microsoft / SimpleStubs

*SimpleStubs* is a simple mocking framework that supports Universal Windows Platform (UWP), .NET Core and .NET framework. SimpleStubs is currently developed and maintained by Microsoft BigPark Studios in Vancouver.
Other
66 stars 29 forks source link

SimpleStubs causes Visual Studio to freeze #45

Closed jlittorin closed 6 years ago

jlittorin commented 6 years ago

Hi,

In a fairly large solution (~70 projects), we use SimpleStubs in three projects. Often after a build, or when adding or removing files from a project, Visual Studio freezes for quite some time (up to a minute, I think). In Task Manager I see the SimpleStubs subprocess under Visual Studio using around 20% of the CPU. Once SimpleStubs CPU goes down to 0, Visual Studio unfreezes.

I'm using Visual Studio 2017 15.6.5, SimpleStubs 2.4.7.

nehmebilal commented 6 years ago

@jlittorin SimpleStubs scans all the code to generate stubs and it does it on every build.

As you can see in ProjectStubber class, we iterate over all interfaces and generate stubs.

This performance drawback is only noticeable on large solutions like yours where the test project is referencing many projects.

There are few options to consider:

As for a long term solution, we would need to optimize stubs generation so we can reuse existing stubs (generated from previous builds) instead of generating them on every build. Another simpler option would be to manually pick interfaces that need to be stubbed. This can be done by using an attribute on the interface, using a configuration file, or simply right-click -> generate stub in visual studio.

I'd suggest you try one of the first two options as a first step and see how it goes.

davidbozjak commented 6 years ago

@jlittorin were you able to confirm it's also SimpleStubs running after adding/removing files?

@nehmebilal if that is the case, is SimpleStubs also doing work outside of build? Is it needed? Can it be disabled via a setting?

jlittorin commented 6 years ago

In the case of a build, it's after the build has completed that VS freezes (the VS status bar will say "Build Completed"/"Failed") -- I would have expected SimpleStubs to go to work during the build.

I could be wrong about adding/removing files. Also worth mentioning, not everyone on the team seems to see this. I'll do some more investigations.

nehmebilal commented 6 years ago

SimpleStubs does not do any work outside of the build. Unless something cause the SimpleStubs process to hang, it should completely die before the build is done.

jlittorin commented 6 years ago

It seems like this was an issue with VisualStudio rather than SimpleStubs; after upgrading to VS 15.7.3 I no longer see it