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

C# nullable support is sketchy #24

Closed
mpdetwiler opened this issue Feb 18, 2022 · 5 comments
Closed

C# nullable support is sketchy #24

mpdetwiler opened this issue Feb 18, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@mpdetwiler
Copy link

  • I have installed 0.11.0 from nuget, I used to use an older version
  • In this new (newest?) version now the operator[] for TomlTable return "object?" instead of just "object"
  • I was under the impression that this never returns null because it will throw KeyNotFoundException instead
  • So now I have to put a ! after every TomlTable lookup ie (long)myTable["some-integer"]!
  • I've had to put literally hundreds of ! to update my codebase to nullable
  • It is bad practice to use so much null forgiveness especially when the function doesn't actually return null (as far as I know)

WHY did you change the return type from "object" to "object?" (did you?) should have just left it alone. Change it back pretty please?

@xoofx
Copy link
Owner

xoofx commented Feb 18, 2022

WHY did you change the return type from "object" to "object?" (did you?) should have just left it alone. Change it back pretty please?

It was an oversight. As I'm no longer using TomlTable directly and I didn't check the usage experience. I will change it back.

@xoofx xoofx added the enhancement New feature or request label Feb 18, 2022
@mpdetwiler
Copy link
Author

It was an oversight. As I'm no longer using TomlTable directly and I didn't check the usage experience. I will change it back.

Okay well I just realized something. Does or has the library always (even before 0.4.0) allowed users to SET keys to map to null objects? If that is the case then the GET could return null if the user ever set it to null for a particular key. In that case I don't think you could change it back because some users might have abused that. I never set keys in my codebase so I never thought of that.

@xoofx
Copy link
Owner

xoofx commented Feb 18, 2022

WHY did you change the return type from "object" to "object?" (did you?) should have just left it alone. Change it back pretty please?

Oh, and also, in the future, when you start to interact with a project owner that has dedicated his time to make it available for free, you could start your message with "Hey, I'm using your library and it's really helpful, thank you.".

@mpdetwiler
Copy link
Author

WHY did you change the return type from "object" to "object?" (did you?) should have just left it alone. Change it back pretty please?

Oh, and also, in the future, when you start to interact with a project owner that has dedicated his time to make it available for free, you could start your message with "Hey, I'm using your library and it's really helpful, thank you.".

I apologize. Do you have cash app or venmo or something?

@xoofx
Copy link
Owner

xoofx commented Feb 25, 2022

This should be fixed in 909dd77 and will be available in next version

@xoofx xoofx closed this as completed Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants