diff --git a/.github/workflows/CI-CD.yml b/.github/workflows/CI-CD.yml index 50563590..f5f8a43d 100644 --- a/.github/workflows/CI-CD.yml +++ b/.github/workflows/CI-CD.yml @@ -23,10 +23,20 @@ jobs: name: "Build and Test" strategy: matrix: - os: [windows-latest, ubuntu-latest] + os: [windows-latest, ubuntu-latest, macos-12] runs-on: ${{ matrix.os }} steps: + - name: Install MacPorts + if: ${{ matrix.os == 'macos-12' }} + uses: melusina-org/setup-macports@v1 + + - name: Install icu4c on macOS + if: ${{ matrix.os == 'macos-12' }} + run: | + sudo port -v install icu + echo "DYLD_FALLBACK_LIBRARY_PATH=$HOME/lib:/usr/local/lib:/usr/lib:/opt/local/lib" >> $GITHUB_ENV + - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: @@ -35,13 +45,17 @@ jobs: - name: Install .NET Core uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Build run: dotnet build --configuration Release source/icu.net.sln - - name: Test - run: dotnet test --configuration Release --no-build source/icu.net.sln -- NUnit.TestOutputXml=TestResults + - name: Test on .NET 8.0 + run: dotnet test -p:TargetFramework=net8.0 --configuration Release --no-build source/icu.net.sln -- NUnit.TestOutputXml=TestResults + + - name: Test on .NET Framework 4.6.1 (Windows only) + if: ${{ matrix.os == 'windows-latest' }} + run: dotnet test -p:TargetFramework=net461 --configuration Release --no-build source/icu.net.sln -- NUnit.TestOutputXml=TestResults - name: Upload Test Results if: always() diff --git a/source/Directory.Build.props b/source/Directory.Build.props index 4490de34..f8e04ee4 100644 --- a/source/Directory.Build.props +++ b/source/Directory.Build.props @@ -1,6 +1,6 @@ - net40;net451;netstandard1.6;net6.0 + net40;net451;netstandard1.6;net8.0 netstandard $(MSBuildThisFileDirectory)\..\output\$(Configuration) $(MSBuildThisFileDirectory)\..\output diff --git a/source/TestHelper/TestHelper.csproj b/source/TestHelper/TestHelper.csproj index f221cf4d..6c92ce47 100644 --- a/source/TestHelper/TestHelper.csproj +++ b/source/TestHelper/TestHelper.csproj @@ -1,6 +1,6 @@ - net461;net6.0 + net461;net8.0 ../../output/$(Configuration)/TestHelper Exe Icu.Tests diff --git a/source/icu.net.tests/IcuWrapperTests.cs b/source/icu.net.tests/IcuWrapperTests.cs index 5f6c16b9..939e03b2 100644 --- a/source/icu.net.tests/IcuWrapperTests.cs +++ b/source/icu.net.tests/IcuWrapperTests.cs @@ -91,8 +91,8 @@ public void IcuVersion() Assert.That(int.TryParse(result.Substring(0, result.IndexOf(".", StringComparison.Ordinal)), out var major), Is.True); } - [Platform(Exclude = "Linux", - Reason = "These tests require ICU4C installed from NuGet packages which isn't available on Linux")] + [Platform(Include = "Win", + Reason = "These tests require ICU4C installed from NuGet packages which is only available on Windows")] [Test] public void ConfineVersions_WorksAfterInit() { @@ -105,8 +105,8 @@ public void ConfineVersions_WorksAfterInit() Assert.That(Wrapper.DataDirectory, Is.EqualTo("Test")); } - [Platform(Exclude = "Linux", - Reason = "These tests require ICU4C installed from NuGet packages which isn't available on Linux")] + [Platform(Include = "Win", + Reason = "These tests require ICU4C installed from NuGet packages which is only available on Windows")] [Test] public void ConfineVersions_LoadFromDifferentDirectory_LowerVersion() { @@ -130,8 +130,8 @@ public void ConfineVersions_LoadFromDifferentDirectory_LowerVersion() Assert.That(result, Is.EqualTo(NativeMethodsTests.MinIcuLibraryVersion)); } - [Platform(Exclude = "Linux", - Reason = "These tests require ICU4C installed from NuGet packages which isn't available on Linux")] + [Platform(Include = "Win", + Reason = "These tests require ICU4C installed from NuGet packages which is only available on Windows")] [Test] public void ConfineVersions_LoadFromDifferentDirectory_HigherVersion() { @@ -155,8 +155,8 @@ public void ConfineVersions_LoadFromDifferentDirectory_HigherVersion() Assert.That(result, Is.EqualTo(NativeMethodsTests.FullIcuLibraryVersion)); } - [Platform(Exclude = "Linux", - Reason = "These tests require ICU4C installed from NuGet packages which isn't available on Linux")] + [Platform(Include = "Win", + Reason = "These tests require ICU4C installed from NuGet packages which is only available on Windows")] [Test] public void ConfineVersions_LoadFromDifferentDirectory_NotInPreferredDir() { diff --git a/source/icu.net.tests/NativeMethods/NativeMethodsHelperTests.cs b/source/icu.net.tests/NativeMethods/NativeMethodsHelperTests.cs index 81977ac8..790e5be2 100644 --- a/source/icu.net.tests/NativeMethods/NativeMethodsHelperTests.cs +++ b/source/icu.net.tests/NativeMethods/NativeMethodsHelperTests.cs @@ -14,6 +14,7 @@ public class NativeMethodsHelperTests { private string _filenameWindows; private string _filenameLinux; + private string _filenameMac; private int CallGetIcuVersionInfoForNetCoreOrWindows() { @@ -36,6 +37,8 @@ public void Setup() File.WriteAllText(_filenameWindows, "just a dummy file"); _filenameLinux = Path.Combine(NativeMethodsTests.OutputDirectory, $"libicuuc.so.{Wrapper.MaxSupportedIcuVersion}.1"); File.WriteAllText(_filenameLinux, "just a dummy file"); + _filenameMac = Path.Combine(NativeMethodsTests.OutputDirectory, $"libicuuc.{Wrapper.MaxSupportedIcuVersion}.dylib"); + File.WriteAllText(_filenameMac, "just a dummy file"); } [TearDown] @@ -43,6 +46,7 @@ public void TearDown() { File.Delete(_filenameWindows); File.Delete(_filenameLinux); + File.Delete(_filenameMac); Wrapper.Cleanup(); } diff --git a/source/icu.net.tests/NativeMethods/NativeMethodsTests.cs b/source/icu.net.tests/NativeMethods/NativeMethodsTests.cs index 006913bf..88e997b4 100644 --- a/source/icu.net.tests/NativeMethods/NativeMethodsTests.cs +++ b/source/icu.net.tests/NativeMethods/NativeMethodsTests.cs @@ -8,8 +8,8 @@ namespace Icu.Tests { - [Platform(Exclude = "Linux", - Reason = "These tests require ICU4C installed from NuGet packages which isn't available on Linux")] + [Platform(Include = "Win", + Reason = "These tests require ICU4C installed from NuGet packages which is only available on Windows")] [TestFixture] public class NativeMethodsTests { diff --git a/source/icu.net.tests/ResourceBundleTests.cs b/source/icu.net.tests/ResourceBundleTests.cs index 567be798..3eab9984 100644 --- a/source/icu.net.tests/ResourceBundleTests.cs +++ b/source/icu.net.tests/ResourceBundleTests.cs @@ -51,14 +51,16 @@ public void GetStringContentsWithKeys() } } - [TestCase("en_US", ExpectedResult = "[a b c d e f g h i j k l m n o p q r s t u v w x y z]")] - [TestCase("de_DE", ExpectedResult = "[a ä b c d e f g h i j k l m n o ö p q r s ß t u ü v w x y z]")] - [TestCase("fr_FR", ExpectedResult = "[a à â æ b c ç d e é è ê ë f g h i î ï j k l m n o ô œ p q r s t u ù û ü v w x y ÿ z]")] + [TestCase("en_US", ExpectedResult = "[abcdefghijklmnopqrstuvwxyz]")] + [TestCase("de_DE", ExpectedResult = "[aäbcdefghijklmnoöpqrsßtuüvwxyz]")] + [TestCase("fr_FR", ExpectedResult = "[aàâæbcçdeéèêëfghiîïjklmnoôœpqrstuùûüvwxyÿz]")] public string GetStringByKey(string localeId) { using (var resourceBundle = new ResourceBundle(null, localeId)) { - return resourceBundle.GetStringByKey("ExemplarCharacters"); + // Ideally this should be parsed by something that understands UnicodeSet structures + // Since spaces aren't meaningful in UnicodeSets, we'll take a shortcut and remove them + return resourceBundle.GetStringByKey("ExemplarCharacters").Replace(" ", ""); } } } diff --git a/source/icu.net.tests/TimeZoneTests.cs b/source/icu.net.tests/TimeZoneTests.cs index a8edf0bc..b8de75cf 100644 --- a/source/icu.net.tests/TimeZoneTests.cs +++ b/source/icu.net.tests/TimeZoneTests.cs @@ -63,6 +63,7 @@ public void GetOffsetTimeZonesTest() Assert.GreaterOrEqual(timezones.Count(), 3); } + [Platform(Exclude = "MacOsX", Reason = "The timezone ID for UTC can come in as Universal")] [Test] public void GetDefaultTimeZoneTest() { diff --git a/source/icu.net.tests/icu.net.tests.csproj b/source/icu.net.tests/icu.net.tests.csproj index 6bd4bab8..f2e5dfe3 100644 --- a/source/icu.net.tests/icu.net.tests.csproj +++ b/source/icu.net.tests/icu.net.tests.csproj @@ -1,6 +1,10 @@ - net461;net6.0 + + net461;net8.0 Icu.Tests icu.net.tests false @@ -10,8 +14,14 @@ - - + + + diff --git a/source/icu.net/NativeMethods/NativeMethodsHelper.cs b/source/icu.net/NativeMethods/NativeMethodsHelper.cs index 02706c8c..9ea8eb8e 100644 --- a/source/icu.net/NativeMethods/NativeMethodsHelper.cs +++ b/source/icu.net/NativeMethods/NativeMethodsHelper.cs @@ -24,9 +24,10 @@ internal static class NativeMethodsHelper private const string Icu4c = nameof(Icu4c); private const string IcuRegexLinux = @"libicu\w+.so\.(?[0-9]{2,})(\.[0-9])*"; private const string IcuRegexWindows = @"icu\w+(?[0-9]{2,})(\.[0-9])*\.dll"; + private const string IcuRegexMac = @"libicu\w+.(?[0-9]{2,})(\.[0-9])*.dylib"; - private static readonly Regex IcuBinaryRegex = new Regex($"{IcuRegexWindows}|{IcuRegexLinux}$", RegexOptions.Compiled); - private static readonly string IcuSearchPattern = Platform.OperatingSystem == OperatingSystemType.Windows ? "icu*.dll" : "libicu*.so.*"; + private static readonly Regex IcuBinaryRegex = new ($"{IcuRegexWindows}|{IcuRegexLinux}|{IcuRegexMac}$", RegexOptions.Compiled); + private static readonly string IcuSearchPattern = Platform.OperatingSystem == OperatingSystemType.Windows ? "icu*.dll" : Platform.OperatingSystem == OperatingSystemType.MacOSX ? "libicu*.*.dylib" : "libicu*.so.*"; private static readonly string NugetPackageDirectory = GetDefaultPackageDirectory(Platform.OperatingSystem); // ReSharper disable once InconsistentNaming diff --git a/source/icu.net/icu.net.csproj b/source/icu.net/icu.net.csproj index b70ee080..d06d3517 100644 --- a/source/icu.net/icu.net.csproj +++ b/source/icu.net/icu.net.csproj @@ -34,6 +34,15 @@ + + + + PreserveNewest + + + + +