dotnet/roslyn

CSharpObjectFormatter throws NotSupportedException if it reaches ref struct property.

Aperta

#51.548 aperta il 28 feb 2021

 (0 commenti) (0 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-InteractiveBugInteractive-ScriptingLogichelp wanted

Metriche repository

Star
 (20.414 stelle)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

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.

Guida contributor