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
DefaultEventSerializer - throw error when Type not found #4
Comments
Have you checked the serialization docs? Types must be registered in the For example, in the test project, all the mappings are registered in the static constructor of the events holder itself: eventuous/test/Eventuous.Tests/Model/BookingEvents.cs Lines 15 to 20 in 70717a8
|
Alexey, I had looked over that when I was working out what I had missed out. So something like:
And with your example:
|
But how can it know what types are needed? It's just a serializer. Until you hit an event, which hasn't been mapped, it's impossible to know. I believe it's something that's easily caught in tests. |
A long time ago I was using a fallback to the CLR type name. However, it did more damage than good. When the serializer throws, you see it very fast. If it keeps storing events, which weren't mapped, you will be caught by surprise when you look at the store and see the wrong event type there, which is impossible to fix without migrating the streams. |
I just got an idea. What if we can create a static analyser, which will trigger warnings in the editor/IDE if you use event types in |
Alexey, Yes, I think that would be great if it was possible. Knowing about this at compile time would be great. |
@StevenBlair123 have to park the code analysis idea facing some substantial work around subscriptions and diagnostics. However, I got some ideas from other projects. For example, would an event type name attribute be a better solution? At least it will be obviously visible in the code. |
Check the PR 👆 |
More checks added by #48 |
Having a play around with this framework and struggled to get the Subscription service working.
I pulled down your repository so I could debug it, and it turned out I hadn't registered my Type.
Opted for the DefaultEventSerializer, which silently handles unknown events.
Wonder if an option to throw an error on this would be useful?
Might be better that happen, than skip passed an event because someone forgot to register the Event.
The text was updated successfully, but these errors were encountered: