Skip to content

Commit ce366e1

Browse files
committed
Annotate test code.
1 parent cd8997e commit ce366e1

3 files changed

Lines changed: 37 additions & 36 deletions

File tree

PropertyChangedAnalyzers.Test/INPC003NotifyForDependentProperty/Valid.CaliburnMicro.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ namespace N
1818
{
1919
public class C : Caliburn.Micro.PropertyChangedBase
2020
{
21-
private string p;
21+
private string? p;
2222
23-
public string P
23+
public string? P
2424
{
2525
get { return this.p; }
2626
set { this.Set(ref this.p, value); }
@@ -38,9 +38,9 @@ namespace N
3838
{
3939
public class C : Caliburn.Micro.PropertyChangedBase
4040
{
41-
private string p;
41+
private string? p;
4242
43-
public string P
43+
public string? P
4444
{
4545
get => this.p;
4646
set => this.Set(ref this.p, value);
@@ -58,11 +58,11 @@ namespace N
5858
{
5959
public class C : Caliburn.Micro.PropertyChangedBase
6060
{
61-
private string p2;
61+
private string? p2;
6262
6363
public string P1 => $""Hello {this.p2}"";
6464
65-
public string P2
65+
public string? P2
6666
{
6767
get { return this.p2; }
6868
set
@@ -86,11 +86,11 @@ namespace N
8686
{
8787
public class C : Caliburn.Micro.PropertyChangedBase
8888
{
89-
private string p2;
89+
private string? p2;
9090
9191
public string P1 => $""Hello{this.P2}"";
9292
93-
public string P2
93+
public string? P2
9494
{
9595
get { return this.p2; }
9696
set

PropertyChangedAnalyzers.Test/INPC003NotifyForDependentProperty/Valid.GenericViewModelBase.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace PropertyChangedAnalyzers.Test.INPC003NotifyForDependentProperty
1+
namespace PropertyChangedAnalyzers.Test.INPC003NotifyForDependentProperty
22
{
33
using Gu.Roslyn.Asserts;
44
using NUnit.Framework;
@@ -20,9 +20,9 @@ public abstract class ViewModelBase<T> : INotifyPropertyChanged
2020
{
2121
public event PropertyChangedEventHandler? PropertyChanged;
2222
23-
protected virtual bool TrySet<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
23+
protected virtual bool TrySet<TValue>(ref TValue field, TValue value, [CallerMemberName] string? propertyName = null)
2424
{
25-
if (EqualityComparer<T>.Default.Equals(field, value))
25+
if (EqualityComparer<TValue>.Default.Equals(field, value))
2626
{
2727
return false;
2828
}
@@ -32,7 +32,7 @@ protected virtual bool TrySet<T>(ref T field, T value, [CallerMemberName] string
3232
return true;
3333
}
3434
35-
protected virtual void OnPropertyChanged<T>(Expression<Func<T>> property)
35+
protected virtual void OnPropertyChanged<TValue>(Expression<Func<TValue>> property)
3636
{
3737
this.OnPropertyChanged(((MemberExpression)property.Body).Member.Name);
3838
}
@@ -52,9 +52,9 @@ namespace N.Client
5252
{
5353
public class C : N.Core.ViewModelBase<int>
5454
{
55-
private string p;
55+
private string? p;
5656
57-
public string P
57+
public string? P
5858
{
5959
get { return this.p; }
6060
set { this.TrySet(ref this.p, value); }
@@ -102,9 +102,9 @@ namespace N.Client
102102
{
103103
public class C : N.Core.ViewModelBase
104104
{
105-
private string p;
105+
private string? p;
106106
107-
public string P
107+
public string? P
108108
{
109109
get { return this.p; }
110110
set { this.TrySet(ref this.p, value); }
@@ -122,9 +122,9 @@ namespace N.Client
122122
{
123123
public class C : N.Core.ViewModelBase<int>
124124
{
125-
private string p;
125+
private string? p;
126126
127-
public string P
127+
public string? P
128128
{
129129
get => this.p;
130130
set => this.TrySet(ref this.p, value);
@@ -142,11 +142,11 @@ namespace N.Client
142142
{
143143
public class C : N.Core.ViewModelBase<int>
144144
{
145-
private string p2;
145+
private string? p2;
146146
147147
public string P1 => $""Hello {this.P2}"";
148148
149-
public string P2
149+
public string? P2
150150
{
151151
get { return this.p2; }
152152
set
@@ -170,11 +170,11 @@ namespace N.Client
170170
{
171171
public class C : N.Core.ViewModelBase<int>
172172
{
173-
private string p2;
173+
private string? p2;
174174
175175
public string P1 => $""Hello {this.P2}"";
176176
177-
public string P2
177+
public string? P2
178178
{
179179
get { return this.p2; }
180180
set
@@ -198,11 +198,11 @@ namespace N
198198
{
199199
public class C : N.Core.ViewModelBase<int>
200200
{
201-
private string p2;
201+
private string? p2;
202202
203203
public string P1 => $""Hello {this.P2}"";
204204
205-
public string P2
205+
public string? P2
206206
{
207207
get => this.p2;
208208
set => this.TrySet(ref this.p2, value, string.Empty);
@@ -220,11 +220,11 @@ namespace N.Client
220220
{
221221
public class C : N.Core.ViewModelBase<int>
222222
{
223-
private string p2;
223+
private string? p2;
224224
225225
public string P1 => $""Hello{this.P2}"";
226226
227-
public string P2
227+
public string? P2
228228
{
229229
get { return this.p2; }
230230
set

PropertyChangedAnalyzers.Test/INPC003NotifyForDependentProperty/Valid.Ignore.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace PropertyChangedAnalyzers.Test.INPC003NotifyForDependentProperty
1+
namespace PropertyChangedAnalyzers.Test.INPC003NotifyForDependentProperty
22
{
33
using Gu.Roslyn.Asserts;
44
using NUnit.Framework;
@@ -23,14 +23,15 @@ public DelegateCommand(Func<object, bool> func)
2323
throw new NotImplementedException();
2424
}
2525
26-
public event EventHandler CanExecuteChanged;
26+
#pragma warning disable CS0067
27+
public event EventHandler? CanExecuteChanged;
2728
28-
public bool CanExecute(object parameter)
29+
public bool CanExecute(object? parameter)
2930
{
3031
throw new NotImplementedException();
3132
}
3233
33-
public void Execute(object parameter)
34+
public void Execute(object? parameter)
3435
{
3536
throw new NotImplementedException();
3637
}
@@ -45,7 +46,7 @@ namespace N
4546
public class C : INotifyPropertyChanged
4647
{
4748
private bool p;
48-
private DelegateCommand command;
49+
private DelegateCommand? command;
4950
5051
public event PropertyChangedEventHandler? PropertyChanged;
5152
@@ -354,11 +355,11 @@ namespace N
354355
355356
public class C : INotifyPropertyChanged
356357
{
357-
private string p;
358+
private string? p;
358359
359360
public event PropertyChangedEventHandler? PropertyChanged;
360361
361-
public string P => this.p;
362+
public string? P => this.p;
362363
363364
public C Create(string p)
364365
{
@@ -417,7 +418,7 @@ namespace N
417418
418419
public class C : INotifyPropertyChanged
419420
{
420-
private string p;
421+
private string p = ""abc"";
421422
private int getCount;
422423
423424
public event PropertyChangedEventHandler? PropertyChanged;
@@ -518,12 +519,12 @@ namespace N
518519
519520
public sealed class C : INotifyPropertyChanged, IDisposable
520521
{
521-
private string p;
522+
private string? p;
522523
private bool disposed;
523524
524525
public event PropertyChangedEventHandler? PropertyChanged;
525526
526-
public string P
527+
public string? P
527528
{
528529
get
529530
{

0 commit comments

Comments
 (0)