You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Guard overloads for nint/nuint, codegen improvements (#3573)
## PR Type
What kind of change does this PR introduce?
<!-- Please uncomment one or more that apply to this PR. -->
<!-- - Bugfix -->
- Feature
- Optimization
<!-- - Code style update (formatting) -->
<!-- - Refactoring (no functional changes, no api changes) -->
<!-- - Build or CI related changes -->
<!-- - Documentation content changes -->
<!-- - Sample app changes -->
<!-- - Other... Please describe: -->
## What is the current behavior?
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->
There are no `nint`/`nuint` overloads for the any `Guard` APIs. These types have been introduced with C# 9, so it makes sense to add proper support for them given that #3356 added full support for C# 9 and .NET 5 to these packages.
Also there were some codegen bits in `Guard.IsCloseTo` that were not ideal.
Additionally, the codegen for the `Guard` APIs didn't leverage compiler support properly.
## What is the new behavior?
<!-- Describe how was this issue resolved or changed? -->
✅ Added new `nint`/`nuint` overloads to `Guard` APIs
🚀 Improved codegen in a number of `Guard.IsCloseTo` overloads
🚀 Improved codegen for faulting blocks
## PR Checklist
Please check if your PR fulfills the following requirements:
- [X] Tested code with current [supported SDKs](../readme.md#supported)
- [ ] Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs). Link: <!-- docs PR link -->
- [ ] Sample in sample app has been added / updated (for bug fixes / features)
- [ ] Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/windows-toolkit/WindowsCommunityToolkit-design-assets)
- [X] Tests for the changes have been added (for bug fixes / features) (if applicable)
- [X] Header has been added to all new source files (run *build/UpdateHeaders.bat*)
- [X] Contains **NO** breaking changes
@@ -37,8 +38,8 @@ GenerateTextForItems(NumericTypes, type =>
37
38
/// <summary>
38
39
/// Asserts that the input value must be not equal to a specified value.
39
40
/// </summary>
40
-
/// <param name="value">The input <see cref="<#=type#>"/> value to test.</param>
41
-
/// <param name="target">The target <see cref="<#=type#>"/> value to test for.</param>
41
+
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
42
+
/// <param name="target">The target <see <#=prefix#>="<#=type#>"/> value to test for.</param>
42
43
/// <param name="name">The name of the input parameter being tested.</param>
43
44
/// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is == <paramref name="target"/>.</exception>
44
45
/// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks>
@@ -56,8 +57,8 @@ GenerateTextForItems(NumericTypes, type =>
56
57
/// <summary>
57
58
/// Asserts that the input value must be less than a specified value.
58
59
/// </summary>
59
-
/// <param name="value">The input <see cref="<#=type#>"/> value to test.</param>
60
-
/// <param name="maximum">The exclusive maximum <see cref="<#=type#>"/> value that is accepted.</param>
60
+
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
61
+
/// <param name="maximum">The exclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
61
62
/// <param name="name">The name of the input parameter being tested.</param>
62
63
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="maximum"/>.</exception>
63
64
/// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks>
@@ -75,8 +76,8 @@ GenerateTextForItems(NumericTypes, type =>
75
76
/// <summary>
76
77
/// Asserts that the input value must be less than or equal to a specified value.
77
78
/// </summary>
78
-
/// <param name="value">The input <see cref="<#=type#>"/> value to test.</param>
79
-
/// <param name="maximum">The inclusive maximum <see cref="<#=type#>"/> value that is accepted.</param>
79
+
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
80
+
/// <param name="maximum">The inclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
80
81
/// <param name="name">The name of the input parameter being tested.</param>
81
82
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="maximum"/>.</exception>
82
83
/// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks>
@@ -94,8 +95,8 @@ GenerateTextForItems(NumericTypes, type =>
94
95
/// <summary>
95
96
/// Asserts that the input value must be greater than a specified value.
96
97
/// </summary>
97
-
/// <param name="value">The input <see cref="<#=type#>"/> value to test.</param>
98
-
/// <param name="minimum">The exclusive minimum <see cref="<#=type#>"/> value that is accepted.</param>
98
+
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
99
+
/// <param name="minimum">The exclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
99
100
/// <param name="name">The name of the input parameter being tested.</param>
100
101
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is <= <paramref name="minimum"/>.</exception>
101
102
/// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks>
@@ -113,8 +114,8 @@ GenerateTextForItems(NumericTypes, type =>
113
114
/// <summary>
114
115
/// Asserts that the input value must be greater than or equal to a specified value.
115
116
/// </summary>
116
-
/// <param name="value">The input <see cref="<#=type#>"/> value to test.</param>
117
-
/// <param name="minimum">The inclusive minimum <see cref="<#=type#>"/> value that is accepted.</param>
117
+
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
118
+
/// <param name="minimum">The inclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
118
119
/// <param name="name">The name of the input parameter being tested.</param>
119
120
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is < <paramref name="minimum"/>.</exception>
120
121
/// <remarks>The method is generic to avoid boxing the parameters, if they are value types.</remarks>
@@ -132,9 +133,9 @@ GenerateTextForItems(NumericTypes, type =>
132
133
/// <summary>
133
134
/// Asserts that the input value must be in a given range.
134
135
/// </summary>
135
-
/// <param name="value">The input <see cref="<#=type#>"/> value to test.</param>
136
-
/// <param name="minimum">The inclusive minimum <see cref="<#=type#>"/> value that is accepted.</param>
137
-
/// <param name="maximum">The exclusive maximum <see cref="<#=type#>"/> value that is accepted.</param>
136
+
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
137
+
/// <param name="minimum">The inclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
138
+
/// <param name="maximum">The exclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
138
139
/// <param name="name">The name of the input parameter being tested.</param>
139
140
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is < <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception>
140
141
/// <remarks>
@@ -155,9 +156,9 @@ GenerateTextForItems(NumericTypes, type =>
155
156
/// <summary>
156
157
/// Asserts that the input value must not be in a given range.
157
158
/// </summary>
158
-
/// <param name="value">The input <see cref="<#=type#>"/> value to test.</param>
159
-
/// <param name="minimum">The inclusive minimum <see cref="<#=type#>"/> value that is accepted.</param>
160
-
/// <param name="maximum">The exclusive maximum <see cref="<#=type#>"/> value that is accepted.</param>
159
+
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
160
+
/// <param name="minimum">The inclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
161
+
/// <param name="maximum">The exclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
161
162
/// <param name="name">The name of the input parameter being tested.</param>
162
163
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or < <paramref name="maximum"/>.</exception>
163
164
/// <remarks>
@@ -178,9 +179,9 @@ GenerateTextForItems(NumericTypes, type =>
178
179
/// <summary>
179
180
/// Asserts that the input value must be in a given interval.
180
181
/// </summary>
181
-
/// <param name="value">The input <see cref="<#=type#>"/> value to test.</param>
182
-
/// <param name="minimum">The exclusive minimum <see cref="<#=type#>"/> value that is accepted.</param>
183
-
/// <param name="maximum">The exclusive maximum <see cref="<#=type#>"/> value that is accepted.</param>
182
+
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
183
+
/// <param name="minimum">The exclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
184
+
/// <param name="maximum">The exclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
184
185
/// <param name="name">The name of the input parameter being tested.</param>
185
186
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is <= <paramref name="minimum"/> or >= <paramref name="maximum"/>.</exception>
186
187
/// <remarks>
@@ -201,9 +202,9 @@ GenerateTextForItems(NumericTypes, type =>
201
202
/// <summary>
202
203
/// Asserts that the input value must not be in a given interval.
203
204
/// </summary>
204
-
/// <param name="value">The input <see cref="<#=type#>"/> value to test.</param>
205
-
/// <param name="minimum">The exclusive minimum <see cref="<#=type#>"/> value that is accepted.</param>
206
-
/// <param name="maximum">The exclusive maximum <see cref="<#=type#>"/> value that is accepted.</param>
205
+
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
206
+
/// <param name="minimum">The exclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
207
+
/// <param name="maximum">The exclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
207
208
/// <param name="name">The name of the input parameter being tested.</param>
208
209
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is > <paramref name="minimum"/> or < <paramref name="maximum"/>.</exception>
209
210
/// <remarks>
@@ -224,9 +225,9 @@ GenerateTextForItems(NumericTypes, type =>
224
225
/// <summary>
225
226
/// Asserts that the input value must be in a given interval.
226
227
/// </summary>
227
-
/// <param name="value">The input <see cref="<#=type#>"/> value to test.</param>
228
-
/// <param name="minimum">The inclusive minimum <see cref="<#=type#>"/> value that is accepted.</param>
229
-
/// <param name="maximum">The inclusive maximum <see cref="<#=type#>"/> value that is accepted.</param>
228
+
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
229
+
/// <param name="minimum">The inclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
230
+
/// <param name="maximum">The inclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
230
231
/// <param name="name">The name of the input parameter being tested.</param>
231
232
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is < <paramref name="minimum"/> or > <paramref name="maximum"/>.</exception>
232
233
/// <remarks>
@@ -247,9 +248,9 @@ GenerateTextForItems(NumericTypes, type =>
247
248
/// <summary>
248
249
/// Asserts that the input value must not be in a given interval.
249
250
/// </summary>
250
-
/// <param name="value">The input <see cref="<#=type#>"/> value to test.</param>
251
-
/// <param name="minimum">The inclusive minimum <see cref="<#=type#>"/> value that is accepted.</param>
252
-
/// <param name="maximum">The inclusive maximum <see cref="<#=type#>"/> value that is accepted.</param>
251
+
/// <param name="value">The input <see <#=prefix#>="<#=type#>"/> value to test.</param>
252
+
/// <param name="minimum">The inclusive minimum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
253
+
/// <param name="maximum">The inclusive maximum <see <#=prefix#>="<#=type#>"/> value that is accepted.</param>
253
254
/// <param name="name">The name of the input parameter being tested.</param>
254
255
/// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="value"/> is >= <paramref name="minimum"/> or <= <paramref name="maximum"/>.</exception>
0 commit comments