Troubleshooting — EricksonLopez.Messaging
Common compiler, analyzer, and DI issues in EricksonLopez.Messaging (2.0.0).
EricksonLopez.Messaging.Analyzers fails compilation (TreatWarningsAsErrors=true) if a type implements IMessage without [MessageType("...")] from EricksonLopez.Messaging.Attributes.
AddMessagingInstrumentation() or AddLogging() Missing
Section titled “AddMessagingInstrumentation() or AddLogging() Missing”AddMessagingInstrumentation(): Importusing OpenTelemetry.Trace;andusing OpenTelemetry.Metrics;(notEricksonLopez.Messaging.OpenTelemetry).ILogger<THandler>in standalone DI:AddMessaging()falls back toNullLogger<T>.Instancefor built-in middleware, but custom handlers injectingILogger<THandler>requireservices.AddLogging()to passValidateOnBuild=true.
NativeAotJsonSerializer & Messaging.Generators Single-Pass Limitation
Section titled “NativeAotJsonSerializer & Messaging.Generators Single-Pass Limitation”- In
v2.0.0,NativeAotJsonSerializerremovedDefaultJsonTypeInfoResolverfallback; supply an explicitJsonSerializerContext(IJsonTypeInfoResolver) in AOT hosts. - Note on
EricksonLopez.Messaging.Generators: Because Roslyn source generators cannot chain intoSystem.Text.Json.SourceGenerationwithin the same compilation pass,GeneratedMessagingJsonSerializerContextmay failCS0534when compiling from source viaProjectReference; use explicit[JsonSerializable]contexts when compiling handlers alongsideIMessagedefinitions.