Windsor 3.1 RC, regression with WithServiceAllInterfaces

85 visningar
Hoppa till det första olästa meddelandet

bling

oläst,
10 juli 2012 18:09:482012-07-10
till castle-pro...@googlegroups.com
the following works with 3.0, but throws an exception in 3.1

var c = new WindsorContainer();
c.Register(Classes.From(typeof(Dictionary<,>)).Pick().WithServiceBase().WithServiceAllInterfaces());

i'm not sure what the actual issue is, but exception message complained about ICollection<KeyValuePair<,>> so i took a guess and was able to reproduce.  a class similar to that signature does exist in my actual code.

thanks,
bling

Krzysztof Koźmic

oläst,
10 juli 2012 18:10:572012-07-10
till castle-pro...@googlegroups.com

Thanks.

Can you create an actual failing test?

Thanks
@k

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/castle-project-users/-/M4VIrLskVH8J.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.

bling

oläst,
10 juli 2012 18:28:532012-07-10
till castle-pro...@googlegroups.com
[Test]
        public void RegisterGenericType_WithServiceAllInterfaces()
        {
            Assert.DoesNotThrow(() => Kernel.Register(Classes.From(typeof(Dictionary<,>)).Pick().WithServiceAllInterfaces()));
        }

On Tuesday, July 10, 2012 6:10:57 PM UTC-4, Krzysztof Koźmic wrote:

Thanks.

Can you create an actual failing test?

Thanks
@k

On Jul 11, 2012 8:09 AM, "bling" <baile...@gmail.com> wrote:
the following works with 3.0, but throws an exception in 3.1

var c = new WindsorContainer();
c.Register(Classes.From(typeof(Dictionary<,>)).Pick().WithServiceBase().WithServiceAllInterfaces());

i'm not sure what the actual issue is, but exception message complained about ICollection<KeyValuePair<,>> so i took a guess and was able to reproduce.  a class similar to that signature does exist in my actual code.

thanks,
bling

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/castle-project-users/-/M4VIrLskVH8J.
To post to this group, send email to castle-project-users@googlegroups.com.
To unsubscribe from this group, send email to castle-project-users+unsub...@googlegroups.com.

Krzysztof Koźmic

oläst,
10 juli 2012 19:23:192012-07-10
till castle-pro...@googlegroups.com
Thanks,

I've got it reproduced. Do you mind logging this as a bug in the issue tracker at issues.castleproject.org ?

cheers,
@K
To view this discussion on the web visit https://groups.google.com/d/msg/castle-project-users/-/f2QKPH2AibYJ.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.

Krzysztof Koźmic

oläst,
10 juli 2012 22:39:072012-07-10
till castle-pro...@googlegroups.com
So leaving this example aside, the reason for this behavior is that Windsor sees you're registering your type as IEnumerable<SomeValueType> which while used to be allowed previously is not really something you'd want to have as a service.

So can you help me better understand in your actual scenario why do you want to expose IEnumerable<SomeValueType> as a service off your component?

thanks,

@K

On 11/07/12 8:28 AM, bling wrote:
To view this discussion on the web visit https://groups.google.com/d/msg/castle-project-users/-/f2QKPH2AibYJ.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.

bling

oläst,
10 juli 2012 22:57:392012-07-10
till castle-pro...@googlegroups.com
I don't.

The way I have my application is the typical:
  • Register explicitly, i.e. Component.For<IFoo>().ImplementedBy<Foo>()..., for things that I need explicit.
  • Then, some convention based things.  Like Classes.Pick().BasedOn<Bar>().WithServiceBase().
  • Finally, the "catch all", which is Register(Classes.Pick().WithServiceSelf().WithServiceAllInterfaces()).
I have an infrastructure library which contains a bunch of helper classes, some of which contain basic services that are required.  As the infrastructure library, it also will contain things that are not services, like a ReadOnlyDictionary<,>, which is what caused the exception.  WithDefaultInterfaces() will not work since some classes are not a 1-to-1 implementation, and implement multiple service interfaces.

Krzysztof Koźmic

oläst,
10 juli 2012 23:56:182012-07-10
till castle-pro...@googlegroups.com
Right,

so what you really want is not "All interfaces" but rather "service interfaces" that would be like all interfaces but filtering out "noise" that is all the ISerializable, IDisposable, IComparable, IEnumerable<ValueType> etc?

@K
To view this discussion on the web visit https://groups.google.com/d/msg/castle-project-users/-/mSI1F8MzbNUJ.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.

bling

oläst,
11 juli 2012 00:03:352012-07-11
till castle-pro...@googlegroups.com
Yep, pretty much.

Krzysztof Koźmic

oläst,
11 juli 2012 01:33:132012-07-11
till castle-pro...@googlegroups.com
Ok, so what do you say on adding a method that behaves like AllInterfaces but filters out all interfaces that are in System namespaces (or one of its subnamespaces)?

I'm just not sure what would be a good name for the method in the API...

WithService.NonSystemInterfaces() just doesn't sound cool :)

Ideas anyone?
@K

bling wrote:

Yep, pretty much.

On Tuesday, July 10, 2012 11:56:18 PM UTC-4, Krzysztof Koźmic wrote:

    Right,

    so what you really want is not "All interfaces" but rather
    "service interfaces" that would be like all interfaces but
    filtering out "noise" that is all the ISerializable, IDisposable,
    IComparable, IEnumerable<ValueType> etc?

    @K


    On 11/07/12 12:57 PM, bling wrote:

    I don't.

    The way I have my application is the typical:

      * Register explicitly, i.e.

        Component.For<IFoo>().ImplementedBy<Foo>()..., for things
        that I need explicit.
      * Then, some convention based things. Like
        Classes.Pick().BasedOn<Bar>().WithServiceBase().
      * Finally, the "catch all", which is
            <mailto:baile...@gmail.com>> wrote:

                the following works with 3.0, but throws an
                exception in 3.1

                var c = new WindsorContainer();
                c.Register(Classes.From(typeof(Dictionary<,>)).Pick().WithServiceBase().WithServiceAllInterfaces());

                i'm not sure what the actual issue is, but exception
                message complained about
                ICollection<KeyValuePair<,>> so i took a guess and
                was able to reproduce. a class similar to that
                signature does exist in my actual code.

                thanks,
                bling
                --
                You received this message because you are subscribed
                to the Google Groups "Castle Project Users" group.
                To view this discussion on the web visit
                https://groups.google.com/d/msg/castle-project-users/-/M4VIrLskVH8J

                To post to this group, send email to
                castle-pro...@googlegroups.com
                <mailto:castle-pro...@googlegroups.com>.

                To unsubscribe from this group, send email to
                castle-project-u...@googlegroups.com
                <mailto:castle-project-users%2Bunsu...@googlegroups.com>.

                For more options, visit this group at
                http://groups.google.com/group/castle-project-users?hl=en


        --
        You received this message because you are subscribed to the
        Google Groups "Castle Project Users" group.
        To view this discussion on the web visit

        To post to this group, send email to
        castle-pro...@googlegroups.com
        <mailto:castle-pro...@googlegroups.com>.

        To unsubscribe from this group, send email to

        For more options, visit this group at
        http://groups.google.com/group/castle-project-users?hl=en



    --
    You received this message because you are subscribed to the
    Google Groups "Castle Project Users" group.
    To view this discussion on the web visit

    To post to this group, send email to

    To unsubscribe from this group, send email to

    For more options, visit this group at
    http://groups.google.com/group/castle-project-users?hl=en



--
You received this message because you are subscribed to the Google
Groups "Castle Project Users" group.
To view this discussion on the web visit

To post to this group, send email to

To unsubscribe from this group, send email to

bling

oläst,
11 juli 2012 09:42:252012-07-11
till castle-pro...@googlegroups.com
that would work.

however, i'm more questioning in the intent of the scanning registration API, since i would expect that to throw any kind of exception.  worst case should be that you don't have something registered.  if that can still be the case, then you can simply ignore IEnumerable<ValueType> instead of throwing.

if that won't fly, you could also do a WithServiceAllInterfaces(bool excludeSystemInterfaces = true)

thx!

p.s. i've logged the bug at http://issues.castleproject.org/issue/IOC-347, although if you add a new WithService* then it'd be more of a feature request.

bling

oläst,
11 juli 2012 09:43:342012-07-11
till castle-pro...@googlegroups.com
correction: "...since i would not expect that to throw..."

Krzysztof Koźmic

oläst,
11 juli 2012 22:11:472012-07-11
till castle-pro...@googlegroups.com
I'm not sure I want to ignore anything. If a user wants to register something they should either get it registered or should be notified it's not supported.

After giving it some more thoughts I'm thinking perhaps we should leave the current behavior. If having IEnumerable<Something> is not your intention be explicit about it and do not include it.

The idea with "system interfaces" is more complicated than it seems. In reality all Microsoft interfaces are in System.something namespace so having a blanket arbitrary rule to filter them out built into Windsor doesn't look like such a good idea after all.

I think the solution I would advise and the one I'm leaning towards most is to leave the behavior and API exactly as it is now, and just recommend people to use WithiService.Select(be specific here) instead.

@K

bling wrote:

correction: "...since i would *not* expect that to throw..."


On Wednesday, July 11, 2012 9:42:25 AM UTC-4, bling wrote:

    that would work.

    however, i'm more questioning in the intent of the scanning
    registration API, since i would expect that to throw any kind of
    exception. worst case should be that you don't have something
    registered. if that can still be the case, then you can simply
    ignore IEnumerable<ValueType> instead of throwing.

    if that won't fly, you could also do a
    WithServiceAllInterfaces(bool excludeSystemInterfaces = true)

    thx!

    p.s. i've logged the bug at
    http://issues.castleproject.org/issue/IOC-347

    add a new WithService* then it'd be more of a feature request.

    On Tuesday, July 10, 2012 6:09:48 PM UTC-4, bling wrote:

        the following works with 3.0, but throws an exception in 3.1

        var c = new WindsorContainer();
        c.Register(Classes.From(typeof(Dictionary<,>)).Pick().WithServiceBase().WithServiceAllInterfaces());

        i'm not sure what the actual issue is, but exception message
        complained about ICollection<KeyValuePair<,>> so i took a
        guess and was able to reproduce. a class similar to that
        signature does exist in my actual code.

        thanks,
        bling

--
You received this message because you are subscribed to the Google
Groups "Castle Project Users" group.
To view this discussion on the web visit

bling

oläst,
12 juli 2012 01:07:562012-07-12
till castle-pro...@googlegroups.com
IMO, i think the whole point of having scanning is to avoid being explicit.  if i need to use WithService.Select, which is not much more useful then registering everything explicitly, to get around the new semantics of WithAllInterfaces, then its usefulness has decreased substantially.

aside, if a user wants to register IEnumerable<ValueType> into Windsor, which worked before (and presumably every version prior to 3.1), why was it changed to not support it?  it's easy to come up with a reasonable use case, like a service which provides real time stock prices in the form of value types, exposed as IEnumerable<StockPrice>.

thx,
bling

To unsubscribe from this group, send email to

Krzysztof Koźmic

oläst,
12 juli 2012 01:16:282012-07-12
till castle-pro...@googlegroups.com
Well that's the thing. I'm not sure it's reasonable. If you want to provide prices you'd expose that via a method, not on the type itself.

And that's the reason for this change in the first place - value type or collection of value type as a service is not a real service and it should never have been supported.

Since v3.1 is a minor update I guess I'm willing to revert that behavior and keep it the old way in this case, while postponing the change to the next major version.

But in the long run, clearly you're registering a service that is not meant to be a service, and is probably never used as such anyway.

What do other folks think of that?

@K



bling wrote:

    To post to this group, send email to

    To unsubscribe from this group, send email to

    For more options, visit this group at
    http://groups.google.com/group/castle-project-users?hl=en


--
You received this message because you are subscribed to the Google
Groups "Castle Project Users" group.
To view this discussion on the web visit

To post to this group, send email to

To unsubscribe from this group, send email to

bling

oläst,
12 juli 2012 01:57:492012-07-12
till castle-pro...@googlegroups.com
GetEnumerator() is a method :P, badly forced example aside, after digging through the code i see that the exception thrown is checking specifically that something is registered as IEnumerable<ValueType>, which affects all forms of registration.

anywho, you don't need to revert the change.  i can exclude anything that implements IEnumerable<ValueType>.

however, i'd also like to hear other opinions.

thanks,
bling

    To unsubscribe from this group, send email to


--
You received this message because you are subscribed to the Google
Groups "Castle Project Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/castle-project-users/-/kJsk4S5RkAoJ.
To post to this group, send email to

To unsubscribe from this group, send email to

Krzysztof Koźmic

oläst,
12 juli 2012 01:59:392012-07-12
till castle-pro...@googlegroups.com
what do you mean by


which affects all forms of registration.

?

@K


bling wrote:

    To unsubscribe from this group, send email to



    --
    You received this message because you are subscribed to the Google
    Groups "Castle Project Users" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/castle-project-users/-/kJsk4S5RkAoJ

    To post to this group, send email to

    To unsubscribe from this group, send email to


--
You received this message because you are subscribed to the Google
Groups "Castle Project Users" group.
To view this discussion on the web visit

To post to this group, send email to

To unsubscribe from this group, send email to

bling

oläst,
12 juli 2012 02:02:162012-07-12
till castle-pro...@googlegroups.com
by all i mean explicit vs implicit:
- Kernel.Register(Component.For<IEnumerable<int>>().Instance(new[] { 1 }));
- Kernel.Register(Classes.From(typeof(int[])).Pick().WithServiceAllInterfaces());

    To unsubscribe from this group, send email to



    --
    You received this message because you are subscribed to the Google
    Groups "Castle Project Users" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/castle-project-users/-/kJsk4S5RkAoJ
    <https://groups.google.com/d/msg/castle-project-users/-/kJsk4S5RkAoJ>.
    To post to this group, send email to

    To unsubscribe from this group, send email to


--
You received this message because you are subscribed to the Google
Groups "Castle Project Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/castle-project-users/-/QKsGQAb3LhYJ.
To post to this group, send email to

To unsubscribe from this group, send email to

Krzysztof Koźmic

oläst,
12 juli 2012 02:03:192012-07-12
till castle-pro...@googlegroups.com
...none of which is valid
In other words, that's by design.

@K

bling wrote:
    <mailto:castle-pro...@googlegroups.com>>>.

    To unsubscribe from this group, send email to




    --
    You received this message because you are subscribed to the Google
    Groups "Castle Project Users" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/castle-project-users/-/kJsk4S5RkAoJ
    <https://groups.google.com/d/msg/castle-project-users/-/kJsk4S5RkAoJ>
    <https://groups.google.com/d/msg/castle-project-users/-/kJsk4S5RkAoJ
    <https://groups.google.com/d/msg/castle-project-users/-/kJsk4S5RkAoJ>>.
    To post to this group, send email to

    To unsubscribe from this group, send email to



    --
    You received this message because you are subscribed to the Google
    Groups "Castle Project Users" group.
    To view this discussion on the web visit

    To post to this group, send email to

    To unsubscribe from this group, send email to


--
You received this message because you are subscribed to the Google
Groups "Castle Project Users" group.
To view this discussion on the web visit

To post to this group, send email to

To unsubscribe from this group, send email to

bling

oläst,
12 juli 2012 02:07:492012-07-12
till castle-pro...@googlegroups.com
i'm not suggesting that it's a good idea to do this.  i just don't think the container should impose technical restrictions on its use.

    To unsubscribe from this group, send email to




    --
    You received this message because you are subscribed to the Google
    Groups "Castle Project Users" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/castle-project-users/-/kJsk4S5RkAoJ
    <https://groups.google.com/d/msg/castle-project-users/-/kJsk4S5RkAoJ>
    <https://groups.google.com/d/msg/castle-project-users/-/kJsk4S5RkAoJ
    <https://groups.google.com/d/msg/castle-project-users/-/kJsk4S5RkAoJ>>.
    To post to this group, send email to

    To unsubscribe from this group, send email to



    --
    You received this message because you are subscribed to the Google
    Groups "Castle Project Users" group.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/castle-project-users/-/QKsGQAb3LhYJ
    <https://groups.google.com/d/msg/castle-project-users/-/QKsGQAb3LhYJ>.
    To post to this group, send email to

    To unsubscribe from this group, send email to


--
You received this message because you are subscribed to the Google
Groups "Castle Project Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/castle-project-users/-/WezzrFNm9EUJ.
To post to this group, send email to

To unsubscribe from this group, send email to

Krzysztof Koźmic

oläst,
12 juli 2012 02:12:052012-07-12
till castle-pro...@googlegroups.com
fair enough

@K

bling wrote:

i'm not suggesting that it's a good idea to do this. i just don't
think the container should impose /technical/ restrictions on its use.
    <mailto:castle-pro...@googlegroups.com>>>>.

    To unsubscribe from this group, send email to
    <mailto:castle-pro...@googlegroups.com>>>.

    To unsubscribe from this group, send email to




    --
    You received this message because you are subscribed to the Google
    Groups "Castle Project Users" group.
    To view this discussion on the web visit

    To unsubscribe from this group, send email to



    --
    You received this message because you are subscribed to the Google
    Groups "Castle Project Users" group.
    To view this discussion on the web visit

    To post to this group, send email to

    To unsubscribe from this group, send email to


--
You received this message because you are subscribed to the Google
Groups "Castle Project Users" group.
To view this discussion on the web visit

To post to this group, send email to

To unsubscribe from this group, send email to
Svara alla
Svara författaren
Vidarebefordra
0 nya meddelanden