Skip to content

Extend validation of ThrowOnPolymorphicSubscription to throw by any unmapped descendant types #48

@ramonsmits

Description

@ramonsmits

Describe the suggested improvement

Is your improvement related to a problem? Please describe.

The validation via ITopicTopology.ThrowOnPolymorphicSubscription checks if a type has descendants and throws if when there are no explicit registrations

https://github.com/Particular/NServiceBus.Transport.IBMMQ/blob/1.0.0/src/Transport/EventRouting/TopicTopology.cs#L259-L289

This is a great validation as that enforced opt-in.

The problem is that if there is a new descendant added in the future that this goes unnoticed.

It would be nice that if we detect a none configured/explicit descendant to result in a validation error.

This means that a subscriber needs explicit registrations for all:

record A : IEvent;
record B : A;
record C : B;

Describe the suggested solution

A solution could be to ALWAYS scan for all descendant types and check if an explicit decision exist:

topology.SubscribeTo<A>;
topology.SubscribeTo<B>;
topology.DoNotSubscribeTo<C>; // <-- New API to make it explicit

Describe alternatives you've considered

Keep the partial validation as-is.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions