Skip to content

Commit 5cbf90f

Browse files
committed
Annotate test code.
1 parent 6f4e1d0 commit 5cbf90f

8 files changed

Lines changed: 84 additions & 86 deletions

File tree

PropertyChangedAnalyzers.Test/INPC016NotifyAfterUpdate/Valid.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace PropertyChangedAnalyzers.Test.INPC016NotifyAfterUpdate
1+
namespace PropertyChangedAnalyzers.Test.INPC016NotifyAfterUpdate
22
{
33
using Gu.Roslyn.Asserts;
44
using Microsoft.CodeAnalysis;
@@ -53,7 +53,6 @@ public static void OnPropertyChangedAfterAssign()
5353
namespace N
5454
{
5555
using System.ComponentModel;
56-
using System.Runtime.CompilerServices;
5756
5857
public class C : INotifyPropertyChanged
5958
{
@@ -97,7 +96,6 @@ public static void PropertyChangedInvokeAfterAssign()
9796
namespace N
9897
{
9998
using System.ComponentModel;
100-
using System.Runtime.CompilerServices;
10199
102100
public class C : INotifyPropertyChanged
103101
{
@@ -143,11 +141,11 @@ namespace N.Client
143141
{
144142
public class C : N.Core.ViewModelBase
145143
{
146-
private string p2;
144+
private string? p2;
147145
148146
public string P1 => $""Hello {this.P2}"";
149147
150-
public string P2
148+
public string? P2
151149
{
152150
get { return this.p2; }
153151
set
@@ -170,11 +168,11 @@ namespace N.Client
170168
{
171169
public class C : N.Core.ViewModelBase
172170
{
173-
private string p2;
171+
private string? p2;
174172
175173
public string P1 => $""Hello {this.P2}"";
176174
177-
public string P2
175+
public string? P2
178176
{
179177
get { return this.p2; }
180178
set
@@ -201,11 +199,11 @@ namespace N.Client
201199
{
202200
public class C : N.Core.ViewModelBase
203201
{
204-
private string p2;
202+
private string? p2;
205203
206204
public string P1 => $""Hello {this.P2}"";
207205
208-
public string P2
206+
public string? P2
209207
{
210208
get { return this.p2; }
211209
set
@@ -228,11 +226,11 @@ namespace N.Client
228226
{
229227
public class C : N.Core.ViewModelBase
230228
{
231-
private string p2;
229+
private string? p2;
232230
233231
public string P1 => $""Hello {this.P2}"";
234232
235-
public string P2
233+
public string? P2
236234
{
237235
get { return this.p2; }
238236
set

PropertyChangedAnalyzers.Test/INPC017BackingFieldNameMustMatch/CodeFix.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace PropertyChangedAnalyzers.Test.INPC017BackingFieldNameMustMatch
1+
namespace PropertyChangedAnalyzers.Test.INPC017BackingFieldNameMustMatch
22
{
33
using Gu.Roslyn.Asserts;
44
using NUnit.Framework;
@@ -21,7 +21,7 @@ namespace N
2121
{
2222
public class C
2323
{
24-
private int wrong;
24+
private int wrong = 1;
2525
2626
public int P => this.↓wrong;
2727
}
@@ -32,7 +32,7 @@ namespace N
3232
{
3333
public class C
3434
{
35-
private int p;
35+
private int p = 1;
3636
3737
public int P => this.p;
3838
}
@@ -52,7 +52,7 @@ namespace N
5252
{
5353
public class C
5454
{
55-
private int _wrong;
55+
private int _wrong = 1;
5656
5757
public int P => ↓_wrong;
5858
}
@@ -63,7 +63,7 @@ namespace N
6363
{
6464
public class C
6565
{
66-
private int _p;
66+
private int _p = 1;
6767
6868
public int P => _p;
6969
}
@@ -83,7 +83,7 @@ namespace N
8383
{
8484
public class C
8585
{
86-
private int wrong;
86+
private int wrong = 1;
8787
8888
public int P
8989
{
@@ -96,7 +96,7 @@ namespace N
9696
{
9797
public class C
9898
{
99-
private int p;
99+
private int p = 1;
100100
101101
public int P
102102
{
@@ -120,7 +120,7 @@ namespace N
120120
{
121121
public class C
122122
{
123-
private int wrong;
123+
private int wrong = 1;
124124
125125
public int P
126126
{
@@ -134,7 +134,7 @@ namespace N
134134
{
135135
public class C
136136
{
137-
private int p;
137+
private int p = 1;
138138
139139
public int P
140140
{
@@ -158,7 +158,7 @@ namespace N
158158
{
159159
public class C
160160
{
161-
private int _wrong;
161+
private int _wrong = 1;
162162
163163
public int P
164164
{
@@ -171,7 +171,7 @@ namespace N
171171
{
172172
public class C
173173
{
174-
private int _p;
174+
private int _p = 1;
175175
176176
public int P
177177
{

PropertyChangedAnalyzers.Test/INPC017BackingFieldNameMustMatch/Valid.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public static void NotifyingProperty()
1616
namespace N
1717
{
1818
using System.ComponentModel;
19-
using System.Runtime.CompilerServices;
2019
2120
public class C : INotifyPropertyChanged
2221
{
@@ -61,7 +60,7 @@ namespace N
6160
{
6261
public class C
6362
{
64-
private int p;
63+
private int p = 1;
6564
6665
public int P => this.p;
6766
}
@@ -78,7 +77,7 @@ namespace N
7877
{
7978
public class C
8079
{
81-
private int @default;
80+
private int @default = 1;
8281
8382
public int Default => this.@default;
8483
}
@@ -260,24 +259,24 @@ namespace N
260259
{
261260
public class C<T> : I
262261
{
263-
private T p;
262+
private T? p;
264263
265-
public T P
264+
public T? P
266265
{
267266
get => this.p;
268267
set => this.p = value;
269268
}
270269
271-
object I.P
270+
object? I.P
272271
{
273272
get => this.p;
274-
set => this.P = (T)value;
273+
set => this.P = (T?)value;
275274
}
276275
}
277276
278277
interface I
279278
{
280-
object P { get; set; }
279+
object? P { get; set; }
281280
}
282281
}";
283282

@@ -294,7 +293,7 @@ namespace N
294293
295294
public class C
296295
{
297-
private int[] ints;
296+
private int[] ints = new int[1];
298297
299298
public int Sum => this.ints.Sum();
300299
}
@@ -311,7 +310,7 @@ namespace N
311310
{
312311
public class C
313312
{
314-
private string text;
313+
private string text = string.Empty;
315314
316315
public int TextLength => this.text.Length;
317316
}
@@ -332,8 +331,8 @@ namespace N
332331
333332
public class C : INotifyPropertyChanged
334333
{
335-
private int f1;
336-
private int f2;
334+
private int f1 = 1;
335+
private int f2 = 2;
337336
private E p2;
338337
339338
public event PropertyChangedEventHandler? PropertyChanged;
@@ -445,9 +444,9 @@ namespace N
445444
{
446445
public class C
447446
{
448-
private string inpcEnabled;
447+
private string? inpcEnabled;
449448
450-
public string INPCEnabled
449+
public string? INPCEnabled
451450
{
452451
get => this.inpcEnabled;
453452
set => this.inpcEnabled = value;
@@ -466,9 +465,9 @@ namespace N
466465
{
467466
public class C
468467
{
469-
private string _inpcEnabled;
468+
private string? _inpcEnabled;
470469
471-
public string INPCEnabled
470+
public string? INPCEnabled
472471
{
473472
get => _inpcEnabled;
474473
set => _inpcEnabled = value;

PropertyChangedAnalyzers.Test/INPC018InvokerShouldBeProtected/Valid.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace PropertyChangedAnalyzers.Test.INPC018InvokerShouldBeProtected
1+
namespace PropertyChangedAnalyzers.Test.INPC018InvokerShouldBeProtected
22
{
33
using Gu.Roslyn.Asserts;
44
using NUnit.Framework;
@@ -14,7 +14,6 @@ public static void ProtectedOnPropertyChanged()
1414
namespace N
1515
{
1616
using System.ComponentModel;
17-
using System.Runtime.CompilerServices;
1817
1918
public class C : INotifyPropertyChanged
2019
{
@@ -37,7 +36,6 @@ public static void PrivateOnPropertyChangedInSealed()
3736
namespace N
3837
{
3938
using System.ComponentModel;
40-
using System.Runtime.CompilerServices;
4139
4240
public sealed class C : INotifyPropertyChanged
4341
{

0 commit comments

Comments
 (0)