Skip to content

?. operator treats DBNull as null causing the methods to not execute #11084

Closed

Description

Since the implementation of ?. operator treats DBNull, NullString and AutomationNull as null, we cannot call any method on them using ?. operator. The concern is only for DBNull as for other types we truly consider them as null.

Steps to reproduce

[System.DBNull]::Value?.GetTypeCode()

Expected behavior

DBNull

Actual behavior

null

Environment data

Build after PR https://github.com/PowerShell/PowerShell/pull/10960 is merged

Activity

  1. vexx32 commented on Nov 15, 2019

    @vexx32
    Collaborator

    This will also affect NullString.Value -- if you are referencing LanguagePrimitives.IsNullLike() anywhere in the implementation of ?. or ?[] you probably want to switch to LanguagePrimitives.IsNull()

  2. rjmholt commented on Nov 15, 2019

    @rjmholt
    Collaborator

    Yes I think we either agree that ?. uses IsNullLike(), in which case I think this is by design, or we use IsNull(), in which case there's a change to make.

  3. SteveL-MSFT commented on Nov 16, 2019

    @SteveL-MSFT
    Member

    I feel we've already crossed this bridge once we decided awhile back that [System.DBNull]::Value -eq $null so usage expects it to act like it was $null (current design) otherwise it'll confuse users with the inconsistency. They can always workaround this by not using this operator.

  4. iSazonov commented on Jan 31, 2020

    @iSazonov
    Collaborator

    Steve Lee (@SteveL-MSFT) Can we close the issue? It seems we revert PR for DBNull.

  5. iSazonov commented on Jan 15, 2021

    @iSazonov
    Collaborator
  6. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  7. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  8. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  9. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or more

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions