-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Suggested fix for NullReferenceException in C# #140
base: master
Are you sure you want to change the base?
Conversation
Is there a use-case for passing
|
No, there is no proper use-case for it. However, please keep in mind that this code is proof of concept for testing, and a user might accidentally pass a string variable containing null. |
throwing inside the class constructor could make the invalid value more immediately obvious. I wonder how far you can get with a |
Sounds good. Technically this use-case is not by design, so this kind of user code is a grey area. |
this is a random personal opinion, but I prefer dealing with these errors as soon as possible. a default value seems more reasonable to me than defaulting deep inside the class then because it demarcates the good and bad input right where it comes in (vs. somewhere inside where we have to hope the other methods also make this check) not sure how the C# folks prefer to handle exceptions. if it's more normative like Python I think there's a case to be made about simply asserting and throwing, but if it's more like JavaScript then a default seems more appropriate. caveat: I don't have commit access here, but I do maintain #80 where I fixed some Unicode issues and that's what we use in our apps, given that there's mostly silence from the maintainer. |
see discussion with @dmsnell in google#140 (comment)
see discussion with @dmsnell in google#140 (comment)
Oops! I'm sure you saw this already, but it looks like an extra space was introduced at the beginning of every line in there… |
Yap, I've noticed it after commit (CRLF settings). |
let's see if @NeilFraser wants to chime in |
The corresponding exception here is |
This is a suggested fix for issues #138 & #139