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

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

Closed bcassell closed 7 years ago

bcassell commented 8 years ago

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.

nehmebilal commented 8 years ago

Hi @bcassell, thanks for reporting this issue!

SimpleStubs currently handles events based on the recommended .Net Framework guidelines which is to use the EventHandler pattern.

That being said, if C# supports it, SimpleStubs should support it (ideally).

Just out of curiosity, is there any reason you prefer not to use the EventHandler pattern?

bcassell commented 8 years ago

This is not code that I wrote, but code that was handed down to me. I'm interested in moving to the recommended pattern, but won't have the time to do it any time soon. I'm fine with just excluding the associated interfaces because they are not interfaces I intend to stub out, but I just wanted to bring this scenario to your attention because I am enjoying this library :).

nehmebilal commented 8 years ago

Sounds good! Thanks for the feedback :)

I'll keep the issue open and will look into it when I get a chance.

nehmebilal commented 7 years ago

Resolved by #17