-
Notifications
You must be signed in to change notification settings - Fork 592
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
Do not throw on invalid ReplyTo address #828
Do not throw on invalid ReplyTo address #828
Conversation
51b56db
to
fb1a62c
Compare
I'm not sure it's a good idea to change the behavior of the Parse method like this. It's pretty standard practice in in the .NET space for If non-throwing behavior is needed because this method is called internally, I think adding a |
Well, documentation states that the property "returns null if ReplyTo property cannot be parsed by PublicationAddress.Parse". So, behavior of Adding a new TryParse method will result in two methods with almost same behavior. The only difference is, |
Thank you! |
Here's my thinking: the method in question is a getter and it would make more sense to return a |
…-not-throw Do not throw on invalid ReplyTo address (cherry picked from commit 7ed249c)
My assumption is that this fix requires a |
I'm still not sure this was the correct approach, and technically this is a breaking behavior change. The actual code in this PR wasn't changing a property getter, it was changing a public method on the That's why I was suggesting adding a And it also fits into the standard Parse/TryParse convention you see for .NET parsing methods. |
@ig-sinicyn would you be up for another PR that introduces a new |
@michaelklishin As an option, the Parse() method logic may be changed to throw on parsing failures. Personally, I do not like the idea as it will be a breaking change. |
Well, try-parse pattern is not recommended for all scenarios. See Framework Design Guidelines for more.
Currently the Parse() method does not throw exceptions for invalid input value, and therefore have no performance penalty. So, the try-parse pattern is not applicable here. |
P.S. Note the CONSIDER tag. In FDG terms, it means that recommendation is not a mandatory thing and should be used with caution. |
It's great that there is an entire book written on .NET patterns and idioms but what the book says and what the community does can and likely will diverge over time. I'll tweak #828 to do what @bording suggests because introducing a new method is fairly trivial. The whole feature is obscure and rarely used but I'd rather do what prominent contributors suggest than spend mental energy on arguing about idioms. Either option is fine with me but one is safer. |
…ge-properties-do-not-throw"" This reverts commit ed65854. See the discussion in #827. We will slightly tweak the approach but at the very least the test added by @ig-sinicyn can be retained.
instead of changing the behavior of an existing one. Per discussion with @bording and @ig-sinicyn in #827.
Proposed Changes
Do not throw ArgumentNullException from
ReplyToAddress
getter andPublicationAddress.Parse()
call. See #827 for more details.Types of Changes
What types of changes does your code introduce to this project?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creatingthe PR. If you're unsure about any of them, don't hesitate to ask on the
mailing list. We're here to help! This is simply a reminder of what we are
going to look for before merging your code.
CONTRIBUTING.md
documentFurther Comments
I've decided to add fix into the
PublicationAddress.Parse()
method asReplyToAddress
documentation states