Skip to content

Commit c584001

Browse files
authored
Skip System.Text.Json tests on iOS/tvOS that don't work (#58276)
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
1 parent e0e7bfc commit c584001

File tree

15 files changed

+34
-17
lines changed

15 files changed

+34
-17
lines changed

src/libraries/System.Text.Json/tests/Common/CollectionTests/CollectionTests.Dictionary.NonStringKey.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ public class SuffixNamingPolicy : JsonNamingPolicy
578578
}
579579

580580
[Fact]
581+
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
581582
public static void RoundtripAllDictionaryConverters()
582583
{
583584
const string Expected = @"{""1"":1}";

src/libraries/System.Text.Json/tests/System.Text.Json.Tests/JsonNode/JsonArrayTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public static void CopyTo()
199199
[Fact]
200200
public static void ConvertJSONArrayToIListOfJsonNode()
201201
{
202-
dynamic obj = JsonSerializer.Deserialize<JsonArray>("[42]");
202+
JsonArray obj = JsonSerializer.Deserialize<JsonArray>("[42]");
203203
Assert.Equal(42, (int)obj[0]);
204204

205205
IList<JsonNode> ilist = obj;

src/libraries/System.Text.Json/tests/System.Text.Json.Tests/NewtonsoftTests/JsonSerializerTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public void DeserializeBoolean_EmptyString()
6565
}
6666

6767
[Fact]
68+
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
6869
public void IncompleteContainers()
6970
{
7071
JsonException e = Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<IList<object>>("[1,"));

src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/CacheTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public static void PropertyCacheWithMinInputsLast()
168168

169169
[Theory]
170170
[MemberData(nameof(WriteSuccessCases))]
171+
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
171172
public static async Task MultipleTypes(ITestClass testObj)
172173
{
173174
Type type = testObj.GetType();

src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/CollectionTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using Xunit;
5+
46
namespace System.Text.Json.Serialization.Tests
57
{
8+
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
69
public sealed partial class CollectionTestsDynamic : CollectionTests
710
{
811
public CollectionTestsDynamic() : base(JsonSerializerWrapperForString.StringSerializer, JsonSerializerWrapperForStream.AsyncStreamSerializer) { }

src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/CustomConverterTests/CustomConverterTests.Dynamic.Sample.Tests.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private enum MyCustomEnum
2222
Hello = 77
2323
}
2424

25-
[Fact]
25+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
2626
public static void VerifyPrimitives()
2727
{
2828
var options = new JsonSerializerOptions();
@@ -67,7 +67,7 @@ public static void VerifyPrimitives()
6767
Assert.Equal(4.2, dbl);
6868
}
6969

70-
[Fact]
70+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
7171
public static void VerifyArray()
7272
{
7373
var options = new JsonSerializerOptions();
@@ -97,7 +97,7 @@ public static void VerifyArray()
9797
Assert.Equal(10, (int)obj.MyArray[0]);
9898
}
9999

100-
[Fact]
100+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
101101
public static void JsonDynamicTypes_Serialize()
102102
{
103103
var options = new JsonSerializerOptions();
@@ -149,7 +149,7 @@ public static void JsonDynamicTypes_Serialize()
149149
JsonTestHelper.AssertJsonEqual("{\"One\":1,\"Two\":2}", json);
150150
}
151151

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

167-
[Fact]
167+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
168168
public static void JsonDynamicTypes_Deserialize_AsObject()
169169
{
170170
var options = new JsonSerializerOptions();
@@ -181,7 +181,7 @@ public static void JsonDynamicTypes_Deserialize_AsObject()
181181
/// <summary>
182182
/// Use a mutable DOM with the 'dynamic' keyword.
183183
/// </summary>
184-
[Fact]
184+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
185185
public static void VerifyMutableDom_UsingDynamicKeyword()
186186
{
187187
var options = new JsonSerializerOptions();
@@ -221,7 +221,7 @@ public static void VerifyMutableDom_UsingDynamicKeyword()
221221
/// <summary>
222222
/// Use a mutable DOM without the 'dynamic' keyword.
223223
/// </summary>
224-
[Fact]
224+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
225225
public static void VerifyMutableDom_WithoutUsingDynamicKeyword()
226226
{
227227
var options = new JsonSerializerOptions();
@@ -263,7 +263,7 @@ public static void VerifyMutableDom_WithoutUsingDynamicKeyword()
263263
/// Use a mutable DOM without the 'dynamic' keyword and use round-trippable values
264264
/// meaning the 'JsonDynamicType' values are used instead of raw primitives.
265265
/// </summary>
266-
[Fact]
266+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
267267
public static void VerifyMutableDom_WithoutUsingDynamicKeyword_JsonDynamicType()
268268
{
269269
var options = new JsonSerializerOptions();
@@ -306,7 +306,7 @@ void Verify()
306306
}
307307
}
308308

309-
[Fact]
309+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
310310
public static void DynamicObject_MissingProperty()
311311
{
312312
var options = new JsonSerializerOptions();
@@ -317,7 +317,7 @@ public static void DynamicObject_MissingProperty()
317317
Assert.Equal(null, obj.NonExistingProperty);
318318
}
319319

320-
[Fact]
320+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
321321
public static void DynamicObject_CaseSensitivity()
322322
{
323323
var options = new JsonSerializerOptions();
@@ -338,7 +338,7 @@ public static void DynamicObject_CaseSensitivity()
338338
Assert.Equal(42, (int)obj.MYPROPERTY);
339339
}
340340

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

356-
[Fact]
356+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
357357
public static void NullHandling()
358358
{
359359
var options = new JsonSerializerOptions();
@@ -363,7 +363,7 @@ public static void NullHandling()
363363
Assert.Null(obj);
364364
}
365365

366-
[Fact]
366+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
367367
public static void QuotedNumbers_Deserialize()
368368
{
369369
var options = new JsonSerializerOptions();
@@ -381,7 +381,7 @@ public static void QuotedNumbers_Deserialize()
381381
Assert.Equal(float.NaN, (float)obj);
382382
}
383383

384-
[Fact]
384+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
385385
public static void QuotedNumbers_Serialize()
386386
{
387387
var options = new JsonSerializerOptions();

src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/DynamicTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ internal static ExpandoObject GetExpandoObject()
3737
return myDynamic;
3838
}
3939

40-
[Fact]
40+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
4141
public static void DynamicKeyword()
4242
{
4343
dynamic myDynamic = GetExpandoObject();
@@ -100,7 +100,7 @@ void VerifyArray()
100100
}
101101
}
102102

103-
[Fact]
103+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsReflectionEmitSupported))]
104104
public static void ExpandoObject()
105105
{
106106
ExpandoObject expando = JsonSerializer.Deserialize<ExpandoObject>(Json);

src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/NullableTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace System.Text.Json.Serialization.Tests
1111
public static partial class NullableTests
1212
{
1313
[Fact]
14+
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
1415
public static void DictionaryWithNullableValue()
1516
{
1617
Dictionary<string, float?> dictWithFloatValue = new Dictionary<string, float?> { { "key", 42.0f } };
@@ -170,6 +171,7 @@ public class SimpleClassWithDictionariesWithNullableValues
170171
}
171172

172173
[Fact]
174+
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
173175
public static void ClassWithDictionariesWithNullableValues()
174176
{
175177
string json =

src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/NumberHandlingTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ public class Class_With_ListsOfBoxedNonNumbers
360360

361361
[Fact]
362362
[ActiveIssue("https://github.com/dotnet/runtime/issues/49936", TestPlatforms.Android)]
363+
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
363364
public static void Number_AsCollectionElement_RoundTrip()
364365
{
365366
RunAsCollectionElementTest(JsonNumberTestData.Bytes);
@@ -603,6 +604,7 @@ private static void AssertDictionaryElements_StringValues(string serialized)
603604
[Fact]
604605
[ActiveIssue("https://github.com/dotnet/runtime/issues/39674", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoInterpreter))]
605606
[SkipOnCoreClr("https://github.com/dotnet/runtime/issues/45464", RuntimeConfiguration.Checked)]
607+
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
606608
public static void DictionariesRoundTrip()
607609
{
608610
RunAllDictionariessRoundTripTest(JsonNumberTestData.ULongs);

src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/Object.ReadTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ private ConcreteDerivedClassWithNoPublicDefaultCtor(string error)
368368
}
369369

370370
[Fact]
371+
[ActiveIssue("https://github.com/dotnet/runtime/issues/58204", TestPlatforms.iOS | TestPlatforms.tvOS)]
371372
public static void ReadClassWithStringToPrimitiveDictionary()
372373
{
373374
TestClassWithStringToPrimitiveDictionary obj = JsonSerializer.Deserialize<TestClassWithStringToPrimitiveDictionary>(TestClassWithStringToPrimitiveDictionary.s_data);

0 commit comments

Comments
 (0)