Skip to content

Possibly wrong pattern match in VirtualizingStackPanel.GetControl #15955

Closed
@jnyrup

Description

@jnyrup

Describe the bug

In C# the pattern x is not A or B is interpreted as x is (not A) or B and not x is not (A or B).

I was grep'ing my local git repositories for code that matched and stumbled upon

fromControl is null && direction is not NavigationDirection.First or NavigationDirection.Last)

So this code is not checking whether direction is "neither First nor Last".
As Last is covered by not First Roslyn even lowers this to != First.
As such this looks like a bug to me

image

SharpLab

To Reproduce

I found this by analyzing the code and didn't write any code I don't know and haven't looked into if this potential bug can be hit.

Expected behavior

No response

Avalonia version

master

OS

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughelp-wantedA contribution from the community would be most welcome.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions