-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Removal of Unnecessary Overloads + Extension method tweaks. #68
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
Conversation
In the case where the method had no params args, as not providing them is the same as the case of method with param args but not supplying them.
Modified CharacterInfo.cs to use it.
|
I don't know if matters here but removing the non-params overloads leads to an unnecessary empty array allocation if no additional arguments are provided. The DiagnosticInfo class that ends up storing the args is prepared to deal with null arrays and that may be a sign that the overloads were intentional. As for IsBetween, well, that sounds like a reasonable attempt at killing the lexer performance 😄 |
Minimise use of "magic strings" More use of interpolation string. Moved Exts to Utilities and renamed to GenericExtensions
|
@mikedn Why would it create an array? If no parameters are passed should the value of the params be Of all the cases (VS can find) it is passed only one argument a string, an array see like to much. |
|
It creates an array of 0 length because that's what the C# specification requires. I searched the code a bit and there are a couple of uses of the non-params overloads. Even if there are no concerns about allocation I'd probably keep those overloads because they avoid bloating the call sites with useless code for the array allocation. |
Modifying DiagnosticsInfo for the case of only one argument a string.
|
Why not optional argument? Plus an overload for the case of See commit 65d3d0a |
|
Seems like too much trouble. Avoiding allocating an empty array at the expense of a couple of null checks and trivial overloads is one thing. Avoiding allocating an array with a single element at the expense of additional overloads and more code to deal with this special case is another thing and should only be done if there's evidence that it improves performance. Also, your PR contains a bunch of unrelated and unnecessary formatting changes. In particular, you seem to indent the code with 2 spaces while this project is using 4. |
|
Then if that's the case why the class OneOrMany? |
|
Presumably because someone has done the necessary analysis and decided that it's worth the trouble. I've never said that one should never do such an optimization, I said that such optimizations should only be done when they're really needed. You started your PR with the goal to cleanup some code and when I pointed out that a particular change might be a de-optimization you changed the goal from cleanup to performance improvement, even if there's no evidence that the improvement is necessary. |
|
Changing: into: might seem pretty and modern but, in reality, it's changing into: Behind the curtain, The same goes to almost all, if not all, uses of string interpolation. |
|
Is there anywhere else in the Roslyn code where optional arguments are being used on public or protected methods? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous error said it was a binary operator while this error states that it is a unary operator.
|
I'm still trying to get used to Git. I thought that a pull request would only pull up to a specific point of time, not subsequent commits. It was only for the overloads and extensions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: blank line separator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: double blank line
|
Thank you for the contribution! A significant portion of this change is simply altering the style of the existing code. In general we are going to be reluctant to take such changes. They generally represent churn in the code base that don't provide concrete value. Overall our code base now follows the .NET Foundation contributing guidelines including their coding style requirements. Much of the code didn't follow this when originally posted but over the last few weeks it has all been migrated to meet those guidelines. The code will continue to follow those guidelines going forward. Style changes will generally be taken only when it:
|
|
@jaredpar The single line if's do improve readability. More of guards and you are talk in the region of half the screen height, before you even get to the "good stuff" of the method. not all of have huge monitors, some laptops has more horizontal space than vertical Simple returns SImple Cases 15 LoC vs 25 (separate lines ) or 35 if in require the breaks. Now consider the case where pattern-matching is included, the code will get both wider and longer (in terms of structural layout). |
|
@AdamSpeight2008 whether or not single line ifs, or most other style decisions, improve readability is subjective. What is preferable to one developer may not be preferable to the other. The important aspect of style is to keep it consistent across the code base. In this specific case though single line ifs are not permitted by the coding guidelines. |
|
@AdamSpeight2008 You submitted a pull request from your To start working on a different proposed change, such as creating new constants for string literals that appear in code, go back to the latest Otherwise, when you send a bunch of different types of changes in a single pull request, it has a high likelihood of getting rejected if people disagree with one of the changes, even if they agree with the majority. |
|
Note: The original repo for this PR as been removed. |
Enable diagnostics
…CodeAnalysis.FxCopAnalyzers-3.3.0 Bump Microsoft.CodeAnalysis.FxCopAnalyzers from 3.0.0 to 3.3.0
No description provided.