1- namespace PropertyChangedAnalyzers . Test . INPC001ImplementINotifyPropertyChanged
1+ namespace PropertyChangedAnalyzers . Test . INPC001ImplementINotifyPropertyChanged
22{
33 using Gu . Roslyn . Asserts ;
4+
45 using NUnit . Framework ;
56
7+ using PropertyChangedAnalyzers . Test . Helpers ;
8+
69 public static partial class Valid
710 {
811 private static readonly ClassDeclarationAnalyzer Analyzer = new ( ) ;
@@ -18,13 +21,12 @@ public static void CallsOnPropertyChanged(string propertyName)
1821namespace N
1922{
2023 using System.ComponentModel;
21- using System.Runtime.CompilerServices;
2224
2325 public class C : INotifyPropertyChanged
2426 {
2527 private int p;
2628
27- public event PropertyChangedEventHandler PropertyChanged;
29+ public event PropertyChangedEventHandler? PropertyChanged;
2830
2931 public int P
3032 {
@@ -59,13 +61,12 @@ public static void CallsRaisePropertyChangedWithEventArgs(string propertyName)
5961namespace N
6062{
6163 using System.ComponentModel;
62- using System.Runtime.CompilerServices;
6364
6465 public class C : INotifyPropertyChanged
6566 {
6667 private int p;
6768
68- public event PropertyChangedEventHandler PropertyChanged;
69+ public event PropertyChangedEventHandler? PropertyChanged;
6970
7071 public int P
7172 {
@@ -101,7 +102,7 @@ public class C : INotifyPropertyChanged
101102 {
102103 private int p;
103104
104- public event PropertyChangedEventHandler PropertyChanged;
105+ public event PropertyChangedEventHandler? PropertyChanged;
105106
106107 public int P
107108 {
@@ -114,7 +115,7 @@ public int P
114115 }
115116 }
116117
117- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
118+ protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
118119 {
119120 this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
120121 }
@@ -140,7 +141,8 @@ namespace N
140141 public class C : INotifyPropertyChanged
141142 {
142143 private int p;
143- public event PropertyChangedEventHandler PropertyChanged;
144+
145+ public event PropertyChangedEventHandler? PropertyChanged;
144146
145147 public int P
146148 {
@@ -173,9 +175,10 @@ namespace N
173175 public class C : INotifyPropertyChanged
174176 {
175177 private static readonly PropertyChangedEventArgs PPropertyChangedArgs = new PropertyChangedEventArgs(nameof(P));
178+
176179 private int p;
177180
178- public event PropertyChangedEventHandler PropertyChanged;
181+ public event PropertyChangedEventHandler? PropertyChanged;
179182
180183 public int P
181184 {
@@ -210,7 +213,7 @@ public class C : INotifyPropertyChanged
210213 {
211214 private TimeSpan timeSpan;
212215
213- public event PropertyChangedEventHandler PropertyChanged;
216+ public event PropertyChangedEventHandler? PropertyChanged;
214217
215218 public long Ticks
216219 {
@@ -227,7 +230,7 @@ public long Ticks
227230 }
228231 }
229232
230- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
233+ protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
231234 {
232235 this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
233236 }
@@ -249,14 +252,14 @@ namespace N
249252
250253 public class ExceptionHandlingRelayCommand : ConditionRelayCommand
251254 {
252- private Exception _exception;
255+ private Exception? _exception;
253256
254257 public ExceptionHandlingRelayCommand(Action action, ICondition condition)
255258 : base(action, condition)
256259 {
257260 }
258261
259- public Exception Exception
262+ public Exception? Exception
260263 {
261264 get => _exception;
262265
@@ -274,7 +277,7 @@ private set
274277 }
275278}" ;
276279
277- RoslynAssert . Valid ( Analyzer , code ) ;
280+ RoslynAssert . Valid ( Analyzer , code , settings : LibrarySettings . Reactive ) ;
278281 }
279282 }
280283}
0 commit comments