Skip to content

fix: Convert newline chars in enumDescriptions to spaces - #1013

Merged
efevans merged 1 commit into
googleapis:mainfrom
efevans:enumdescriptions-newlines
Oct 2, 2026
Merged

efevans merged 1 commit into
googleapis:mainfrom
efevans:enumdescriptions-newlines

Conversation

@efevans

@efevans efevans commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

b/567102951

@efevans
efevans requested a review from a team as a code owner September 30, 2026 18:01

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the CodeGenerator to normalize newlines in enumDescriptions to spaces, ensuring proper formatting for XML documentation, and exposes the NormalizeDescriptions method as internal to allow for unit testing. A review comment suggests using Children().OfType<JValue>() instead of Children<JValue>() to avoid potential InvalidCastException errors if non-value elements are present in the enumDescriptions array.

Comment thread Google.Api.Generator.Rest/CodeGenerator.cs Outdated

namespace Google.Api.Generator.Rest.Tests
{
public class DescriptionNewlineTest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of adding these, let's add Compute to golden tests.

@efevans efevans Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. For golden tests do we add the discovery doc and *.g.cs as-is or do we trim it down? compute.preview looks to be considerably larger than our current golden tests, about 15MB for the discovery doc and generated source file which is larger that the rest of the golden test files combined.

edit: I've added the whole thing for now

}

private static string NormalizeDescriptions(string discoveryJson)
internal static string NormalizeDescriptions(string discoveryJson)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we add compute to golden tests we don't need to make this internal.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added


// Enum descriptions are used for XML documentation as well (for enums generated for parameters),
// so they need the same normalization.
var enumDescriptions = raw.Descendants()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's concat descriptions and enumDescriptions to keep a single foreach loop.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated to concat the two

@efevans
efevans force-pushed the enumdescriptions-newlines branch 2 times, most recently from 4bc17fa to 375f53a Compare October 2, 2026 18:59
@efevans
efevans force-pushed the enumdescriptions-newlines branch from 375f53a to b43fcb8 Compare October 2, 2026 19:00
@efevans
efevans requested a review from amanda-tarafa October 2, 2026 19:03

@amanda-tarafa amanda-tarafa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thanks

And yes, it's OK to add Compute whole. If something complains at some point because o the size, we'll deal with it.

@efevans

efevans commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@amanda-tarafa Do you know what requirement need to be met for the gapic-generator-csharp-presubmit?

@amanda-tarafa

Copy link
Copy Markdown
Contributor

@amanda-tarafa Do you know what requirement need to be met for the gapic-generator-csharp-presubmit?

That's broken, we should remove it. But it's optional, you can ignore it and merge.

@efevans
efevans merged commit 3c7668d into googleapis:main Oct 2, 2026
12 of 13 checks passed
@efevans
efevans deleted the enumdescriptions-newlines branch October 2, 2026 23:18
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.

2 participants