Skip to content

Preserve standalone date and timestamp names during C# normalization - #11741

Draft
Jorge Rangel (jorgerangel-msft) with Copilot wants to merge 14 commits into
mainfrom
copilot/tighten-date-normalization
Draft

Preserve standalone date and timestamp names during C# normalization#11741
Jorge Rangel (jorgerangel-msft) with Copilot wants to merge 14 commits into
mainfrom
copilot/tighten-date-normalization

Conversation

Copilot AI commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Date naming normalization could rename standalone members such as Timestamp or Date to the ambiguous On.

  • Preserve names when removing the date/time suffix would leave no prefix.
  • Continue normalizing compound names such as CreatedAt to CreatedOn.
  • Add coverage for properties, parameters, and serialization paths.
Timestamp → Timestamp
Date      → Date
CreatedAt → CreatedOn

Copilot AI and others added 3 commits August 21, 2026 19:51
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI 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.

Pull request overview

Preserves standalone C# date/time names while retaining compound-name normalization.

Changes:

  • Avoids replacing an entire date/time name with On.
  • Updates property, parameter, and utility coverage.
  • Updates XML serialization/deserialization expectations.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
CSharpNameExtensions.cs Preserves names consisting solely of a recognized suffix.
CSharpNameExtensionsTests.cs Covers standalone Date and Timestamp variants.
PropertyProviderTests.cs Verifies property-name preservation.
ParameterProviderTests.cs Verifies parameter-name preservation.
XmlSerializationTests.cs Updates serialization assertion for Timestamp.
XmlDeserializationTests.cs Updates deserialization assertion for timestamp.
XmlSerializationHandlesNullableDateTimeOffsetProperty.cs Updates generated serialization baseline.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pkg-pr-new

pkg-pr-new Bot commented Aug 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@11741

commit: a731b05

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.

Copilot we need to handle another scenario as part of this pull request. The issue is described in Azure/azure-sdk-for-net#62333 (comment). It seems the CodeGenMember is not working as expected on model properties, and possibly, other members. To validate, we should add a unit test to mirror the issue in the comment, and validate that a custom property can replace a generated one whose name is normalized as part of the normalization process.

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>

Copilot AI commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Copilot we need to handle another scenario as part of this pull request. The issue is described in Azure/azure-sdk-for-net#62333 (comment). It seems the CodeGenMe...

Implemented in 5f37608. CodeGenMember("CreatedAt") now replaces the generated CreatedOn property, with regression coverage.

Copilot AI 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.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>

Copilot AI commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Copilot another additional case we need to handle:

ExpirationDateTime -> ExpiresOn
...

Implemented in 6d45b4f. ExpirationDate now normalizes to ExpiresOn, including compound names such as modelExpirationDatemodelExpiresOn.

Copilot another additional case we need to handle:

ExpirationDateTime -> ExpiresOn...

Implemented in 6d45b4f. ExpirationDateTime now normalizes to ExpiresOn, with utility, property, and parameter coverage.

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>

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.

Copilot lets update the pr description and title to reflect all the changes we made

Copilot AI commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Jorge Rangel (@jorgerangel-msft) Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 5e386530-a172-45d0-868f-3c7cb4a82037

Sorry for the inconvenience!

@jorgerangel-msft

Copy link
Copy Markdown
Contributor

Jorge Rangel (Jorge Rangel (@jorgerangel-msft)) Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 5e386530-a172-45d0-868f-3c7cb4a82037

Sorry for the inconvenience!

Copilot update the pr description and title to reflect the changes we've made

Copilot AI 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.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Comment on lines +476 to +479
if (specPropertiesByName.TryGetValue(originalName, out var inputProperty) && !inputProperty.IsExactName)
{
customNames.Add(originalName.NormalizeCSharpAcronyms(inputProperty.Type.IsDateTimeInputType()));
}

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.

Copilot validate if this is true, and if so, address the feedback

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.

Validated — this was reproducible when [CodeGenMember] used the raw spec casing (for example "creationDate"). I addressed it in 1392c25 by resolving OriginalName through identifier casing before normalized matching, and added regression coverage (CustomCodeReplacesDateNormalizedPropertyUsingRawSpecName). I also re-ran the full npm run test:generator suite after npm ci; it passed.

Copilot AI commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Jorge Rangel (Jorge Rangel (@jorgerangel-msft)) Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentio...

I can’t edit PR metadata directly from this environment, but here’s an updated proposal you can apply:

PR title
Refine C# name normalization and CodeGenMember matching for date/time and acronyms

PR description
This PR expands C# naming normalization and custom-member replacement behavior in the generator.

  • Preserve standalone date/time names (Date, Timestamp) instead of collapsing to On.
  • Normalize expiration names to ExpiresOn (including ExpirationDate and ExpirationDateTime) and avoid ExpireOn.
  • Ensure CodeGenMember replacement works against normalized generated names (date/time suffix and acronym normalization).
  • Keep exact-name members safe from normalized replacement paths.
  • Preserve required-property metadata/constructor behavior when custom members replace normalized generated members.
  • Add and update regression coverage using TestData snapshots for date, acronym, and exact-name customization scenarios.

Copilot AI and others added 2 commits August 21, 2026 23:38
… normalization

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants