hooklift / gowsdl

WSDL2Go code generation as well as its SOAP proxy
Mozilla Public License 2.0
1.14k stars 390 forks source link

Avoid XML name conflicts in XML tags between field tag and struct's XMLName field #227

Closed w65536 closed 2 years ago

w65536 commented 2 years ago

This fixes #224.

The problem was initially addressed with PR #109 (issue #73) in commit dd8f1cae4f65c55c7ddca89a21925dd9d85ad14e. However that commit does not address all possible name mismatch scenarios.

If multiple elements with different names are of the same complexType, the existing logic arbitrarily takes the first element's name for the struct's XMLName field tag. All other elements with different names then conflict with that tag.

Errors would typically look like these:

This PR proposes two changes:

  1. A modification to the original commit dd8f1cae4f65c55c7ddca89a21925dd9d85ad14e to avoid generating potentially conflicting XML name tags. This is probably more of an unintended bug because the author worked with upper case type names in the first place and therefore would not notice this problem.
  2. A much more generic implementation by enhancing the traverser to actually find and detect conflicting names and omit the respective XMLName struct fields with tags in complexTypes.

Both changes are required to solve all conflicting cases.

Test fixtures are adapted and verified for this change.

c4milo commented 2 years ago

Looks like merging your earlier PRs made this one enter into a conflict again @w65536

w65536 commented 2 years ago

Conflict resolved. I had inadvertently introduced a problem in commit 8a6ef869c463ef931de19b57cde914b97c038fc0 when arranging various commits for separate pull requests. By resolving the merge conflict, this problem "automatically" goes away.

c4milo commented 2 years ago

Great, thanks Patrick!