Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for XmlEnumAttribute specifiying custom names for enum members #986

Merged

Conversation

edgridin
Copy link
Contributor

@edgridin edgridin commented Jan 7, 2024

Feature request: support for XmlEnumAttribute to be able to specifiy custom names for enum members

for the example enum, used in test CheckEnumWithCustomNamesXmlSerializedWsdl

public enum EnumWithCustomNames
	{
		[XmlEnum("F")]
		FirstEnumMember,

		[XmlEnum("S")]
		SecondEnumMember,

		ThirdEnumMember
	}

the expected output would be

<xsd:simpleType name="EnumWithCustomNames">
        <xsd:restriction base="xsd:string">
          <xsd:enumeration value="F" />
          <xsd:enumeration value="S" />
          <xsd:enumeration value="ThirdEnumMember" />
        </xsd:restriction>
      </xsd:simpleType>

Copy link
Collaborator

@andersjonsson andersjonsson left a comment

Choose a reason for hiding this comment

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

Thank you very much for the PR!

Looks good! I left a comment regarding the performance. Please take a look at that and we can get this PR merged shortly

src/SoapCore/Meta/MetaBodyWriter.cs Outdated Show resolved Hide resolved
@edgridin
Copy link
Contributor Author

edgridin commented Jan 8, 2024

hi Anders,

wow, I didn't expect, that a Linq query with a join would have better performance, than just looping and querying for single members. But yeah, the difference is huge, so I've changed the implementation to your proposal.

Maybe an additional question - I've seen, that wsdl generation with XmlSerializer currently doesn't support SOAP fault contracts. Do you know, if someone is already on it? Otherwise I could try to implement it.

Best regards,
Eduard

@andersjonsson
Copy link
Collaborator

hi Anders,

wow, I didn't expect, that a Linq query with a join would have better performance, than just looping and querying for single members. But yeah, the difference is huge, so I've changed the implementation to your proposal.

Yeah, it's the query per member that's killing perf. That same "pattern" has caused me lots of headache over the years 😅
A pre-constructed dictionary, so that you wouldn't have to run a linq-query per iteration, would work just as well.

Maybe an additional question - I've seen, that wsdl generation with XmlSerializer currently doesn't support SOAP fault contracts. Do you know, if someone is already on it? Otherwise I could try to implement it.

Not to my knowledge. You are more than welcome to give it a go 😄

@andersjonsson andersjonsson merged commit d714e11 into DigDes:develop Jan 8, 2024
3 checks passed
@andersjonsson
Copy link
Collaborator

Merged! Thanks again!

@edgridin
Copy link
Contributor Author

edgridin commented Jan 8, 2024

Maybe an additional question - I've seen, that wsdl generation with XmlSerializer currently doesn't support SOAP fault contracts. Do you know, if someone is already on it? Otherwise I could try to implement it.

Not to my knowledge. You are more than welcome to give it a go 😄

OK, I'll give it a try :-)

Could you maybe publish the new package version? This XmlEnum stuff is really needed, otherwise I'd have an enum with one-letter-members in my current project, which is terrible 😄

@andersjonsson
Copy link
Collaborator

Done. A new version should be available on nuget in a couple of minutes

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.

2 participants