-
Notifications
You must be signed in to change notification settings - Fork 401
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
Bump AnalysisLevel to 8 #4131
base: master
Are you sure you want to change the base?
Bump AnalysisLevel to 8 #4131
Conversation
A bit of a controversial one maybe, but sadly this one isn't shown in the IDE so putting it on suggestion level is useless, so it's either warning or nothing.
This inspection is pretty jank and doesn't show half the time. I think it has its valid cases, but it shouldn't be on warning level.
Way too aggressive and even flags private static initializers that only run once. Unusable as is.
I guarantee this never worked correctly
"Use the 'StringComparison' method overloads to perform case-insensitive string comparisons"
Rebased, dropping commits which are already on
I also needed to mute I resolved the warning in |
Yeah I'm still not too sure about it. How about we leave the ones I converted in this PR and mute the rule for all others that might come up to not annoy people unnecesarily?
This actually only fires for internal or private methods, so this will only ever report suggestions when all existing callsites support the method signature change and it actually reduces virtual or interface calls (that's what it says at least). So in general this seems like a free performance optimization hint, the only reason I haven't applied all inspections and have lowered it to suggestion is because
Yeah this one basically reports every single method call with inline array creation, even if those methods are only called once and even if they are part of a
I disagree with this one. If I'm seeing it right, the only case of this in the repo is
It seems quite clear to me that this IS in a fact an "accident" and was just fixing the garbage code from before. This should either be Array.Clear(_ram, 0, _ram.Length) as it's being done in countless other places or at least the suggested _ram.AsSpan().Clear() . This does look like a very valid suggestion to me, especially if you are not aware that Clear() exists.A Clear method being synonymous to setting everything to 0 is logical to me, so I don't see how you'd get more clarity by using a Fill method instead.
|
General point: Having a rule muted doesn't preclude a human from noticing and refactoring bad code. There are rules for pointing out code smells and there are rules for banning harmful practices, and the former aren't as binary.
It's can-kicking either way so idrc.
So even when it's working it's not very useful. Aren't all of our hot paths declared
Saxxon replaced the loop with |
Sure, however if you're against changing certain code then it doesn't matter whether there is a rule suggesting the change or not. At the end of the day these changes were all done and checked manually (by me, a human).
I would assume most hot paths are actually private, not public, but this isn't primarily about performance (none of these type changes will have noticable performance impact) and more about not overcomplicating code needlessly. Using interfaces like For example in
I doubt there was any intent behind the original code besides "I want to clear this array but I don't know how to do it efficiently, so I'll write a loop". Funnily enough, the original code was also written by Saxxon and they are the ones who changed the code to a |
Using a collection interface is correct in almost every case—it does do more than just abstracting over a class. The choice of
Regardless of the intent there, I still value explicitness. |
No. Quoting from the documentation: IList This is precisely the problem here: By allowing an abstract type but then not handling this abstract type, you're just complicating things unncessarily. |
You want to |
This bumps the
AnalysisLevel
for code analyzers from 6 to 8, enabling more analyzers by default. This is now safe as we require the .NET 8 SDK to build.I've applied fixes and severity changes to all new inspections. Open to feedback on whether any of those are disagreed on.
Check if completed: