Old thread, but in case anyone stumbles across this...
Diagnostics should only be use in Analyzers (not Generators).
Reason: With a Generator, you need to cache Diagnostic info during parsing as part of an ImmutableArray. This needs to get passed to your RegisterSourceOutput handler (SourceProductionContext is required to report the Diagnostic).
The reason you should NOT do this is because that diagnostic info invariably relies on Symbol locations, which are highly variant. Thus, you are constantly breaking the cache-flow that relies on immutable data to remain relatively stable.
The means means your Generator will be really slow.