PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Remove unneeded casts

Open AZero13 opened this issue 3 years ago • 15 comments

These casts are not needed and can be safely removed

Summary of the Pull Request

Removed casts that did not need to happen because the variable is already the target type.

PR Checklist

  • [x] Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • [X] Tests: Added/updated and all pass
  • [X] Localization: All end user facing strings can be localized
  • [X] Dev docs: Added/updated
  • [x] New binaries: Added on the required places
  • [X] Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Tests passed

AZero13 avatar Oct 14 '22 14:10 AZero13

How are these getting determined unneeded. Trying to see why this hasn’t been done yet

crutkas avatar Oct 15 '22 06:10 crutkas

Well, for starters, all casts to object are redundant by definition.

AZero13 avatar Oct 15 '22 15:10 AZero13

Second, static analysis shows that these casts were superfluous

AZero13 avatar Oct 15 '22 15:10 AZero13

My feedback is your suggestion changes but not helping explain from a PR stance why.

What tool are you running or is this an existing flag in the build output?

not saying this is a bad thing, trying to understand how these got flagged.

Trust me, I’m all about getting analysis tools built into the pipelines.

crutkas avatar Oct 15 '22 16:10 crutkas

@crutkas these were Rosyln (the C# compiler) warnings

AZero13 avatar Oct 16 '22 15:10 AZero13

@AtariDreams This is larger than casting now.

PRs really need to be scoped

crutkas avatar Oct 17 '22 17:10 crutkas

Done!

AZero13 avatar Oct 17 '22 17:10 AZero13

@crutkas Fixed the PR

AZero13 avatar Oct 17 '22 18:10 AZero13

These changes were from when changes from different PRs got mixed in.

AZero13 avatar Oct 20 '22 21:10 AZero13

@crutkas fixed!

AZero13 avatar Oct 20 '22 21:10 AZero13

my main question of how these are getting flagged is still unanswered.

Is this a warning in the build output? A screenshot would be massively helpful for helping us cause right now I do not understand why we are removing the casts

crutkas avatar Oct 29 '22 07:10 crutkas

Some were found manually. Others were by Roslyn warnings

AZero13 avatar Oct 31 '22 13:10 AZero13

@crutkas Also, casts to (object) are redundant, and casts to literals are redundant as well

AZero13 avatar Nov 04 '22 13:11 AZero13

Once again, I need to understand how we can validate this. We did an aggressive scrub with analyzers a while back and I’m surprised this wasn’t caught as a build warning at a minimum by them

crutkas avatar Nov 04 '22 15:11 crutkas

Where are these warnings appear exactly? How can we repro this?

jaimecbernardo avatar Nov 09 '22 14:11 jaimecbernardo

Closing this, as it's not clear why the change is needed. Please re-open if you feel it's still neccessary.

jaimecbernardo avatar Nov 14 '22 17:11 jaimecbernardo