dotnet/roslyn

CSharpObjectFormatter throws NotSupportedException if it reaches ref struct property.

開放

#51,548 建立於 2021年2月28日

 (0 則留言) (0 個反應) (0 位負責人)C# (4,257 個分叉)batch import
Area-InteractiveBugInteractive-ScriptingLogichelp wanted

倉庫指標

星標
 (20,414 顆星)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 256 個 PR)

描述

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.

貢獻者指南