@@ -201,7 +201,7 @@ public virtual void OnPropertyChanged([System.Runtime.CompilerServices.CallerMem
201201 }" ) ;
202202 }
203203
204- // Helper to convert AccessorAccessibility to C# keyword for property (never empty)
204+ // Helper: C# keyword for property (never empty)
205205 static string ToPropertyAccessibilityString ( string access )
206206 {
207207 return access switch
@@ -216,15 +216,16 @@ static string ToPropertyAccessibilityString(string access)
216216 } ;
217217 }
218218
219- // Helper to get the accessor modifier (empty if matches property)
220- static string ToAccessorModifier ( string accessor , string propertyRaw )
219+ // Helper: Only emit accessor modifier if it differs from property (compare raw, not formatted )
220+ static string ToAccessorModifier ( string accessor , string propertyAccess )
221221 {
222- if ( string . Equals ( accessor , propertyRaw , System . StringComparison . OrdinalIgnoreCase ) || accessor == null )
222+ if ( string . IsNullOrEmpty ( accessor ) ) accessor = "Public" ;
223+ if ( string . Equals ( accessor , propertyAccess , System . StringComparison . OrdinalIgnoreCase ) )
223224 return "" ;
224225 return ToPropertyAccessibilityString ( accessor ) ;
225226 }
226227
227- // Helper to rank accessibilities for comparison
228+ // Helper: Accessibility rank
228229 static int GetAccessibilityRank ( string access )
229230 {
230231 return access switch
@@ -239,7 +240,7 @@ static int GetAccessibilityRank(string access)
239240 } ;
240241 }
241242
242- // Helper to get the widest (most accessible) accessibility
243+ // Helper: Widest accessibility (raw, e.g. "Public")
243244 static string GetWidestAccessibility ( string getter , string setter )
244245 {
245246 return GetAccessibilityRank ( getter ) >= GetAccessibilityRank ( setter ) ? getter : setter ;
@@ -282,13 +283,12 @@ static string GetWidestAccessibility(string getter, string setter)
282283 var getter = args . Length > 4 ? args [ 4 ] . Value : null ;
283284 var setter = args . Length > 5 ? args [ 5 ] . Value : null ;
284285
285- // Get string values for getter/setter, defaulting to "Public"
286286 string getterValue = ( getter ?? "Public" ) . ToString ( ) ;
287287 string setterValue = ( setter ?? "Public" ) . ToString ( ) ;
288- string propertyAccessRaw = GetWidestAccessibility ( getterValue , setterValue ) ; // e.g., "Public"
289- string propertyAccessibilityStr = ToPropertyAccessibilityString ( propertyAccessRaw ) ; // e.g., "public "
290- string getterStr = ToAccessorModifier ( getterValue , propertyAccessRaw ) ; // e.g., "" if getter is "Public"
291- string setterStr = ToAccessorModifier ( setterValue , propertyAccessRaw ) ; // e.g., "private " if setter is "Private"
288+ string propertyAccessRaw = GetWidestAccessibility ( getterValue , setterValue ) ; // e.g. "Public"
289+ string propertyAccessibilityStr = ToPropertyAccessibilityString ( propertyAccessRaw ) ; // e.g. "public "
290+ string getterStr = ToAccessorModifier ( getterValue , propertyAccessRaw ) ; // "" if getter is "Public"
291+ string setterStr = ToAccessorModifier ( setterValue , propertyAccessRaw ) ; // "private " if setter is "Private"
292292
293293 var lockerArg = threadSafe ? "_Locker" : "null" ;
294294 var notifyArg = notify ? "true" : "false" ;
@@ -355,13 +355,12 @@ static string GetWidestAccessibility(string getter, string setter)
355355 var getter = args . Length > 2 ? args [ 2 ] . Value : null ;
356356 var setter = args . Length > 3 ? args [ 3 ] . Value : null ;
357357
358- // Get string values for getter/setter, defaulting to "Public"
359358 string getterValue = ( getter ?? "Public" ) . ToString ( ) ;
360359 string setterValue = ( setter ?? "Public" ) . ToString ( ) ;
361- string propertyAccessRaw = GetWidestAccessibility ( getterValue , setterValue ) ; // e.g., "Public"
362- string propertyAccessibilityStr = ToPropertyAccessibilityString ( propertyAccessRaw ) ; // e.g., "public "
363- string getterStr = ToAccessorModifier ( getterValue , propertyAccessRaw ) ; // e.g., "" if getter is "Public"
364- string setterStr = ToAccessorModifier ( setterValue , propertyAccessRaw ) ; // e.g., "private " if setter is "Private"
360+ string propertyAccessRaw = GetWidestAccessibility ( getterValue , setterValue ) ; // e.g. "Public"
361+ string propertyAccessibilityStr = ToPropertyAccessibilityString ( propertyAccessRaw ) ; // e.g. "public "
362+ string getterStr = ToAccessorModifier ( getterValue , propertyAccessRaw ) ; // "" if getter is "Public"
363+ string setterStr = ToAccessorModifier ( setterValue , propertyAccessRaw ) ; // "private " if setter is "Private"
365364
366365 var lockerArg = threadSafe ? "_Locker" : "null" ;
367366 if ( readOnly )
0 commit comments