Skip to content

Conversation

@halgab
Copy link
Contributor

@halgab halgab commented Dec 1, 2023

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

@ghost ghost assigned halgab Dec 1, 2023
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Dec 1, 2023
@ghost ghost requested review from dipeshmsft and singhashish-wpf December 1, 2023 09:59
@ghost ghost added Community Contribution A label for all community Contributions draft labels Dec 1, 2023
@lindexi
Copy link
Member

lindexi commented Dec 1, 2023

Awesome, thank you @halgab for your contribution.

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}'.
Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor Author

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))
Copy link
Contributor Author

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))
Copy link
Contributor Author

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

Comment on lines -365 to -369
if ((value < 0) || (value > 255))
{
throw new System.ArgumentOutOfRangeException("value", SR.Format(SR.ParameterMustBeBetween, 0, 255));
}

Copy link
Contributor Author

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))
Copy link
Contributor Author

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))
Copy link
Contributor Author

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

@halgab halgab marked this pull request as ready for review December 1, 2023 13:19
@halgab halgab requested a review from a team as a code owner December 1, 2023 13:19
@ghost ghost removed the draft label Dec 1, 2023
@halgab halgab changed the title Use more ArgumentOutOfRangeException.ThrowIf* to replace custom error messages More uses of ArgumentOutOfRangeException.ThrowIf* to replace custom error messages Dec 3, 2023
@halgab halgab requested a review from rchauhan18 December 27, 2023 21:27
@rchauhan18
Copy link
Contributor

Thanks @halgab for the contribution!

@halgab halgab deleted the aoore-helpers-4 branch January 10, 2024 09:35
@github-actions github-actions bot locked and limited conversation to collaborators Feb 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants