Skip to content

Commit

Permalink
update icu.net to 3.0.0-beta.296
Browse files Browse the repository at this point in the history
  • Loading branch information
hahn-kev committed Aug 2, 2024
1 parent aa1c857 commit 883cbb1
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 51 deletions.
2 changes: 1 addition & 1 deletion SIL.WritingSystems.Tests/SIL.WritingSystems.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="NDesk.DBus" Version="0.15.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<!-- this reference is required to exhibit an issue where the icu.net version for net8.0 conflicts with the version used by SIL.WritingSystems-->
<PackageReference Include="icu.net" Version="2.10.0"/>
<PackageReference Include="icu.net" Version="3.0.0-beta.296"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.3.2" PrivateAssets="All" />
<PackageReference Include="SIL.ReleaseTasks" Version="2.5.0" PrivateAssets="All" />
<PackageReference Include="Spart" Version="1.0.0" />
Expand Down
49 changes: 0 additions & 49 deletions SIL.WritingSystems/IcuRulesCollator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,7 @@ public static bool ValidateSortRules(string rules, out string message)

public SortKey GetSortKey(string source)
{
#if NET461
return _collator.GetSortKey(source);
#elif NETSTANDARD2_0
Icu.SortKey icuSortKey = _collator.GetSortKey(source);
SortKey sortKey = CultureInfo.InvariantCulture.CompareInfo.GetSortKey(string.Empty, CompareOptions.None);
string keyDataFieldName, origStringFieldName;
if (Platform.IsDotNetFramework)
{
keyDataFieldName = "m_KeyData";
origStringFieldName = "m_String";
}
else if (Platform.IsDotNetCore)
{
keyDataFieldName = "_keyData";
origStringFieldName = "_string";
}
else if (Platform.IsMono)
{
keyDataFieldName = "key";
origStringFieldName = "source";
}
else
{
throw new PlatformNotSupportedException();
}

SetInternalFieldForPublicProperty(sortKey, "SortKey.KeyData", keyDataFieldName, icuSortKey.KeyData);
SetInternalFieldForPublicProperty(sortKey, "SortKey.OriginalString", origStringFieldName,
icuSortKey.OriginalString);
return sortKey;
#endif
}

///<summary>Compares two strings and returns a value indicating whether one is less than,
Expand All @@ -114,24 +84,5 @@ public int Compare(object x, object y)
{
return Compare((string) x, (string) y);
}

#if NETSTANDARD2_0
private static void SetInternalFieldForPublicProperty(object instance, string propertyName, string fieldName,
object value)
{
Type type = instance.GetType();

FieldInfo fieldInfo = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);

Debug.Assert(fieldInfo != null,
"Unsupported runtime",
"Could not figure out an internal field for" + propertyName);

if (fieldInfo == null)
throw new PlatformNotSupportedException();

fieldInfo.SetValue(instance, value);
}
#endif
}
}
2 changes: 1 addition & 1 deletion SIL.WritingSystems/SIL.WritingSystems.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="SIL.ReleaseTasks" Version="2.5.0" PrivateAssets="All" />
<PackageReference Include="icu.net" Version="2.8.1" />
<PackageReference Include="icu.net" Version="3.0.0-beta.296" />
<PackageReference Include="Spart" Version="1.0.0" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
Expand Down

0 comments on commit 883cbb1

Please sign in to comment.