Skip to content

Add CultureInfo.GetParents() and CultureInfo.GetSelfAndParents() extensions#18

Merged
Tyrrrz merged 2 commits intoprimefrom
copilot/add-cultureinfo-extensions
Apr 14, 2026
Merged

Add CultureInfo.GetParents() and CultureInfo.GetSelfAndParents() extensions#18
Tyrrrz merged 2 commits intoprimefrom
copilot/add-cultureinfo-extensions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Adds two new CultureInfo extension methods for traversing the culture hierarchy.

  • GetParents() — yields ancestors from immediate parent up to InvariantCulture; returns empty sequence for InvariantCulture itself
  • GetSelfAndParents() — yields the culture itself followed by GetParents()
new CultureInfo("en-US").GetParents();
// → [en, InvariantCulture]

new CultureInfo("en-US").GetSelfAndParents();
// → [en-US, en, InvariantCulture]

CultureInfo.InvariantCulture.GetParents();
// → []

@Tyrrrz Tyrrrz added the enhancement New feature or request label Apr 14, 2026
@Tyrrrz Tyrrrz marked this pull request as ready for review April 14, 2026 09:48
Copilot AI review requested due to automatic review settings April 14, 2026 09:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds CultureInfo traversal helpers to PowerKit, enabling consumers to enumerate a culture’s ancestor chain (and optionally include the culture itself) in a consistent, lazy manner.

Changes:

  • Added CultureInfo.GetParents() to enumerate parent cultures up to CultureInfo.InvariantCulture (exclusive for invariant itself).
  • Added CultureInfo.GetSelfAndParents() to enumerate the culture followed by its parents.
  • Added unit tests covering both methods and key cases (en-US, en, and InvariantCulture).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
PowerKit/Extensions/CultureInfoExtensions.cs Introduces the two new CultureInfo extension methods for hierarchy traversal.
PowerKit.Tests/CultureInfoExtensionsTests.cs Adds tests validating expected traversal sequences and invariant behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread PowerKit.Tests/CultureInfoExtensionsTests.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants