Skip to content

Refactor: Empty string handling as extension#272

Open
Root-Core wants to merge 1 commit intonzbdav-dev:mainfrom
Root-Core:string_to_null_ext
Open

Refactor: Empty string handling as extension#272
Root-Core wants to merge 1 commit intonzbdav-dev:mainfrom
Root-Core:string_to_null_ext

Conversation

@Root-Core
Copy link
Contributor

@Root-Core Root-Core commented Jan 24, 2026

Split refactoring part from #216


  • The current implementation is more error prone and verbose.
  • The refactor is a bit more polished, safe and has less boilerplate.
  • The refactor is explicit in casting the type string to null if empty.

  • While I appreciate the refactor, I personally think StringUtil.EmptyToNull(...) is a little more clear on what it does versus the .OrNull() extension.

One last try. :)
I renamed it to ToNullIfEmpty(), as it casts to null. This is more clear and the To part indicates the type change.

  • And I'm generally a fan of extension methods :) The repo is full of them.

You are right, I missed that.. I moved the extension into the existing StringExtensions.cs.


Disclaimer: No AI was used in this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant