orleans
orleans copied to clipboard
Added #pragma warning disable CS1591 to supress warnings in the source generated code
Description
Added #pragma warning disable CS1591 and "#pragma warning restore CS1591 to the source generated file to supress warnings when projects contains <GenerateDocumentationFile>True</GenerateDocumentationFile>
Fix
- #8290
Thank you for opening this PR, @m3nax!
I was looking for the Roslyn-native way to do this. It might look something like this, in CodeGenerator.cs before we return the CompilationSyntax but I haven't tested this yet:
var disabledWarnings = new List<string>();
assemblyAttributes[0] = assemblyAttributes[0]
.WithLeadingTrivia(
SingletonList(
PragmaWarningDirectiveTrivia(
Token(SyntaxKind.DisableKeyword),
SeparatedList(disabledWarnings.Select(w => (ExpressionSyntax)w.GetLiteralExpression())), isActive: true)));
return CompilationUnit()
.WithAttributeLists(List(assemblyAttributes))
.WithMembers(List(namespaces));
I Will test It tomorrow
@ReubenBond I have updated the implementation as you suggested but, as it is the first time I have modified a source generator, I did not understand how to remove the double quotes from the list of warnings to be suppressed
Now the output of orleans.g,cs is like this:
#pragma warning disable "CS1591"
[assembly: global::Orleans.ApplicationPartAttribute("ConsoleApp1")]
[assembly: global::Orleans.ApplicationPartAttribute("Orleans.Core.Abstractions")]
[assembly: global::Orleans.ApplicationPartAttribute("Orleans.Serialization")]
[assembly: global::Orleans.Serialization.Configuration.TypeManifestProviderAttribute(typeof(OrleansCodeGen.ConsoleApp1.Metadata_ConsoleApp1))]
namespace OrleansCodeGen.ConsoleApp1
{
// CODE
}
#pragma warning restore "CS1591"
Do you have any suggestions?
@ReubenBond Problem fixed
Fantastic, thank you, @m3nax!