Skip to content

Represent elements of choices as pointers#105

Merged
xuri merged 9 commits intoxuri:masterfrom
marshallmoats-wk:master
Sep 26, 2025
Merged

Represent elements of choices as pointers#105
xuri merged 9 commits intoxuri:masterfrom
marshallmoats-wk:master

Conversation

@marshallmoats-wk
Copy link
Contributor

@marshallmoats-wk marshallmoats-wk commented Sep 17, 2025

PR Details

Description

(Note: this PR includes the changes from #102. That PR should be merged before this one.) This PR marks elements as optional when some ancestor element is a choice. In Go, this allows such elements to be omitted from XML serialization when that element was not present in the choice (i.e. when the pointer is nil).

The other (quite minor) change is that, in Go code generation, when an element is both plural and optional, this would generate a field of type []*T, where T is the generated Go type of the element. I've changed it so that it will generate []T instead--the optional-ness of this element is best represented by an empty slice, so pointers are unnecessary. However, for complexTypes, T will be generated as a pointer anyway, so this doesn't change anything in such cases. This was already done in a previous PR, I was not aware.

Related Issue

Motivation and Context

How Has This Been Tested

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Owner

@xuri xuri left a comment

Choose a reason for hiding this comment

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

Code conflicts should be resolve.

@xuri xuri added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 18, 2025
# Conflicts:
#	genGo.go
#	test/go/base64.xsd.go
#	test/java/base64.xsd.java
#	test/ts/base64.xsd.ts
#	test/xsd/base64.xsd
@xuri xuri added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 22, 2025
xuri added a commit to xuri/xsd that referenced this pull request Sep 25, 2025
@codecov
Copy link

codecov bot commented Sep 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.92%. Comparing base (ca26c15) to head (58ddaf3).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #105      +/-   ##
==========================================
- Coverage   81.93%   81.92%   -0.01%     
==========================================
  Files          37       37              
  Lines        1871     1870       -1     
==========================================
- Hits         1533     1532       -1     
  Misses        246      246              
  Partials       92       92              
Flag Coverage Δ
unittests 81.92% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@marshallmoats-wk
Copy link
Contributor Author

@xuri Let me know if there's anything else that I'll need to do before this can be merged.

Copy link
Owner

@xuri xuri left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your contribution.

@xuri xuri merged commit 2cb22a3 into xuri:master Sep 26, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants