Skip to content

Commit c798cbc

Browse files
committed
fix warning
1 parent d01d8de commit c798cbc

File tree

1 file changed

+5
-3
lines changed
  • src/System.Windows.Forms.Design/src/System/Windows/Forms/Design

1 file changed

+5
-3
lines changed

src/System.Windows.Forms.Design/src/System/Windows/Forms/Design/CommandSet.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ internal partial class CommandSet : IDisposable
5353
private StatusCommandUI _statusCommandUI; // Used to update the statusBar Information.
5454
private readonly IUIService? _uiService;
5555

56+
private ICollection? _toBeCopiedComponents;
57+
5658
/// <summary>
5759
/// Creates a new CommandSet object. This object implements the set
5860
/// of commands that the UI.Win32 form designer offers.
@@ -422,6 +424,7 @@ internal static bool ExecuteSafely(Action action, bool throwOnException)
422424

423425
// This function will return true if call to func is successful, false otherwise
424426
// Output of call to func is available in result out parameter
427+
[SuppressMessage("Style", "IDE0051:Remove unused private members", Justification = "retain this unused method")]
425428
private static bool ExecuteSafely<T>(Func<T> func, bool throwOnException, [MaybeNullWhen(false)] out T result)
426429
{
427430
try
@@ -1383,7 +1386,6 @@ protected void OnMenuCenterSelection(object? sender, EventArgs e)
13831386
}
13841387
}
13851388

1386-
private ICollection _toBeCopiedComponents;
13871389
/// <summary>
13881390
/// Called when the copy menu item is selected.
13891391
/// </summary>
@@ -1835,9 +1837,9 @@ protected void OnMenuPaste(object? sender, EventArgs e)
18351837

18361838
using DesignerTransaction trans = host.CreateTransaction(SR.CommandSetPaste);
18371839

1838-
components = DesignerUtils.CopyDragObjects(new ReadOnlyCollection<IComponent>([.. _toBeCopiedComponents.Cast<IComponent>()]), GetService<IDesignerHost>());
1840+
components = DesignerUtils.CopyDragObjects(new ReadOnlyCollection<IComponent>([.. _toBeCopiedComponents.Cast<IComponent>()]), GetService<IDesignerHost>()!);
18391841

1840-
if (_toBeCopiedComponents.Count == components.Count)
1842+
if (components is not null && _toBeCopiedComponents.Count == components.Count)
18411843
{
18421844
int i = 0;
18431845
foreach (IComponent component in _toBeCopiedComponents)

0 commit comments

Comments
 (0)