autorest icon indicating copy to clipboard operation
autorest copied to clipboard

Add setting for C# gen to specify constructor protection level

Open stankovski opened this issue 10 years ago • 4 comments

If set constructors should be generated as internal

stankovski avatar Jan 14 '16 23:01 stankovski

What's the scenario for this?

bitsforthought avatar Jan 14 '16 23:01 bitsforthought

Allow to generate clients with "internal" ctor so that the client can not be initialized directly. Customization layer would be used to wrap the client and customize it as needed. This is necessary for scenarios where clients need to be forcefully pre-configured (e.g. custom delegating halndlers, custom retry policy, etc.).

stankovski avatar Jan 14 '16 23:01 stankovski

Cool, that's something we're interested in for the Search SDK as well. But why stop at the constructor? Why not make the classes themselves internal?

bitsforthought avatar Jan 15 '16 00:01 bitsforthought

@brjohnstmsft keeping class public allows developers to re-use the entire client and just hide the ctor. For example you can have a custom ctor that takes in an account name and appends it to base Uri as is the case in DataLake

stankovski avatar Jan 15 '16 19:01 stankovski