Open IEvangelist opened 2 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
Tagging subscribers to this area: @dotnet/area-system-runtime See info in area-owners.md if you want to be subscribed.
Author: | IEvangelist |
---|---|
Assignees: | - |
Labels: | `area-System.Runtime`, `untriaged` |
Milestone: | - |
Description
When I first saw the message for the
ArgumentException
I assumed it was mistakenly pulling from theArgumentOutOfRangeException
message. That is not the case, but it could be improved upon nonetheless. I'd like to propose a fix where the default message is something like:But it's actual value is:
Reproduction Steps
To reproduce this, instantiate an
ArgumentException
with the various.ctor
's and evaluate the messages, I've put together a Sharplab.io that provides a bit of contextual output:Expected behavior
I'd expect the default
ArgumentException.Message
to not mislead consumers by mentioning a value falling within the expected range. That sort of messaging feels appropriate with theArgumentOutOfRangeException
message, but not theArgumentException
.I'd expect messaging like this:
Actual behavior
This is the actual behavior:
These values are coming from the src/libraries/System.Private.CoreLib/src/Resources/Strings.resx file:
https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx#L190-L192
And assigned here:
https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/ArgumentException.cs#L95
Regression?
This appears to have been this way for as long as I can tell.
Known Workarounds
You can use the
.ctor
that allows you to specify a custommessage
instead.Configuration
This applies to all.
Other information
No response