Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DebuggerDisplay] for JsonTypeInfo does not render #65960

Closed
martincostello opened this issue Feb 28, 2022 · 2 comments · Fixed by #65971
Closed

[DebuggerDisplay] for JsonTypeInfo does not render #65960

martincostello opened this issue Feb 28, 2022 · 2 comments · Fixed by #65971
Assignees
Labels
area-System.Text.Json enhancement Product code improvement that does NOT require public API changes/additions
Milestone

Comments

@martincostello
Copy link
Member

Description

While debugging some code using the JSON source generator in Visual Studio 2022 I found that the debugger display for a JsonSerializerContext class is broken.

image

Instead of showing the intended display text, instead the IDE shows a message similar to ConverterStrategy.error CS0119: 'ConverterStrategy' is a type, which is not valid in the given context, "Boolean".

Following the code through, it looks like there's an issue with the value passed to the constructor of the [DebuggerDisplay] attribute on JsonTypeInfo here:

[DebuggerDisplay("ConverterStrategy.{ConverterStrategy}, {Type.Name}")]

Reproduction Steps

View a derived instance of `` using the JSON source generator in an IDE with Intellisense, such as Visual Studio 2022.

using System.Text.Json.Serialization;

var context = new CustomJsonSerializerContext();

// Put a breakpoint on the line below and inspect context in the debugger
Console.ReadLine();

[JsonSerializable(typeof(bool))]
internal sealed partial class CustomJsonSerializerContext : JsonSerializerContext
{
}

Expected behavior

A compiler error is not shown in the rendered debugger display for the class' properties.

Actual behavior

The properties all show a compiler error similar to the below.

ConverterStrategy.error CS0119: 'ConverterStrategy' is a type, which is not valid in the given context, "Boolean".

Regression?

No, this functionality was new in .NET 6.

Known Workarounds

None.

Configuration

> dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.200
 Commit:    4c30de7899

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.200\

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Text.Json untriaged New issue has not been triaged by the area owner labels Feb 28, 2022
@ghost
Copy link

ghost commented Feb 28, 2022

Tagging subscribers to this area: @dotnet/area-system-text-json
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

While debugging some code using the JSON source generator in Visual Studio 2022 I found that the debugger display for a JsonSerializerContext class is broken.

image

Instead of showing the intended display text, instead the IDE shows a message similar to ConverterStrategy.error CS0119: 'ConverterStrategy' is a type, which is not valid in the given context, "Boolean".

Following the code through, it looks like there's an issue with the value passed to the constructor of the [DebuggerDisplay] attribute on JsonTypeInfo here:

[DebuggerDisplay("ConverterStrategy.{ConverterStrategy}, {Type.Name}")]

Reproduction Steps

View a derived instance of `` using the JSON source generator in an IDE with Intellisense, such as Visual Studio 2022.

using System.Text.Json.Serialization;

var context = new CustomJsonSerializerContext();

// Put a breakpoint on the line below and inspect context in the debugger
Console.ReadLine();

[JsonSerializable(typeof(bool))]
internal sealed partial class CustomJsonSerializerContext : JsonSerializerContext
{
}

Expected behavior

A compiler error is not shown in the rendered debugger display for the class' properties.

Actual behavior

The properties all show a compiler error similar to the below.

ConverterStrategy.error CS0119: 'ConverterStrategy' is a type, which is not valid in the given context, "Boolean".

Regression?

No, this functionality was new in .NET 6.

Known Workarounds

None.

Configuration

> dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.200
 Commit:    4c30de7899

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.200\

Other information

No response

Author: martincostello
Assignees: -
Labels:

area-System.Text.Json, untriaged

Milestone: -

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Feb 28, 2022
@eiriktsarpalis
Copy link
Member

Thanks, I've been seeing this as well. It seems to be impacting a few internal serializer types as well. I submitted a fix in #65971

@eiriktsarpalis eiriktsarpalis added enhancement Product code improvement that does NOT require public API changes/additions and removed untriaged New issue has not been triaged by the area owner labels Feb 28, 2022
@eiriktsarpalis eiriktsarpalis added this to the 7.0.0 milestone Feb 28, 2022
@eiriktsarpalis eiriktsarpalis self-assigned this Feb 28, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Mar 4, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Apr 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Text.Json enhancement Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants