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

"S".Pluralize(false) throws an IndexOutOfRangeException #1541

Open
joostverhoog opened this issue Sep 13, 2024 · 3 comments
Open

"S".Pluralize(false) throws an IndexOutOfRangeException #1541

joostverhoog opened this issue Sep 13, 2024 · 3 comments

Comments

@joostverhoog
Copy link

joostverhoog commented Sep 13, 2024

I expected the output of "S".Pluralize(false) to be "Ss", because I see "s" appended for other letters. e.g. "K".Pluralize(false) == "Ks"

However, it throws an exception:

System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.String.get_Chars(Int32 index)
at Humanizer.Inflections.Vocabulary.MatchUpperCase(String word, String replacement) in //src/Humanizer/Inflections/Vocabulary.cs:line 158
at Humanizer.Inflections.Vocabulary.ApplyRules(IList`1 rules, String word, Boolean skipFirstRule) in /
/src/Humanizer/Inflections/Vocabulary.cs:line 148
at Humanizer.Inflections.Vocabulary.Pluralize(String word, Boolean inputIsKnownToBeSingular) in //src/Humanizer/Inflections/Vocabulary.cs:line 85
at Humanizer.InflectorExtensions.Pluralize(String word, Boolean inputIsKnownToBeSingular) in /
/src/Humanizer/InflectorExtensions.cs:line 42

Found in Humanizer.Core 2.14.1

@hangy
Copy link
Contributor

hangy commented Sep 15, 2024

Could you test if you also get this Exception with a 3.x beta? I think this should've been fixed in #1178.

@joostverhoog
Copy link
Author

joostverhoog commented Sep 16, 2024

I tested with 3.0.0-beta.54 and there it is solved.

Is a GA version of 3.0.0 in the planning? I would be happy to create a pull request to add these changes to 2.14, but it looks like there is no active development on that version.

@hangy
Copy link
Contributor

hangy commented Sep 22, 2024

I think 3.x is the only relevant branch. @SimonCropp or @clairernovotny might know more about a release schedule

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

No branches or pull requests

2 participants