MT and FXCop

131 views
Skip to first unread message

Jon Ceanfaglione

unread,
Jun 10, 2013, 3:09:31 PM6/10/13
to masstrans...@googlegroups.com
I saw some discussion in the archives about avoiding the VS crash that happens when you enable CodeAnalysis for Visual Studio projects that have references to MT.  

Dru - could you elaborate on the method you use to wire your consumers while minimizing the dependencies on MT in the projects?

Thanks.

Jon

Dru Sellers

unread,
Jun 10, 2013, 6:37:09 PM6/10/13
to masstrans...@googlegroups.com
If you do your own type scanning, you can scan all of your types in during registration and subscribe them using the 'Handler' style mappings.


-d


--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/CAOznY96GzMVKZt%2B%2BRCFQqc4W%2BaV2WdwiqmioK7dxi2hqk9tuZw%40mail.gmail.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Chris Patterson

unread,
Jun 11, 2013, 12:21:04 PM6/11/13
to masstrans...@googlegroups.com
There is a branch that has yet to see the light of day that allows for dependency-free convention based mapping of consumers.

In the simplest case, something like this:


Would be used to create consumers without any dependencies, but it's just a hack that limits the ability of consumers to be able to do anything complex, which sort of makes it less than useful.



--

Jon Ceanfaglione

unread,
Jun 12, 2013, 9:12:26 AM6/12/13
to masstrans...@googlegroups.com
So this is what we're doing (using Autofac):

ConsumerModule.cs

var a  = Assembly.Load("SomeAssemblyWithConsumers.dll");

builder.RegisterAssemblyTypes(a).AsClosedTypesOf(Consumes<>.All)).InstancePerLifetimeScope().AsImplementedInterfaces();

Each consumer implements a base class which does:

public void SubscribeConsumer(IServiceBus bus) {
      this.Bus = bus;
      var unsubscribe = Bus.SubscribeInstance(this);
}
And finally, in the endpoint 

1. we wire up the bus using ServiceBusFactory.New()
2. resolve all instances from the container that are Consumers
3. call SubscribeConsumer() on each message handler passing in the bus instance

So, if I use this convention:
s.Handler((ctx, msg) => {});
Can I still inject the bus into each handler?  Would I have access to the DI container?

I've not really used the "Handler" convention for anything complex.

Thanks.

Jon

Chris Patterson

unread,
Jun 12, 2013, 11:02:38 AM6/12/13
to masstrans...@googlegroups.com
I would highly recommend not using SubscribeConsumer, as you can skip messages (which will end up in the error queue).

There are examples of loading consumers from the container using the LoadFrom(container) extension method in the Autofac integration project, so I would consider using those.

Also, make sure you don't get duplicates for cases in which a consumer consumes two or more message types, and register as the concrete types not the implemented interfaces.



--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Brad Wilson

unread,
Jun 19, 2013, 1:49:26 PM6/19/13
to masstrans...@googlegroups.com
So is there any plans to fix the core issue of MassTransit breaking FxCop? I don't think we should gloss over the issue by saying "use conventional registration".

Dru Sellers

unread,
Jun 19, 2013, 2:01:33 PM6/19/13
to masstrans...@googlegroups.com
probably not since neither chris or I use it. we are happy to take pull requests though. :)


On Wed, Jun 19, 2013 at 12:49 PM, Brad Wilson <dotn...@gmail.com> wrote:
So is there any plans to fix the core issue of MassTransit breaking FxCop? I don't think we should gloss over the issue by saying "use conventional registration".

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Chris Patterson

unread,
Jun 19, 2013, 8:26:30 PM6/19/13
to masstrans...@googlegroups.com
I'm not exactly sure how it "breaks" FxCop. I've heard it can't be analyzed, but I can't explain why.


On Wed, Jun 19, 2013 at 10:49 AM, Brad Wilson <dotn...@gmail.com> wrote:
So is there any plans to fix the core issue of MassTransit breaking FxCop? I don't think we should gloss over the issue by saying "use conventional registration".

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Brad Wilson

unread,
Jun 19, 2013, 8:32:38 PM6/19/13
to masstrans...@googlegroups.com
Our team did a little spelunking, and apparently there are some recursive type definitions in both the state machine implementations that are causing a stack overflow for FxCop. I haven't personally looked at it yet, so I'm not 100% sure what the cause is, but it's on my TODO list. :)

Chris Patterson

unread,
Jun 19, 2013, 8:48:15 PM6/19/13
to masstrans...@googlegroups.com
Wow, that's crazy. I just had a guy here try it too and apparently it just locks up the process. I wonder what is recursive in the state machine.


Brad Wilson

unread,
Jun 19, 2013, 9:19:36 PM6/19/13
to masstrans...@googlegroups.com
It's really hard to get an accurate stack trace, since it never calls into any of my code, but I'm trying... :) Unfortunately (but not at ALL surprisingly), the symbols server doesn't have symbols for any of FxCop.

Dru Sellers

unread,
Jun 19, 2013, 9:32:09 PM6/19/13
to masstrans...@googlegroups.com

Brad Wilson

unread,
Jun 20, 2013, 12:44:40 AM6/20/13
to masstrans...@googlegroups.com
I'm still debugging through things, but it looks like it's probably the same issue (sorry for the red herring earlier).

I'll send more information tomorrow.

Brad Wilson

unread,
Jun 21, 2013, 1:03:42 PM6/21/13
to masstrans...@googlegroups.com
Okay, this is the smallest repro of the issue:


public
 class ContextConsumerSubscriptionConnector<TConsumerTMessage>      where TConsumer : Consumes<IConsumeContext<TMessage>>.All { } public static class Consumes<TMessage> {      public interface All { }      public interface Context : Consumes<IConsumeContext<TMessage>>.All { } } public interface IConsumeContext<T> { }


The problem appears to be the interplay between ContextConsumerSubscriptionConnector and the inner interface Consumes<T>.Context. It causes FxCop to go into a type resolution spiral that looks like this:

  ContextConsumerSubscriptionConnector<TConsumer,TMessage>
  Consumes<IConsumesContext<TMessage>>
  Consumes<IConsumesContext<IConsumesContext<TMessage>>>
  Consumes<IConsumesContext<IConsumesContext<IConsumesContext<TMessage>>>>

etc.

Off the top of my head, I don't know a way around this. The type declarations are, as far as I can tell, perfectly legal.

It would probably be worth reporting this, but I expect it won't be fixed until two VS versions from now (since VS2013 is doing a go-live preview in about a week, this seems like an unlikely bug for them to fix now).

- Brad

Jon Ceanfaglione

unread,
Jun 21, 2013, 2:13:12 PM6/21/13
to masstrans...@googlegroups.com

This issue was raised with the visual studio team I'm pretty sure.  Doubt they'll even bother to do anything about it

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Travis Smith

unread,
Jun 21, 2013, 3:48:28 PM6/21/13
to masstrans...@googlegroups.com
Well, we can raise it again. More feedback makes it more likely to get fixed. 

-Travis


Brad Wilson

unread,
Jun 24, 2013, 12:27:25 PM6/24/13
to masstrans...@googlegroups.com

Brad Wilson

unread,
Jun 24, 2013, 12:33:18 PM6/24/13
to masstrans...@googlegroups.com

Wiebe Tijsma

unread,
Jun 24, 2013, 5:35:36 PM6/24/13
to masstrans...@googlegroups.com
Voted (again) too, though I'm afraid they're no longer actively maintaining it, perhaps the next VS version...

Thanks for bringing it up again though!

Wiebe

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.

Travis Smith

unread,
Jun 24, 2013, 5:58:28 PM6/24/13
to masstrans...@googlegroups.com
Through super-secret* channels, this has apparently been forwarded to someone on the team. I have no idea if it will matter, but it should at least provide some visibility. I have no visibility into it at this point, nor expect I will. If for some reason I do hear anything back, I'll report back. 

*Super-secret is just asking a friend who works in a totally unrelated area of MS what the best channel to bring this up would be. I guess that involved him forwarding it to that team. 

-Travis


Travis Smith

unread,
Jun 26, 2013, 9:11:26 PM6/26/13
to masstrans...@googlegroups.com

I have been informed that this is fixed in "Dev12 Preview build". It was corrected a few months ago. I haven't tried it, but I'm assuming that means the VS 2013 preview that dropped today has the fix in it.


-Travis

Wiebe Tijsma

unread,
Jun 27, 2013, 5:43:18 AM6/27/13
to masstrans...@googlegroups.com
Lovely those super-secret* channels! :)

- Wiebe

Jon Ceanfaglione

unread,
Nov 5, 2013, 10:04:57 AM11/5/13
to masstrans...@googlegroups.com
In case anyone was wondering, I've done some very early testing and it looks like Code Metrics has been fixed in VS 2013.  When referencing Mass Transit, FxCop doesn't lock up during code analysis. 


Reply all
Reply to author
Forward
0 new messages