question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ancestor classes without properties

See original GitHub issue

The Autorest tool seems to have a limitation when it comes to ancestor classes with zero properties. This is causing issues for our API architecture:

        [HttpGet]
        [ActionName("ListJobs")]
        [SupportedGroupVersion("2016-05-01,2016-06-01")]
        [SwaggerResponseRemoveDefaults]
        [SwaggerResponse(
            HttpStatusCode.OK, 
            "Lists all the jobs in your Recovery Services Vault according to the query filters " + 
                "and the pagination parameters.", 
            typeof(ResourceList<JobBase>))]
        public HttpResponseMessage ListJobs(string resourceId)

And the models are defined thus: jobs class structure

We have an empty base to support requirements in the future which might not be met by the derived class – Jobin the middle. The SDK clients will be creating the specific derived objects (AzureIaaSVMJobor MabJob) based on the JobTypefield which also acts as the polymorphic discriminator. We cannot take a dependency on the C# Object(base of all objects) as this would break the contract at the service.

This will be a blocking issue for our SDK release where we need to generate the code for September release. Please let us know when this can be fixed in the autorest tool so that I can validate it.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
matthchrcommented, Aug 1, 2016

I am not on the core AutoRest team (so please do not take anything I say as officially from them), but as a C# developer I am not sure I understand the point of the JobBase class… how would it help me as a client? It has no properties so if something didn’t fit into the Job class then what could I do with the base class? As you’ve draw the diagram here, JobBase is basically an alias for C# Object – a class with no properties or methods on it (and it seems no abstract methods as well?)

I don’t get the point of it – can you outline a scenario where such a thing is actually helpful? Specifically I am interested in this case:

We have an empty base to support requirements in the future which might not be met by the derived class

If and when such a requirement comes, will the base class get properties (for the new requirement?) If yes, why not just wait until the requirement comes to add the base class (and until then just have Job inherit from object)?

0reactions
fearthecowboycommented, Jul 17, 2017

This doesn’t seem to be a blocker for anyone at this point. The next c# generator may have an option for this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ancestors, Descendants, and Class Hierarchies - RAD Studio
Each generation in the hierarchy contains more than its ancestors, since a class inherits everything from its ancestors, then adds new properties and...
Read more >
Can a parent class not have attributes or functions?
The real question is, do they share behavior and I think the answer is "yes" if your language supports generics or class templates....
Read more >
How to show all methods of a class without ancestors methods ...
To show all methods defined by a particular class, but without methods that are defined in ancestors classes, I'm writing like this.
Read more >
Inheritance - Learning the Java Language
A subclass inherits all the members (fields, methods, and nested classes) from its superclass. Constructors are not members, so they are not inherited...
Read more >
Ancestor and descendent variables
The compiler knows only the properties and functions of the ancestor class uo_empdata (or the system class UserObject if that is what you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found