-
Notifications
You must be signed in to change notification settings - Fork 1.2k
More uses of ArgumentOutOfRangeException.ThrowIf* to replace custom error messages #8489
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
Conversation
|
Awesome, thank you @halgab for your contribution. |
ba81218 to
4648142
Compare
| ParameterMustBeGreaterThanZero=The parameter value must be greater than zero. | ||
| ParameterCannotBeLessThan=The parameter value cannot be less than '{0}'. | ||
| ParameterCannotBeGreaterThan=The parameter value cannot be greater than '{0}'. | ||
| ParameterMustBeBetween=The parameter value must be between '{0}' and '{1}'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I should clean up the other lines corresponding to the resources I removed in my previous PR. Should I do it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you can remove the lines here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| { | ||
| throw new System.ArgumentOutOfRangeException("value", SR.Format(SR.ParameterMustBeBetween, 1, 255)); | ||
| } | ||
| ArgumentOutOfRangeException.ThrowIfZero(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a byte, value cannot be negative or greater than 255
| } | ||
| set | ||
| { | ||
| if ((value < 0) || (value > 3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a byte, value cannot be negative
| } | ||
| set | ||
| { | ||
| if ((value < 0) || (value > 2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a byte, value cannot be negative
| if ((value < 0) || (value > 255)) | ||
| { | ||
| throw new System.ArgumentOutOfRangeException("value", SR.Format(SR.ParameterMustBeBetween, 0, 255)); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a byte, value cannot be negative or greater than 255, so this check is redundant
| } | ||
| set | ||
| { | ||
| if ((value < 0) || (value > 3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a byte, value cannot be negative
| } | ||
| set | ||
| { | ||
| if ((value < 0) || (value > 4)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a byte, value cannot be negative
|
Thanks @halgab for the contribution! |
Follow-up to #8408
Description
As mentioned in #8408, ParameterMustBeBetween, ParameterValueCannotBeInfinity and ParameterValueCannotBeNaN are good candidates for replacing custom ressources with inbox ones. This PR addresses those two cases, each in its own commit
Regression
No
Testing
CI
Risk
Low. I manually searched and removed the error messages, and let CA1512 finish the work
Microsoft Reviewers: Open in CodeFlow