@@ -27,9 +27,10 @@ internal sealed class ClassicObservabilityStrategyImpl : IObservabilityStrategy
27
27
private readonly IMethod ? _baseOnPropertyChangedOverridableMethod ;
28
28
private readonly IMethod ? _baseOnChildPropertyChangedMethod ;
29
29
private readonly IMethod ? _baseOnObservablePropertyChangedMethod ;
30
- private readonly Assets _assets ;
31
30
private readonly bool _targetImplementsInpc ;
32
31
32
+ public Assets Assets { get ; }
33
+
33
34
// Useful to see when debugging:
34
35
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
35
36
private readonly bool _baseImplementsInpc ;
@@ -52,23 +53,23 @@ public ClassicObservabilityStrategyImpl( IAspectBuilder<INamedType> aspectBuilde
52
53
var target = aspectBuilder . Target ;
53
54
54
55
this . AspectBuilder = aspectBuilder ;
55
- this . _assets = target . Compilation . Cache . GetOrAdd ( _ => new Assets ( ) ) ;
56
- this . InpcInstrumentationKindLookup = new InpcInstrumentationKindLookup ( this . CurrentType , this . _assets ) ;
56
+ this . Assets = target . Compilation . Cache . GetOrAdd ( _ => new Assets ( ) ) ;
57
+ this . InpcInstrumentationKindLookup = new InpcInstrumentationKindLookup ( this . CurrentType , this . Assets ) ;
57
58
this . _commonOptions = this . CurrentType . Enhancements ( ) . GetOptions < ObservabilityOptions > ( ) ;
58
59
this . _classicOptions = this . CurrentType . Enhancements ( ) . GetOptions < ClassicObservabilityStrategyOptions > ( ) ;
59
60
60
61
// TODO: Consider using BaseType.Definition where possible for better performance.
61
62
62
63
this . _baseImplementsInpc =
63
64
target . BaseType != null && (
64
- target . BaseType . Is ( this . _assets . INotifyPropertyChanged )
65
+ target . BaseType . Is ( this . Assets . INotifyPropertyChanged )
65
66
|| ( target . BaseType is { BelongsToCurrentProject : true }
66
67
&& target . BaseType . Definition . Enhancements ( ) . HasAspect ( typeof ( ObservableAttribute ) ) ) ) ;
67
68
68
- this . _targetImplementsInpc = this . _baseImplementsInpc || target . Is ( this . _assets . INotifyPropertyChanged ) ;
69
+ this . _targetImplementsInpc = this . _baseImplementsInpc || target . Is ( this . Assets . INotifyPropertyChanged ) ;
69
70
( this . _baseOnPropertyChangedInvocableMethod , this . _baseOnPropertyChangedOverridableMethod ) = GetOnPropertyChangedMethods ( target ) ;
70
71
this . _baseOnChildPropertyChangedMethod = GetOnChildPropertyChangedMethod ( target ) ;
71
- this . _baseOnObservablePropertyChangedMethod = GetOnObservablePropertyChangedMethod ( target , this . _assets ) ;
72
+ this . _baseOnObservablePropertyChangedMethod = GetOnObservablePropertyChangedMethod ( target , this . Assets ) ;
72
73
73
74
var useOnObservablePropertyChangedMethod =
74
75
this . _classicOptions . EnableOnObservablePropertyChangedMethod == true &&
@@ -128,7 +129,7 @@ public void BuildAspect( IAspectBuilder<INamedType> builder )
128
129
this . _commonOptions ,
129
130
this . _classicOptions ,
130
131
this . CurrentType ,
131
- this . _assets ,
132
+ this . Assets ,
132
133
this . InpcInstrumentationKindLookup ,
133
134
this . ObservableTypeInfo ,
134
135
this . _onObservablePropertyChangedMethod ? . Value ,
@@ -154,7 +155,7 @@ private bool ValidateRootAutoProperties()
154
155
. Where (
155
156
p =>
156
157
p is { IsStatic : false , IsAutoPropertyOrField : true }
157
- && ! p . Attributes . Any ( this . _assets . NotObservableAttribute ) ) ;
158
+ && ! p . Attributes . Any ( this . Assets . NotObservableAttribute ) ) ;
158
159
159
160
var allValid = true ;
160
161
@@ -316,7 +317,7 @@ private bool TryIntroduceOnChildPropertyChangedMethod()
316
317
{
317
318
b . AddAttribute (
318
319
AttributeConstruction . Create (
319
- this . _assets . InvokedForAttribute ,
320
+ this . Assets . InvokedForAttribute ,
320
321
this . _propertyPathsForOnChildPropertyChangedMethod . OrderBy ( s => s ) . ToArray ( ) ) ) ;
321
322
}
322
323
@@ -383,7 +384,7 @@ private bool TryIntroduceOnObservablePropertyChanged()
383
384
{
384
385
b . AddAttribute (
385
386
AttributeConstruction . Create (
386
- this . _assets . InvokedForAttribute ,
387
+ this . Assets . InvokedForAttribute ,
387
388
this . _propertyNamesForOnObservablePropertyChangedMethod . OrderBy ( s => s ) . ToArray ( ) ) ) ;
388
389
}
389
390
@@ -447,7 +448,7 @@ private void IntroduceInterfaceIfRequired()
447
448
if ( ! this . _targetImplementsInpc )
448
449
{
449
450
this . AspectBuilder . Advice . WithTemplateProvider ( Templates . Provider )
450
- . ImplementInterface ( this . CurrentType , this . _assets . INotifyPropertyChanged ) ;
451
+ . ImplementInterface ( this . CurrentType , this . Assets . INotifyPropertyChanged ) ;
451
452
}
452
453
}
453
454
@@ -539,7 +540,7 @@ private void ProcessAutoPropertiesAndReferencedFields()
539
540
target . Fields
540
541
. Where ( f => f is { IsStatic : false , IsImplicitlyDeclared : false } )
541
542
. Select ( p => ( ClassicObservablePropertyInfo ) this . ObservableTypeInfo . GetOrAddProperty ( p ) ) )
542
- . Where ( node => ! node . FieldOrProperty . Attributes . Any ( this . _assets . NotObservableAttribute ) )
543
+ . Where ( node => ! node . FieldOrProperty . Attributes . Any ( this . Assets . NotObservableAttribute ) )
543
544
. ToList ( ) ;
544
545
545
546
foreach ( var propertyInfo in properties )
@@ -645,7 +646,7 @@ private void ProcessAutoPropertiesAndReferencedFields()
645
646
public bool HasInheritedOnChildPropertyChangedPropertyPath ( string parentPropertyPath )
646
647
{
647
648
this . _inheritedOnChildPropertyChangedPropertyPaths ??=
648
- BuildPropertyPathLookup ( GetPropertyPaths ( this . _assets . InvokedForAttribute , this . _baseOnChildPropertyChangedMethod ) ) ;
649
+ BuildPropertyPathLookup ( GetPropertyPaths ( this . Assets . InvokedForAttribute , this . _baseOnChildPropertyChangedMethod ) ) ;
649
650
650
651
return this . _inheritedOnChildPropertyChangedPropertyPaths . Contains ( parentPropertyPath ) ;
651
652
}
@@ -657,7 +658,7 @@ public bool HasInheritedOnObservablePropertyChangedProperty( string propertyName
657
658
this . _inheritedOnObservablePropertyChangedPropertyNames ??=
658
659
BuildPropertyPathLookup (
659
660
GetPropertyPaths (
660
- this . _assets . InvokedForAttribute ,
661
+ this . Assets . InvokedForAttribute ,
661
662
this . _baseOnObservablePropertyChangedMethod ) ) ;
662
663
663
664
return this . _inheritedOnObservablePropertyChangedPropertyNames . Contains ( propertyName ) ;
@@ -721,7 +722,7 @@ private IField GetOrCreateHandlerField( ClassicObservableExpression node )
721
722
. IntroduceField (
722
723
this . CurrentType ,
723
724
handlerFieldName ,
724
- this . _assets . NullablePropertyChangedEventHandler ,
725
+ this . Assets . NullablePropertyChangedEventHandler ,
725
726
IntroductionScope . Instance ,
726
727
OverrideStrategy . Fail ,
727
728
b => b . Accessibility = Accessibility . Private ) ;
0 commit comments