Skip to content

Conversation

@wiegell
Copy link
Contributor

@wiegell wiegell commented Jul 31, 2025

PR Details

Fixes #98 for go generation

I have debugged the code and the proto tree seems to be generated fine. The problem lies in the following code generation.

Description

Related Issue

#98

Motivation and Context

We have an .xsd at work that suffers from this issue

How Has This Been Tested

A test has been made that passes for the go generation, but i would like some advice on how/if this issue should be fixed for the other languages supported

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.

@wiegell wiegell changed the title add test for element and type of same name and fix go Add support and test for element with equal type and name Jul 31, 2025
@wiegell wiegell changed the title Add support and test for element with equal type and name Fixes #98, Add support and test for element with equal type and name Jul 31, 2025
@wiegell wiegell changed the title Fixes #98, Add support and test for element with equal type and name Fixes #98: Add support and test for element with equal type and name Jul 31, 2025
@wiegell wiegell mentioned this pull request Aug 1, 2025
10 tasks
@xuri xuri added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 4, 2025
xuri added a commit to xuri/xsd that referenced this pull request Aug 7, 2025
xuri added a commit to xuri/xsd that referenced this pull request Aug 8, 2025
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.

Hi @wiegell, thanks for your PR, I've left some comments.

@@ -1,4 +1,7 @@
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:here="http://example.org/" targetNamespace="http://example.org/">
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:here="http://example.org/"
Copy link
Owner

Choose a reason for hiding this comment

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

Please update expected generation code of this xsd for other supported languages to fix unit tests build break.

if _, ok := gen.StructAST[v.Name]; !ok {
// If v.Name == v.Type generating a type alias will reference itself
// and result in a duplicate type definition error from the go compiler
if _, ok := gen.StructAST[v.Name]; !ok && v.Name != v.Type {
Copy link
Owner

Choose a reason for hiding this comment

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

Do we need add this check for other languages generator?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Element with same name and type fails to generate correct types

2 participants