Skip to content

Commit

Permalink
[dotnet] Add ICU support for iOS builds (#11163)
Browse files Browse the repository at this point in the history
and re-enable some tests for dotnet

Part of the fix for #8906

Known Issues
* [some Calendar are not the expected ones](dotnet/runtime#50859)
* [No support for tvOS (bitcode)](dotnet/runtime#48508)
  • Loading branch information
spouliot committed Apr 9, 2021
1 parent 1e11c21 commit f85af09
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
9 changes: 7 additions & 2 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@
<EnableUnsafeUTF7Encoding Condition="'$(EnableUnsafeUTF7Encoding)' == ''">false</EnableUnsafeUTF7Encoding>
<EventSourceSupport Condition="'$(EventSourceSupport)' == ''">false</EventSourceSupport>
<HttpActivityPropagationSupport Condition="'$(HttpActivityPropagationSupport)' == ''">false</HttpActivityPropagationSupport>
<!-- .NET only supports invariant globalization for Apple platforms for now: https://github.com/xamarin/xamarin-macios/issues/8906 -->
<InvariantGlobalization Condition="'$(InvariantGlobalization)' == ''">true</InvariantGlobalization>
<!-- tvOS support blocked by https://github.com/dotnet/runtime/issues/48508 (see xamarin_bridge_vm_initialize in monovm-bridge.m) -->
<InvariantGlobalization Condition="'$(_PlatformName)' == 'tvOS' And '$(InvariantGlobalization)' == ''">true</InvariantGlobalization>
<StartupHookSupport Condition="'$(StartupHookSupport)' == ''">false</StartupHookSupport>
<UseSystemResourceKeys Condition="'$(UseSystemResourceKeys)' == ''">true</UseSystemResourceKeys>
<UseNativeHttpHandler Condition="'$(_PlatformName)' != 'macOS' And '$(UseNativeHttpHandler)' == ''">true</UseNativeHttpHandler>
Expand Down Expand Up @@ -245,6 +245,7 @@
@(_XamarinFrameworkAssemblies -> 'FrameworkAssembly=%(Filename)')
Interpreter=$(MtouchInterpreter)
IntermediateLinkDir=$(IntermediateLinkDir)
InvariantGlobalization=$(InvariantGlobalization)
ItemsDirectory=$(_LinkerItemsDirectory)
IsSimulatorBuild=$(_SdkIsSimulator)
LinkMode=$(_LinkMode)
Expand Down Expand Up @@ -696,6 +697,10 @@
Update="@(ResolvedFileToPublish)"
RelativePath="$([MSBuild]::MakeRelative($(MSBuildProjectDirectory)$(PublishDir),$(_DylibPublishDir)))\%(Filename)%(Extension)"
Condition="'%(Extension)' == '.dylib'" />
<ResolvedFileToPublish
Update="@(ResolvedFileToPublish)"
RelativePath="$([MSBuild]::MakeRelative($(MSBuildProjectDirectory)$(PublishDir),$(_AssemblyPublishDir)))%(Filename)%(Extension)"
Condition="'$(_PlatformName)' != 'macOS' And '$(InvariantGlobalization)' != 'true' And '%(Filename)%(Extension)' == 'icudt.dat'" />
</ItemGroup>
</Target>

Expand Down
2 changes: 2 additions & 0 deletions runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -2437,10 +2437,12 @@ -(void) xamarinSetFlags: (enum XamarinGCHandleFlags) flags;
const char *propertyKeys[] = {
"APP_PATHS",
"PINVOKE_OVERRIDE",
"ICU_DAT_FILE_PATH",
};
const char *propertyValues[] = {
xamarin_get_bundle_path (),
pinvokeOverride,
"icudt.dat",
};
static_assert (sizeof (propertyKeys) == sizeof (propertyValues), "The number of keys and values must be the same.");

Expand Down
4 changes: 0 additions & 4 deletions tests/EmbeddedResources/ResourcesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@ public void Embedded ()
Assert.AreEqual ("Welcome", manager.GetString ("String1", new CultureInfo ("en")), "en");
Assert.AreEqual ("G'day", manager.GetString ("String1", new CultureInfo ("en-AU")), "en-AU");
Assert.AreEqual ("Willkommen", manager.GetString ("String1", new CultureInfo ("de")), "de");
#if !NET // https://github.com/xamarin/xamarin-macios/issues/8906
Assert.AreEqual ("Willkommen", manager.GetString ("String1", new CultureInfo ("de-DE")), "de-DE");
#endif
Assert.AreEqual ("Bienvenido", manager.GetString ("String1", new CultureInfo ("es")), "es");
#if !NET // https://github.com/xamarin/xamarin-macios/issues/8906
Assert.AreEqual ("Bienvenido", manager.GetString ("String1", new CultureInfo ("es-AR")), "es-AR");
Assert.AreEqual ("Bienvenido", manager.GetString ("String1", new CultureInfo ("es-ES")), "es-ES");
#endif
}
}
}
2 changes: 2 additions & 0 deletions tests/common/DotNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public static void CompareApps (string old_app, string new_app)
var filename = Path.GetFileName (v);
switch (filename) {
case "icudt.dat":
return false; // ICU data file only present on .NET
case "runtime-options.plist":
return false; // the .NET runtime will deal with selecting the http handler, no need for us to do anything
}
Expand Down
3 changes: 0 additions & 3 deletions tests/monotouch-test/Foundation/LocaleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ public void FromLocaleIdentifier ()
Assert.That (NSLocale.FromLocaleIdentifier (ident).Identifier, Is.EqualTo (ident), "FromLocaleIdentifier");
}

#if NET
[Ignore ("No globalization data yet - https://github.com/xamarin/xamarin-macios/issues/8906")]
#endif
[Test]
public void InitRegionInfo ()
{
Expand Down
4 changes: 4 additions & 0 deletions tools/dotnet-linker/LinkerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class LinkerConfiguration {
public Version DeploymentTarget { get; private set; }
public HashSet<string> FrameworkAssemblies { get; private set; } = new HashSet<string> ();
public string IntermediateLinkDir { get; private set; }
public bool InvariantGlobalization { get; private set; }
public string ItemsDirectory { get; private set; }
public bool IsSimulatorBuild { get; private set; }
public LinkMode LinkMode => Application.LinkMode;
Expand Down Expand Up @@ -228,6 +229,9 @@ public static LinkerConfiguration GetInstance (LinkContext context, bool createI
throw new InvalidOperationException ($"Invalid XamarinRuntime '{value}' in {linker_file}");
Application.XamarinRuntime = rv;
break;
case "InvariantGlobalization":
InvariantGlobalization = string.Equals ("true", value, StringComparison.OrdinalIgnoreCase);
break;
default:
throw new InvalidOperationException ($"Unknown key '{key}' in {linker_file}");
}
Expand Down
4 changes: 3 additions & 1 deletion tools/dotnet-linker/Steps/GenerateMainStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ protected override void TryEndProcess ()
contents.AppendLine ("#include <stdlib.h>");
contents.AppendLine ("static void xamarin_initialize_dotnet ()");
contents.AppendLine ("{");
contents.AppendLine ("\tsetenv (\"DOTNET_SYSTEM_GLOBALIZATION_INVARIANT\", \"1\", 1); // https://github.com/xamarin/xamarin-macios/issues/8906");
if (Configuration.InvariantGlobalization) {
contents.AppendLine ("\tsetenv (\"DOTNET_SYSTEM_GLOBALIZATION_INVARIANT\", \"1\", 1);");
}
contents.AppendLine ("}");
contents.AppendLine ();

Expand Down

4 comments on commit f85af09

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

Packages generated

View packages

Test results

2 tests failed, 179 tests passed.

Failed tests

  • xammac tests/Mac Modern/Release: Failed (Test run failed.
    Tests run: 2444 Passed: 2390 Inconclusive: 14 Failed: 1 Ignored: 53)
  • introspection/watchOS 32-bits - simulator/Debug (watchOS 5.0): LaunchFailure

Pipeline on Agent XAMBOT-1036'

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Tests failed catastrophically on VSTS: device tests tvOS (no summary found). 🔥

Result file $(TEST_SUMMARY_PATH) not found.

Pipeline on Agent

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Tests failed catastrophically on VSTS: device tests iOS32b (no summary found). 🔥

Result file $(TEST_SUMMARY_PATH) not found.

Pipeline on Agent

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Tests failed catastrophically on VSTS: device tests iOS (no summary found). 🔥

Result file $(TEST_SUMMARY_PATH) not found.

Pipeline on Agent

Please sign in to comment.