@@ -29,10 +29,12 @@ GenerateTextForItems(EnumerableTypes, item =>
29
29
[MethodImpl(MethodImplOptions.AggressiveInlining)]
30
30
public static void IsEmpty<T>(<#=item.Type#> <#=item.Name#>, string name)
31
31
{
32
- if (<#=item.Name#>.<#=item.Size#> ! = 0)
32
+ if (<#=item.Name#>.<#=item.Size#> = = 0)
33
33
{
34
- ThrowHelper.ThrowArgumentExceptionForIsEmpty(<#=item.Cast#><#=item.Name#>, name) ;
34
+ return ;
35
35
}
36
+
37
+ ThrowHelper.ThrowArgumentExceptionForIsEmpty(<#=item.Cast#><#=item.Name#>, name);
36
38
}
37
39
38
40
/// <summary>
@@ -45,29 +47,31 @@ GenerateTextForItems(EnumerableTypes, item =>
45
47
[MethodImpl(MethodImplOptions.AggressiveInlining)]
46
48
public static void IsNotEmpty<T>(<#=item.Type#> <#=item.Name#>, string name)
47
49
{
48
- if (<#=item.Name#>.<#=item.Size#> = = 0)
50
+ if (<#=item.Name#>.<#=item.Size#> ! = 0)
49
51
{
52
+ return;
53
+ }
54
+
50
55
<#
51
56
if (item.Type == "Span<T>")
52
57
{
53
58
#>
54
- ThrowHelper.ThrowArgumentExceptionForIsNotEmptyWithSpan<T>(name);
59
+ ThrowHelper.ThrowArgumentExceptionForIsNotEmptyWithSpan<T>(name);
55
60
<#
56
61
}
57
62
else if (item.Type == "ReadOnlySpan<T>")
58
63
{
59
64
#>
60
- ThrowHelper.ThrowArgumentExceptionForIsNotEmptyWithReadOnlySpan<T>(name);
65
+ ThrowHelper.ThrowArgumentExceptionForIsNotEmptyWithReadOnlySpan<T>(name);
61
66
<#
62
67
}
63
68
else
64
69
{
65
70
#>
66
- ThrowHelper.ThrowArgumentExceptionForIsNotEmpty<<#=item.Type#>>(name);
71
+ ThrowHelper.ThrowArgumentExceptionForIsNotEmpty<<#=item.Type#>>(name);
67
72
<#
68
73
}
69
74
#>
70
- }
71
75
}
72
76
73
77
/// <summary>
@@ -81,10 +85,12 @@ GenerateTextForItems(EnumerableTypes, item =>
81
85
[MethodImpl(MethodImplOptions.AggressiveInlining)]
82
86
public static void HasSizeEqualTo<T>(<#=item.Type#> <#=item.Name#>, int size, string name)
83
87
{
84
- if (<#=item.Name#>.<#=item.Size#> ! = size)
88
+ if (<#=item.Name#>.<#=item.Size#> = = size)
85
89
{
86
- ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(<#=item.Cast#><#=item.Name#>, size, name) ;
90
+ return ;
87
91
}
92
+
93
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(<#=item.Cast#><#=item.Name#>, size, name);
88
94
}
89
95
90
96
/// <summary>
@@ -98,10 +104,12 @@ GenerateTextForItems(EnumerableTypes, item =>
98
104
[MethodImpl(MethodImplOptions.AggressiveInlining)]
99
105
public static void HasSizeNotEqualTo<T>(<#=item.Type#> <#=item.Name#>, int size, string name)
100
106
{
101
- if (<#=item.Name#>.<#=item.Size#> = = size)
107
+ if (<#=item.Name#>.<#=item.Size#> ! = size)
102
108
{
103
- ThrowHelper.ThrowArgumentExceptionForHasSizeNotEqualTo(<#=item.Cast#><#=item.Name#>, size, name) ;
109
+ return ;
104
110
}
111
+
112
+ ThrowHelper.ThrowArgumentExceptionForHasSizeNotEqualTo(<#=item.Cast#><#=item.Name#>, size, name);
105
113
}
106
114
107
115
/// <summary>
@@ -115,10 +123,12 @@ GenerateTextForItems(EnumerableTypes, item =>
115
123
[MethodImpl(MethodImplOptions.AggressiveInlining)]
116
124
public static void HasSizeGreaterThan<T>(<#=item.Type#> <#=item.Name#>, int size, string name)
117
125
{
118
- if (<#=item.Name#>.<#=item.Size#> <= size)
126
+ if (<#=item.Name#>.<#=item.Size#> > size)
119
127
{
120
- ThrowHelper.ThrowArgumentExceptionForHasSizeGreaterThan(<#=item.Cast#><#=item.Name#>, size, name) ;
128
+ return ;
121
129
}
130
+
131
+ ThrowHelper.ThrowArgumentExceptionForHasSizeGreaterThan(<#=item.Cast#><#=item.Name#>, size, name);
122
132
}
123
133
124
134
/// <summary>
@@ -132,10 +142,12 @@ GenerateTextForItems(EnumerableTypes, item =>
132
142
[MethodImpl(MethodImplOptions.AggressiveInlining)]
133
143
public static void HasSizeGreaterThanOrEqualTo<T>(<#=item.Type#> <#=item.Name#>, int size, string name)
134
144
{
135
- if (<#=item.Name#>.<#=item.Size#> < size)
145
+ if (<#=item.Name#>.<#=item.Size#> >= size)
136
146
{
137
- ThrowHelper.ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(<#=item.Cast#><#=item.Name#>, size, name) ;
147
+ return ;
138
148
}
149
+
150
+ ThrowHelper.ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo(<#=item.Cast#><#=item.Name#>, size, name);
139
151
}
140
152
141
153
/// <summary>
@@ -149,10 +161,12 @@ GenerateTextForItems(EnumerableTypes, item =>
149
161
[MethodImpl(MethodImplOptions.AggressiveInlining)]
150
162
public static void HasSizeLessThan<T>(<#=item.Type#> <#=item.Name#>, int size, string name)
151
163
{
152
- if (<#=item.Name#>.<#=item.Size#> >= size)
164
+ if (<#=item.Name#>.<#=item.Size#> < size)
153
165
{
154
- ThrowHelper.ThrowArgumentExceptionForHasSizeLessThan(<#=item.Cast#><#=item.Name#>, size, name) ;
166
+ return ;
155
167
}
168
+
169
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThan(<#=item.Cast#><#=item.Name#>, size, name);
156
170
}
157
171
158
172
/// <summary>
@@ -166,10 +180,12 @@ GenerateTextForItems(EnumerableTypes, item =>
166
180
[MethodImpl(MethodImplOptions.AggressiveInlining)]
167
181
public static void HasSizeLessThanOrEqualTo<T>(<#=item.Type#> <#=item.Name#>, int size, string name)
168
182
{
169
- if (<#=item.Name#>.<#=item.Size#> > size)
183
+ if (<#=item.Name#>.<#=item.Size#> <= size)
170
184
{
171
- ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(<#=item.Cast#><#=item.Name#>, size, name) ;
185
+ return ;
172
186
}
187
+
188
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(<#=item.Cast#><#=item.Name#>, size, name);
173
189
}
174
190
175
191
/// <summary>
@@ -183,23 +199,25 @@ GenerateTextForItems(EnumerableTypes, item =>
183
199
[MethodImpl(MethodImplOptions.AggressiveInlining)]
184
200
public static void HasSizeEqualTo<T>(<#=item.Type#> source, <#=item.DestinationType#> destination, string name)
185
201
{
186
- if (source.<#=item.Size#> ! = destination.<#=item.Size#>)
202
+ if (source.<#=item.Size#> = = destination.<#=item.Size#>)
187
203
{
204
+ return;
205
+ }
206
+
188
207
<#
189
208
if (item.HasCountProperty)
190
209
{
191
210
#>
192
- ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(<#=item.Cast#>source, destination.<#=item.Size#>, name);
211
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(<#=item.Cast#>source, destination.<#=item.Size#>, name);
193
212
<#
194
213
}
195
214
else
196
215
{
197
216
#>
198
- ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(source, <#=item.Cast#>destination, name);
217
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(source, <#=item.Cast#>destination, name);
199
218
<#
200
219
}
201
220
#>
202
- }
203
221
}
204
222
205
223
/// <summary>
@@ -213,23 +231,25 @@ GenerateTextForItems(EnumerableTypes, item =>
213
231
[MethodImpl(MethodImplOptions.AggressiveInlining)]
214
232
public static void HasSizeLessThanOrEqualTo<T>(<#=item.Type#> source, <#=item.DestinationType#> destination, string name)
215
233
{
216
- if (source.<#=item.Size#> > destination.<#=item.Size#>)
234
+ if (source.<#=item.Size#> <= destination.<#=item.Size#>)
217
235
{
236
+ return;
237
+ }
238
+
218
239
<#
219
240
if (item.HasCountProperty)
220
241
{
221
242
#>
222
- ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(<#=item.Cast#>source, destination.<#=item.Size#>, name);
243
+ ThrowHelper.ThrowArgumentExceptionForHasSizeEqualTo(<#=item.Cast#>source, destination.<#=item.Size#>, name);
223
244
<#
224
245
}
225
246
else
226
247
{
227
248
#>
228
- ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(source, <#=item.Cast#>destination, name);
249
+ ThrowHelper.ThrowArgumentExceptionForHasSizeLessThanOrEqualTo(source, <#=item.Cast#>destination, name);
229
250
<#
230
251
}
231
252
#>
232
- }
233
253
}
234
254
235
255
/// <summary>
@@ -250,10 +270,12 @@ GenerateTextForItems(EnumerableTypes, item =>
250
270
// For more info and code sample, see the original conversation here:
251
271
// https://github.com/windows-toolkit/WindowsCommunityToolkit/pull/3131#discussion_r390682835
252
272
#>
253
- if ((uint)index >= (uint)<#=item.Name#>.<#=item.Size#>)
273
+ if ((uint)index < (uint)<#=item.Name#>.<#=item.Size#>)
254
274
{
255
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRangeFor(index, <#=item.Cast#><#=item.Name#>, name) ;
275
+ return ;
256
276
}
277
+
278
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsInRangeFor(index, <#=item.Cast#><#=item.Name#>, name);
257
279
}
258
280
259
281
/// <summary>
@@ -267,10 +289,12 @@ GenerateTextForItems(EnumerableTypes, item =>
267
289
[MethodImpl(MethodImplOptions.AggressiveInlining)]
268
290
public static void IsNotInRangeFor<T>(int index, <#=item.Type#> <#=item.Name#>, string name)
269
291
{
270
- if ((uint)index < (uint)<#=item.Name#>.<#=item.Size#>)
292
+ if ((uint)index >= (uint)<#=item.Name#>.<#=item.Size#>)
271
293
{
272
- ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(index, <#=item.Cast#><#=item.Name#>, name) ;
294
+ return ;
273
295
}
296
+
297
+ ThrowHelper.ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor(index, <#=item.Cast#><#=item.Name#>, name);
274
298
}
275
299
<#
276
300
});
0 commit comments