Skip to content

[csharp] Don't duplicate parent properties in derived classes#4080

Closed
jimschubert wants to merge 2 commits intoswagger-api:masterfrom
jimschubert:csharp/3829
Closed

[csharp] Don't duplicate parent properties in derived classes#4080
jimschubert wants to merge 2 commits intoswagger-api:masterfrom
jimschubert:csharp/3829

Conversation

@jimschubert
Copy link
Copy Markdown
Contributor

PR checklist

  • Read the contribution guildelines.
  • Ran the shell/batch script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)
  • Filed the PR against the correct branch: master for non-breaking changes and 2.3.0 branch for breaking (non-backward compatible) changes.

Description of the PR

referring to #3829, this sets parent properties only on base types in the C# client generator. It looks like there's a similar solution in the NancyFX generator, but it didn't port correctly to AbstractCSharpCodegen.

I'd like to move logic from this PR into AbstractCSharpCodegen to be shared across generators, but I'd need to look more into how NancyFX is doing its inheritance (because it doesn't have supportsInheritance = true set).

One of my main concerns is that the code block I have commented "Cleanup possible duplicates." may or may not indicate a bug elsewhere (wherever readWriteVars is used). Without this cleanup block, when supportsInheritance = true and I debug ./bin/csharp-petstore.sh, I get readWriteVars containing duplicates for all parent properties . My assumption is that the name property of these codegen properties isn't being compared in a case-insensitive way, or post-processing of property names isn't being done before the sorting. I spent some time trying to track this down and couldn't find it.

I was wondering if someone could:

  • verify this code generates the correct C# code?
  • remove the "Cleanup possible duplicates" block and supportsInheritance = true; to see if readWriteVars does indeed include duplicates?

I plan to take another look, but it may be a week or so before I get around to it.

This includes supportsInheritance only for the client codegen at the
moment, because setting in AbstractCSharpCodegen would require the
change to be tested in all derived generators, possibly including
similar template changes to this commit's.
@jimschubert jimschubert changed the title Csharp/3829 [csharp] Don't duplicate parent properties in derived classes Oct 27, 2016
@wing328 wing328 modified the milestone: v2.2.3 Feb 22, 2017
@manuc66
Copy link
Copy Markdown
Contributor

manuc66 commented Jun 22, 2017

@jimschubert I leverage your work to add subtype inheritance support in https://github.com/manuc66/swagger-codegen/tree/feature/csharp-subtypes could you have a look ?

@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Sep 7, 2017

Closed via #5922

@wing328 wing328 closed this Sep 7, 2017
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.

3 participants