Skip to content

Bug during null check #241

@NilesDavis

Description

@NilesDavis

I came in a situation where I checked a Polygon2D if it was null or not and in any case it returned false.
Try this code to reproduce:

Polygon2D polygon = null;
bool isNull = polygon == null;

The variable isNull should result in being true, but is not!

Essentially what is missing in the "=="-operator is something like this:

//both null
if (ReferenceEquals(left, null) && ReferenceEquals(right, null))
    return true;
//for null-condition
if (ReferenceEquals(left, null) || ReferenceEquals(right, null))
    return false;

This seems to be the same situation for nearly all classes of Euclidian namespace!

  • CoordinateSystem (null-condition NOT checked)
  • PolyLine2D (null-condition is checked)
  • PolyLine3D (null-condition is checked)
  • Polygon2D (null-condition is checked)

Or am I missing something? As mathnet-spatial mostly uses structs it is not that obvious

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions