I just installed Reshaper 4.5 and it has come up with the following suggestions:
return this.GetRuleViolations().Count() == 0; -- REMOVE this.
new string[] { this.ID.ToString(), this.Registration } -- REMOVE string, MAKE ANONYMOUS TYPE
int i = Method.GetNumber(); -- REPLACE int WITH var
Should I do these?
I think in some cases it is going to make the code less readable but will it improve performance? what are the benefits of making these changes?
Thanks
Eliminate errors and code smells Not only does ReSharper warn you when there are problems in your code but it provides quick-fixes to solve them automatically.
ReSharper 2021.3 release supports Visual Studio 2022 out-of-the-box.
Resharper is a great Visual Studio productivity extension but on the other hand it slows down significantly the IDE, especially when working with large solutions.
The power of Alt+Enter icon, this means ReSharper has detected an error or other code issue and it can help you fix it. Press Alt+Enter to take advantage of this. For more information, see Quick-fixes for code issues.
1) The explicit this
pointer is only necessary when the reference would otherwise be ambiguous. Since GetRuleViolations
is defined on the type, you most likely do not need this
.
Another point here is that if GetRuleViolations
return an IEnumerable
of something, you will generally be much better off using Any()
instead of Count() == 0
as you risk enumerating the entire sequence.
2) String can be inferred from the initialization.
3) Resharper prefers var
over specific types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With