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

Fix nullable annotations for ICollectionFormatter #1471

Merged
merged 3 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,11 @@ namespace Humanizer
public interface ICollectionFormatter
{
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, object> objectFormatter);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, string> objectFormatter);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, object?> objectFormatter);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, string?> objectFormatter);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, string separator);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, object> objectFormatter, string separator);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, string> objectFormatter, string separator);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, object?> objectFormatter, string separator);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, string?> objectFormatter, string separator);
}
public interface ICulturedStringTransformer : Humanizer.IStringTransformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ namespace Humanizer
public interface ICollectionFormatter
{
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, object> objectFormatter);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, string> objectFormatter);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, object?> objectFormatter);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, string?> objectFormatter);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, string separator);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, object> objectFormatter, string separator);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, string> objectFormatter, string separator);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, object?> objectFormatter, string separator);
string Humanize<T>(System.Collections.Generic.IEnumerable<T> collection, System.Func<T, string?> objectFormatter, string separator);
}
public interface ICulturedStringTransformer : Humanizer.IStringTransformer
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ public DefaultCollectionFormatter(string defaultSeparator) =>
public virtual string Humanize<T>(IEnumerable<T> collection) =>
Humanize(collection, o => o?.ToString(), DefaultSeparator);

public virtual string Humanize<T>(IEnumerable<T> collection, Func<T, string> objectFormatter) =>
public virtual string Humanize<T>(IEnumerable<T> collection, Func<T, string?> objectFormatter) =>
Humanize(collection, objectFormatter, DefaultSeparator);

public string Humanize<T>(IEnumerable<T> collection, Func<T, object> objectFormatter) =>
public string Humanize<T>(IEnumerable<T> collection, Func<T, object?> objectFormatter) =>
Humanize(collection, objectFormatter, DefaultSeparator);

public virtual string Humanize<T>(IEnumerable<T> collection, string separator) =>
Expand All @@ -36,7 +36,7 @@ public virtual string Humanize<T>(IEnumerable<T> collection, Func<T, string?> ob
separator);
}

public string Humanize<T>(IEnumerable<T> collection, Func<T, object> objectFormatter, string separator)
public string Humanize<T>(IEnumerable<T> collection, Func<T, object?> objectFormatter, string separator)
{
if (collection == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public interface ICollectionFormatter
/// <summary>
/// Formats the collection for display, calling <paramref name="objectFormatter"/> on each element.
/// </summary>
string Humanize<T>(IEnumerable<T> collection, Func<T, string> objectFormatter);
string Humanize<T>(IEnumerable<T> collection, Func<T, string?> objectFormatter);

/// <summary>
/// Formats the collection for display, calling <paramref name="objectFormatter"/> on each element.
/// </summary>
string Humanize<T>(IEnumerable<T> collection, Func<T, object> objectFormatter);
string Humanize<T>(IEnumerable<T> collection, Func<T, object?> objectFormatter);

/// <summary>
/// Formats the collection for display, calling ToString() on each object
Expand All @@ -30,11 +30,11 @@ public interface ICollectionFormatter
/// Formats the collection for display, calling <paramref name="objectFormatter"/> on each element.
/// and using <paramref name="separator"/> before the final item.
/// </summary>
string Humanize<T>(IEnumerable<T> collection, Func<T, string> objectFormatter, string separator);
string Humanize<T>(IEnumerable<T> collection, Func<T, string?> objectFormatter, string separator);

/// <summary>
/// Formats the collection for display, calling <paramref name="objectFormatter"/> on each element.
/// and using <paramref name="separator"/> before the final item.
/// </summary>
string Humanize<T>(IEnumerable<T> collection, Func<T, object> objectFormatter, string separator);
string Humanize<T>(IEnumerable<T> collection, Func<T, object?> objectFormatter, string separator);
}