Skip to content

Code Quality: Fix CA1859 and CA1829 #14955

@gumbarros

Description

@gumbarros

Description

.NET 8 introduce this 2 new analyzers to improve performance

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1829
https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1859

Concerned code

CA1829:

var pinnedItemsCount = instance.Items.Where(x => x.GroupName == JumpListPinnedGroupHeader).Count();

CA1859:

private static IDictionary<CommandCodes, IRichCommand> CreateModifiableCommands() => new Dictionary<CommandCodes, IRichCommand>

Gains

  • Better readibility (no useless casting at CA1859 )
  • Better performance

Requirements

  • Refactor to the suggestions of the analyzer

Comments

I created #14951 but it was recused, it has compile errors and do more things, if authorized I can create a new PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions