Giter Club home page Giter Club logo

simplestubs's Introduction

SimpleStubs

Join the chat at https://gitter.im/Microsoft/SimpleStubs Build status NuGet

SimpleStubs is a simple mocking framework that supports Universal Windows Platform (UWP), .NET Core and .NET framework. SimpleStubs was developed and is maintained by Nehme Bilal, a software engineer at Microsoft Vancouver.

The framework can be installed to your test project using SimpleStubs NuGet package.

Please read the documentation below to learn more about how to install and use SimpleStubs.

Documentation

Contribute!

We welcome contributions of all sorts including pull requests, suggestions, documentation, etc. Please feel free to open an issue to discuss any matter.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

License

This project is licensed under the MIT license.

simplestubs's People

Contributors

arashadbm avatar bkardol avatar gitter-badger avatar jlaanstra avatar microsoft-github-policy-service[bot] avatar msftgits avatar nehme-bilal-ah avatar nehmebilal avatar poplawskidaniel avatar portikus avatar timpalpant avatar velocitysystems avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simplestubs's Issues

Issue with generic interface

Hello Awesome SimpleStubs team,

I found an issue in the generated stubs for the following case of generic interface.

 public interface IFlyoutWrapper<TVm, TR> where TVm : class, IDismissible<TR>
    {
        TVm ViewModel { get; }
        bool IsOpened { get; }
        Flyout Flyout { get; set; }
        Task<TR> ShowAsync();
    }

 public interface IDismissible<T>
    {
        event EventHandler<T> DismissRequested;
    }

Actual Stubs result:

   [CompilerGenerated]
    public class StubIFlyoutWrapper<TVm, TR> : IFlyoutWrapper<TVm, TR> where TVm : class, IDismissible
    {
      ...
    }

Expected Stubs result:

   [CompilerGenerated]
    public class StubIFlyoutWrapper<TVm, TR> : IFlyoutWrapper<TVm, TR> where TVm : class, IDismissible<TR>
    {
      ...
    }

More background on the use case, the IFlyoutWrapper interface accepts two generic parameters, the first one refers to viewmodel type which should implement the interface IDismissable. TR here refers to the return type expected to be returned from this viewmodel.

I'm using the latest Nugget version 2.3.4

Best,
Ahmed

SimpleStubs.generated.cs does not change

Hi,

I have tried to use SimpleStubs but no matter what I do, the SimpleStubs.generated.cs contains only these three lines:

using System; using System.Runtime.CompilerServices; using Etg.SimpleStubs;

This is what I tried:

  • I created a Unit Test (Universal Windows) project in VS 2015.
  • I added the SimpleStubs NuGet package to the test project.
  • I created a reference in the test project to my other Universal Windows project that I need to test. Let's call it Project1.
  • I created a SimpleStubs.json file in the root of my test project and set "StubInternalInterfaces": true because I need to stub the internal interfaces of the Project1.
  • I re-build the entire solution.
  • SimpleStubs.generated.cs did not change. It contained the same three using statements as before.
  • I added a public interface to Project1 (just for testing) and re-built the projects. SimpleStubs.generated.cs did not change.
  • I re-installed the SimpleStubs NuGet package and re-built the projects. SimpleStubs.generated.cs did not change.
  • I set "StubCurrentProject": true in the SimpleStubs.json file and re-built the projects. SimpleStubs.generated.cs did not change.

What else can I try? Apparently, I must do something wrong. The projects are not shared so the solution from here: #10 does not work.

Thanks,
Leszek

Unused using directive when exculding interfaces

I referenced a project with a nuget package. The referenced project contains one interface with at least one method that returns types from the nuget package.
I excluded this interface and the interface is successfully ignored by SimpleStubs.
However, the using directive to the nuget package is still there and I cannot build the UnitTest project.
I have to reference the nuget package to make it build.

Async events are not awaitable.

Hi,

I want to stub a Interface containing a event with a delegate which returns a Task.

delegate Task AsyncEventHandler(object sender, EventArgs eventArgs);
event AsyncEventHandler AsyncEvent;

If I now try to generate a stub, SimpleStubs handles this event like a normal event and creates a AsyncEvent_Raise method with return type void. But of corse this wont work if I want to await the raised event in my unit tests.

I created a extension method to raise such an async event in my code (see AsyncEventHandlerExtension in repo solution). There you can see what to do if an event delagate is having a Task as return type.

But maybe you just return an IEnumerable<T> to handle every return type and let it to the user to handle the return type.

Repo solution: SimpleStubsAndAsyncEvent.zip

Repo steps:

  1. Restore nuget packages
  2. Build solution
    => build error "can not await void" in TestClass.cs

Simplestubs encountered errors when opening the workspace (referenced project platform different from test project)

Things seem to work properly but I am seeing this message for referenced projects with a platform different from the unit test platform (i.e. x64, Any CPU)

Simplestubs encountered errors when opening the workspace; Stubs will be generated only for projects that successfully opened..Cannot resolve Assembly or Windows Metadata file...

Simple Stubs is looking for the dll in the wrong folder. In the Configuration Manager the project dll that SimpleStubs can't find is listed as Any CPU, where as the unit test project is listed as x64. SimpleStubs in looking for the compiled dlls in bin\x64\Debug when according to the Configuration Manager it should be looking for it in bin\Debug because the project platfor is Any CPU

SimpleStubs.json file generating stubs for ignored interface

I have an interface like below :

namespace RepoLib.Data.RepositoryInterface
{
    public interface IRepository<TDomain, TEntity> where TEntity : IEntity
    {
        Task InsertOrUpdateAsync(TDomain domainObject);
        Task InsertOrUpdateAsync(List<TDomain> domainObjects);
    }

    public interface IMyRepository : IRepository<MyDomainClass, MyEntityClass>
    {
        Task<List<MyDomainClass>> GetSomethingExceptional();
    }
}

namespace RepoLib.Data.Repository
{
    public interface MyRepository : IMyRepository 
    {
        // Interface implementation
    }
}

I don't want to generate stubs for IRepository interface, so I did below in SimpleStubs.json

{
    "IgnoredProjects": [
        "MyLib.Common",
        "MyLib.Domain",
        "MyLib.Framework"
      ],
  "IgnoredInterfaces": [
    "RepoLib.Data.RepositoryInterface.IRepository"
  ],
    "StubInternalInterfaces": false    
}

Problem is, when I build, it still generating stubs for IRepository

Stub generation leading to uncompilable code with a certain form of event handlers

When I have events/delegates like the following:

public delegate void ColorsUpdatedHandler(string primaryColor, string secondaryColor, string tertiaryColor);

public interface IAppServices
{
    event ColorsUpdatedHandler ColorsUpdated;
    ...
}

the code generation is confused by the delegate declaration. It seems to be expecting something like, handler(object sender, EventArgs args), rather than the actual delegate declaration.

Error with interfaces having methods returning tuples

Hi,

It seems the methods returning tuples cannot be stubbed right now:

For instance:
DateTime min, DateTime max) ComputeDates();

Causes the following code to be generated:
void global::My.Package.IService.ComputeDates()

Instead of:
(DateTime min, DateTime max) global::My.Package.IService.ComputeDates()

Alex.

Issue in generating generic interface with gerneric parameter referring to the interface itself

Hello, SimpleStubs has trouble generating stub for a generic interface with T referring to the interface itself.

Example :

public interface IUpdatable<T> : IEquatable<T> where T : IUpdatable<T>
   {
       void Update(T newItem);
   }
  • Expected Stub :
  public class StubIUpdatable<T> : IUpdatable<T> where T : IUpdatable<T>
  {
  }
  • Actual Stub :
  public class StubIUpdatable<T> : IUpdatable<T> where T : IUpdatable
  {
  }

Best,
Ahmed
P.S you guys are doing great job with this tool.

Unable to exclude vcxproj file

In my solution there is a '.vcxproj' file. When compiling the unit test project with Etg.SimpleStubs, I get the error message:
1> Simplestubs encountered errors when opening the workspace; Stubs will be generated only for projects that successfully opened. Errors: [Failure] Cannot open project '.vcxproj' because the file extension '.vcxproj' is not associated with a language.
Adding the name of the project to the 'SimpleStubs.json' file in the 'IgnoredProjects' node, does not solve the error.

Latest version does not compile when test project has x64-only project reference

Even though I have specified the x64 build configuration for my solution and in my Tests project settings, SimpleStubs appears to force one of my project references to compile using "Any CPU" which will not work as this project includes native dependencies (ADBMobile) and can only target x86, x64, or ARM. If I unload the Tests project, the solution builds fine.

This did not occur in the previous version of SimpleStubs.

Here is the relevant error output:

10>  SimpleStubs: Generating stubs for project: C:\Code\Foo\Tests\Tests.csproj
10>  SimpleStubs: Failed to generate stubs: System.AggregateException: One or more errors occurred. ---> System.Exception: Failed to open project, Errors: [Failure] Msbuild failed when processing the file 'C:\Code\Foo\SDK\SDK.csproj' with message: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets: (2307, 5): The processor architecture of the project being built "Any CPU" is not supported by the referenced SDK "ADBMobile, Version=4.0". Please consider changing the targeted processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: "x86, ARM, x64".
10>  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets: (2307, 5): The processor architecture of the project being built "Any CPU" is not supported by the referenced SDK "Microsoft.VCLibs, Version=14.0". Please consider changing the targeted processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: "x86, x64, ARM, ARM64".
10>  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets: (2307, 5): The processor architecture of the project being built "Any CPU" is not supported by the referenced SDK "Microsoft.VCLibs.120, Version=14.0". Please consider changing the targeted processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: "x86, x64, ARM".
10>  
10>     at Etg.SimpleStubs.CodeGen.SimpleStubsGenerator.<GenerateStubs>d__3.MoveNext()
10>     --- End of inner exception stack trace ---
10>     at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
10>     at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
10>     at System.Threading.Tasks.Task`1.get_Result()
10>     at Etg.SimpleStubs.CodeGen.Program.Main(String[] args)
10>  ---> (Inner Exception #0) System.Exception: Failed to open project, Errors: [Failure] Msbuild failed when processing the file 'C:\Code\Foo\SDK\SDK.csproj' with message: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets: (2307, 5): The processor architecture of the project being built "Any CPU" is not supported by the referenced SDK "ADBMobile, Version=4.0". Please consider changing the targeted processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: "x86, ARM, x64".
10>  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets: (2307, 5): The processor architecture of the project being built "Any CPU" is not supported by the referenced SDK "Microsoft.VCLibs, Version=14.0". Please consider changing the targeted processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: "x86, x64, ARM, ARM64".
10>  C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets: (2307, 5): The processor architecture of the project being built "Any CPU" is not supported by the referenced SDK "Microsoft.VCLibs.120, Version=14.0". Please consider changing the targeted processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: "x86, x64, ARM".
10>  
10>     at Etg.SimpleStubs.CodeGen.SimpleStubsGenerator.<GenerateStubs>d__3.MoveNext()<---
10>  
10>CSC : error CS2001: Source file 'C:\Code\Foo\Tests\obj\x64\Debug\SimpleStubs.generated.cs' could not be found.
========== Rebuild All: 9 succeeded, 1 failed, 0 skipped ==========

Etg.SimpleStubs Missing Reference

Hi,

I'm using VS 2013 Pro. I installed Etg.SimpleStubs via the package manager console. I'm getting: Error 1 The type or namespace name 'Etg' could not be found (are you missing a using directive or an assembly reference?)

I'm getting that in SimpleStubs.generated.cs:

using System;
using System.Runtime.CompilerServices;
using Etg.SimpleStubs;

Thanks,
Darren

Edit:
Okay so I downloaded the package and extracted the proper version, added a reference and it works. I'm running Windows 10.

Edit Again:
It's making stubs but I'm getting a compiler error.

        public delegate float AdjustedFitness_Get_Delegate();

        public StubIIndividual **AdjustedFitness_Get**(AdjustedFitness_Get_Delegate del, int count = Times.Forever, bool overwrite = false)
        {
            _stubs.SetMethodStub(del, count, overwrite);
            return this;
        }


The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

SimpleStubs not generating stubs with generic Enum constraints correctly

It looks like the latest version of SimpleStubs (2.4.7) is not generating stubs with generic enum constraints correctly (new in C# 7.3). This is the build error I'm getting:

Error	CS0314	The type 'TFrame' cannot be used as type parameter 'TFrame' in the generic type or method 'INavigationService<TFrame, TPage>'. There is no boxing conversion or type parameter conversion from 'TFrame' to 'System.Enum'.

Here is the generated stub:

    [CompilerGenerated]
    public class StubINavigationService<TFrame, TPage> : INavigationService<TFrame, TPage>
        where TFrame : struct
        where TPage : struct

Here is the original interface. Please note the Enum constraint:

    public interface INavigationService<TFrame, TPage>
        where TFrame : struct, Enum
        where TPage : struct, Enum

Stubbing Lazy<ISomeInterface> parameter with SimpleStubs

In an Windows 10 UWP project I'm testing a class which is expecting a Lazy object as parameter in its ctor, like:

   public MyClient(Lazy<IBufferRepo>, IMyMapper ...)`

The method under test is generic and expects an object corresponding to the type parameter. It does some mapping and writes to a buffering repository. I want to test the correct transfer of the parameter object into the buffer. I tried to prepare the test with:

public class TestClass { 
   ...
   private Lazy<StubIBufferRepo> _repo;   // class fields

   [TestInitialize]
   public void TestInitialize() 
   {
      _repo = new Lazy<StubIBufferRepo>(() => new StubIBufferRepo());   
      _repo.Value.Enqueue<TypeToBuffer>((t) => Task.FromResult(new BufferItem<TypeToBuffer>(t));
      _myMapper = ...

This looks nice, but when it comes to instantiating the SuT in TestInitialize with

      _systemUnderTest = new MyClient(_repo, _myMapper, ...
   }

I see the following complaint:

Argument type Lazy<StubIBufferRepo> is not assignable to parameter type Lazy<IBufferRepo>

Obviously Lazy<StubIMyBufferRepo> is not regarded as equivalent to Lazy<IMyBufferRepo> even though it's based on the same interface. This prevents stubbing the method on MyBufferRepo called by the method under test.

Any ideas?

What should I do if I want to mock an object ? Order of Execution ?

Fresh man to unit test in VS

I had just finish reading the README and cannot find out the way to use StubXxx , And I wanna know whether I should create a StubXxx.class file or just directly new an StubXxx object if I wanna mock the Xxx class object?

My Environment:

  • Windows 10 | Visual Studio 2017 | MSTest Framework 1.2.0 | Etg.SimpleStubs 2.4.6 |

SimpleStubs fails in VS 2019 v16.7.5

Hi,

I'm trying to use SimpleStubs in a UI test project for UWP but I get the following error:

3>  SimpleStubs: Generating stubs for project: <...>
3>  SimpleStubs: Failed to generate stubs: System.AggregateException: One or more errors occurred. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Stack trace:

3>     at System.MemoryExtensions.AsSpan(String text)
3>     at Microsoft.Build.Evaluation.Expander`2.Function`1.ExtractPropertyFunction(String expressionFunction, IElementLocation elementLocation, Object propertyValue, UsedUninitializedProperties usedUnInitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertyBody(String propertyBody, Object propertyValue, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveTypedAndEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ExpandPropertyUnescaped(ToolsetPropertyDefinition property, Expander`2 expander)
3>     at Microsoft.Build.Evaluation.ToolsetReader.EvaluateAndSetProperty(ToolsetPropertyDefinition property, PropertyDictionary`1 properties, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& toolsPath, String& binPath, Expander`2& expander)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadToolset(ToolsetPropertyDefinition toolsVersion, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadEachToolset(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadToolsets(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& msBuildOverrideTasksPath, String& defaultOverrideToolsVersion)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2 toolsets, ToolsetRegistryReader registryReader, ToolsetConfigurationReader configurationReader, PropertyDictionary`1 environmentProperties, PropertyDictionary`1 globalProperties, ToolsetDefinitionLocations locations)
3>     at Microsoft.Build.Evaluation.ProjectCollection.InitializeToolsetCollection(ToolsetRegistryReader registryReader, ToolsetConfigurationReader configReader)
3>     at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCount, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly)
3>     at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties)
3>     at Microsoft.CodeAnalysis.MSBuild.Build.ProjectBuildManager.StartBatchBuild(IDictionary`2 globalProperties)
3>     at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.<LoadAsync>d__18.MoveNext()
3>  --- End of stack trace from previous location where exception was thrown ---
3>     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
3>     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
3>     at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.<LoadProjectInfoAsync>d__22.MoveNext()
3>  --- End of stack trace from previous location where exception was thrown ---
3>     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
3>     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
3>     at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.<OpenProjectAsync>d__24.MoveNext()
3>  --- End of stack trace from previous location where exception was thrown ---
3>     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
3>     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
3>     at Etg.SimpleStubs.CodeGen.SimpleStubsGenerator.<GenerateStubs>d__3.MoveNext()
3>     --- End of inner exception stack trace ---
3>     at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
3>     at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
3>     at System.Threading.Tasks.Task`1.get_Result()
3>     at Etg.SimpleStubs.CodeGen.Program.Main(String[] args)
3>  ---> (Inner Exception #0) System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
3>  File name: 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
3>     at System.MemoryExtensions.AsSpan(String text)
3>     at Microsoft.Build.Evaluation.Expander`2.Function`1.ExtractPropertyFunction(String expressionFunction, IElementLocation elementLocation, Object propertyValue, UsedUninitializedProperties usedUnInitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertyBody(String propertyBody, Object propertyValue, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveTypedAndEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
3>     at Microsoft.Build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ExpandPropertyUnescaped(ToolsetPropertyDefinition property, Expander`2 expander)
3>     at Microsoft.Build.Evaluation.ToolsetReader.EvaluateAndSetProperty(ToolsetPropertyDefinition property, PropertyDictionary`1 properties, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& toolsPath, String& binPath, Expander`2& expander)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadToolset(ToolsetPropertyDefinition toolsVersion, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadEachToolset(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadToolsets(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& msBuildOverrideTasksPath, String& defaultOverrideToolsVersion)
3>     at Microsoft.Build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2 toolsets, ToolsetRegistryReader registryReader, ToolsetConfigurationReader configurationReader, PropertyDictionary`1 environmentProperties, PropertyDictionary`1 globalProperties, ToolsetDefinitionLocations locations)
3>     at Microsoft.Build.Evaluation.ProjectCollection.InitializeToolsetCollection(ToolsetRegistryReader registryReader, ToolsetConfigurationReader configReader)
3>     at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCount, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly)
3>     at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties)
3>     at Microsoft.CodeAnalysis.MSBuild.Build.ProjectBuildManager.StartBatchBuild(IDictionary`2 globalProperties)
3>     at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.Worker.<LoadAsync>d__18.MoveNext()
3>  --- End of stack trace from previous location where exception was thrown ---
3>     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
3>     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
3>     at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.<LoadProjectInfoAsync>d__22.MoveNext()
3>  --- End of stack trace from previous location where exception was thrown ---
3>     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
3>     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
3>     at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.<OpenProjectAsync>d__24.MoveNext()
3>  --- End of stack trace from previous location where exception was thrown ---
3>     at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
3>     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
3>     at Etg.SimpleStubs.CodeGen.SimpleStubsGenerator.<GenerateStubs>d__3.MoveNext()

Detailed log:

3>  === Pre-bind state information ===
3>  LOG: DisplayName = System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
3>   (Fully-specified)
3>  LOG: Appbase = file:///C:/Users/nitroagility/.nuget/packages/simplestubs/2.4.8.2/tools/
3>  LOG: Initial PrivatePath = NULL
3>  Calling assembly : System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51.
3>  ===
3>  LOG: This bind starts in LoadFrom load context.
3>  WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
3>  LOG: Using application configuration file: C:\Users\nitroagility\.nuget\packages\simplestubs\2.4.8.2\tools\Etg.SimpleStubs.CodeGen.exe.Config
3>  LOG: Using host configuration file: 
3>  LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
3>  LOG: Post-policy reference: System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
3>  LOG: The same bind was seen before, and was failed with hr = 0x80070002.
3>  <---

Is there a way to fix the issue?

Inner Interfaces not being stubbed

When an interface is declared inside a class, it is not being stubbed.
Example:

public class BookCase
{
    public interface IPhoneBook
    {

    }
}

In this example, the interface IPhoneBook is not stubbed.

SimpleStubs.generated.cs not generate stubs from shared project.

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:

using System;
using System.Runtime.CompilerServices;
using Etg.SimpleStubs;

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.

Configurable dir for SimpleStubs.generated.cs

Hi,
it is possible to configure the directory where the SimpleStubs.generated.cs file is generated in?
We have often the problem that VisualStudio and ReSharper don't recognize the generated file in the obj folder.
A possibility to configure the target for the file would be great.

SimpleStubs causes Visual Studio to freeze

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.

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:

  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.

Problem with classes with the same name in sub namespaces

Hi,

I have two classes with the same name in two namespaces. One of the namespaces is a sub namespace of the other.
When SimpleStubs now generates the stubs it will generate for property getter the following code:

if (!_stubs.TryGetMethodStub<GetClass1_Get_Delegate>("get_GetClass1", out del))
{
     return default(Class1);
}

But this wont compile because the compiler it says: Cannont convert expression type Library1.Class1 to return type Class1.
If the generated code would look like the following the compilation would work:

if (!_stubs.TryGetMethodStub<GetClass1_Get_Delegate>("get_GetClass1", out del))
{
     return default(Library1.SubLibrary.Class1);
}

I crated a small repo solution so that you can look at the problem.
EDIT
While I created the solution I ran into another problem with simple stubs, but I dont know how to fix this, just open the solution and you will see.
SimpleStubsNamespaceBug.zip

Problem with action substitutions leads to failing build. Error CS0138.

Hello
This is not a big problem since the substitution is only for brevity but i am reporting it because it took me some time to figure out what the problem was.
Consider the following delegate:

public delegate string ParamsDelegate(string someParameter, params object[] args);

We can substitute an Action for this delagte as:

using MyCallback = System.Action<SimpleStubError.ParamsDelegate>;

namespace SimpleStubError
{
    public interface ISomeInterface
    {
        void DoSomething(MyCallback paramsDelegate);
    }
}

This above interface leads to an error on stub generation:

Error CS0138 A 'using namespace' directive can only be applied to namespaces; 'Action' is a type not a namespace. Consider a 'using static' directive instead

If you remove the substitution and use the real action everything is fine.
Thank you for reading.
Example_VS2017.zip

SimpleStubs fails in VS 2019 v16.7.0

To get SimpleStubs working for my app using the latest release of VS 2019 (v16.7.0), I needed to update the .targets file as discussed in #61 plus I needed to update all NuGet package dependencies and regenerate the SimpleStubs package.

UPDATE: This is no longer an issue with the release of VS 2019 v16.7.1.

strong named version of dll

Hi,
Our solution has a strong named libraries which sometimes requires our test projects to be strong named as well. This makes it difficult to use Simplestubs as it is not a strong named dll. Would it be possible to release a strong named version of simplestubs?

Thanks,
Rupa

Interface with indexer creates incorrect stub

Having an interface with an indexer-declaration, the generated stub compiles with this error: Indexers must have at least one parameter.

The interface is defined like this:

public interface ISample
{
    int this[DateTimeOffset day] { get; } 
}

And this is the generated stub code:

int global::Services.ISample.this[]
{
  get
  {
    return _stubs.GetMethodStub<Item_Get_Delegate>("get_item").Invoke();
  }
}

which compiles with the error Indexers must have at least one parameter.

Interfaces from c++cx Windows Runtime Component project get ignored

Hi,

We have a setup where our C# is referencing a C++cx Windows Runtime Component project for interfaces. We then have tests for the C# project and that's where we would like to utilize SimpleStubs. Unfortunately those interfaces do not get stubbed, even though the project is referenced and used.

I tried getting around that by implementing a empty interface in the C# Test project, like so:

public interface ITestInterfaceCsharp : ITestInterface { }

Then a StubITestInterfaceCsharp does get generated, however I get a build time error that the ITestInterface definitions aren't implemented. Basically the generated stub is just a stub of an empty interface.

Is that something that should work?

Thanks!
David

SimpleStubs does not generate members for all interfaces

Hi,

I detected a quite strange behavior.

Situation:

I have an interface 'IScheduler' which extends one of my other interfaces 'IRunnable'.
The IRunnable interface is located in one of my .dll. I reference this dll via a HintPath not via project reference because the projects are in different solutions.

Repo:

To reproduce the bug you can donwload my repo solution SimpleStubsBug.zip.
In the project ClassLibrary1 is the IRunnable interface and in the ClassLibrary2 is the IScheduler interface.
The project SimpleStubsBug references the ClassLibrary2 via project reference and includes the SimpleStubs nuget package.
To reproduce the bug follow these steps:

  1. Restore NuGet-Packages
  2. Set Configuration to Release
  3. Build the ClassLibrary1 project.
  4. Build the SimpleStubsBug project.

Expected behavior:

No compiler errors expected.

Actual behavior:

Following compiler error:

Error CS0535 'StubIScheduler' does not implement interface member 'IRunnable.StartAsync()'

It seems that simple stubs does not generate methods for the IRunnable interface.
The strange thing (and the reason why I needed hours to find it) is that in Debug mode the generating of the stubs works without errors.
And if you just build ClassLibrary1 in Debug mode then it is even possible to build the SimpleStubsBug project in Release mode and it works without errors too.

Additional Information:

You may be notice that the way how I reference the ClassLibrary1 is Release/Debug independent. I added a $(Configuration) instead of Debug or Release in the hint path. Just have a look at the ClassLibrary2.csproj column 36 to see what I mean.

Cannot stub IAsyncOperation.

When I add my own interface that inherits from IAsyncOperation, the generated code code compiles with the error "The name 'handler' does not exist in the current context".

From the following code that gets generated, the putter for Completed is trying to invoke with a parameter that does not exist (handler).

        global::Windows.Foundation.AsyncOperationCompletedHandler<T> global::Windows.Foundation.IAsyncOperation<T>.Completed
        {
            get
            {
                return _stubs.GetMethodStub<Completed_Get_Delegate>("get_Completed").Invoke();
            }

            set
            {
                _stubs.GetMethodStub<Completed_Set_Delegate>("put_Completed").Invoke(handler);
            }
        }

Error with events and IEnumerable<T>

Hi I have an Inteface with the following event:

 event EventHandler<IEnumerable<string>> SomeEvent;

When SimpleStubs is now generating the stubs it generates the following:

protected void On_SomeEvent(object sender, IEnumerable args)
{
     global::System.EventHandler<global::System.Collections.Generic.IEnumerable<string>> handler = SomeEvent;
     if (handler != null) { handler(sender, args); }
}
public void SomeEvent_Raise(object sender, IEnumerable args)
{
     On_SomeEvent(sender, args);
}

It generates methods for IEnumerable not for IEnumerable<string> which wont compile.

Don't publish MSBuild assemblies in the NuGet package

https://developercommunity.visualstudio.com/content/problem/208668/the-finddependenciesofexternallyresolvedreferences.html

Customers are reporting issues with projects that use SimpleStubs. We added a parameter to Resolve Assembly References (RAR) in 15.6 and the common targets were updated to use the new parameter. Since Etg.SimpleStubs packages MSBuild (currently 15.5.180) it will load DLLs from that location but common targets/toolset from the installed location.

Options:

  1. Redistribute all of MSBuild. You need to define a toolset (see msbuild.exe.config) for things can be found. It would need all targets/tasks needed to do what you're trying to do. This is really hard to get right since VS installs stuff to the MSBuild extensions folder.
  2. Dynamically load MSBuild at run-time. See https://www.nuget.org/packages/Microsoft.Build.Locator/1.0.7-preview-ge60d679b53
    Code/samples available here: https://github.com/Microsoft/MSBuildLocator

If you choose one, we'll continue to have this issue where we add features and things are out of sync. I can help out with 2 if needed. If you build the repo the sample app shows a simple build and prompts which VS to use (you probably don't want to prompt, but something similar).

Preprocessing directives in namespace definitions not handled correctly

#endif is always missing in generated stubs, when the interface has namespace definition with preprocessor directives.
Example:

namespace myProject.sublibrary
{
    using System;
    using System.Collections.Generic;
    using System.IO;
#if WinIoT
    using System.Threading.Tasks;
#else
    using myProject.ThreadingLib
#endif

In this case the generated stubs contain the #if statement, but no #else or #endif and therefore no build is possible.

Error Code 9009 when compiling

I added the package to an empty UWP class library project. Tried compiling it and received an error code 9009.

2>  'C:\Users\RYAN' is not recognized as an internal or external command,
2>  operable program or batch file.
2>C:\Users\RYAN LEE\.nuget\packages\etg.simplestubs\2.4.3\build\Etg.SimpleStubs.targets(16,5): error MSB3073: The command "C:\Users\RYAN LEE\.nuget\packages\etg.simplestubs\2.4.3\build\\..\tools\Etg.SimpleStubs.CodeGen.exe -ProjectPath:"C:\Users\RYAN LEE\Documents\Projects\GitLight\GitLight\GeneratedStubs\GeneratedStubs.csproj" -OutputPath:"obj\x64\Debug\SimpleStubs.generated.cs" -Configuration:"Debug" -Platform:"x64"" exited with code 9009.

I suspect this is due to the space in my user name?

Generating stubs fails with ReflectionTypeLoadException: Unable to load one or more of the requested types

Description

ReflectionTypeLoadException: Unable to load one or more of the requested types.

Steps to Reproduce

  1. Create an empty .NET Standard class library.
  2. Add SimpleStubs NuGet package
  3. Build the project.

Expected Behavior

Build should complete and the stubs class should be generated.

Actual Behavior

Build fails and the stubs class is not generated.

Basic Information

  • Version with issue: 2.4.7
  • Last known good version: Error doesn't occur on 2.3.1.
  • IDE: Visual Studio Professional 2017 v15.9.6
1>SimpleStubs: Generating stubs for project: C:\Users\velocitysystems\Desktop\EmptyClassLibrary\EmptyClassLibrary.csproj
1>SimpleStubs: Failed to generate stubs: System.AggregateException: One or more errors occurred. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
1>   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
1>   at System.Reflection.RuntimeAssembly.get_DefinedTypes()
1>   at System.Composition.Hosting.ContainerConfiguration.<>c.<WithAssemblies>b__16_0(Assembly a)
1>   at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
1>   at System.Composition.TypedParts.TypedPartExportDescriptorProvider..ctor(IEnumerable`1 types, AttributedModelProvider attributeContext)
1>   at System.Composition.Hosting.ContainerConfiguration.CreateContainer()
1>   at Microsoft.CodeAnalysis.Host.Mef.MefHostServices.Create(IEnumerable`1 assemblies)
1>   at Microsoft.CodeAnalysis.Host.Mef.DesktopMefHostServices.get_DefaultServices()
1>   at Etg.SimpleStubs.CodeGen.SimpleStubsGenerator.<GenerateStubs>d__3.MoveNext()
1>   --- End of inner exception stack trace ---
1>   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
1>   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
1>   at System.Threading.Tasks.Task`1.get_Result()
1>   at Etg.SimpleStubs.CodeGen.Program.Main(String[] args)

It seems this only started occurring on (or around) the latest VS 2017 update to 15.9.6.
Previously, the stubs project generated fine.

No Intellisense for Stubs in VS2017 15.7.6

We recently upgraded our app to UWP, and our previous Unit Tests relied on Telerik JustMock, which does not support UWP, enter SimpleStubs.

I am able to get the Test project compiling and running, but none of my generated stub classes have Intellisense under VS2017.
Is this normal?
image

Adding C# content to UWP NuGet

Delivering C# files through the content folder is not supported for UWP projects (see here). This was not an issue so far as all we needed to do is to manually add the SimpleStubs.generated.cs file to the project.

However, with the recently introduced Loose/Strict mock behaviour (thanks to @mclift), it's not possible anymore to put all the stubs in one project and reference that project from test projects. This issue is that the Stubs in the SimpleStubs.generated.cs file are not self contained anymore, they rely on code that resides in the Etg.SimpleStubs.dll (e.g. MockBehaviour enum).

It would be great if we can fix this as it's very handy to be able to put all the stubs in our projects that references all the projects to be stubbed.

Two solutions I can think of.

  1. Split the SimpleStubs NuGet into two NuGets: Etg.SimpleStubs and Etg.SimpleStubs.Api (or something like that), where Etg.SimpleStubs.Api contains all the code that is referenced from the stubs. With this approach, we can install Etg.SimpleStubs.Api to the projects that are using the stubs but don't need to generate stubs.

  2. Put all the code needed by the Stubs (e.g. MockBehaviour enum) in a C# file and deliver that with the NuGet. The advantage of this approach is that it's easier to use as the user won't need to install any additional NuGet packages to the test projects referencing the stubs. However, because of the lack of NuGet support for delivering C# files for UWP projects, this is a bit problematic. Some research revealed that there might be a solution for delivering C# files for UWP (see here). We might end-up with two NuGet packages, one for UWP and one for .Net Framework but ideally we'd have one that work for both (with some conditionals).

Let me know what you think!

The type or namespace name 'Dictionary<,>' could not be found (are you missing a using directive or an assembly reference?) on Stubbed Interface

When I try to build, I find a compilation error:

"The type or namespace name 'Dictionary<,>' could not be found (are you missing a using directive or an assembly reference?)"

for each of the stubbed interfaces.

I took a look at generated code, and found that the first line of each interface stub was like this:

private readonly Dictionary<string, object> _stubs = new Dictionary<string, object>();

but among the using statements there weren't any using System.Collections.Generic; That was what caused the error

It looks like you aren't adding the Dictionary namespace in the usings. Just the usings that are declared in the stubbed interface

As a workaround, I added System.Collections.Generic to the stubbed interface. And it kinda Works. But it's dirty dirty dirty

Interface with restriction constraints

Hello,
there is an issue using restriction constraint on generic interface :

Interface :
public interface IRepository where TEntity : class
{
}

Generated code :
public class StubIAsyncRepository : IAsyncRepository
{
}
where TEntity : class is missing at the end of stub declaration whish provocs compilation error.

Stubs not generated.

After upgrading from SimpleStubs 2.3.4 to 2.4.7 the stubs aren't generated anymore. I created the empty file (SimpleStubs.generated.cs) again in the properties directory of my UWP project but it is failing to generate the stubs.

When I look in my Build Output I see the following:

5>------ Rebuild All started: Project: XXXXX.Tests, Configuration: Debug x64 ------
5>  SimpleStubs: Generating stubs for project: XXXXX.csproj
5>  MSBuildWorkspace loaded with no errors!
5>  SimpleStubs: Writing stubs to file: obj\x64\Debug\SimpleStubs.generated.cs

In 2.3.4 everything was working fine for me. It looks like I cannot make things work again after version 2.4.1. Am I missing something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.