Skip to content

Add IntegerType setting to CSharpGeneratorSettings#1889

Open
Copilot wants to merge 2 commits intomasterfrom
copilot/add-integertype-support
Open

Add IntegerType setting to CSharpGeneratorSettings#1889
Copilot wants to merge 2 commits intomasterfrom
copilot/add-integertype-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 1, 2026

CSharpGeneratorSettings had configurable type mappings for numbers, dates, and collections but no equivalent for integer, making it impossible to default to long instead of int globally.

Changes

  • CSharpGeneratorSettings: Added IntegerType property (default: "int") alongside the existing numeric type settings
  • CSharpTypeResolver.ResolveInteger: Changed from static to instance method; uses Settings.IntegerType as the default fallback (guards against null/whitespace with "int"). Also removed a duplicate long format branch that existed in the original code
  • Tests + snapshots: Added two tests covering default int generation and custom type override

Usage

var generator = new CSharpGenerator(schema, new CSharpGeneratorSettings
{
    IntegerType = "long"  // all unformatted integer properties now map to long
});

Note: this setting applies only to integer properties with no explicit format — byte, long (int64 format), and ulong format mappings are unaffected.

Original prompt

This section details on the original issue you should resolve

<issue_title>Support for IntegerType in CSharpGeneratorSettings</issue_title>
<issue_description>We can set several useful default types in CSharpGeneratorSettings, but nothing for integer. Could we get a setting that allows us to use long instead of int by default?</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: lahma <171892+lahma@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for IntegerType in CSharpGeneratorSettings Add IntegerType setting to CSharpGeneratorSettings Mar 1, 2026
Copilot finished work on behalf of lahma March 1, 2026 20:00
@lahma lahma marked this pull request as ready for review March 1, 2026 20:04
@lahma lahma requested a review from RicoSuter March 7, 2026 13:18
return isNullable ? "long?" : "long";
}

if (schema.Format is JsonFormatStrings.Long or "long")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think we should keep this one, no? Breaking change otherwise.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this branch is duplicated just above, so basically removing one of them doesn't matter?

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.

Support for IntegerType in CSharpGeneratorSettings

3 participants