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

[Host.HybridMessageSerialzier] #238 Resolve HybridMessageSerializer dependencies from IServiceProvider [Alternative implementation] #242

Conversation

EtherZa
Copy link
Contributor

@EtherZa EtherZa commented Apr 6, 2024

As discussed in #238, here is an alternative implementation based on specialised builders for the hybrid message serializer.

As with all things, there are a few pros and cons

Pros:

  • Implementation does not manipulate the DI which should result in no hidden surprises
  • Builder code maintenance should be simpler (far simpler code required)
  • Easier to add custom (unpackaged) registrations (can also exclude action is registered with container elsewhere)
builder
    .RegisterSerializer<SerializerTwo>(services => services.AddSingleton<SerializerTwo>())
    .For(typeof(SampleTwo));
  • No potential runtime exceptions due to state of builder not being as expected (won't compile on a misplaced .For())
  • Intellisense shows what's available and nothing else
    image

Cons:

  • The hybrid message serializer becomes a special implementation requiring its own interfaces and implementation in other (unrelated) serializers
  • Functionality needs an extra extension method to be added when adding a message serializer (old one remains, so it won't be a breaking change though)
    image

@EtherZa EtherZa changed the title #238 Resolve HybridMessageSerializer dependencies from IServiceProvider [Host.HybridMessageSerialzier] #238 Resolve HybridMessageSerializer dependencies from IServiceProvider [Alternative implementation] Apr 6, 2024
@EtherZa EtherZa force-pushed the feature/hybrid-serializer-dependency-injection-alternative branch from 1f40bd1 to 3a9e6aa Compare April 6, 2024 16:18
Copy link

sonarqubecloud bot commented Apr 6, 2024

@EtherZa EtherZa closed this Apr 8, 2024
@EtherZa EtherZa deleted the feature/hybrid-serializer-dependency-injection-alternative branch April 15, 2024 23:34
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

Successfully merging this pull request may close these issues.

1 participant