Skip to content

refactor: Implemented analyzer suggestions and smaller refactorings#937

Merged
egil merged 5 commits intomainfrom
refactor/analyzers
Dec 15, 2022
Merged

refactor: Implemented analyzer suggestions and smaller refactorings#937
egil merged 5 commits intomainfrom
refactor/analyzers

Conversation

@linkdotnet
Copy link
Collaborator

This PR was meant to fix some of the new analyzers shipped with net7.0 that got activated with 7.0.1.

What did I do?

  • Made internal/private types sealed
  • When IEnumerable was enumerated multiple times, I created a List
  • Simplified some exception handling
  • Simplified some foreach loops

@linkdotnet linkdotnet requested a review from egil December 14, 2022 09:41
egil
egil previously approved these changes Dec 14, 2022
@linkdotnet
Copy link
Collaborator Author

I don't wanna jinx anything here, but since we removed the blame stuff I do feel the builds are way more stable.

egil
egil previously approved these changes Dec 14, 2022
@egil
Copy link
Member

egil commented Dec 14, 2022

@linkdotnet there is very little overhead in doing multiple iterations over what is very likely to be a list or array already, but even so, I could not help myself and did try to avoid the ToArray/ToList call in one place. In reality, just doing multiple enumerations over the innumerable are completely fine in the cases affected by this PR, since that IEnumerable is very likely going to be in memory already, so this could also be a case we can just ignore the analyzer.

EDIT: ok nevermind just broke it :)

@egil egil merged commit 9ef9eb1 into main Dec 15, 2022
@egil egil deleted the refactor/analyzers branch December 15, 2022 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants