Skip to content

Commit 909d588

Browse files
committed
Enable nullability in DesignerActionMethodItem
1 parent dba5d6e commit 909d588

File tree

3 files changed

+85
-24
lines changed

3 files changed

+85
-24
lines changed

src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt

+9-9
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434
~override System.Windows.Forms.Design.WindowsFormsDesignerOptionService.PopulateOptionCollection(System.ComponentModel.Design.DesignerOptionService.DesignerOptionCollection options) -> void
3535
~static System.Windows.Forms.Design.ParentControlDesigner.InvokeCreateTool(System.Windows.Forms.Design.ParentControlDesigner toInvoke, System.Drawing.Design.ToolboxItem tool) -> void
3636
~System.ComponentModel.Design.ArrayEditor.ArrayEditor(System.Type type) -> void
37-
~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName) -> void
38-
~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, bool includeAsDesignerVerb) -> void
39-
~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, string category) -> void
40-
~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, string category, bool includeAsDesignerVerb) -> void
41-
~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, string category, string description) -> void
42-
~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, string category, string description, bool includeAsDesignerVerb) -> void
43-
~System.ComponentModel.Design.DesignerActionMethodItem.RelatedComponent.get -> System.ComponentModel.IComponent
44-
~System.ComponentModel.Design.DesignerActionMethodItem.RelatedComponent.set -> void
37+
System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList? actionList, string? memberName, string? displayName) -> void
38+
System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList? actionList, string? memberName, string? displayName, bool includeAsDesignerVerb) -> void
39+
System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList? actionList, string? memberName, string? displayName, string? category) -> void
40+
System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList? actionList, string? memberName, string? displayName, string? category, bool includeAsDesignerVerb) -> void
41+
System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList? actionList, string? memberName, string? displayName, string? category, string? description) -> void
42+
System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList? actionList, string? memberName, string? displayName, string? category, string? description, bool includeAsDesignerVerb) -> void
43+
System.ComponentModel.Design.DesignerActionMethodItem.RelatedComponent.get -> System.ComponentModel.IComponent?
44+
System.ComponentModel.Design.DesignerActionMethodItem.RelatedComponent.set -> void
4545
~System.Drawing.Design.IToolboxService.AddCreator(System.Drawing.Design.ToolboxItemCreatorCallback creator, string format) -> void
4646
~System.Drawing.Design.IToolboxService.AddCreator(System.Drawing.Design.ToolboxItemCreatorCallback creator, string format, System.ComponentModel.Design.IDesignerHost host) -> void
4747
~System.Drawing.Design.IToolboxService.AddLinkedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, string category, System.ComponentModel.Design.IDesignerHost host) -> void
@@ -90,7 +90,7 @@
9090
~System.Windows.Forms.Design.ParentControlDesigner.CreateTool(System.Drawing.Design.ToolboxItem tool, System.Drawing.Rectangle bounds) -> void
9191
~System.Windows.Forms.Design.ParentControlDesigner.GetControl(object component) -> System.Windows.Forms.Control
9292
~System.Windows.Forms.Design.ParentControlDesigner.MouseDragTool.get -> System.Drawing.Design.ToolboxItem
93-
~virtual System.ComponentModel.Design.DesignerActionMethodItem.MemberName.get -> string
93+
virtual System.ComponentModel.Design.DesignerActionMethodItem.MemberName.get -> string?
9494
~virtual System.Windows.Forms.Design.ComponentDocumentDesigner.GetToolSupported(System.Drawing.Design.ToolboxItem tool) -> bool
9595
~virtual System.Windows.Forms.Design.ComponentTray.AddComponent(System.ComponentModel.IComponent component) -> void
9696
~virtual System.Windows.Forms.Design.ComponentTray.CanCreateComponentFromTool(System.Drawing.Design.ToolboxItem tool) -> bool

src/System.Windows.Forms.Design/src/System/ComponentModel/Design/DesignerActionMethodItem.cs

+74-14
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,108 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
#nullable disable
5-
64
using System.Reflection;
75

86
namespace System.ComponentModel.Design;
97

108
public class DesignerActionMethodItem : DesignerActionItem
119
{
12-
private readonly DesignerActionList _actionList;
13-
private MethodInfo _methodInfo;
14-
15-
public DesignerActionMethodItem(DesignerActionList actionList, string memberName, string displayName, string category, string description, bool includeAsDesignerVerb)
10+
private readonly DesignerActionList? _actionList;
11+
private MethodInfo? _methodInfo;
12+
13+
public DesignerActionMethodItem(
14+
DesignerActionList? actionList,
15+
string? memberName,
16+
string? displayName,
17+
string? category,
18+
string? description,
19+
bool includeAsDesignerVerb)
1620
: base(displayName, category, description)
1721
{
1822
_actionList = actionList;
1923
MemberName = memberName;
2024
IncludeAsDesignerVerb = includeAsDesignerVerb;
2125
}
2226

23-
public DesignerActionMethodItem(DesignerActionList actionList, string memberName, string displayName) : this(actionList, memberName, displayName, null, null, false)
27+
public DesignerActionMethodItem(
28+
DesignerActionList? actionList,
29+
string? memberName,
30+
string? displayName)
31+
: this(
32+
actionList,
33+
memberName,
34+
displayName,
35+
category: null,
36+
description: null,
37+
includeAsDesignerVerb: false)
2438
{
2539
}
2640

27-
public DesignerActionMethodItem(DesignerActionList actionList, string memberName, string displayName, bool includeAsDesignerVerb) : this(actionList, memberName, displayName, null, null, includeAsDesignerVerb)
41+
public DesignerActionMethodItem(
42+
DesignerActionList? actionList,
43+
string? memberName,
44+
string? displayName,
45+
bool includeAsDesignerVerb)
46+
: this(
47+
actionList,
48+
memberName,
49+
displayName,
50+
category: null,
51+
description: null,
52+
includeAsDesignerVerb)
2853
{
2954
}
3055

31-
public DesignerActionMethodItem(DesignerActionList actionList, string memberName, string displayName, string category) : this(actionList, memberName, displayName, category, null, false)
56+
public DesignerActionMethodItem(
57+
DesignerActionList? actionList,
58+
string? memberName,
59+
string? displayName,
60+
string? category)
61+
: this(
62+
actionList,
63+
memberName,
64+
displayName,
65+
category,
66+
description: null,
67+
includeAsDesignerVerb: false)
3268
{
3369
}
3470

35-
public DesignerActionMethodItem(DesignerActionList actionList, string memberName, string displayName, string category, bool includeAsDesignerVerb) : this(actionList, memberName, displayName, category, null, includeAsDesignerVerb)
71+
public DesignerActionMethodItem(
72+
DesignerActionList? actionList,
73+
string? memberName,
74+
string? displayName,
75+
string? category,
76+
bool includeAsDesignerVerb)
77+
: this(
78+
actionList,
79+
memberName,
80+
displayName,
81+
category,
82+
description: null,
83+
includeAsDesignerVerb)
3684
{
3785
}
3886

39-
public DesignerActionMethodItem(DesignerActionList actionList, string memberName, string displayName, string category, string description) : this(actionList, memberName, displayName, category, description, false)
87+
public DesignerActionMethodItem(
88+
DesignerActionList? actionList,
89+
string? memberName,
90+
string? displayName,
91+
string? category,
92+
string? description)
93+
: this(
94+
actionList,
95+
memberName,
96+
displayName,
97+
category,
98+
description,
99+
includeAsDesignerVerb: false)
40100
{
41101
}
42102

43-
public virtual string MemberName { get; }
103+
public virtual string? MemberName { get; }
44104

45-
public IComponent RelatedComponent { get; set; }
105+
public IComponent? RelatedComponent { get; set; }
46106

47107
public virtual bool IncludeAsDesignerVerb { get; }
48108

@@ -61,7 +121,7 @@ public virtual void Invoke()
61121
// this is only use for verbs so that a designer action method item can
62122
// be converted to a verb. Verbs use an EventHandler to call their invoke
63123
// so we need a way to translate the EventHandler Invoke into ou own Invoke
64-
internal void Invoke(object sender, EventArgs args)
124+
internal void Invoke(object? sender, EventArgs args)
65125
{
66126
Invoke();
67127
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ internal class DesignerActionVerbItem : DesignerActionMethodItem
77
{
88
private readonly DesignerVerb _targetVerb;
99

10-
public DesignerActionVerbItem(DesignerVerb verb) : base(null, null, null)
10+
public DesignerActionVerbItem(DesignerVerb verb)
11+
: base(actionList: null, memberName: null, displayName: null)
1112
{
1213
Debug.Assert(verb is not null, "All callers check whether the verb is null.");
1314
_targetVerb = verb;

0 commit comments

Comments
 (0)