Azure / autorest.csharp

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

Suppressing client methods still generates REST methods #3315

Closed heaths closed 1 year ago

heaths commented 1 year ago

When using [CodeGenSuppress("MethodName", typeof(param1), ...)] (and for Async) to suppress methods, which some libraries do, the generated *RestClient still has members related to creating and invoking requests e.g.,

They're not public, but still unnecessarily increase the size of the assembly. Low pri.

ArcturusZhang commented 1 year ago

I believe this is an issue for HLC instead of DPG. DPG does not generate RestClient methods.

We could add the corresponding attribute to the *RestClient to make them vanish, and I believe we should always require that attribute to remove the corresponding rest client, because the purpose of CodeGenSuppress is just removing the given member from the class with the attribute

heaths commented 1 year ago

I believe this is an issue for HLC instead of DPG. DPG does not generate RestClient methods.

We could add the corresponding attribute to the *RestClient to make them vanish, and I believe we should always require that attribute to remove the corresponding rest client, because the purpose of CodeGenSuppress is just removing the given member from the class with the attribute

I think that makes sense. I hadn't considered making a partial class - since the rest client is already partial - to hide those, and this does allow for a manually written partial client class to still call them in different ways. I'll go ahead and close this. It's a good workaround - even solution - and not worth spending lots of time on HLCs right now.