@@ -281,11 +281,13 @@ static string GetWidestAccessibility(string getter, string setter)
281281 if ( alsoNotify == null )
282282 alsoNotify = new string [ 0 ] ;
283283
284- var getter = args . Length > 4 ? args [ 4 ] . Value : null ;
285- var setter = args . Length > 5 ? args [ 5 ] . Value : null ;
284+ var getterEnum = args . Length > 4 ? args [ 4 ] . Value : null ;
285+ var setterEnum = args . Length > 5 ? args [ 5 ] . Value : null ;
286+
287+ // Convert the numeric enum value to its string representation
288+ string getterValue = getterEnum != null ? GetAccessibilityName ( ( int ) getterEnum ) : "Public" ;
289+ string setterValue = setterEnum != null ? GetAccessibilityName ( ( int ) setterEnum ) : "Public" ;
286290
287- string getterValue = ( getter ?? "Public" ) . ToString ( ) ;
288- string setterValue = ( setter ?? "Public" ) . ToString ( ) ;
289291 string propertyAccessRaw = GetWidestAccessibility ( getterValue , setterValue ) ; // e.g. "Public"
290292 string propertyAccessibilityStr = ToPropertyAccessibilityString ( propertyAccessRaw ) ; // e.g. "public "
291293 string getterStr = ToAccessorModifier ( getterValue , propertyAccessRaw ) ; // "" if getter is "Public"
@@ -371,11 +373,13 @@ static string GetWidestAccessibility(string getter, string setter)
371373 var args = info . AttributeData . ConstructorArguments ;
372374 var readOnly = args . Length > 0 && ( bool ) args [ 0 ] . Value ! ;
373375 var threadSafe = args . Length > 1 && ( bool ) args [ 1 ] . Value ! ;
374- var getter = args . Length > 2 ? args [ 2 ] . Value : null ;
375- var setter = args . Length > 3 ? args [ 3 ] . Value : null ;
376+ var getterEnum = args . Length > 2 ? args [ 2 ] . Value : null ;
377+ var setterEnum = args . Length > 3 ? args [ 3 ] . Value : null ;
378+
379+ // Convert the numeric enum value to its string representation
380+ string getterValue = getterEnum != null ? GetAccessibilityName ( ( int ) getterEnum ) : "Public" ;
381+ string setterValue = setterEnum != null ? GetAccessibilityName ( ( int ) setterEnum ) : "Public" ;
376382
377- string getterValue = ( getter ?? "Public" ) . ToString ( ) ;
378- string setterValue = ( setter ?? "Public" ) . ToString ( ) ;
379383 string propertyAccessRaw = GetWidestAccessibility ( getterValue , setterValue ) ; // e.g. "Public"
380384 string propertyAccessibilityStr = ToPropertyAccessibilityString ( propertyAccessRaw ) ; // e.g. "public "
381385 string getterStr = ToAccessorModifier ( getterValue , propertyAccessRaw ) ; // "" if getter is "Public"
@@ -432,6 +436,20 @@ private static bool ImplementsInterface(INamedTypeSymbol type, string interfaceN
432436 return type . AllInterfaces . Any ( i => i . ToDisplayString ( ) == interfaceName ) ;
433437 }
434438
439+ private static string GetAccessibilityName ( int value )
440+ {
441+ return value switch
442+ {
443+ 0 => "Public" ,
444+ 1 => "Private" ,
445+ 2 => "Protected" ,
446+ 3 => "Internal" ,
447+ 4 => "ProtectedInternal" ,
448+ 5 => "PrivateProtected" ,
449+ _ => "Public" // Default to Public for safety
450+ } ;
451+ }
452+
435453 private struct BindableFieldInfo
436454 {
437455 public IFieldSymbol FieldSymbol { get ; set ; }
0 commit comments