Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/CI-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ jobs:
- name: Test on .NET 10.0
run: dotnet test -p:TargetFramework=net10.0 --configuration Release --no-build source/icu.net.sln -- NUnit.TestOutputXml=TestResults

- name: Test on .NET Framework 4.6.1 (Windows only)
- name: Test on .NET Framework 4.6.2 (Windows only)
if: ${{ matrix.os == 'windows-latest' }}
run: dotnet test -p:TargetFramework=net461 --configuration Release --no-build source/icu.net.sln -- NUnit.TestOutputXml=TestResults
run: dotnet test -p:TargetFramework=net462 --configuration Release --no-build source/icu.net.sln -- NUnit.TestOutputXml=TestResults

- name: Upload Test Results
if: always()
Expand Down
33 changes: 31 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
UVerticalOrientation, UIdentifierStatus, UIdentifierType.
- Added net10.0 target framework.

### Changed

- **BREAKING CHANGE:** Replaced the `net451` target framework with `net462`, matching the
framework already used by current consumers (e.g. libpalaso, LibChorus) and remaining the
nearest compatible target for others (FieldWorks, SayMore, HearThis). Any consumer targeting
`net461` or lower will no longer resolve a compatible .NET Framework build of this package
(falling back to the `netstandard2.0` build instead, if their tooling supports it). The
`net461`-targeted test/tooling projects in this repo were bumped to `net462` to match.
- Upgraded `System.ValueTuple` from 4.5.0 to 4.6.2.
- Unified `Microsoft.Extensions.DependencyModel` on version 10.0.9 across all target frameworks:
it now officially supports `net462`, so the old net451-era pin to 2.1.0 (and the accompanying
`Newtonsoft.Json` override) is no longer needed.
- Removed the explicit `Microsoft.SourceLink.GitHub` `PackageReference`: verified that the .NET
SDK (8.0+) now embeds correct `raw.githubusercontent.com` source link mappings for GitHub repos
without it — confirmed by inspecting the packed `.snupkg` PDBs for all four target frameworks.
- Removed the `System.IO.FileSystem` / `System.IO.FileSystem.Primitives` 4.3.0 references from
the test project: netstandard1.x-era facades, both deprecated on nuget.org, no longer needed
now that the lowest test target is `net462`.

### Fixed

- Fixed `Transliterator.Transliterate` throwing `OverflowException` for characters that expand
Expand Down Expand Up @@ -86,12 +105,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- In Character class, added \[Obsolete\] attribute to enum members UDecompositionType.COUNT and
UNumericType.COUNT.

### Removed

- **BREAKING CHANGE:** Dropped the `net40` target framework. A GitHub code search across
sillsdev's repos found no remaining consumers, and nothing in icu-dotnet's own test suite
exercised it either, but any project still building against `net40` specifically will no
longer find a compatible asset in this package.
- Removed dead `#if NET40` / `#if !NET40` conditional code (and the comments explaining it) from
`NativeMethods.cs`, `NativeMethodsHelper.cs`, `NativeMethodsTests.cs`, `NativeMethodsHelperTests.cs`,
`CharacterTests.cs`, and `LocaleTests.cs`, now that `net40` is no longer a target framework.
Also updated remaining `net461`/`4.5.1`-specific comments to reflect the `net462` retarget.

### Security

- Upgraded `Microsoft.Extensions.DependencyModel` from 2.0.4 to 10.0.9 on non-.NET-Framework
targets, eliminating the transitive dependency on `Newtonsoft.Json` 9.0.1 (high severity
vulnerability). The `net451` target retains `Microsoft.Extensions.DependencyModel` 2.1.0 (the
newest version with net451 support) and pins the latest `Newtonsoft.Json`.
vulnerability).

- Upgraded `SIL.ReleaseTasks` to 4.0.0, which upgrades its own `SIL.Core` dependency to bring
`Newtonsoft.Json` to 13.0.1 — past the vulnerability (GHSA-5crp-9r3c-p9vr) — and no longer
Expand Down
4 changes: 2 additions & 2 deletions build/icu-dotnet.proj
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

<Target Name="RunNUnitTC" Condition="'$(IsOnTeamCity)'=='true'">
<ItemGroup>
<TestAssemblies Include="$(OutputDir)/$(Configuration)/net461/*tests.dll"/>
<TestAssemblies Include="$(OutputDir)/$(Configuration)/net462/*tests.dll"/>
</ItemGroup>

<NUnitTeamCity
Expand All @@ -90,7 +90,7 @@

<Target Name="RunNUnit" Condition="'$(IsOnTeamCity)'!='true'">
<ItemGroup>
<TestAssemblies Include="$(OutputDir)/$(Configuration)/net461/*tests.dll"/>
<TestAssemblies Include="$(OutputDir)/$(Configuration)/net462/*tests.dll"/>
</ItemGroup>

<SIL.BuildTasks.UnitTestTasks.NUnit3 Assemblies="@(TestAssemblies)"
Expand Down
2 changes: 1 addition & 1 deletion source/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net40;net451;netstandard2.0;net8.0;net10.0</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.0;net8.0;net10.0</TargetFrameworks>
<PlatformAlias>netstandard</PlatformAlias>
<OutputPath>$(MSBuildThisFileDirectory)\..\output\$(Configuration)</OutputPath>
<PackageOutputPath>$(MSBuildThisFileDirectory)\..\output</PackageOutputPath>
Expand Down
2 changes: 1 addition & 1 deletion source/TestHelper/TestHelper.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461;net8.0;net10.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0;net10.0</TargetFrameworks>
<OutputPath>../../output/$(Configuration)/TestHelper</OutputPath>
<OutputType>Exe</OutputType>
<RootNamespace>Icu.Tests</RootNamespace>
Expand Down
4 changes: 0 additions & 4 deletions source/icu.net.tests/CharacterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ public class CharacterTests
private void SetUICulture(string culture)
{
var cultureInfo = new CultureInfo(culture);
#if NET40
System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;
#else
CultureInfo.CurrentUICulture = cultureInfo;
#endif
}

// valid digit tests
Expand Down
8 changes: 0 additions & 8 deletions source/icu.net.tests/LocaleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,21 +303,13 @@ public void ImplicitCast()
private void SetUICulture(string culture)
{
var cultureInfo = new CultureInfo(culture);
#if NET40
System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;
#else
CultureInfo.CurrentUICulture = cultureInfo;
#endif
}

private void SetCulture(string culture)
{
var cultureInfo = new CultureInfo(culture);
#if NET40
System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo;
#else
CultureInfo.CurrentCulture = cultureInfo;
#endif
}
}
}
2 changes: 1 addition & 1 deletion source/icu.net.tests/MessageFormatterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class MessageFormatterTests

// Skip when umsg_format produces wrong results due to the non-ARM64 Unix ICU 74+
// double-varargs ABI mismatch (https://github.com/dotnet/runtime/issues/48752).
// net461 only runs on Windows, so the check is unnecessary there.
// .NET Framework tests only run on Windows, so the check is unnecessary there.
private static void SkipIfUnreliableOnThisPlatform()
{
#if !NETFRAMEWORK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Icu.Tests
{
#if !NET40
[TestFixture]
public class NativeMethodsHelperTests
{
Expand Down Expand Up @@ -71,5 +70,4 @@ public void GetIcuVersionInfoForNetCoreOrWindows_DoesNotCrash()
Assert.That(result, Is.EqualTo(Wrapper.MaxSupportedIcuVersion));
}
}
#endif
}
6 changes: 2 additions & 4 deletions source/icu.net.tests/NativeMethods/NativeMethodsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ internal static string GetArchSubdir(string prefix = "")

internal static string OutputDirectory => Path.GetDirectoryName(
new Uri(
#if NET40
typeof(NativeMethodsTests).Assembly.CodeBase
#elif NET5_0_OR_GREATER
#if NET5_0_OR_GREATER
typeof(NativeMethodsTests).GetTypeInfo().Assembly.Location
#else
typeof(NativeMethodsTests).GetTypeInfo().Assembly.CodeBase
Expand Down Expand Up @@ -122,7 +120,7 @@ private static void CopyMinimalIcuFiles(string targetDir)

internal static void CopyTestFiles(string sourceDir, string targetDir)
{
// sourceDir is something like output/Debug/net461, TestHelper is in output/Debug/TestHelper/net461
// sourceDir is something like output/Debug/net*, TestHelper is in output/Debug/TestHelper/net*
var framework = Path.GetFileName(sourceDir);
sourceDir = Path.Combine(sourceDir, "..", "TestHelper", framework);
CopyFilesFromDirectory(sourceDir, targetDir);
Expand Down
10 changes: 4 additions & 6 deletions source/icu.net.tests/icu.net.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<!--
If you only want to test on a particular target framework, run
`dotnet test -p:TargetFramework=XXX`. For example, on macOS you want to run with
`-p:TargetFramework=net8.0` or `-p:TargetFramework=net10.0` since 4.6.1 isn't supported
`-p:TargetFramework=net8.0` or `-p:TargetFramework=net10.0` since 4.6.2 isn't supported
-->
<TargetFrameworks>net461;net8.0;net10.0</TargetFrameworks>
<TargetFrameworks>net462;net8.0;net10.0</TargetFrameworks>
<RootNamespace>Icu.Tests</RootNamespace>
<AssemblyTitle>icu.net.tests</AssemblyTitle>
<IsPackable>false</IsPackable>
Expand All @@ -17,15 +17,13 @@
<PackageReference Include="NUnit" Version="3.14.0" />
<!--
Only version 4.3.2 of NUnit3TestAdapter is able to run tests for both .NET 8.0+ and .NET
Framework 4.6.1.
Framework 4.6.2.
https://docs.nunit.org/articles/vs-test-adapter/Supported-Frameworks.html

Going forward we'll have to drop 4.6.1 support to be able to update NUnit3TestAdapter.
Going forward we'll have to drop 4.6.2 support to be able to update NUnit3TestAdapter.
-->
<PackageReference Include="NUnit3TestAdapter" Version="4.3.2" />
<PackageReference Include="NUnit.Console" Version="3.22.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\icu.net\icu.net.csproj" />
Expand Down
13 changes: 0 additions & 13 deletions source/icu.net/NativeMethods/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,7 @@ internal static string DirectoryOfThisAssembly
{
get
{
//NOTE: .GetTypeInfo() is not supported until .NET 4.5 onwards.
#if NET40
var currentAssembly = typeof(NativeMethods).Assembly;
#else
var currentAssembly = typeof(NativeMethods).GetTypeInfo().Assembly;
#endif
#if NET
var managedPath = currentAssembly.Location;
// If the application is published as a single file, Assembly.Location will be an empty string.
Expand Down Expand Up @@ -538,7 +533,6 @@ private static void ResetIcuVersionInfo()
IcuVersion = 0;
_IcuPath = null;

#if !NET40
NativeMethodsHelper.Reset();
var icuInfo = NativeMethodsHelper.GetIcuVersionInfoForNetCoreOrWindows();

Expand All @@ -547,7 +541,6 @@ private static void ResetIcuVersionInfo()
_IcuPath = icuInfo.IcuPath.FullName;
IcuVersion = icuInfo.IcuVersion;
}
#endif
}

// This method is thread-safe and idempotent
Expand Down Expand Up @@ -593,13 +586,7 @@ private static T GetMethod<T>(IntPtr handle, string methodName, bool missingInMi

if (methodPointer != IntPtr.Zero)
{
// NOTE: Starting in .NET 4.5.1, Marshal.GetDelegateForFunctionPointer(IntPtr, Type) is obsolete.
#if NET40
return Marshal.GetDelegateForFunctionPointer(
methodPointer, typeof(T)) as T;
#else
return Marshal.GetDelegateForFunctionPointer<T>(methodPointer);
#endif
}
if (missingInMinimal)
{
Expand Down
8 changes: 0 additions & 8 deletions source/icu.net/NativeMethods/NativeMethodsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
#if !NET40
using Microsoft.Extensions.DependencyModel;
#endif

// ReSharper disable once CheckNamespace
namespace Icu
Expand Down Expand Up @@ -76,7 +74,6 @@ public static IcuVersionInfo GetIcuVersionInfoForNetCoreOrWindows()
return IcuVersion;
}

#if !NET40
var context = DependencyContext.Default;
// If this is false, something went wrong. These files should have
// either been found above or we should have been able to locate the
Expand All @@ -103,7 +100,6 @@ public static IcuVersionInfo GetIcuVersionInfoForNetCoreOrWindows()
}

TrySetIcuPathFromDirectory(new DirectoryInfo(packagePath), nativeAssetPaths);
#endif

return IcuVersion;
}
Expand Down Expand Up @@ -169,14 +165,12 @@ private static bool TryGetPathFromAssemblyDirectory()
}

string[] nativeAssetPaths = null;
#if !NET40
// 3. Check in {directoryOfAssembly}/runtimes/{runtimeId}/native/
if (!TryGetNativeAssetPaths(DependencyContext.Default, out nativeAssetPaths))
{
Trace.WriteLine("Could not locate icu native assets from DependencyModel.");
return false;
}
#endif
// If we found the icu*.dll files under {directoryOfAssembly}/runtimes/{rid}/native/,
// they should ALL be there... or else something went wrong in publishing the app or
// restoring the files, or packaging the NuGet package.
Expand Down Expand Up @@ -258,7 +252,6 @@ private static bool TrySetIcuPathFromDirectory(DirectoryInfo baseDirectory, stri
return doAllAssetsExistInDirectory;
}

#if !NET40
/// <summary>
/// Tries to get the icu native binaries by searching the Runtime
/// ID graph to find the first set of paths that have those binaries.
Expand Down Expand Up @@ -317,7 +310,6 @@ private static bool TryResolvePackagePath(CompilationLibrary library, string bas

return Directory.Exists(packagePath);
}
#endif

/// <summary>
/// Tries to fetch the default package directory for NuGet packages.
Expand Down
9 changes: 2 additions & 7 deletions source/icu.net/icu.net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@
<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="6.0.5" PrivateAssets="all" />
<PackageReference Include="JetBrains.Annotations" Version="2026.2.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.401" PrivateAssets="all" />
<PackageReference Include="SIL.ReleaseTasks" Version="4.0.0" PrivateAssets="all" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="System.ValueTuple" Version="4.6.2" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net451'">
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="10.0.9" />
</ItemGroup>

Expand Down
Loading