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

Fix missing marshaller #103

Merged
merged 5 commits into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Templates/ModelTemplate.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ else
</text>
}

@if (Model.BaseIsPolymorphic || Model.IsPolymorphic || Model.AllProperties.Any(p => p.ModelType is DictionaryTypeGo))
@if (Model.BaseIsPolymorphic || Model.IsPolymorphic || Model.HasFlattenedFields || Model.AllProperties.Any(p => p.ModelType is DictionaryTypeGo))
Copy link
Author

Choose a reason for hiding this comment

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

@mcardosos do you think is any reason to keep this here ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Here you mean in models.go?


In reply to: 172636578 [](ancestors = 172636578)

Copy link
Author

Choose a reason for hiding this comment

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

sorry, somehow posted this. Yes we need this.

I was looking at the old CS where we had tne trick with the alias but we are using this now to populate the discriminator value

Copy link
Contributor

Choose a reason for hiding this comment

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

Question. If model has flattened fields, does it need an unmarshaller? Unmarshaller should only be needed with discriminator stuff

Copy link
Author

Choose a reason for hiding this comment

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

yes , is the same issue. if the embedded type has a custom unmarshaller and the embedding type doesnt, the one from the embedded type will be used on the entire embedding type which will result in deserialization errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

:( but we dont want an unmarshaller just becase it has flattened types, right? only if it is flattened and the flattened stuff has some polymorphism
I would not like to create unmarshallers for everything that has a flattened type

Copy link
Author

@vladbarosan vladbarosan Mar 7, 2018

Choose a reason for hiding this comment

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

correct if we can check that all chain of embedded types does not have any polymorphism than we can have an if on that. Opened issue to track this Azure/azure-sdk-for-go#1204

{
<text>
@EmptyLine
Expand Down Expand Up @@ -319,7 +319,7 @@ else
{
@:@(Model.Name.FixedValue.ToShortName()).@(p.Name) = @(CodeNamerGo.Instance.GetVariableName(p.Name))
}
else
else
{
@:@(Model.Name.FixedValue.ToShortName()).@(p.Name) = &@(CodeNamerGo.Instance.GetVariableName(p.Name))
}
Expand Down
12 changes: 12 additions & 0 deletions test/src/tests/generated/lro/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions test/src/tests/generated/model-flattening/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.