-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[Proposal] Analyzer that suggests ToUpperInvariant/ToLowerInvariant in place of ToUpper/ToLower #43976
Comments
@mavasani created a PR for this - dotnet/roslyn-analyzers#2186 |
@mavasani should this go through API review in the runtime repo, or is this just an improvement to an existing analyzer? |
@mavasani This issue was opened back in 2017 before we decided that Roslyn analyzer proposals should be approved in the API review meeting in the runtime repo. It already has a PR opened back in 2019, but it wasn't discussed here or approved. Should we move it to the runtime repo to approve it first? |
Yes, I agree we need a proposal/triage in runtime repo before taking this forward. |
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
@jamesqo as suggested in this thread you need to add the proposal up in the issue description. are you suggesting to have the analyzer suggest ToUpperInvariant/ToLowerInvariant all the time when ToUpper/ToLower show up? or would be depending on the context of the callsite? |
I think if we do not recommend to use ToUpper/ToLower at all we should deprecate it or change implementation to call into To*Invariant (perhaps with a switch to bring back the old behavior) |
I don't think it is a good idea to change the behavior even with a switch. From other discussions with the community in other issues, it looks using the switch is not a solution for all situations. I agree to deprecate |
I updated the description to get this proposal ready for review. @jamesqo @TKharaishvili @tarekgh let me know if you have any comments about my edit. Otherwise, let's wait for the API review meeting to discuss this. |
I am fine with the proposal. Only the last part |
|
@TKharaishvili just checking, are you still working on that? @carlossanlop looks you were doing more follow up here. do you have more info about the plan for this one? |
I moved this to 7.0 as I am not seeing urgency to have it for 6.0. That is fine if we get a PR for 6.0 too. |
@tarekgh I won't have any time to work on this in the next 2 months. I'll come back to it afterwards if that works for you guys. |
@TKharaishvili are you still going to work on this? |
@carlossanlop yes, I'll have an updated PR over the next several days. |
Hi @carlossanlop I tested positive for covid and won't be able to get any work done for some time. If you guys need this taken care of urgently, please unassign me from the issue, otherwise I'll get back to it once I'm better. |
Hi @carlossanlop I'm back at it. I see a lot has changed in the repo since I first sent that PR(which is to be expected for a 3 year gap). Originally I added the analyzer source file to the Also I'm thinking of dropping this current PR and creating a new one instead. Doing a merge after this long is proving to be too much of a headache. |
@carlossanlop @buyaa-n could you please help with @TKharaishvili question in the previous comment? @TKharaishvili are you still willing to submit the PR? Thanks! |
Sorry for late reply @TKharaishvili @tarekgh
Yes that is the right place
Right, sounds good, feel free to close your old PR then |
@TKharaishvili hello, are you still working on this ? |
@danmoseley I pushed the latest code review requested changes yesterday. Waiting for another round of review now. |
When using
String.ToUpper()
orString.ToLower()
, suggest usingString.ToUpperInvariant()
andString.ToLowerInvariant()
.Something similar is already in place here, but for string comparisons: CA1309: Use ordinal StringComparison
A PR already exists to fix this. We want to get this proposal approved before reviewing it: dotnet/roslyn-analyzers#2186
Usage examples:
The text was updated successfully, but these errors were encountered: