Skip to content

Commit

Permalink
.Net: Fix ArgumentNullException from TextPlugin.Uppercase/Lowercase o…
Browse files Browse the repository at this point in the history
…n .NET Framework (#6324)

On .NET Framework, a null CultureInfo triggers an ArgumentNullException.
  • Loading branch information
stephentoub authored May 18, 2024
1 parent ec93cb4 commit e17e05a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dotnet/src/Plugins/Plugins.Core/TextPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public sealed class TextPlugin
/// <param name="cultureInfo"> An object that supplies culture-specific casing rules. </param>
/// <returns> The converted string. </returns>
[KernelFunction, Description("Convert a string to uppercase.")]
public string Uppercase(string input, CultureInfo? cultureInfo = null) => input.ToUpper(cultureInfo);
public string Uppercase(string input, CultureInfo? cultureInfo = null) =>
input.ToUpper(cultureInfo ?? CultureInfo.CurrentCulture);

/// <summary>
/// Convert a string to lowercase.
Expand All @@ -50,7 +51,8 @@ public sealed class TextPlugin
/// <param name="cultureInfo"> An object that supplies culture-specific casing rules. </param>
/// <returns> The converted string. </returns>
[KernelFunction, Description("Convert a string to lowercase.")]
public string Lowercase(string input, CultureInfo? cultureInfo = null) => input.ToLower(cultureInfo);
public string Lowercase(string input, CultureInfo? cultureInfo = null) =>
input.ToLower(cultureInfo ?? CultureInfo.CurrentCulture);

/// <summary>
/// Get the length of a string. Returns 0 if null or empty
Expand Down

0 comments on commit e17e05a

Please sign in to comment.