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

[browser][non-icu] HybridGlobalization calendar data #89255

Merged
merged 41 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6748e09
Calendar WIP.
ilonatommy Jun 30, 2023
8db7ddf
Genitive months.
ilonatommy Jul 3, 2023
c7eb1d3
Short pattern.
ilonatommy Jul 3, 2023
bd38cec
NativeCalendarName does not exist on WebAPI - use EnglishCalendarName.
ilonatommy Jul 4, 2023
ac29569
Fix failures in Locales caused by calendars data removal.
ilonatommy Jul 12, 2023
27d438d
Fix to previous commit.
ilonatommy Jul 12, 2023
354b545
Whitespace.
ilonatommy Jul 12, 2023
70cf0c4
Implemented Eras.
ilonatommy Jul 14, 2023
cfaa05f
Populate NativeName with EnglishName.
ilonatommy Jul 14, 2023
3fd5e90
Fix tests.
ilonatommy Jul 17, 2023
bb937ee
Typos + comments removal + block failing test.
ilonatommy Jul 17, 2023
49b494a
AM/PM designators are not in ICU anymore.
ilonatommy Jul 18, 2023
c779e4c
ShortTimePattern is ready.
ilonatommy Jul 19, 2023
7693c83
Fix some failing tests.
ilonatommy Jul 20, 2023
3d40405
LongTimePatterns is ready.
ilonatommy Jul 20, 2023
0cb6d94
Ask about all culture info from JS at once.
ilonatommy Jul 20, 2023
0faa678
Fix remaining tests.
ilonatommy Jul 20, 2023
9dec94b
Calendar Globalization tests fixed.
ilonatommy Jul 20, 2023
f2e483a
Adding test files to projects.
ilonatommy Jul 20, 2023
97b753b
Merge branch 'main' into hg-calendar-data
ilonatommy Jul 20, 2023
0b4bc9d
Build fix.
ilonatommy Jul 20, 2023
6db3374
Fix the fix.
ilonatommy Jul 20, 2023
0ab52c6
.
ilonatommy Jul 20, 2023
56d02d9
Fix tests.
ilonatommy Jul 21, 2023
def56db
Load locale info on request + fix Browser scenario tests.
ilonatommy Jul 21, 2023
a64416b
Fix test on v8.
ilonatommy Jul 21, 2023
0b63515
Forgotten clean-up.
ilonatommy Jul 21, 2023
6d18729
Small cleanup in ts.
ilonatommy Jul 21, 2023
41a32da
Merge branch 'main' into hg-calendar-data
ilonatommy Jul 24, 2023
2e91baf
V8 11 is behaves more like browser.
ilonatommy Jul 24, 2023
09b3ddf
Fixed skipped failing tests.
ilonatommy Jul 24, 2023
9121b1f
Syntax
ilonatommy Jul 24, 2023
c790e29
V8 returns the same as Browser.
ilonatommy Jul 24, 2023
5784ba5
This API is not affected, no need to test. + Add documentation.
ilonatommy Jul 26, 2023
6b5fe9a
Revert unintentional change.
ilonatommy Jul 26, 2023
b5f8700
Feedback.
ilonatommy Jul 26, 2023
36fb55b
@radical's feedback + fix after removing unnecessary set.
ilonatommy Aug 3, 2023
f8db090
Fix.
ilonatommy Aug 4, 2023
a9aad85
Feedback.
ilonatommy Aug 7, 2023
ab86ec4
Merge branch 'main' into hg-calendar-data
ilonatommy Aug 7, 2023
39dad99
Fix tests.
ilonatommy Aug 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/libraries/Common/src/Interop/Browser/Interop.Calendar.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Globalization;
using System.Runtime.CompilerServices;

internal static partial class Interop
{
internal static unsafe partial class JsGlobalization
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern unsafe int GetCalendarInfo(in string culture, CalendarId calendarId, char* buffer, int bufferLength, out int exceptionalResult, out object result);
}
}
17 changes: 17 additions & 0 deletions src/libraries/Common/src/Interop/Browser/Interop.Locale.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.CompilerServices;

internal static partial class Interop
{
internal static unsafe partial class JsGlobalization
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern unsafe int GetCultureInfo(in string culture, char* buffer, int bufferLength, out int exceptionalResult, out object result);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern unsafe int GetFirstDayOfWeek(in string culture, out int exceptionalResult, out object result);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern unsafe int GetFirstWeekOfYear(in string culture, out int exceptionalResult, out object result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ public static string GetDistroVersionString()
public static bool IsHybridGlobalizationOnOSX => m_isHybrid.Value && (IsOSX || IsMacCatalyst || IsiOS || IstvOS);
public static bool IsNotHybridGlobalizationOnBrowser => !IsHybridGlobalizationOnBrowser;
public static bool IsNotInvariantGlobalization => !IsInvariantGlobalization;
public static bool IsIcuGlobalization => ICUVersion > new Version(0, 0, 0, 0);
public static bool IsIcuGlobalization => ICUVersion > new Version(0, 0, 0, 0);
ilonatommy marked this conversation as resolved.
Show resolved Hide resolved
public static bool IsIcuGlobalizationAndNotHybridOnBrowser => IsIcuGlobalization && IsNotHybridGlobalizationOnBrowser;
public static bool IsNlsGlobalization => IsNotInvariantGlobalization && !IsIcuGlobalization;

public static bool IsSubstAvailable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent)-browser</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TestRuntime>true</TestRuntime>
<HybridGlobalization>true</HybridGlobalization>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\System\Globalization\CalendarTestBase.cs" />
<Compile Include="..\System\Globalization\ChineseLunisolarCalendarTests.cs" />
<Compile Include="..\System\Globalization\EastAsianLunisolarCalendarTestBase.cs" />
<Compile Include="..\System\Globalization\GregorianCalendarTests.cs" />
<Compile Include="..\System\Globalization\HebrewCalendarTests.cs" />
<Compile Include="..\System\Globalization\HijriCalendarTests.cs" />
<Compile Include="..\System\Globalization\JapaneseCalendarTests.cs" />
<Compile Include="..\System\Globalization\JapaneseLunisolarCalendarTests.cs" />
<Compile Include="..\System\Globalization\JulianCalendarTests.cs" />
<Compile Include="..\System\Globalization\KoreanCalendarTests.cs" />
<Compile Include="..\System\Globalization\KoreanLunisolarCalendarTests.cs" />
<Compile Include="..\System\Globalization\PersianCalendarTests.cs" />
<Compile Include="..\System\Globalization\TaiwanCalendarTests.cs" />
<Compile Include="..\System\Globalization\TaiwanLunisolarCalendarTests.cs" />
<Compile Include="..\System\Globalization\ThaiBuddhistCalendarTests.cs" />
<Compile Include="..\System\Globalization\UmAlQuraCalendarTests.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarAddMonths.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarAddYears.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarGetDayOfMonth.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarGetDayOfWeek.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarGetDayOfYear.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarGetDaysInMonth.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarGetDaysInYear.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarGetEra.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarGetMonth.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarGetLeapMonth.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarGetMonthsInYear.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarGetWeekOfYear.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarGetYear.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarIsLeapDay.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarIsLeapMonth.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarIsLeapYear.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarTests.Utilities.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarToDateTime.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarToFourDigitYear.cs" />
<Compile Include="..\GregorianCalendar\GregorianCalendarTwoDigitYearMax.cs" />
<Compile Include="..\ISOWeek\ISOWeekTests.cs" />
<Compile Include="..\JapaneseCalendar\JapaneseCalendarAddMonths.cs" />
<Compile Include="..\JapaneseCalendar\JapaneseCalendarToFourDigitYear.cs" />
<Compile Include="..\JapaneseCalendar\JapaneseCalendarTwoDigitYearMax.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarToDateTime.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarAddMonths.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarAddYears.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarGetDayOfMonth.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarGetDayOfWeek.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarGetDayOfYear.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarGetDaysInMonth.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarGetDaysInYear.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarGetEra.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarGetMonth.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarGetMonthsInYear.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarGetWeekOfYear.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarGetYear.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarIsLeapDay.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarIsLeapMonth.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarIsLeapYear.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarToFourDigitYear.cs" />
<Compile Include="..\KoreanCalendar\KoreanCalendarTwoDigitYearMax.cs" />
<Compile Include="..\Misc\MiscCalendars.cs" />
<Compile Include="..\Misc\Calendars.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarUtilities.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarAddMonths.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarAddYears.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarDaysAndMonths.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarGetDayOfMonth.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarGetDayOfWeek.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarGetDayOfYear.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarGetDaysInMonth.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarGetDaysInYear.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarGetEra.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarGetMonth.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarGetMonthsInYear.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarGetWeekOfYear.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarGetYear.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarIsLeapDay.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarIsLeapMonth.cs" />
<Compile Include="..\TaiwanCalendar\TaiWanCalendarIsLeapYear.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarToDateTime.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarToFourDigitYear.cs" />
<Compile Include="..\TaiwanCalendar\TaiwanCalendarTwoDigitYearMax.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarAddMonths.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarAddYears.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarGetDayOfMonth.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarGetDayOfWeek.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarGetDayOfYear.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarGetDaysInMonth.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarGetDaysInYear.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarGetEra.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarGetMonth.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarGetMonthsInYear.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarGetWeekOfYear.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarGetYear.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarIsLeapDay.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarIsLeapMonth.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarIsLeapYear.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarToDateTime.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarToFourDigitYear.cs" />
<Compile Include="..\ThaiBuddhistCalendar\ThaiBuddhistCalendarTwoDigitYearMax.cs" />
<Compile Include="$(CommonTestPath)System\RandomDataGenerator.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -423,14 +423,17 @@ public void TwoDigitYearMax_Invalid_ThrowsArgumentOutOfRangeException()
Assert.Throws<ArgumentOutOfRangeException>(() => calendar.TwoDigitYearMax = max + 1);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))]
public void GetEra_Invalid_ThrowsArgumentOutOfRangeException()
{
Calendar calendar = Calendar;
Assert.All(DateTime_TestData(calendar), dt =>
{
// JapaneseCalendar throws on ICU, but not on NLS
if ((calendar is JapaneseCalendar && PlatformDetection.IsNlsGlobalization) || calendar is HebrewCalendar || calendar is TaiwanLunisolarCalendar || calendar is JapaneseLunisolarCalendar)
// JapaneseCalendar throws on ICU, but not on NLS or in HybridGlobalization on Browser
if ((calendar is JapaneseCalendar && (PlatformDetection.IsNlsGlobalization || PlatformDetection.IsHybridGlobalizationOnBrowser)) ||
ilonatommy marked this conversation as resolved.
Show resolved Hide resolved
calendar is HebrewCalendar ||
calendar is TaiwanLunisolarCalendar ||
calendar is JapaneseLunisolarCalendar)
{
calendar.GetEra(dt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public void TestCreationWithTemporaryLCID(int lcid)
[InlineData("de-DE-u-co-phonebk-t-xx", "de-DE-t-xx", "de-DE-t-xx_phoneboo")]
[InlineData("de-DE-u-co-phonebk-t-xx-u-yy", "de-DE-t-xx-u-yy", "de-DE-t-xx-u-yy_phoneboo")]
[InlineData("de-DE", "de-DE", "de-DE")]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalization))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalizationAndNotHybridOnBrowser))]
public void TestCreationWithMangledSortName(string cultureName, string expectedCultureName, string expectedSortName)
{
CultureInfo ci = CultureInfo.GetCultureInfo(cultureName);
Expand All @@ -457,7 +457,7 @@ public void TestCreationWithMangledSortName(string cultureName, string expectedC
[InlineData("qps-plocm", "qps-PLOCM")] // ICU normalize this name to "qps--plocm" which we normalize it back to "qps-plocm"
[InlineData("zh_CN", "zh_cn")]
[InlineData("km_KH", "km_kh")]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalization), nameof(PlatformDetection.IsNotWindowsServerCore))]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalizationAndNotHybridOnBrowser), nameof(PlatformDetection.IsNotWindowsServerCore))]
public void TestCreationWithICUNormalizedNames(string cultureName, string expectedCultureName)
{
CultureInfo ci = CultureInfo.GetCultureInfo(cultureName);
Expand Down
Loading