@@ -66,7 +66,7 @@ public partial class TypeMeta
6666 public ( ushort Tag , INamedTypeSymbol Type ) [ ] UnionTags { get ; }
6767 public bool IsUseEmptyConstructor => Constructor == null || Constructor . Parameters . IsEmpty ;
6868
69- public TypeMeta ( INamedTypeSymbol symbol , ReferenceSymbols reference )
69+ public TypeMeta ( SemanticModel semanticModel , INamedTypeSymbol symbol , ReferenceSymbols reference )
7070 {
7171 this . reference = reference ;
7272 this . Symbol = symbol ;
@@ -104,7 +104,7 @@ public TypeMeta(INamedTypeSymbol symbol, ReferenceSymbols reference)
104104 }
105105 return true ;
106106 } )
107- . Select ( ( x , i ) => new MemberMeta ( x , Constructor , reference , i ) )
107+ . Select ( ( x , i ) => new MemberMeta ( semanticModel , x , Constructor , reference , i ) )
108108 . OrderBy ( x => x . Order )
109109 . ToArray ( ) ;
110110
@@ -616,6 +616,7 @@ partial class MemberMeta
616616 public bool HasExplicitOrder { get ; }
617617 public MemberKind Kind { get ; }
618618 public string DefaultValueExpression { get ; } = "default!" ;
619+ readonly SemanticModel semanticModel ;
619620
620621 MemberMeta ( int order )
621622 {
@@ -626,8 +627,9 @@ partial class MemberMeta
626627 this . Kind = MemberKind . Blank ;
627628 }
628629
629- public MemberMeta ( ISymbol symbol , IMethodSymbol ? constructor , ReferenceSymbols references , int sequentialOrder )
630+ public MemberMeta ( SemanticModel semanticModel , ISymbol symbol , IMethodSymbol ? constructor , ReferenceSymbols references , int sequentialOrder )
630631 {
632+ this . semanticModel = semanticModel ;
631633 this . Symbol = symbol ;
632634 this . Name = symbol . Name ;
633635 this . Order = sequentialOrder ;
@@ -677,13 +679,13 @@ public MemberMeta(ISymbol symbol, IMethodSymbol? constructor, ReferenceSymbols r
677679 {
678680 if ( variables . First ( ) . Initializer is { } initializer )
679681 {
680- DefaultValueExpression = initializer . Value . ToString ( ) ;
682+ DefaultValueExpression = EmitExpression ( initializer . Value ) ;
681683 break ;
682684 }
683685 }
684686 if ( syntax is VariableDeclaratorSyntax { Initializer : { } initializer2 } )
685687 {
686- DefaultValueExpression = initializer2 . Value . ToString ( ) ;
688+ DefaultValueExpression = EmitExpression ( initializer2 . Value ) ;
687689 break ;
688690 }
689691 }
@@ -705,7 +707,7 @@ public MemberMeta(ISymbol symbol, IMethodSymbol? constructor, ReferenceSymbols r
705707 {
706708 if ( syntaxReference . GetSyntax ( ) is PropertyDeclarationSyntax { Initializer : { } initializer } )
707709 {
708- DefaultValueExpression = initializer . Value . ToString ( ) ;
710+ DefaultValueExpression = EmitExpression ( initializer . Value ) ;
709711 break ;
710712 }
711713 }
0 commit comments