-
Notifications
You must be signed in to change notification settings - Fork 964
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
CollectionHumanizeExtensions.Humanize causes NullReferenceException for null items #555
Comments
Happy to accept a PR to fix this. I would think that there should be a default null value that's overridable if desired. Some people may want |
Now that I think about it, users might expect |
@jnm2 I agree with your behavior as default if we use a flag to allow something else. We can adapt
For Humanize:
Where |
What about this: [Flags] enum StringJoinOptions
{
None = 0,
TrimEntries = 1 << 0,
RemoveBlankEntries = 1 << 1,
Default = TrimEntries | RemoveBlankEntries
}
|
@onovotny Need some direction- how configurable should this be? Don't want to go overboard. |
The options you have there seem ok -- I agree there's no need to go overboard, we can always add more later if we need. |
You're okay with a default value that would trim all items and remove empty ones? What would the new default mean for back-compat and versioning, or can |
This is a headache for me.
.Select(_ => _?.ToString() ?? string.Empty).Humanize()
seems unnecessary; wouldn't it be a sensible default to allow.Humanize()
directly on collections containing nulls?Happy to do a PR if you think so.
The text was updated successfully, but these errors were encountered: