Skip to content

Commit

Permalink
Prefer the ElementType.XmlProperties.Name if present (#269)
Browse files Browse the repository at this point in the history
* Prefer the ElementType.XmlProperties.Name if present

* Bump to v2.0.22
  • Loading branch information
RikkiGibson authored Jul 11, 2018
1 parent cd3d5d4 commit 164eb8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft.azure/autorest.java",
"version": "2.0.21",
"version": "2.0.22",
"description": "The Java extension for classic generators in AutoRest.",
"scripts": {
"autorest": "autorest",
Expand Down
12 changes: 10 additions & 2 deletions src/JavaCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,7 @@ private static IEnumerable<XmlSequenceWrapper> ParseXmlSequenceWrappers(AutoRest
if (parameterType is ListType parameterListType && parameter.ModelType is AutoRestSequenceType sequenceType)
{
string xmlRootElementName = sequenceType.XmlName;
string xmlListElementName = sequenceType.ElementXmlName;
string xmlListElementName = sequenceType.ElementType.XmlProperties?.Name ?? sequenceType.ElementXmlName;
if (!xmlSequenceWrappers.Any(existingWrapper => existingWrapper.XmlRootElementName == xmlRootElementName && existingWrapper.XmlListElementName == xmlListElementName))
{
HashSet<string> xmlSequenceWrapperImports = new HashSet<string>()
Expand Down Expand Up @@ -1812,7 +1812,15 @@ private static ServiceModelProperty ParseModelProperty(AutoRestProperty autoRest
IType propertyClientType = ConvertToClientType(propertyWireType);

AutoRestIModelType autoRestPropertyModelType = autoRestProperty.ModelType;
string xmlListElementName = autoRestPropertyModelType is AutoRestSequenceType autoRestPropertyModelSequenceType ? autoRestPropertyModelSequenceType.ElementXmlName : null;
string xmlListElementName = null;
if (autoRestPropertyModelType is AutoRestSequenceType sequence)
{
try
{
xmlListElementName = sequence.ElementType.XmlProperties?.Name ?? sequence.ElementXmlName;
}
catch { }
}

bool isConstant = autoRestProperty.IsConstant;

Expand Down

0 comments on commit 164eb8a

Please sign in to comment.