@@ -609,6 +609,7 @@ partial class MemberMeta
609609 public int Order { get ; }
610610 public bool HasExplicitOrder { get ; }
611611 public MemberKind Kind { get ; }
612+ public string DefaultValueExpression { get ; } = "default!" ;
612613
613614 MemberMeta ( int order )
614615 {
@@ -638,8 +639,12 @@ public MemberMeta(ISymbol symbol, IMethodSymbol? constructor, ReferenceSymbols r
638639
639640 if ( constructor != null )
640641 {
641- this . IsConstructorParameter = constructor . TryGetConstructorParameter ( symbol , out var constructorParameterName ) ;
642- this . ConstructorParameterName = constructorParameterName ;
642+ this . IsConstructorParameter = constructor . TryGetConstructorParameter ( symbol , out var constructorParameter ) ;
643+ this . ConstructorParameterName = constructorParameter ? . Name ;
644+ if ( constructorParameter ? . HasExplicitDefaultValue == true )
645+ {
646+ DefaultValueExpression = EmitConstantValue ( constructorParameter . ExplicitDefaultValue ) ;
647+ }
643648 }
644649 else
645650 {
@@ -657,7 +662,10 @@ public MemberMeta(ISymbol symbol, IMethodSymbol? constructor, ReferenceSymbols r
657662#endif
658663 ;
659664 MemberType = f . Type ;
660-
665+ if ( f . HasConstantValue )
666+ {
667+ DefaultValueExpression = EmitConstantValue ( f . ConstantValue ) ;
668+ }
661669 }
662670 else if ( symbol is IPropertySymbol p )
663671 {
@@ -670,6 +678,16 @@ public MemberMeta(ISymbol symbol, IMethodSymbol? constructor, ReferenceSymbols r
670678#endif
671679 && ( p . SetMethod != null && ! p . SetMethod . IsInitOnly ) ;
672680 MemberType = p . Type ;
681+
682+ // Detect default value
683+ foreach ( var syntaxReference in p . DeclaringSyntaxReferences )
684+ {
685+ if ( syntaxReference . GetSyntax ( ) is PropertyDeclarationSyntax { Initializer : { } initializer } )
686+ {
687+ DefaultValueExpression = initializer . Value . ToString ( ) ;
688+ break ;
689+ }
690+ }
673691 }
674692 else
675693 {
0 commit comments