SerilogAnalyzer
SerilogAnalyzer copied to clipboard
Analysis not performed when Serilog is used indirectly
We have a quite complicated framework that uses Serilog for logging internally, but exposes the same functionality via wrapper methods. We have wrapper methods decorated with MessageTemplateFormatMethod and initially every diagnostic worked - within the core framework assemblies.
When we started adding the package to the consumer assemblies, the diagnostics were not shown. A short investigation has shown us that it happens because the consumer assemblies do not reference Serilog, so this code shorts out:
var messageTemplateAttribute = context.SemanticModel.Compilation.GetTypeByMetadataName("Serilog.Core.MessageTemplateFormatMethodAttribute");
if (messageTemplateAttribute == null)
{
return;
}
So, the question is: is there any way to enable the diagnostics for the consumer assemblies without having them reference Serilog directly? As soon as we add the reference, everything works, but we would like to avoid that.
We are also interested in the same. This is causing us to more difficulty sharing packages as SerilogAnalyser require specific attribute from Serilog.Core
Is there any way to avoid the requirement of Serilog.Core.MessageTemplateFormatMethodAttribute and allow a custom attribute for the purpose?