Skip to content

SecurityIdentifier.CompareTo throws an exception if compared to null #100990

Closed
@mslukebo

Description

@mslukebo

Description

The implementation of SecurityIdentifier.CompareTo does not allow comparing against null, which goes against the interface definition of IComparable<T>.CompareTo. According to that interface, the input to the method is T?, and should return 1 according to these doc's remarks.

Reproduction Steps

SecurityIdentifier sid = new SecurityIdentifier(. . .);
sid.CompareTo(null);

Expected behavior

CompareTo should return 1,

Actual behavior

An exception is thrown.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

Tangentially related to #99722

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions