excubo-ag / Blazor.Canvas

https://excubo-ag.github.io/Blazor.Canvas/
MIT License
220 stars 23 forks source link

Code Analysis Generates Many Errors on Generated Code #145

Closed rjarrattmsft closed 3 years ago

rjarrattmsft commented 3 years ago

If I enable full code analysis on the solution that references this package I am flooded with code analysis errors on files like GroupAttribute.cs. I don't really get why I need the grouping thing anyway, but given that it is there it would be good to make sure it does not generate code analysis errors.

stefanloerwald commented 3 years ago

Hi @rjarrattmsft,

could you please provide a list of the code analysis error/warning codes that you think should be suppressed?

Thanks Stefan

rjarrattmsft commented 3 years ago

Actually I just realised they are StyleCop errors, like SA1633, SA1200, SA1629, SA1101 (and a few others).

stefanloerwald commented 3 years ago

Thanks for getting back to me so quickly. To be honest, I consider this a minor issue of roslyn/source-generators/IDEs: source generated files shouldn't be subject to code styles of the user at all. I could now go ahead and add a bunch of suppressions into the relevant files, but it will probably never be a complete list. What do you think?

rjarrattmsft commented 3 years ago

There used to be a way to mark files as auto generated that suppressed all analysis, although I am not sure if that is always respected. I would be happy just for all analysis to be suppressed on generated code.

rjarrattmsft commented 3 years ago

I wouldn't call it a minor issue though because once you start to ignore some warnings then you can't see the warnings that actually do matter and you can't fail the build because of warnings, which I think is very important generally (but not in my specific instance).

stefanloerwald commented 3 years ago

I consider this a minor issue as it only affects optional code analysis which can be configured to ignore certain files.

Anyway: I have updated the code generator to include a // <auto-generated /> comment at the top of each auto-generated file. Hopefully that resolves your issue. Please let me know whether you still get those warnings with version 2.5.9.

stefanloerwald commented 3 years ago

Sorry, didn't mean to close this yet...

rjarrattmsft commented 3 years ago

That seems to have fixed it. Thanks for the super-quick response!