Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventWiringRegistrationExtensions.PublishEvent fluent version is not working in VS2015 #200

Closed
Kladzey opened this issue Mar 7, 2017 · 4 comments
Milestone

Comments

@Kladzey
Copy link

Kladzey commented Mar 7, 2017

When I use EventWiringRegistrationExtensions.PublishEvent fluent version in VS2015, exception is thrown:

System.ArgumentException = Delegate given was not a method subscribption delegate. Please use something similar to: 'publisher => publisher += null'. If you did, than it's probably a bug. Please use the other overload and specify name of the event as string.

My colleagues, that are using VS2013, doesn't have such problem. I think current implementation of NaiveMethodNameExtractor is not compatible with Roslyn compiler.

RoslynPad example

#r "$NuGet\Castle.Core\3.3.0\lib\net45\Castle.Core.dll"
#r "$NuGet\Castle.Windsor\3.4.0\lib\net45\Castle.Windsor.dll"
#r "$NuGet\Castle.EventWiringFacility\3.4.0\lib\net45\Castle.Facilities.EventWiring.dll"
#r "System.Xml"

using System;
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using Castle.Facilities.EventWiring;

public interface ITest
{
    event Action<string> Do;
}

public class Test : ITest
{
    public event Action<string> Do;
}

public class Notifier
{
    public void NotifySubscribers()
    {
    }
}

public class WindsorInstaller : IWindsorInstaller
{
    public void Install(IWindsorContainer container, IConfigurationStore store)
    {
        container
            .AddFacility<EventWiringFacility>()
            .Register(
                Component.For<Test>()
                    .Forward<ITest>()
                    .PublishEvent(
                        a => a.Do += null,
                        es => es.To<Notifier>(dns => dns.NotifySubscribers()))
                    .LifestyleSingleton());
    }
}

var container = new WindsorContainer().Install(new WindsorInstaller());
@ghost
Copy link

ghost commented Mar 9, 2017

Had a very brief look at this and could verify it without Roslyn Pad.

https://github.com/fir3pho3nixx/event-wiring-registration-extensions-publishevent/blob/master/ConsoleApplication/Program.cs

I have had fun with this little guy(NaiveMethodNameExtractor) before.

Give us a bit more time to check it out. Will get back to you.

@ghost
Copy link

ghost commented Mar 10, 2017

I have already fixed this issue in master.

Please see commit history for: https://github.com/castleproject/Windsor/commits/master/src/Castle.Facilities.EventWiring/OpCodeValues.cs

Stack frame locals flipped from LdArg0 to LdArg1 for Delegates between framework versions.

@kkozmic and I are a bit puzzled as to why this happened. Smells like a bug in dotnet 4.5. I also remember Stack Overflow Devs reporting this but cannot remember the detail.

We are currently chasing a DOTNET CORE release in issue #185 && #145. So master is actively in flux ATM.

@jonorossi can we do a minor patch release? We should prob rebase master interactively until b0465f4 and transplant all my efforts for DOTNET CORE into a new branch?

@jonorossi
Copy link
Member

can we do a minor patch release? We should prob rebase master interactively until b0465f4 and transplant all my efforts for DOTNET CORE into a new branch?

Yes we can do a patch release to get this fix out. I'll get a 3.4.x branch created from the 3.4.0 tag and get TeamCity set back up, let's leave master as our development branch.

@jonorossi jonorossi added this to the v4.0 milestone Jun 29, 2017
@jonorossi
Copy link
Member

We didn't make end up making a patch release with the fix in #168 because we went off to move away from TeamCity. This fix will be in v4.0 out very soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants