Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug during null check #241

Open
NilesDavis opened this issue Jun 10, 2024 · 2 comments
Open

Bug during null check #241

NilesDavis opened this issue Jun 10, 2024 · 2 comments

Comments

@NilesDavis
Copy link

NilesDavis commented Jun 10, 2024

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

@jkalias
Copy link
Member

jkalias commented Jun 16, 2024

Hi @NilesDavis,

Thanks for the feedback. This seems indeed like a bug. I don't need a proper definition for ==, neither for PolyLine2D which you say is implemented properly. Would you mind opening a PR (including unit tests)?

Thanks

@NilesDavis
Copy link
Author

Hi @jkalias .
To be honest, I wanted to, but I couldnt get the build Environment running for Standard 2.0 in VS2022. That kept me of doing it, sorry. You know the code is not the problem but tooling is...
So you have it running that you can compile it?

Cheers,
Nils

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants