Skip to content
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

Added #pragma warning disable CS1591 to supress warnings in the source generated code #8940

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

m3nax
Copy link
Contributor

@m3nax m3nax commented Apr 11, 2024

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

@m3nax m3nax changed the title Added #pragma to supress warning CS1591 to the source generated code Added #pragma warning disable CS1591 to supress warning in the source generated code Apr 11, 2024
@m3nax m3nax changed the title Added #pragma warning disable CS1591 to supress warning in the source generated code Added #pragma warning disable CS1591 to supress warnings in the source generated code Apr 11, 2024
@ReubenBond
Copy link
Member

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));

@m3nax
Copy link
Contributor Author

m3nax commented Apr 20, 2024

I Will test It tomorrow

@m3nax m3nax marked this pull request as draft April 22, 2024 08:31
@m3nax
Copy link
Contributor Author

m3nax commented Apr 22, 2024

@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 ReubenBond self-assigned this May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants