Open jnm2 opened 3 years ago
Roslyn clearly knows these are content files external to the solution, so it should treat them like it would treat generated code.
In Visual Studio we definitely know this but the compiler is just passed files, it can't differentiate their source at that level.
I agree with the thesis presented though: If a file is effectively readonly then I should not see diagnostics for it. My initial thoughts are that we would capture some MSBuild metadata about the files and pass them to the compiler via the CompilerVisibleProperty
mechanism. Then the analysis engine could filter from there
Version Used: 16.9.2, 16.10.P1
This is a full minimal repro. Open this project in VS, and you will see tons of suggestions in the error list. In the real-world version of this, it's full of warnings too because other analyzers are present. Both warnings and suggestions coming from source included in NuGet compile content files are a bad thing. Warnings break builds, and suggestions and warnings at this scale wash away all useful entries in the error list for the consuming project.
This problem is exacerbated by the fact that the consuming project's .editorconfig has no ability to silence these diagnostics as a workaround for this challenge. This in itself should be another sign that showing these diagnostics in the consuming project does not make sense.
Roslyn clearly knows these are content files external to the solution, so it should treat them like it would treat generated code.
"Just add
// <auto-generated/>
"No, that would make the source package incredibly painful to develop. It would silence warnings that are really needed while editing these files. Adding a packaging step to insert this line in the NuGet package without having it present in the edited source files would also add major maintenance overhead to producing a source package.
Takeaway
The out-of-the-box defaults on both sides, both for producers and consumers of source packages (and analyzers), should only result in sensible interactions in the consuming projects.