Azure / autorest.csharp

Extension for AutoRest (https://github.com/Azure/autorest) that generates C# code
MIT License
142 stars 166 forks source link

Internal generated methods should not use default parameters #1240

Open KrzysztofCwalina opened 3 years ago

KrzysztofCwalina commented 3 years ago

When we generate a service method as internal, the method should not have default parameters. Internal methods will almost always be hand wrapped, and we want the wrapper to be forced to pass all parameters.

Moreover, if we generate an internal content-less method with RequestOptions defaulted and then a public method is added manually that takes CancellationToken in place of the RequestOptions, intenral code, e.g. tests, result in many callsite ambiguities.

chamons commented 3 years ago

This is a good idea, but could possibly break a lot of generated code (that would need manual fixes) in rest client.

AlexanderSher commented 2 years ago

@KrzysztofCwalina do we still want to have this implemented?

KrzysztofCwalina commented 2 years ago

I think so. Why not? The assumption is that if somebody forces generated method to be internal, they are probably manually wrapping it and it will be easier to correctly wrap such methods if they don't have default parameters.