@@ -10,25 +10,28 @@ protected Accessor(Context cx, IMethodSymbol init)
1010 : base ( cx , init ) { }
1111
1212 /// <summary>
13- /// Gets the property symbol associated with this accessor.
13+ /// Gets the property symbol associated accessor `symbol`, or `null`
14+ /// if there is no associated symbol.
1415 /// </summary>
15- IPropertySymbol PropertySymbol
16+ public static IPropertySymbol GetPropertySymbol ( IMethodSymbol symbol )
1617 {
17- get
18- {
19- // Usually, the property/indexer can be fetched from the associated symbol
20- var prop = symbol . AssociatedSymbol as IPropertySymbol ;
21- if ( prop != null )
22- return prop ;
18+ // Usually, the property/indexer can be fetched from the associated symbol
19+ var prop = symbol . AssociatedSymbol as IPropertySymbol ;
20+ if ( prop != null )
21+ return prop ;
2322
24- // But for properties/indexers that implement explicit interfaces, Roslyn
25- // does not properly populate `AssociatedSymbol`
26- var props = symbol . ContainingType . GetMembers ( ) . OfType < IPropertySymbol > ( ) ;
27- props = props . Where ( p => SymbolEqualityComparer . Default . Equals ( symbol , p . GetMethod ) || SymbolEqualityComparer . Default . Equals ( symbol , p . SetMethod ) ) ;
28- return props . SingleOrDefault ( ) ;
29- }
23+ // But for properties/indexers that implement explicit interfaces, Roslyn
24+ // does not properly populate `AssociatedSymbol`
25+ var props = symbol . ContainingType . GetMembers ( ) . OfType < IPropertySymbol > ( ) ;
26+ props = props . Where ( p => SymbolEqualityComparer . Default . Equals ( symbol , p . GetMethod ) || SymbolEqualityComparer . Default . Equals ( symbol , p . SetMethod ) ) ;
27+ return props . SingleOrDefault ( ) ;
3028 }
3129
30+ /// <summary>
31+ /// Gets the property symbol associated with this accessor.
32+ /// </summary>
33+ IPropertySymbol PropertySymbol => GetPropertySymbol ( symbol ) ;
34+
3235 public new Accessor OriginalDefinition => Create ( Context , symbol . OriginalDefinition ) ;
3336
3437 public override void Populate ( TextWriter trapFile )
0 commit comments