KEMBAR78
Add boilerplate documentation to generated types by mlorbetske · Pull Request #30259 · dotnet/maui · GitHub
Skip to content

Conversation

mlorbetske
Copy link

Description of Change

Add boilerplate documentation to types and constructors produced by CodeBehindGenerator to prevent CS1591 from being raised on these members when documentation build is turned on.

Issues Fixed

Fixes #27911

@Copilot Copilot AI review requested due to automatic review settings June 26, 2025 23:01
@mlorbetske mlorbetske requested a review from a team as a code owner June 26, 2025 23:01
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 26, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds XML documentation boilerplate to code-behind classes and their default constructors generated by CodeBehindGenerator, preventing CS1591 warnings during documentation builds.

  • Inserts <summary> comments before the generated class and its XAML attribute.
  • Adds <summary> comments for the optional default constructor.
  • Supports issue #27911 by ensuring documentation warnings are suppressed.
Comments suppressed due to low confidence (1)

src/Controls/src/SourceGen/CodeBehindGenerator.cs:307

  • [nitpick] Consider referencing the generated class's CLR type name rather than the file path in the summary (e.g. 'Generated XAML code-behind for MainPage') to improve clarity for consumers.
		sb.AppendLine($"\t/// Generated XAML code behind for {projItem.RelativePath}");


sb.AppendLine($"namespace {rootClrNamespace}");
sb.AppendLine("{");
sb.AppendLine($"\t/// <summary>");
Copy link

Copilot AI Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Public docs live in XML under /docs/. Please update the relevant docs XML to describe the new boilerplate documentation feature so public documentation aligns with code changes.

Copilot uses AI. Check for mistakes.

//optional default ctor
if (generateDefaultCtor)
{
sb.AppendLine($"\t\t/// <summary>");
Copy link

Copilot AI Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure there are automated tests in TestCases.Shared.Tests and TestCases.HostApp that verify CodeBehindGenerator emits the expected <summary> comments for generated types and constructors.

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@StephaneDelcroix StephaneDelcroix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd very much prefer having [GeneratedCode] attribute on generated types __Type without user defined code behind

if (generateDefaultCtor)
{
sb.AppendLine($"\t\t/// <summary>");
sb.AppendLine($"\t\t/// Creates a new {rootType}");
Copy link
Contributor

@dotMorten dotMorten Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should follow the standard doc convention for constructors, otherwise anyone having standard doc enforced in their code analyzers would just generate warnings here.

Suggested change
sb.AppendLine($"\t\t/// Creates a new {rootType}");
sb.AppendLine($"\t\t/// Initializes a new instance of the <see cref=\"{rootType}\" /> class.");

sb.AppendLine($"namespace {rootClrNamespace}");
sb.AppendLine("{");
sb.AppendLine($"\t/// <summary>");
sb.AppendLine($"\t/// Generated XAML code behind for {projItem.RelativePath}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a great summary to end up in class documentation - those paths doesn't make sense in IntelliSense. Seems cleaner to just add a [GeneratedCode] attribute.

@jfversluis jfversluis added the s/pr-needs-author-input PR needs an update from the author label Jul 29, 2025
@dotnet-policy-service
Copy link
Contributor

Hi @@mlorbetske. We have added the "s/pr-needs-author-input" label to this issue, which indicates that we have an open question/action for you before we can take further action. This PRwill be closed automatically in 14 days if we do not hear back from you by then - please feel free to re-open it if you come back to this PR after that time.

StephaneDelcroix added a commit that referenced this pull request Jul 29, 2025
some types are 100% generated (for xaml-only resourcedictionaries). They
should cause documentation to be generated, so mark them as [Generated]

- fixes #27911
- closes #30259
StephaneDelcroix added a commit that referenced this pull request Jul 29, 2025
some types are 100% generated (for xaml-only resourcedictionaries). They
should cause documentation to be generated, so mark them as [Generated]

- fixes #27911
- closes #30259
@jfversluis
Copy link
Member

Fixed with #30903, closing this one. Thanks for the effort!

@jfversluis jfversluis closed this Jul 29, 2025
github-actions bot pushed a commit that referenced this pull request Jul 29, 2025
some types are 100% generated (for xaml-only resourcedictionaries). They
should cause documentation to be generated, so mark them as [Generated]

- fixes #27911
- closes #30259
@github-actions github-actions bot locked and limited conversation to collaborators Aug 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community ✨ Community Contribution s/pr-needs-author-input PR needs an update from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resource files generates warnings when comment file is enabled

4 participants