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

Testable initialization of Gu.Localizalization.Culture #85

Merged
merged 8 commits into from
Sep 24, 2018

Conversation

General-Fault
Copy link
Contributor

This simplifies the initialization of the internal class Gu.Localization.Culture. And by virtue of making AllCultures settable, the class is a little easier to test. It is also another solution to issue #82 .

{
get
{
return AllCultures.Select(x => TryGetRegion(x, out var region) ? region : null).Where(x => x != null).ToList();
Copy link
Member

Choose a reason for hiding this comment

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

LINQ in the getter is potentially expensive here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might be the first time at least. The RegionInfo is cached by Microsoft, so it might not be that bad. Are you up for profiling this?

@@ -8,52 +8,18 @@ namespace Gu.Localization
/// <summary> Utility class for <see cref="CultureInfo"/> </summary>
internal static class Culture
{
internal static readonly IReadOnlyList<CultureInfo> AllCultures =
internal static IReadOnlyList<CultureInfo> AllCultures =
Copy link
Member

Choose a reason for hiding this comment

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

Can't be readonly here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not necessary for functionality to be settable. But it makes testing TryGet possible.

@JohanLarsson JohanLarsson merged commit 64c1f36 into GuOrg:master Sep 24, 2018
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

Successfully merging this pull request may close these issues.

2 participants