|
3 | 3 |
|
4 | 4 | using System.Buffers;
|
5 | 5 | using System.IO;
|
6 |
| -using System.Linq; |
| 6 | +using System.Threading; |
| 7 | +using System.Threading.Tasks; |
7 | 8 | using Xunit;
|
8 | 9 |
|
9 | 10 | namespace System.Text.Json.Serialization.Tests
|
@@ -219,22 +220,36 @@ public static void DeepEquals_NotEqualValuesReturnFalse(string value1, string va
|
219 | 220 | }
|
220 | 221 |
|
221 | 222 | [Theory]
|
222 |
| - [InlineData(10)] |
223 |
| - [InlineData(100)] |
224 |
| - [InlineData(500)] |
| 223 | + [InlineData(5)] |
| 224 | + [InlineData(50)] |
225 | 225 | public static void DeepEquals_DeepJsonDocument(int depth)
|
226 | 226 | {
|
227 | 227 | using JsonDocument jDoc = CreateDeepJsonDocument(depth);
|
228 | 228 | JsonElement element = jDoc.RootElement;
|
229 | 229 | Assert.True(JsonElement.DeepEquals(element, element));
|
230 | 230 | }
|
231 | 231 |
|
232 |
| - [Fact] |
233 |
| - public static void DeepEquals_TooDeepJsonDocument_ThrowsInsufficientExecutionStackException() |
| 232 | + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))] |
| 233 | + [ActiveIssue("https://github.com/dotnet/runtime/issues/105490", TestRuntimes.Mono)] |
| 234 | + public static async Task DeepEquals_TooDeepJsonDocument_ThrowsInsufficientExecutionStackException() |
234 | 235 | {
|
235 |
| - using JsonDocument jDoc = CreateDeepJsonDocument(10_000); |
236 |
| - JsonElement element = jDoc.RootElement; |
237 |
| - Assert.Throws<InsufficientExecutionStackException>(() => JsonElement.DeepEquals(element, element)); |
| 236 | + var tcs = new TaskCompletionSource<bool>(); |
| 237 | + new Thread(() => |
| 238 | + { |
| 239 | + try |
| 240 | + { |
| 241 | + using JsonDocument jDoc = CreateDeepJsonDocument(10_000); |
| 242 | + JsonElement element = jDoc.RootElement; |
| 243 | + Assert.Throws<InsufficientExecutionStackException>(() => JsonElement.DeepEquals(element, element)); |
| 244 | + tcs.SetResult(true); |
| 245 | + } |
| 246 | + catch (Exception e) |
| 247 | + { |
| 248 | + tcs.SetException(e); |
| 249 | + } |
| 250 | + }, maxStackSize: 100_000) { IsBackground = true }.Start(); |
| 251 | + |
| 252 | + await tcs.Task; |
238 | 253 | }
|
239 | 254 |
|
240 | 255 | private static JsonDocument CreateDeepJsonDocument(int depth)
|
|
0 commit comments