dotnet/roslyn

CSharpObjectFormatter throws NotSupportedException if it reaches ref struct property.

Aberta

#51.548 aberto em 28 de fev. de 2021

 (0 comentário) (0 reação) (0 responsável)C# (4.257 forks)batch import
Area-InteractiveBugInteractive-ScriptingLogichelp wanted

Métricas do repositório

Stars
 (20.414 estrelas)
Métricas de merge de PR
 (Mesclagem média 6d 17h) (256 fundiu PRs em 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.

Guia do colaborador