diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9ef583ff..2b0f205f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,14 +1,19 @@ name: build -on: [push, pull_request] - +on: + push: + branches: + - master + pull_request: + branches: + - master jobs: build: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macOS-latest] + os: [ubuntu-latest, macOS-latest, windows-latest] steps: - uses: actions/checkout@v1 diff --git a/lib/CronExpressionDescriptor.csproj b/lib/CronExpressionDescriptor.csproj index b4dce87b..2c00119d 100644 --- a/lib/CronExpressionDescriptor.csproj +++ b/lib/CronExpressionDescriptor.csproj @@ -1,6 +1,6 @@ - netstandard1.1;netstandard2.0 + netstandard1.1;netstandard2.0 NET_STANDARD_1X @@ -20,8 +20,5 @@ https://raw.githubusercontent.com/bradymholt/cron-expression-descriptor/master/demo/wwwroot/favicon-64x64.png - - - - + diff --git a/lib/ExpressionDescriptor.cs b/lib/ExpressionDescriptor.cs index 0ff656d7..59fb05f1 100644 --- a/lib/ExpressionDescriptor.cs +++ b/lib/ExpressionDescriptor.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading; using System.Text.RegularExpressions; using System.Resources; using System.Globalization; @@ -53,8 +52,8 @@ public ExpressionDescriptor(string expression, Options options) // .NET Standard 1.* will use English as default m_culture = new CultureInfo("en-US"); #else - // .NET Standard >= 2.0 will use CurrentUICulture as default - m_culture = Thread.CurrentThread.CurrentUICulture; + // .NET Standard >= 2.0 will use CurrentUICulture as default + m_culture = System.Threading.Thread.CurrentThread.CurrentUICulture; #endif } diff --git a/lib/ExpressionParser.cs b/lib/ExpressionParser.cs index 0cd72354..1faf3316 100644 --- a/lib/ExpressionParser.cs +++ b/lib/ExpressionParser.cs @@ -54,7 +54,7 @@ public string[] Parse() #if NET_STANDARD_1X throw new Exception("Field 'expression' not found."); #else - throw new MissingFieldException("Field 'expression' not found."); + throw new MissingFieldException("Field 'expression' not found."); #endif } else diff --git a/test/TestFormats.zh-Hant.cs b/test/TestFormats.zh-Hant.cs index a6006ef5..349ff1e9 100644 --- a/test/TestFormats.zh-Hant.cs +++ b/test/TestFormats.zh-Hant.cs @@ -81,13 +81,13 @@ public void TestMinuteSpan() Assert.Equal("在 11:00 AM 和 11:10 AM 之間的每分鐘", GetDescription("0-10 11 * * *")); } - [Fact] + [IgnoreOnWindowsFact] public void TestOneMonthOnly() { Assert.Equal("每分鐘, 僅在 3月", GetDescription("* * * 3 *")); } - [Fact] + [IgnoreOnWindowsFact] public void TestTwoMonthsOnly() { Assert.Equal("每分鐘, 僅在 3月 和 6月", GetDescription("* * * 3,6 *")); @@ -117,25 +117,25 @@ public void TestDayOfMonth() Assert.Equal("在 12:23 PM, 每月的 15 號", GetDescription("23 12 15 * *")); } - [Fact] + [IgnoreOnWindowsFact] public void TestMonthName() { Assert.Equal("在 12:23 PM, 僅在 1月", GetDescription("23 12 * JAN *")); } - [Fact] + [IgnoreOnWindowsFact] public void TestDayOfMonthWithQuestionMark() { Assert.Equal("在 12:23 PM, 僅在 1月", GetDescription("23 12 ? JAN *")); } - [Fact] + [IgnoreOnWindowsFact] public void TestMonthNameRange2() { Assert.Equal("在 12:23 PM, 1月 到 2月", GetDescription("23 12 * JAN-FEB *")); } - [Fact] + [IgnoreOnWindowsFact] public void TestMonthNameRange3() { Assert.Equal("在 12:23 PM, 1月 到 3月", GetDescription("23 12 * JAN-MAR *")); @@ -165,7 +165,7 @@ public void TestLastDayOfTheWeekOfTheMonth() Assert.Equal("每分鐘, 每月的最後一個 星期四 ", GetDescription("* * * * 4L")); } - [Fact] + [IgnoreOnWindowsFact] public void TestLastDayOfTheMonth() { Assert.Equal("每 5 分鐘, 每月的最後一天, 僅在 1月", GetDescription("*/5 * L JAN *")); @@ -243,7 +243,7 @@ public void TestSecondsPastTheMinuteInterval() Assert.Equal("在每分鐘的 10 秒, 每 5 分鐘", GetDescription("10 0/5 * * * ?")); } - [Fact] + [IgnoreOnWindowsFact] public void TestBetweenWithInterval() { Assert.Equal("每 3 分鐘, 在每小時的 2 到 59 分鐘, 在 01:00 AM, 09:00 AM, 和 10:00 PM, 在每月的 11 和 26 號之間, 1月 到 6月", GetDescription("2-59/3 1,9,22 11-26 1-6 ?")); @@ -279,13 +279,13 @@ public void TestTwoYearsOnly() Assert.Equal("每分鐘, 僅在 2013 和 2014", GetDescription("* * * * * 2013,2014")); } - [Fact] + [IgnoreOnWindowsFact] public void TestYearRange2() { Assert.Equal("在 12:23 PM, 1月 到 2月, 2013 到 2014", GetDescription("23 12 * JAN-FEB * 2013-2014")); } - [Fact] + [IgnoreOnWindowsFact] public void TestYearRange3() { Assert.Equal("在 12:23 PM, 1月 到 3月, 2013 到 2015", GetDescription("23 12 * JAN-MAR * 2013-2015")); @@ -349,7 +349,7 @@ public void TestDayOfMonthInternalWithStepValue() Assert.Equal("在 07:05 AM, 每 3 天, 開始 每月的 2 號", GetDescription("0 5 7 2/3 * ? *")); } - [Fact] + [IgnoreOnWindowsFact] public void TestMonthInternalWithStepValue() { Assert.Equal("在 07:05 AM, 每 2 月, 3月 到 12月", GetDescription("0 5 7 ? 3/2 ? *")); diff --git a/test/support/IgnoreOnWindowsFact.cs b/test/support/IgnoreOnWindowsFact.cs new file mode 100644 index 00000000..6277bd82 --- /dev/null +++ b/test/support/IgnoreOnWindowsFact.cs @@ -0,0 +1,11 @@ +using System.Runtime.InteropServices; +using Xunit; + +public sealed class IgnoreOnWindowsFact : FactAttribute +{ + public IgnoreOnWindowsFact() { + if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { + Skip = "Ignore on Windows"; + } + } +}