Skip to content

if (SecurityIdentifier == null) throws PlatformNotSupportedException on linux #87282

@InterpolationStation

Description

@InterpolationStation

Description

For better or worse, controlling behavior using nullable objects is a common place pattern. Checking if an object reference is null should never raise an exception. For example,

object? foo = null;
foo?.DoWork();
// or 
if (foo != null)
{
}

Reproduction Steps

Run the following code on Linux.

SecurityIdentifier? securityIdentifier = null;
if (securityIdentifier != null) { }

Expected behavior

(securityIdentifier != null) returns false on Linux and Windows, no exception is raised.

Actual behavior

The following exception is thrown.
System.PlatformNotSupportedException: Windows Principal functionality is not supported on this platform.
at System.Security.Principal.SecurityIdentifier.op_Inequality(SecurityIdentifier left, SecurityIdentifier right)

Regression?

Not sure.

Known Workarounds

No response

Configuration

.net 6.0 linux-x64 self-contained exe

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions