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

Minor Issue: Can never be Null #26

Closed
kabua opened this issue Apr 14, 2021 · 2 comments · Fixed by #27 or #28
Closed

Minor Issue: Can never be Null #26

kabua opened this issue Apr 14, 2021 · 2 comments · Fixed by #27 or #28

Comments

@kabua
Copy link
Contributor

kabua commented Apr 14, 2021

Just trying to promote good programming practices.

The first line of each test reads:
if (cancellationToken == null) throw new ArgumentNullException(nameof(cancellationToken));

CancellationToken is a struct and thus can never be null.

CS0037 - Cannot convert null to 'type' because it is a non-nullable value type.

See: cs0037

While I love testing arguments for valid state and it is better to check than not to check, this check is redundant and more importantly is teaching junior developers, who may not know any better, that structs might be null - which by definition they can't.

@martincostello
Copy link
Member

Good catch 👍 - feel free to open a PR to resolve this, and any other improvements you might find.

@kabua
Copy link
Contributor Author

kabua commented Apr 14, 2021

@martincostello I don't use github for pushing so I had some issues pushing my changes back up from SourceTree and I don't think I followed your contrib rules - sorry. However, I hope the changes to the WPF main page are acceptable. Take a look and let me know what you think of the proposed changes.

@martincostello martincostello linked a pull request Apr 15, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants