Skip to content

Commit

Permalink
Merge pull request #32 from microsoft/main
Browse files Browse the repository at this point in the history
Bugfix for the pascal case function
  • Loading branch information
ewoutkramer authored Jun 1, 2023
2 parents c5c43d0 + ad955da commit 2daf6cf
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -378,25 +378,50 @@ public static string ToLowerSnakeCaseWord(this IEnumerable<string> words, bool r
/// A string extension method that converts this object to a pascal dot case.
/// </summary>
/// <param name="word"> The word to act on.</param>
/// <param name="removeDelimiters">(Optional) True to remove delimiters.</param>
/// <returns>The given data converted to a string.</returns>
public static string ToPascalDotCase(this string word, bool removeDelimiters = true)
=> ToPascalCase(word, removeDelimiters, ".");
public static string ToPascalDotCase(this string word)
{
if (string.IsNullOrEmpty(word))
{
return string.Empty;
}

return string.Join('.', word.Split(_wordDelimiters, _wordSplitOptions).Select(w => w.ToPascalCase(false)));
}

/// <summary>A string extension method that converts this object to a pascal dot case.</summary>
/// <param name="words"> The words.</param>
/// <param name="removeDelimiters">(Optional) True to remove delimiters.</param>
/// <returns>The given data converted to a string.</returns>
public static string[] ToPascalDotCase(this string[] words, bool removeDelimiters = true)
=> ToPascalCase(words, removeDelimiters, ".");
public static string[] ToPascalDotCase(this string[] words)
{
if (!(words?.Any() ?? false))
{
return Array.Empty<string>();
}

string[] output = new string[words.Length];

for (int i = 0; i < words.Length; i++)
{
output[i] = ToPascalDotCase(words[i]);
}

return output;
}

/// <summary>
/// An IEnumerable&lt;string&gt; extension method that converts this object to a pascal dot case
/// word.
/// </summary>
/// <param name="words"> The words.</param>
/// <param name="removeDelimiters">(Optional) True to remove delimiters.</param>
/// <returns>The given data converted to a string.</returns>
public static string ToPascalDotCaseWord(this IEnumerable<string> words, bool removeDelimiters = true)
=> ToPascalCaseWord(words, removeDelimiters, ".");
public static string ToPascalDotCaseWord(this IEnumerable<string> words)
{
if (!(words?.Any() ?? false))
{
return string.Empty;
}

return string.Join('.', words.Select(w => w.ToPascalDotCase()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public string NameForExport(

case NamingConvention.PascalDotNotation:
{
string value = _path.ToPascalDotCase(true);
string value = _path.ToPascalDotCase();

if ((reservedWords != null) &&
reservedWords.Contains(value))
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.Health.Fhir.CodeGenCommon/Models/FhirUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public static string ToConvention(

case NamingConvention.PascalDotNotation:
{
return value.ToPascalDotCase(true);
return value.ToPascalDotCase();
}

case NamingConvention.PascalCase:
Expand Down Expand Up @@ -305,7 +305,7 @@ public static string SanitizedToConvention(string sanitized, NamingConvention co

case NamingConvention.PascalDotNotation:
{
return sanitized.ToPascalDotCase(true);
return sanitized.ToPascalDotCase();
}

case NamingConvention.PascalCase:
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.Health.Fhir.SpecManager/Language/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System.IO;
using System.Text.Json;
using Microsoft.Health.Fhir.CodeGenCommon.Extensions;
using Microsoft.Health.Fhir.SpecManager.Manager;

namespace Microsoft.Health.Fhir.SpecManager.Language
Expand Down

0 comments on commit 2daf6cf

Please sign in to comment.