-
Notifications
You must be signed in to change notification settings - Fork 32
SimpleStubs.generated.cs not generate stubs from shared project. #10
Comments
Hi @poplawskidaniel, I have a feeling that you might have installed SimpleStubs to the wrong project in your solution. If SimpleStubs is installed to The other possibility I can think of is that your interfaces are Please let me know if that's the case. Thanks |
Hi @nehmebilal, I think that I found what is the problem here. Both (App project and Unit tests project) our projects are added as shared reference :( (shared.shproj).
Am I right ? |
@poplawskidaniel No need to install SimpleStubs to a shared project. If you install SimpleStubs to your test project, and the test project has a reference to the shared project (direct reference) or to a project that references the shared project (indirect reference), the stubs will be generated. Did you make sure that your interface is public? I hope that helps. |
@nehmebilal Thanks. My interfaces are public for sure.
Writing 'shared' project I mean special project type in Visual Studio that is named shared project and have shproj extension. @nehmebilal Can you confirm this by checking on your PC? |
Yes I tried the same yesterday and the stubs were generated for shared projects. Even when I had a dependeny to a normal project that was referecing a shared project (without direct dependency from the test project to the shared project it still worked. Can you attach your fake project? I'll take a look. |
Sure. Thanks! So maybe there is a chance that I'm doing something wrong :). |
@poplawskidaniel Looks like you were right :) If your test project directly depends on a shared project, stubs will not be generated. The reason is that a shared project is like a folder of code that gets copied to the project that is referencing it. For this reason, Roslyn doesn't see it as a dependency of the test project but as if the interfaces belonged in the test project itself. As a work around, you can create a class library that depends on the shared project and add a reference the class library to your test project. It's actually recommended to put all your stubs in one class library as explained in the Tips and Tricks section. Your dependencies would basically look like the following:
Let me know if that works? |
@nehmebilal Thank you for answer an idea of work around. Is it possible in future to add implementation that will work also with shared projects ? Also some logs from generation of Stubs would be useful. |
Unfortunately I cannot make it work. I don't want to go to details. Simply reason is that our app is a shared project and have a lot of dependencies. Our test project is also shared project that should have reference to the main etc. I give up for now :(. |
@poplawskidaniel Thanks for the update and sorry that didn't work for you. The fact that your test project is a shared project complicates things quite a bit as this is unusual. If it wasn't, you could add a class library and reference all other shared projects from it, then, reference the class library from the test project. There are two issues we discussed here:
Even if we solve 1, 2 is still an issue for you right? Unfortunately 2 might not be possible because shared projects don't get built like normal projects which makes it impossible to inject a build task into them. Besides, NuGet doesn't support installation to shared projects. |
@nehmebilal Thanks :)
to configuration file. And it works :D. Now I can just add SimpleStubs to my test project (that reference to our shared projects with code) and stubs are there :D. |
Resoved by #12, thanks @poplawskidaniel! |
Hi.
I tried to use SimpleStubs in some C# UWP project. I added nuget package to it as tutorial section describes. Unfortunatelly SimpleStubs.generates.cs file have only this 3 includes inside:
I don't know why :(.
I use shared unit test project that is connected to Solution with SimpleStubs.
To be sure I also created public interface inside solution with SimpleStubs without success :( (Still empty generated file).
There are no errors on output just: "SimpleStubs: Generating stubs".
What can be wrong ?
================================== INFOS ======================
Info:
SimpleStubs: v. 2.3.0
Microsoft Visual Studio Professional 2015
Version 14.0.25431.01 Update 3
Microsoft .NET Framework
Version 4.6.01586
Installed Version: Professional
LightSwitch for Visual Studio 2015 00322-50051-85707-AA788
Microsoft LightSwitch for Visual Studio 2015
Visual Basic 2015 00322-50051-85707-AA788
Microsoft Visual Basic 2015
Visual C# 2015 00322-50051-85707-AA788
Microsoft Visual C# 2015
Visual C++ 2015 00322-50051-85707-AA788
Microsoft Visual C++ 2015
Windows Phone SDK 8.0 - ENU 00322-50051-85707-AA788
Windows Phone SDK 8.0 - ENU
Application Insights Tools for Visual Studio Package 7.11.01104.1
Application Insights Tools for Visual Studio
ASP.NET and Web Tools 2015.1 (Beta8) 14.1.11107.0
ASP.NET and Web Tools 2015.1 (Beta8)
ASP.NET Web Frameworks and Tools 2012.2 4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563
ASP.NET Web Frameworks and Tools 2013 5.2.40314.0
For additional information, visit http://www.asp.net/
Common Azure Tools 1.8
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
JavaScript Language Service 2.0
JavaScript Language Service
JavaScript Project System 2.0
JavaScript Project System
JetBrains ReSharper Ultimate 2016.2.2 Build 106.0.20160913.91321
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2016 JetBrains, Inc.
Microsoft Azure Mobile Services Tools 1.4
Microsoft Azure Mobile Services Tools
NuGet Package Manager 3.4.4
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
PreEmptive Analytics Visualizer 1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.
SQL Server Data Tools 14.0.60519.0
Microsoft SQL Server Data Tools
TypeScript 1.8.36.0
TypeScript tools for Visual Studio
Visual Studio Tools for Universal Windows Apps 14.0.25527.01
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.
XamlStylerVSPackage 1.0
XAML Styler.
The text was updated successfully, but these errors were encountered: