-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[csharp][netcore-httpclient] Refactor of constructors: removed obsolete attribute #9373
Conversation
Lets best continue the discussion over here then. I am against removing the obsolete Attribute again. The reason being that as it stands right now people WILL assume that just building the API accessor class is fine, if they get an obsolete warning (not an error) they are at least aware that what they are doing is not really what they should be doing. I understand the sentiment of wanting to relieve the burden of people that just "want to use it in a simple project" however those people could just view the message on be like: "Ok doesn't apply to me" |
I let that choice to you and @wing328. In case this is not the expected I will close the PR. For my point of view, in a .net core project, I want the HttpClient exposed because I want to manage it correctly. But if someone put the parameterless constructor for example in a controller, the issue start consuming sockets giving real pressure on the environment. As I said starting the issue a month ago, we have stressed a lot our production environment from the inside, moving a project from net framework to net core, and it was really difficult to understand the change of behavior. |
From what I understand, we all agree this constructor will NOT be removed in the future releases. Then the next question is whether
Agreed. Have been working on this project for a while and this happens from time to time that users ignore warnings/messages or whatever we put down in the documentation/docstring/code comments, etc. Even though we mark it as obsolete, users may still ignore it. What about updating the following lines: with additional information: |
I agree the obsolete is intended for the removal not a warning. We can use the remarks element in comment. |
I think obsolete is still semantically correct. It exists purely for backwards compatibility purposes (or quick testing) and while it won't be removed it definitely is obsolete for usage purposes. |
Another point for debate is how the users (developers) interpret the word "obsolete". What about going with my suggestion in #9373 (comment) and revise later baed on users' feedback/question? |
Obsolete means that it has been superseded by a different method. The problem is that C# doesn't offer a different attribute that would give you a compiler warning. So we don't really have a choice if we want to give any warning inside the code that doesn't rely on people reading the readme in advance. I'm fine with removing the "and are considered deprecated" as its not necessarily true that they will be gone at some point. |
I've pushed an update (aa0adcd) to include a clickable link in the tooltip, e.g. Please review to see if this looks better to you. |
I think having that clickable link there is definitely a good thing. I'm not sure people will notice it more if you write IMPORTANT. As I usually don't read the description for methods that I have used before or that I don't expect have any relevance to me. How about putting the part after IMPORTANT into the Obsolete Attribute as a quite clear warning. |
In the worst case nothing (including obsolete) matters to the users who skip everything. Here is the official definition of obsolete: Ref: https://docs.microsoft.com/en-us/dotnet/api/system.obsoleteattribute?view=net-5.0 But I don't think the constructor in questions fits the definition. |
As I said obsolete doesn't quite fit the bill. I thought it was probably the only easy way to make a warning available to the consumers. However we might just want to use a
inside the constructor code that should also trigger a compiler warning which is much more visible. |
Pushed another commit to update the samples to use HttpClient, HttpClientHandler. Updated tests with HttpClient, HttpClientHandler. Please have a look when you guys have time. |
For me it's ok the remark and think about the obsolete in the near future based on feedback. |
@lucamazzanti agreed. Let's go with this. We can always revise later as |
Removed the obsolete attribute on constructors without the HttpClient parameter.
See last comments in PR #9145.
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
,5.1.x
,6.0.x
cc @mandrean (2017/08) @frankyjuang (2019/09) @shibayan (2020/02) @Blackclaws (2021/03)