Skip to content

ObjectListExtensions.OfType should ignore null values #647

@wmrutten

Description

@wmrutten

Concerning the extension method ObjectListExtensions.OfType in the Hl7.Fhir.Support library:

  1. Why this custom method, as LINQ also provides a (generic) method OfType<T> with same behavior out of the box?
  2. The LINQ OfType<T> method uses the is operator, which automatically skips/excludes null values but includes subclasses. The custom method compares runtime types, which throws an exception for null values and excludes subclasses.

Suggestions:

  1. Remove this method, use LINQ instead
  2. Or rewrite the method to behave exactly the same as the LINQ method (using is operator)
  3. Or rename this method to e.g. OfExactType (only if the API depends on such behavior)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bitesize!breaking changeThis issue/commit causes a breaking change, and requires a major version upgrade

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions