Skip to content

Commit

Permalink
Skip System.Text.Json tests on iOS/tvOS that don't work (#58276)
Browse files Browse the repository at this point in the history
A number of tests using `dynamic` can't work on iOS devices due to "dynamic invoke" (where Mono does an indirect runtime invoke using a single universal invoke wrapper) not being supported, added PlatformDetection checks for System.Reflection.Emit since that is a close enough approximation for those.

A few other tests run into an "Attempting to JIT compile method" issue that is tracked by #58204
  • Loading branch information
akoeplinger authored Aug 30, 2021
1 parent e0e7bfc commit c584001
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ public class SuffixNamingPolicy : JsonNamingPolicy
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public static void RoundtripAllDictionaryConverters()
{
const string Expected = @"{""1"":1}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public static void CopyTo()
[Fact]
public static void ConvertJSONArrayToIListOfJsonNode()
{
dynamic obj = JsonSerializer.Deserialize<JsonArray>("[42]");
JsonArray obj = JsonSerializer.Deserialize<JsonArray>("[42]");
Assert.Equal(42, (int)obj[0]);

IList<JsonNode> ilist = obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void DeserializeBoolean_EmptyString()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public void IncompleteContainers()
{
JsonException e = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<IList<object>>("[1,"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public static void PropertyCacheWithMinInputsLast()

[Theory]
[MemberData(nameof(WriteSuccessCases))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public static async Task MultipleTypes(ITestClass testObj)
{
Type type = testObj.GetType();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Xunit;

namespace System.Text.Json.Serialization.Tests
{
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public sealed partial class CollectionTestsDynamic : CollectionTests
{
public CollectionTestsDynamic() : base(JsonSerializerWrapperForString.StringSerializer, JsonSerializerWrapperForStream.AsyncStreamSerializer) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private enum MyCustomEnum
Hello = 77
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void VerifyPrimitives()
{
var options = new JsonSerializerOptions();
Expand Down Expand Up @@ -67,7 +67,7 @@ public static void VerifyPrimitives()
Assert.Equal(4.2, dbl);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void VerifyArray()
{
var options = new JsonSerializerOptions();
Expand Down Expand Up @@ -97,7 +97,7 @@ public static void VerifyArray()
Assert.Equal(10, (int)obj.MyArray[0]);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void JsonDynamicTypes_Serialize()
{
var options = new JsonSerializerOptions();
Expand Down Expand Up @@ -149,7 +149,7 @@ public static void JsonDynamicTypes_Serialize()
JsonTestHelper.AssertJsonEqual("{\"One\":1,\"Two\":2}", json);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void JsonDynamicTypes_Deserialize()
{
var options = new JsonSerializerOptions();
Expand All @@ -164,7 +164,7 @@ public static void JsonDynamicTypes_Deserialize()
JsonSerializer.Deserialize<JsonDynamicString>("\"str\"", options);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void JsonDynamicTypes_Deserialize_AsObject()
{
var options = new JsonSerializerOptions();
Expand All @@ -181,7 +181,7 @@ public static void JsonDynamicTypes_Deserialize_AsObject()
/// <summary>
/// Use a mutable DOM with the 'dynamic' keyword.
/// </summary>
[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void VerifyMutableDom_UsingDynamicKeyword()
{
var options = new JsonSerializerOptions();
Expand Down Expand Up @@ -221,7 +221,7 @@ public static void VerifyMutableDom_UsingDynamicKeyword()
/// <summary>
/// Use a mutable DOM without the 'dynamic' keyword.
/// </summary>
[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void VerifyMutableDom_WithoutUsingDynamicKeyword()
{
var options = new JsonSerializerOptions();
Expand Down Expand Up @@ -263,7 +263,7 @@ public static void VerifyMutableDom_WithoutUsingDynamicKeyword()
/// Use a mutable DOM without the 'dynamic' keyword and use round-trippable values
/// meaning the 'JsonDynamicType' values are used instead of raw primitives.
/// </summary>
[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void VerifyMutableDom_WithoutUsingDynamicKeyword_JsonDynamicType()
{
var options = new JsonSerializerOptions();
Expand Down Expand Up @@ -306,7 +306,7 @@ void Verify()
}
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void DynamicObject_MissingProperty()
{
var options = new JsonSerializerOptions();
Expand All @@ -317,7 +317,7 @@ public static void DynamicObject_MissingProperty()
Assert.Equal(null, obj.NonExistingProperty);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void DynamicObject_CaseSensitivity()
{
var options = new JsonSerializerOptions();
Expand All @@ -338,7 +338,7 @@ public static void DynamicObject_CaseSensitivity()
Assert.Equal(42, (int)obj.MYPROPERTY);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void NamingPoliciesAreNotUsed()
{
const string Json = "{\"myProperty\":42}";
Expand All @@ -353,7 +353,7 @@ public static void NamingPoliciesAreNotUsed()
JsonTestHelper.AssertJsonEqual(Json, json);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void NullHandling()
{
var options = new JsonSerializerOptions();
Expand All @@ -363,7 +363,7 @@ public static void NullHandling()
Assert.Null(obj);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void QuotedNumbers_Deserialize()
{
var options = new JsonSerializerOptions();
Expand All @@ -381,7 +381,7 @@ public static void QuotedNumbers_Deserialize()
Assert.Equal(float.NaN, (float)obj);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void QuotedNumbers_Serialize()
{
var options = new JsonSerializerOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal static ExpandoObject GetExpandoObject()
return myDynamic;
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void DynamicKeyword()
{
dynamic myDynamic = GetExpandoObject();
Expand Down Expand Up @@ -100,7 +100,7 @@ void VerifyArray()
}
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
public static void ExpandoObject()
{
ExpandoObject expando = JsonSerializer.Deserialize<ExpandoObject>(Json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace System.Text.Json.Serialization.Tests
public static partial class NullableTests
{
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public static void DictionaryWithNullableValue()
{
Dictionary<string, float?> dictWithFloatValue = new Dictionary<string, float?> { { "key", 42.0f } };
Expand Down Expand Up @@ -170,6 +171,7 @@ public class SimpleClassWithDictionariesWithNullableValues
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public static void ClassWithDictionariesWithNullableValues()
{
string json =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ public class Class_With_ListsOfBoxedNonNumbers

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/49936", TestPlatforms.Android)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public static void Number_AsCollectionElement_RoundTrip()
{
RunAsCollectionElementTest(JsonNumberTestData.Bytes);
Expand Down Expand Up @@ -603,6 +604,7 @@ private static void AssertDictionaryElements_StringValues(string serialized)
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/39674", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoInterpreter))]
[SkipOnCoreClr("https://github.com/dotnet/runtime/issues/45464", RuntimeConfiguration.Checked)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public static void DictionariesRoundTrip()
{
RunAllDictionariessRoundTripTest(JsonNumberTestData.ULongs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ private ConcreteDerivedClassWithNoPublicDefaultCtor(string error)
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public static void ReadClassWithStringToPrimitiveDictionary()
{
TestClassWithStringToPrimitiveDictionary obj = JsonSerializer.Deserialize<TestClassWithStringToPrimitiveDictionary>(TestClassWithStringToPrimitiveDictionary.s_data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static void VerifyTypeFail()

[Theory]
[MemberData(nameof(WriteSuccessCases))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public static void Write(ITestClass testObj)
{
var options = new JsonSerializerOptions { IncludeFields = true };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ public static void ReadSimpleStruct()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public static void ReadClasses()
{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,7 @@ public static void ReferenceObjectBeforePreservedObject()

[Theory]
[MemberData(nameof(ReadSuccessCases))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public static void ReadTestClassesWithExtensionOption(Type classType, byte[] data)
{
var options = new JsonSerializerOptions { IncludeFields = true, ReferenceHandler = ReferenceHandler.Preserve };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static void ParseNullTypeFail()

[Theory]
[MemberData(nameof(ReadSuccessCases))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public static void Read(Type classType, byte[] data)
{
var options = new JsonSerializerOptions { IncludeFields = true };
Expand All @@ -27,6 +28,7 @@ public static void Read(Type classType, byte[] data)

[Theory]
[MemberData(nameof(ReadSuccessCases))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public static void ReadFromStream(Type classType, byte[] data)
{
MemoryStream stream = new MemoryStream(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public partial class StreamTests
[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/35927", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoInterpreter))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/35927", TestPlatforms.Browser)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
public async Task HandleCollectionsAsync()
{
await RunTestAsync<string>();
Expand Down

0 comments on commit c584001

Please sign in to comment.