forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add [DebuggerDisplay] to Json types (dotnet/corefx#38275)
* Add [DebuggerDisplay] to Json types Note that there is an issue with turning the TokenType to string in Utf8JsonReader. Probably reflection related? I've been unable to create a more focused repro. * Add some simple sanity tests * Address some feedback. * Use JsonValueType Commit migrated from dotnet/corefx@b506d4a
- Loading branch information
1 parent
760185c
commit 82f07be
Showing
9 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.IO; | ||
using System.Reflection; | ||
using Xunit; | ||
|
||
namespace System.Text.Json.Tests | ||
{ | ||
public class DebuggerTests | ||
{ | ||
[Fact] | ||
public void DefaultJsonElement() | ||
{ | ||
// Validating that we don't throw on default | ||
JsonElement element = default; | ||
GetDebuggerDisplayProperty(element); | ||
} | ||
|
||
[Fact] | ||
public void DefaultJsonProperty() | ||
{ | ||
// Validating that we don't throw on default | ||
JsonProperty property = default; | ||
GetDebuggerDisplayProperty(property); | ||
} | ||
|
||
[Fact] | ||
public void DefaultUtf8JsonWriter() | ||
{ | ||
// Validating that we don't throw on new object | ||
Utf8JsonWriter writer = new Utf8JsonWriter(new MemoryStream()); | ||
GetDebuggerDisplayProperty(writer); | ||
} | ||
|
||
private static string GetDebuggerDisplayProperty<T>(T value) | ||
{ | ||
return (string)typeof(T).GetProperty("DebuggerDisplay", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters