Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Beginning with .NET 10 preview1, a source generator adds public partial class Program
to a Program.cs file that uses top-level statements. This automates a step that developers previously had to do manually for integration testing of their apps.
But when the project is configured to GenerateDocumentationFile
, this results in an odd analyzer warning on the first statement in Program.cs:

But the warning cannot be resolved by adding an XML comment above this first statement (which is actually the fix suggested by Copilot):

The only way I could find to resolve this is by adding public partial class Program {};
at the end of the file with an XML comment on it.

Oh ... there is another way, which is to suppress the analyzer warning for missing XML comment on the public partial class Program;
statement:

Expected Behavior
I think statements added by source generators should not cause analyzer warnings. So I think the source generator in this case should add the suppression pragmas as shown above.
Steps To Reproduce
Create a new .NET 10 webapi and then enable GenerateDocumentationFile
in the project file.
Exceptions (if any)
No response
.NET Version
10.0.100-preview.4.25229.110
Anything else?
No response