Skip to content

fix(csharp): cross-namespace type and enum resolution, scalar validator guards, and array defaults#233

Merged
jamieshorten merged 4 commits into
accordproject:mainfrom
muhabdulkadir:moh/csharp
May 26, 2026
Merged

fix(csharp): cross-namespace type and enum resolution, scalar validator guards, and array defaults#233
jamieshorten merged 4 commits into
accordproject:mainfrom
muhabdulkadir:moh/csharp

Conversation

@muhabdulkadir
Copy link
Copy Markdown
Contributor

@muhabdulkadir muhabdulkadir commented May 25, 2026

Closes #

  • Always emit using System.Collections.Generic and using System.ComponentModel.DataAnnotations
  • Fix scalar validator guard in writeField: DataAnnotation attributes ([MinLength], [MaxLength], [RegularExpression], [Range]) are now only emitted on raw primitive-typed fields. Previously they were also emitted on scalar-backed fields, which produced invalid attributes like [RegularExpression] on a struct property rather than on the struct's inner Value.
  • Cross-namespace type qualification for relationships and map values: visitRelationship and resolveMapSide now call getDotNetNamespaceOfType to fully qualify types whose target lives in a different C# namespace. Previously cross-namespace references were emitted as unqualified names that wouldn't compile.
  • Array default guard: array fields no longer inherit a scalar or primitive default initializer. The previous code could emit public SSN[] Ssns { get; set; } = new("default"); which is invalid C#.
  • Remove dead mapSideHasValidators no longer called after [ValidateComplexType] was removed in a prior commit.

Related Issues

  • Issue #
  • Pull Request #

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from fork:branchname

…, and array defaults

Signed-off-by: muhammed-abdulkadir <muhammed.abdulkadir@docusign.com>
Signed-off-by: muhammed-abdulkadir <muhammed.abdulkadir@docusign.com>
Signed-off-by: muhammed-abdulkadir <muhammed.abdulkadir@docusign.com>
Copy link
Copy Markdown
Contributor

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 updates the C# code generator to improve cross-namespace type resolution (relationships + map sides), tighten when DataAnnotations validators are emitted (avoiding invalid attributes on scalar-backed struct properties), and prevent invalid array default initializers. It also bumps Concerto dependencies to 4.1.3 and adjusts tests/snapshots accordingly.

Changes:

  • Always emit using System.Collections.Generic; and using System.ComponentModel.DataAnnotations; in generated C# files.
  • Fix type qualification for cross-namespace relationship/map references; add additional guards around scalar validators and array defaults.
  • Update unit tests and snapshots; bump @accordproject/concerto-* dependency versions to 4.1.3.

Reviewed changes

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

Show a summary per file
File Description
lib/codegen/fromcto/csharp/csharpvisitor.js Generator logic updates: namespace/type qualification, validator guarding, array default handling, and map type resolution changes.
test/codegen/fromcto/csharp/csharpvisitor.js Updates/extends test expectations for new using lines, relationship qualification, and validator/range behavior; removes several Newtonsoft scalar tests.
test/codegen/snapshots/codegen.js.snap Snapshot updates reflecting new using lines and validator emission changes.
package.json Bumps Concerto dependency versions to 4.1.3.
package-lock.json Lockfile updates for Concerto 4.1.3.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/codegen/fromcto/csharp/csharpvisitor.js
Comment thread lib/codegen/fromcto/csharp/csharpvisitor.js
Comment thread test/codegen/fromcto/csharp/csharpvisitor.js
@muhabdulkadir muhabdulkadir changed the title fix(csharp): cross-namespace type resolution, scalar validator guards, and array defaults fix(csharp): cross-namespace type and enum resolution, scalar validator guards, and array defaults May 26, 2026
Signed-off-by: muhammed-abdulkadir <muhammed.abdulkadir@docusign.com>
@jamieshorten jamieshorten merged commit f2824b6 into accordproject:main May 26, 2026
11 checks passed
@muhabdulkadir muhabdulkadir deleted the moh/csharp branch May 26, 2026 12:45
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.

4 participants