autorest icon indicating copy to clipboard operation
autorest copied to clipboard

Azure C# clients should also have CustomInitialize method

Open bitsforthought opened this issue 10 years ago • 5 comments

This is a follow-on to this issue: https://github.com/Azure/autorest/issues/789

When AutoRest generates a non-Azure C# client, the ServiceClient-derived class includes a partial CustomInitialize method. This would be really handy to have for Azure C# clients as well.

@jhancock93 FYI

bitsforthought avatar May 25 '16 01:05 bitsforthought

@tbombach and I were just discussing this approach, and while it works for this case, we're not so sure that this is the best pattern to lay down for this type of enhancement.

We're leaning towards enabling a means of having the generator create the type as internal partial, and mark methods as virtual so that the developer can create a subclass of that and just use override methods to change what they'd like. We're kinda thinking that would be more flexible in the long run, rather than one-offing methods to customize individual methods as we go.

fearthecowboy avatar Jun 10 '16 18:06 fearthecowboy

@fearthecowboy I disagree. The CustomInitialize method works great and is minimally invasive. With your proposal, we'd have to change the name of our client in our Swagger specs and introduce a new derived class just to make a few small customizations. This doesn't really make sense.

bitsforthought avatar Jun 10 '16 19:06 bitsforthought

We're leaning towards enabling a means of having the generator create the type as internal partial ,

Also, this won't work because you can't have a public type inherit from an internal one.

bitsforthought avatar Jun 10 '16 19:06 bitsforthought

Given that it's already in the one, I can see why we need to take this to let it work in the other.

Yeah, I forgot that there isn't any private inheritance in .NET. sigh

fearthecowboy avatar Jun 10 '16 19:06 fearthecowboy

Merged.

fearthecowboy avatar Jun 10 '16 20:06 fearthecowboy