Skip to content

Commit 94de3b9

Browse files
Address review feedback.
1 parent 7c8aab6 commit 94de3b9

6 files changed

Lines changed: 144 additions & 169 deletions

File tree

src/System.Windows.Forms.Analyzers/src/System/Windows/Forms/Analyzers/Diagnostics/DiagnosticIDs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace System.Windows.Forms.Analyzers.Diagnostics;
55

66
internal static class DiagnosticIDs
77
{
8-
public const string UrlFormat = "https://aka.ms/winforms-experimental/{0}";
8+
public const string UrlFormat = "https://aka.ms/winforms-warnings/{0}";
99

1010
// Application Configuration, number group 0001+
1111
public const string UnsupportedProjectType = "WFO0001";

src/System.Windows.Forms/src/GlobalSuppressions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,10 @@
260260
[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "Public API", Scope = "member", Target = "~F:System.Windows.Forms.BindingManagerBase.onPositionChangedHandler")]
261261
[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "Public API", Scope = "member", Target = "~F:System.Windows.Forms.CurrencyManager.listposition")]
262262
[assembly: SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "Public API", Scope = "member", Target = "~F:System.Windows.Forms.CurrencyManager.finalType")]
263+
[assembly: SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Analyzer wrongly complains for new APIs - known issue.", Scope = "member", Target = "~M:System.Windows.Forms.Control.InvokeAsync``1(System.Func{``0},System.Threading.CancellationToken)~System.Threading.Tasks.Task{``0}")]
264+
[assembly: SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Analyzer wrongly complains for new APIs - known issue.", Scope = "member", Target = "~M:System.Windows.Forms.Control.InvokeAsync(System.Func{System.Threading.CancellationToken,System.Threading.Tasks.ValueTask},System.Threading.CancellationToken)~System.Threading.Tasks.Task")]
265+
[assembly: SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Analyzer wrongly complains for new APIs - known issue.", Scope = "member", Target = "~M:System.Windows.Forms.Control.InvokeAsync``1(System.Func{System.Threading.CancellationToken,System.Threading.Tasks.ValueTask{``0}},System.Threading.CancellationToken)~System.Threading.Tasks.Task{``0}")]
266+
[assembly: SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Analyzer wrongly complains for new APIs - known issue.", Scope = "member", Target = "~M:System.Windows.Forms.Control.InvokeAsync(System.Action,System.Threading.CancellationToken)~System.Threading.Tasks.Task")]
267+
[assembly: SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Analyzer wrongly complains for new APIs - known issue.", Scope = "member", Target = "~M:System.Windows.Forms.TaskDialog.ShowDialogAsync(System.Windows.Forms.TaskDialogPage,System.Windows.Forms.TaskDialogStartupLocation)~System.Threading.Tasks.Task{System.Windows.Forms.TaskDialogButton}")]
268+
[assembly: SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Analyzer wrongly complains for new APIs - known issue.", Scope = "member", Target = "~M:System.Windows.Forms.TaskDialog.ShowDialogAsync(System.Windows.Forms.IWin32Window,System.Windows.Forms.TaskDialogPage,System.Windows.Forms.TaskDialogStartupLocation)~System.Threading.Tasks.Task{System.Windows.Forms.TaskDialogButton}")]
269+
[assembly: SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters", Justification = "Analyzer wrongly complains for new APIs - known issue.", Scope = "member", Target = "~M:System.Windows.Forms.TaskDialog.ShowDialogAsync(System.IntPtr,System.Windows.Forms.TaskDialogPage,System.Windows.Forms.TaskDialogStartupLocation)~System.Threading.Tasks.Task{System.Windows.Forms.TaskDialogButton}")]

src/System.Windows.Forms/src/PublicAPI.Unshipped.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
static System.Windows.Forms.TaskDialog.ShowDialogAsync(nint hwndOwner, System.Windows.Forms.TaskDialogPage! page) -> System.Threading.Tasks.Task<System.Windows.Forms.TaskDialogButton!>!
2-
static System.Windows.Forms.TaskDialog.ShowDialogAsync(nint hwndOwner, System.Windows.Forms.TaskDialogPage! page, System.Windows.Forms.TaskDialogStartupLocation startupLocation) -> System.Threading.Tasks.Task<System.Windows.Forms.TaskDialogButton!>!
3-
static System.Windows.Forms.TaskDialog.ShowDialogAsync(System.Windows.Forms.TaskDialogPage! page) -> System.Threading.Tasks.Task<System.Windows.Forms.TaskDialogButton!>!
4-
static System.Windows.Forms.TaskDialog.ShowDialogAsync(System.Windows.Forms.TaskDialogPage! page, System.Windows.Forms.TaskDialogStartupLocation startupLocation) -> System.Threading.Tasks.Task<System.Windows.Forms.TaskDialogButton!>!
1+
static System.Windows.Forms.TaskDialog.ShowDialogAsync(nint hwndOwner, System.Windows.Forms.TaskDialogPage! page, System.Windows.Forms.TaskDialogStartupLocation startupLocation = System.Windows.Forms.TaskDialogStartupLocation.CenterOwner) -> System.Threading.Tasks.Task<System.Windows.Forms.TaskDialogButton!>!
2+
static System.Windows.Forms.TaskDialog.ShowDialogAsync(System.Windows.Forms.IWin32Window! owner, System.Windows.Forms.TaskDialogPage! page, System.Windows.Forms.TaskDialogStartupLocation startupLocation = System.Windows.Forms.TaskDialogStartupLocation.CenterOwner) -> System.Threading.Tasks.Task<System.Windows.Forms.TaskDialogButton!>!
3+
static System.Windows.Forms.TaskDialog.ShowDialogAsync(System.Windows.Forms.TaskDialogPage! page, System.Windows.Forms.TaskDialogStartupLocation startupLocation = System.Windows.Forms.TaskDialogStartupLocation.CenterScreen) -> System.Threading.Tasks.Task<System.Windows.Forms.TaskDialogButton!>!
54
System.Windows.Forms.Control.InvokeAsync(System.Action! callback, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
65
System.Windows.Forms.Control.InvokeAsync(System.Func<System.Threading.CancellationToken, System.Threading.Tasks.ValueTask>! callback, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!
76
System.Windows.Forms.Control.InvokeAsync<T>(System.Func<System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<T>>! callback, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<T>!

src/System.Windows.Forms/src/System/Windows/Forms/Control_InvokeAsync.cs

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ public partial class Control
2727
/// <see cref="InvokeAsync{T}(Func{CancellationToken, ValueTask{T}}, CancellationToken)"/>.
2828
/// </para>
2929
/// </remarks>
30-
#pragma warning disable RS0026 // API with optional parameter(s) should have the most parameters amongst its public overloads
3130
public async Task InvokeAsync(Action callback, CancellationToken cancellationToken = default)
32-
#pragma warning restore RS0026 // API with optional parameter(s) should have the most parameters amongst its public overloads
3331
{
3432
ArgumentNullException.ThrowIfNull(callback);
3533

@@ -38,12 +36,12 @@ public async Task InvokeAsync(Action callback, CancellationToken cancellationTok
3836
return;
3937
}
4038

41-
TaskCompletionSource tcs = new(TaskCreationOptions.RunContinuationsAsynchronously);
39+
TaskCompletionSource completion = new(TaskCreationOptions.RunContinuationsAsynchronously);
4240

43-
using (cancellationToken.Register(() => tcs.SetCanceled(), useSynchronizationContext: false))
41+
using (cancellationToken.Register(() => completion.SetCanceled(), useSynchronizationContext: false))
4442
{
4543
BeginInvoke(WrappedAction);
46-
await tcs.Task.ConfigureAwait(false);
44+
await completion.Task.ConfigureAwait(false);
4745
}
4846

4947
void WrappedAction()
@@ -52,16 +50,16 @@ void WrappedAction()
5250
{
5351
if (cancellationToken.IsCancellationRequested)
5452
{
55-
tcs.SetCanceled(cancellationToken);
53+
completion.SetCanceled(cancellationToken);
5654
return;
5755
}
5856

5957
callback();
60-
tcs.TrySetResult();
58+
completion.TrySetResult();
6159
}
6260
catch (Exception ex)
6361
{
64-
tcs.TrySetException(ex);
62+
completion.TrySetException(ex);
6563
}
6664
}
6765
}
@@ -95,9 +93,7 @@ void WrappedAction()
9593
/// <see cref="InvokeAsync{T}(Func{CancellationToken, ValueTask{T}}, CancellationToken)"/>.
9694
/// </para>
9795
/// </remarks>
98-
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
9996
public async Task<T> InvokeAsync<T>(Func<T> callback, CancellationToken cancellationToken = default)
100-
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
10197
{
10298
ArgumentNullException.ThrowIfNull(callback);
10399

@@ -106,12 +102,12 @@ public async Task<T> InvokeAsync<T>(Func<T> callback, CancellationToken cancella
106102
return default!;
107103
}
108104

109-
TaskCompletionSource<T> tcs = new(TaskCreationOptions.RunContinuationsAsynchronously);
105+
TaskCompletionSource<T> completion = new(TaskCreationOptions.RunContinuationsAsynchronously);
110106

111-
using (cancellationToken.Register(() => tcs.SetCanceled(), useSynchronizationContext: false))
107+
using (cancellationToken.Register(() => completion.SetCanceled(), useSynchronizationContext: false))
112108
{
113109
BeginInvoke(WrappedCallback);
114-
return await tcs.Task.ConfigureAwait(false);
110+
return await completion.Task.ConfigureAwait(false);
115111
}
116112

117113
void WrappedCallback()
@@ -120,16 +116,16 @@ void WrappedCallback()
120116
{
121117
if (cancellationToken.IsCancellationRequested)
122118
{
123-
tcs.TrySetCanceled(cancellationToken);
119+
completion.TrySetCanceled(cancellationToken);
124120
return;
125121
}
126122

127123
T result = callback();
128-
tcs.TrySetResult(result);
124+
completion.TrySetResult(result);
129125
}
130126
catch (Exception ex)
131127
{
132-
tcs.TrySetException(ex);
128+
completion.TrySetException(ex);
133129
}
134130
}
135131
}
@@ -162,9 +158,7 @@ void WrappedCallback()
162158
/// <see cref="InvokeAsync(Action, CancellationToken)"/>.
163159
/// </para>
164160
/// </remarks>
165-
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
166161
public async Task InvokeAsync(Func<CancellationToken, ValueTask> callback, CancellationToken cancellationToken = default)
167-
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
168162
{
169163
ArgumentNullException.ThrowIfNull(callback);
170164

@@ -173,12 +167,12 @@ public async Task InvokeAsync(Func<CancellationToken, ValueTask> callback, Cance
173167
return;
174168
}
175169

176-
TaskCompletionSource tcs = new(TaskCreationOptions.RunContinuationsAsynchronously);
170+
TaskCompletionSource completion = new(TaskCreationOptions.RunContinuationsAsynchronously);
177171

178-
using (cancellationToken.Register(() => tcs.SetCanceled(), useSynchronizationContext: false))
172+
using (cancellationToken.Register(() => completion.SetCanceled(), useSynchronizationContext: false))
179173
{
180174
BeginInvoke(async () => await WrappedCallbackAsync().ConfigureAwait(false));
181-
await tcs.Task.ConfigureAwait(false);
175+
await completion.Task.ConfigureAwait(false);
182176
}
183177

184178
async Task WrappedCallbackAsync()
@@ -187,16 +181,16 @@ async Task WrappedCallbackAsync()
187181
{
188182
if (cancellationToken.IsCancellationRequested)
189183
{
190-
tcs.TrySetCanceled(cancellationToken);
184+
completion.TrySetCanceled(cancellationToken);
191185
return;
192186
}
193187

194188
await callback(cancellationToken).ConfigureAwait(false);
195-
tcs.TrySetResult();
189+
completion.TrySetResult();
196190
}
197191
catch (Exception ex)
198192
{
199-
tcs.TrySetException(ex);
193+
completion.TrySetException(ex);
200194
}
201195
}
202196
}
@@ -228,9 +222,7 @@ async Task WrappedCallbackAsync()
228222
/// <see cref="InvokeAsync(Action, CancellationToken)"/>.
229223
/// </para>
230224
/// </remarks>
231-
#pragma warning disable RS0026 // API with optional parameter(s) should have the most parameters amongst its public overloads
232225
public async Task<T> InvokeAsync<T>(Func<CancellationToken, ValueTask<T>> callback, CancellationToken cancellationToken = default)
233-
#pragma warning restore RS0026 // API with optional parameter(s) should have the most parameters amongst its public overloads
234226
{
235227
ArgumentNullException.ThrowIfNull(callback);
236228

@@ -239,24 +231,24 @@ public async Task<T> InvokeAsync<T>(Func<CancellationToken, ValueTask<T>> callba
239231
return default!;
240232
}
241233

242-
TaskCompletionSource<T> tcs = new(TaskCreationOptions.RunContinuationsAsynchronously);
234+
TaskCompletionSource<T> completion = new(TaskCreationOptions.RunContinuationsAsynchronously);
243235

244-
using (cancellationToken.Register(() => tcs.SetCanceled(), useSynchronizationContext: false))
236+
using (cancellationToken.Register(() => completion.SetCanceled(), useSynchronizationContext: false))
245237
{
246238
BeginInvoke(async () => await WrappedCallbackAsync().ConfigureAwait(false));
247-
return await tcs.Task.ConfigureAwait(false);
239+
return await completion.Task.ConfigureAwait(false);
248240
}
249241

250242
async Task WrappedCallbackAsync()
251243
{
252244
try
253245
{
254246
var returnValue = await callback(cancellationToken).ConfigureAwait(false);
255-
tcs.TrySetResult(returnValue);
247+
completion.TrySetResult(returnValue);
256248
}
257249
catch (Exception ex)
258250
{
259-
tcs.TrySetException(ex);
251+
completion.TrySetException(ex);
260252
}
261253
}
262254
}

0 commit comments

Comments
 (0)