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

Fix exception constructor argument order #1910

Merged
merged 3 commits into from
Jul 16, 2024

Conversation

glopesdev
Copy link
Member

@glopesdev glopesdev commented Jul 14, 2024

For some reason the order of arguments into the ArgumentOutOfRangeException constructor was swapped in all instances of the call in the DirectedGraph class, most likely because it is the reverse order from the more common ArgumentException.

@glopesdev glopesdev added the fix Pull request that fixes an issue label Jul 14, 2024
@glopesdev glopesdev added this to the 2.8.5 milestone Jul 14, 2024
Copy link
Member

@PathogenDavid PathogenDavid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good as-is, but it might be a good idea to swap most of these over to the ArgumentOutOfRngeException(string paramName) overload instead since their messages don't really add anything over the default one. (That overload is why the order is swapped from the base ArgumentException.)


It also might be worth enabling CA2208 to avoid this mistake in the future:

# Add to .editorconfig
dotnet_diagnostic.CA2208.severity = warning

Although it's worth noting that'll complain about inappropriate usage of ArgumentOutOfRangeException in Slice.cs. (Because they're locals rather than parameters, but I think it makes reasonable sense in a Bonsai context--could just suppress.)

@glopesdev
Copy link
Member Author

Although it's worth noting that'll complain about inappropriate usage of ArgumentOutOfRangeException in Slice.cs. (Because they're locals rather than parameters, but I think it makes reasonable sense in a Bonsai context--could just suppress.)

Actually that was indeed another inappropriate use, so I've turned diagnostic severity to warning. We have been using InvalidOperationException rather than ArgumentException for these, but Slice is old enough that it retained some legacy.

@glopesdev glopesdev merged commit ab59036 into bonsai-rx:main Jul 16, 2024
10 checks passed
@glopesdev glopesdev deleted the dag-exceptions branch July 16, 2024 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Pull request that fixes an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants