dotnet/roslyn

CSharpObjectFormatter throws NotSupportedException if it reaches ref struct property.

Open

#51,548 opened on Feb 28, 2021

View on GitHub
 (0 comments) (0 reactions) (0 assignees)C# (4,257 forks)batch import
Area-InteractiveBugInteractive-ScriptingLogichelp wanted

Repository metrics

Stars
 (20,414 stars)
PR merge metrics
 (Avg merge 6d 17h) (256 merged PRs in 30d)

Description

Version Used: Microsoft.CodeAnalysis.CSharp.Scripting 3.8.0 and 3.9.0-5.final (I tested both)

Steps to Reproduce:

ref struct X {};
class Y { public X x => default; };
CSharpObjectFormatter.Instance.FormatObject(new Y()); // dies

Expected Behavior:

CSharpObjectFormatter to ignore properties that are ref structs.

Actual Behavior:

CSharpObjectFormatter tries to fetch the value of the ref struct property with reflection, which throws because reflection does not support ref structs.

Contributor guide