diff --git a/src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt b/src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt index b9ea11b684a..684b9293a03 100644 --- a/src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt +++ b/src/System.Windows.Forms.Design/src/PublicAPI.Shipped.txt @@ -1,7 +1,7 @@ #nullable enable -~override System.ComponentModel.Design.ArrayEditor.CreateCollectionItemType() -> System.Type -~override System.ComponentModel.Design.ArrayEditor.GetItems(object editValue) -> object[] -~override System.ComponentModel.Design.ArrayEditor.SetItems(object editValue, object[] value) -> object +override System.ComponentModel.Design.ArrayEditor.CreateCollectionItemType() -> System.Type! +override System.ComponentModel.Design.ArrayEditor.GetItems(object? editValue) -> object![]! +override System.ComponentModel.Design.ArrayEditor.SetItems(object? editValue, object![]? value) -> object? ~override System.Windows.Forms.Design.ComponentTray.GetService(System.Type serviceType) -> object ~override System.Windows.Forms.Design.ComponentTray.OnDragDrop(System.Windows.Forms.DragEventArgs de) -> void ~override System.Windows.Forms.Design.ComponentTray.OnDragEnter(System.Windows.Forms.DragEventArgs de) -> void @@ -31,7 +31,7 @@ ~override System.Windows.Forms.Design.ParentControlDesigner.SnapLines.get -> System.Collections.IList ~override System.Windows.Forms.Design.WindowsFormsDesignerOptionService.PopulateOptionCollection(System.ComponentModel.Design.DesignerOptionService.DesignerOptionCollection options) -> void ~static System.Windows.Forms.Design.ParentControlDesigner.InvokeCreateTool(System.Windows.Forms.Design.ParentControlDesigner toInvoke, System.Drawing.Design.ToolboxItem tool) -> void -~System.ComponentModel.Design.ArrayEditor.ArrayEditor(System.Type type) -> void +System.ComponentModel.Design.ArrayEditor.ArrayEditor(System.Type! type) -> void ~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName) -> void ~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, bool includeAsDesignerVerb) -> void ~System.ComponentModel.Design.DesignerActionMethodItem.DesignerActionMethodItem(System.ComponentModel.Design.DesignerActionList actionList, string memberName, string displayName, string category) -> void diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ArrayEditor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ArrayEditor.cs index 7ee3ed5dda0..5a1e15bc091 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ArrayEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/ArrayEditor.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#nullable disable - namespace System.ComponentModel.Design; /// @@ -22,12 +20,16 @@ public ArrayEditor(Type type) : base(type) /// Gets or sets the data type this collection contains. /// protected override Type CreateCollectionItemType() - => CollectionType?.GetElementType(); + { + Type? type = CollectionType.GetElementType(); + + return type is null ? throw new InvalidOperationException() : type; + } /// /// Gets the items in the array. /// - protected override object[] GetItems(object editValue) + protected override object[] GetItems(object? editValue) { if (editValue is Array valueArray) { @@ -42,7 +44,7 @@ protected override object[] GetItems(object editValue) /// /// Sets the items in the array. /// - protected override object SetItems(object editValue, object[] value) + protected override object? SetItems(object? editValue, object[]? value) { if (editValue is not null and not Array) { diff --git a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.cs b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.cs index d6579661143..807bd5244c0 100644 --- a/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.cs +++ b/src/System.Windows.Forms.Design/src/System/ComponentModel/Design/CollectionEditor.cs @@ -23,7 +23,7 @@ public partial class CollectionEditor : UITypeEditor /// /// Initializes a new instance of the class using the specified collection type. /// - public CollectionEditor(Type type) => CollectionType = type; + public CollectionEditor(Type type) => CollectionType = type.OrThrowIfNull(); /// /// Gets the data type of each item in the collection. diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ArrayEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ArrayEditorTests.cs index bda27a91e4d..a7e75178e24 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ArrayEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/ArrayEditorTests.cs @@ -11,17 +11,8 @@ namespace System.ComponentModel.Design.Tests; public class ArrayEditorTests { [Theory] - [InlineData(typeof(object), null)] - [InlineData(typeof(string), null)] + [InlineData(typeof(string[]), typeof(string))] [InlineData(typeof(int[]), typeof(int))] - [InlineData(typeof(IList), null)] - [InlineData(typeof(IList), null)] - [InlineData(typeof(ClassWithItem), null)] - [InlineData(typeof(ClassWithPrivateItem), null)] - [InlineData(typeof(ClassWithStaticItem), null)] - [InlineData(typeof(ClassWithItems), null)] - [InlineData(typeof(ClassWithPrivateItems), null)] - [InlineData(typeof(ClassWithStaticItems), null)] public void ArrayEditor_Ctor_Type(Type type, Type expectedItemType) { SubArrayEditor editor = new(type); @@ -34,16 +25,27 @@ public void ArrayEditor_Ctor_Type(Type type, Type expectedItemType) Assert.Equal([expectedItemType], editor.NewItemTypes); } + [Theory] + [InlineData(typeof(object))] + [InlineData(typeof(string))] + [InlineData(typeof(IList))] + [InlineData(typeof(IList))] + [InlineData(typeof(ClassWithItem))] + [InlineData(typeof(ClassWithPrivateItem))] + [InlineData(typeof(ClassWithStaticItem))] + [InlineData(typeof(ClassWithItems))] + [InlineData(typeof(ClassWithPrivateItems))] + [InlineData(typeof(ClassWithStaticItems))] + public void ArrayEditor_Ctor_Invalid_Type(Type type) + { + SubArrayEditor editor = new(type); + Assert.Throws(() => editor.CollectionItemType); + } + [Fact] - public void ArrayEditor_Ctor_NullType() + public void ArrayEditor_Ctor_NullType_ThrowsArgumentNullException() { - SubArrayEditor editor = new(null); - Assert.Null(editor.CollectionItemType); - Assert.Null(editor.CollectionType); - Assert.Null(editor.Context); - Assert.Equal("net.ComponentModel.CollectionEditor", editor.HelpTopic); - Assert.False(editor.IsDropDownResizable); - Assert.Equal([null], editor.NewItemTypes); + Assert.Throws(() => new SubArrayEditor(null)); } public static IEnumerable CanRemoveInstance_TestData() @@ -58,7 +60,7 @@ public static IEnumerable CanRemoveInstance_TestData() [MemberData(nameof(CanRemoveInstance_TestData))] public void ArrayEditor_CanRemoveInstance_Invoke_ReturnsExpected(object value) { - SubArrayEditor editor = new(null); + SubArrayEditor editor = new(typeof(string[])); Assert.True(editor.CanRemoveInstance(value)); } @@ -77,29 +79,19 @@ public void ArrayEditor_CanRemoveInstance_InheritanceAttribute_ReturnsExpected(I { using Component component = new(); TypeDescriptor.AddAttributes(component, attribute); - SubArrayEditor editor = new(null); + SubArrayEditor editor = new(typeof(string[])); Assert.Equal(expected, editor.CanRemoveInstance(component)); } [Fact] public void ArrayEditor_CanSelectMultipleInstances_Invoke_ReturnsFalse() { - SubArrayEditor editor = new(null); + SubArrayEditor editor = new(typeof(string[])); Assert.True(editor.CanSelectMultipleInstances()); } public static IEnumerable GetDisplayText_TestData() { - yield return new object[] { null, null, string.Empty }; - yield return new object[] { null, string.Empty, "String" }; - yield return new object[] { null, "string", "string" }; - - yield return new object[] { null, new ClassWithStringName { Name = "CustomName" }, "CustomName" }; - yield return new object[] { null, new ClassWithStringName { Name = string.Empty }, "ClassWithStringName" }; - yield return new object[] { null, new ClassWithStringName { Name = null }, "ClassWithStringName" }; - yield return new object[] { null, new ClassWithNonStringName { Name = 1 }, "ClassWithNonStringName" }; - yield return new object[] { null, new ClassWithNullToString(), "ClassWithNullToString" }; - yield return new object[] { typeof(int), null, string.Empty }; yield return new object[] { typeof(int), "", "String" }; yield return new object[] { typeof(int), "value", "value" }; @@ -135,7 +127,7 @@ public void ArrayEditor_GetDisplayText_ValueDoesNotMatchCollectionType_ThrowsTar [CommonMemberData(typeof(CommonTestHelperEx), nameof(CommonTestHelperEx.GetITypeDescriptorContextTestData))] public void ArrayEditor_GetEditStyle_Invoke_ReturnsModal(ITypeDescriptorContext context) { - ArrayEditor editor = new(null); + ArrayEditor editor = new(typeof(string[])); Assert.Equal(UITypeEditorEditStyle.Modal, editor.GetEditStyle(context)); } @@ -151,7 +143,7 @@ public static IEnumerable GetItems_TestData() [MemberData(nameof(GetItems_TestData))] public void ArrayEditor_GetItems_Invoke_ReturnsExpected(object editValue, object[] expected) { - SubArrayEditor editor = new(null); + SubArrayEditor editor = new(typeof(string[])); object[] items = editor.GetItems(editValue); Assert.Equal(expected, items); Assert.IsType(expected.GetType(), items); @@ -162,7 +154,7 @@ public void ArrayEditor_GetItems_Invoke_ReturnsExpected(object editValue, object [CommonMemberData(typeof(CommonTestHelperEx), nameof(CommonTestHelperEx.GetITypeDescriptorContextTestData))] public void ArrayEditor_GetPaintValueSupported_Invoke_ReturnsFalse(ITypeDescriptorContext context) { - ArrayEditor editor = new(null); + ArrayEditor editor = new(typeof(string[])); Assert.False(editor.GetPaintValueSupported(context)); } @@ -202,17 +194,6 @@ public void ArrayEditor_SetItems_InvokeNonArrayValue_ReturnsExpected(object edit Assert.Same(expected, editor.SetItems(editValue, value)); } - [Theory] - [InlineData(typeof(object))] - [InlineData(null)] - public void ArrayEditor_SetItems_NullCollectionItemType_ThrowsArgumentNullException(Type type) - { - SubArrayEditor editor = new(type); - Assert.Null(editor.CollectionItemType); - Assert.Throws("elementType", () => editor.SetItems(null, Array.Empty())); - Assert.Throws("elementType", () => editor.SetItems(Array.Empty(), Array.Empty())); - } - private class SubArrayEditor : ArrayEditor { public SubArrayEditor(Type type) : base(type) diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionEditorTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionEditorTests.cs index 1380021c8b4..a800acb0fe8 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionEditorTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionEditorTests.cs @@ -38,21 +38,15 @@ public void CollectionEditor_Ctor_Type(Type type, Type expectedItemType) } [Fact] - public void CollectionEditor_Ctor_NullType() + public void CollectionEditor_Ctor_NullType_ThrowsArgumentNullException() { - SubCollectionEditor editor = new(null); - Assert.Throws("type", () => editor.CollectionItemType); - Assert.Null(editor.CollectionType); - Assert.Null(editor.Context); - Assert.Equal("net.ComponentModel.CollectionEditor", editor.HelpTopic); - Assert.False(editor.IsDropDownResizable); - Assert.Throws("type", () => editor.NewItemTypes); + Assert.Throws(() => new SubCollectionEditor(null)); } [Fact] public void CollectionEditor_CollectionEditor_CancelChanges_Invoke_Nop() { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); editor.CancelChanges(); } @@ -68,7 +62,7 @@ public static IEnumerable CanRemoveInstance_TestData() [MemberData(nameof(CanRemoveInstance_TestData))] public void CollectionEditor_CanRemoveInstance_Invoke_ReturnsExpected(object value) { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); Assert.True(editor.CanRemoveInstance(value)); } @@ -87,14 +81,14 @@ public void CollectionEditor_CanRemoveInstance_InheritanceAttribute_ReturnsExpec { using Component component = new(); TypeDescriptor.AddAttributes(component, attribute); - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); Assert.Equal(expected, editor.CanRemoveInstance(component)); } [Fact] public void CollectionEditor_CanSelectMultipleInstances_Invoke_ReturnsFalse() { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); Assert.True(editor.CanSelectMultipleInstances()); } @@ -106,13 +100,6 @@ public void CollectionEditor_CreateCollectionForm_Invoke_Success() Assert.NotSame(form, editor.CreateCollectionForm()); } - [Fact] - public void CollectionEditor_CreateCollectionForm_NullCollectionType_ThrowsArgumentNullException() - { - SubCollectionEditor editor = new(null); - Assert.Throws("type", editor.CreateCollectionForm); - } - [Theory] [InlineData(typeof(object), typeof(object))] [InlineData(typeof(int[]), typeof(object))] @@ -131,13 +118,6 @@ public void CollectionEditor_CreateCollectionItemType_Invoke_ReturnsExpected(Typ Assert.Same(itemType, editor.CreateCollectionItemType()); } - [Fact] - public void CollectionEditor_CreateCollectionItemType_NullType_ThrowsArgumentNullException() - { - SubCollectionEditor editor = new(null); - Assert.Throws("type", editor.CreateCollectionItemType); - } - public static IEnumerable InvalidDesignerHost_TestData() { yield return new object[] { null }; @@ -350,14 +330,14 @@ public static IEnumerable CreateInstance_InvokeWithoutContext_TestData [MemberData(nameof(CreateInstance_InvokeWithoutContext_TestData))] public void CollectionEditor_CreateInstance_InvokeWithoutContext_ReturnsExpected(Type type, object expected) { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); Assert.Equal(expected, editor.CreateInstance(type)); } [Fact] public void CollectionEditor_CreateInstance_NullItemType_ThrowsArgumentNullException() { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); Assert.Throws("itemType", () => editor.CreateInstance(null)); } @@ -379,13 +359,6 @@ public void CollectionEditor_CreateNewItemTypes_Invoke_ReturnsExpected(Type type Assert.NotSame(itemTypes, editor.CreateNewItemTypes()); } - [Fact] - public void CollectionEditor_CreateNewItemTypes_NullType_ThrowsArgumentNullException() - { - SubCollectionEditor editor = new(null); - Assert.Throws("type", editor.CreateNewItemTypes); - } - public static IEnumerable DestroyInstance_NormalObject_TestData() { yield return new object[] { null }; @@ -396,7 +369,7 @@ public static IEnumerable DestroyInstance_NormalObject_TestData() [MemberData(nameof(DestroyInstance_NormalObject_TestData))] public void CollectionEditor_DestroyInstance_NormalObject_Nop(object instance) { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); editor.DestroyInstance(instance); } @@ -496,7 +469,7 @@ public void CollectionEditor_DestroyInstance_IComponentWithoutHost_CallsDispose( .Setup(c => c.Dispose()) .Verifiable(); - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); editor.DestroyInstance(mockComponent.Object); mockComponent.Verify(c => c.Dispose(), Times.Once()); } @@ -509,7 +482,7 @@ public void CollectionEditor_DestroyInstance_IDisposable_CallsDispose() .Setup(d => d.Dispose()) .Verifiable(); - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); editor.DestroyInstance(mockDisposable.Object); mockDisposable.Verify(d => d.Dispose(), Times.Once()); } @@ -724,32 +697,11 @@ public void CollectionEditor_EditValue_ValidProviderValidHostWithIComponentChang mockEditorService.Verify(s => s.ShowDialog(It.IsAny
()), Times.Once()); } - [Fact] - public void CollectionEditor_EditValue_NullType_ThrowsArgumentNullException() - { - Mock mockEditorService = new(MockBehavior.Strict); - Mock mockServiceProvider = new(MockBehavior.Strict); - mockServiceProvider - .Setup(p => p.GetService(typeof(IWindowsFormsEditorService))) - .Returns(mockEditorService.Object); - Mock mockContext = new(MockBehavior.Strict); - mockContext - .Setup(c => c.GetService(typeof(IDesignerHost))) - .Returns((IDesignerHost)null); - mockContext - .Setup(c => c.GetService(typeof(AmbientProperties))) - .Returns(null); - - SubCollectionEditor editor = new(null); - object value = new(); - Assert.Throws("type", () => editor.EditValue(mockContext.Object, mockServiceProvider.Object, value)); - } - [Theory] [CommonMemberData(typeof(CommonTestHelperEx), nameof(CommonTestHelperEx.GetEditValueInvalidProviderTestData))] public void CollectionEditor_EditValue_InvalidProvider_ReturnsValue(IServiceProvider provider, object value) { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); Assert.Same(value, editor.EditValue(null, provider, value)); Assert.Null(editor.Context); } @@ -758,7 +710,7 @@ public void CollectionEditor_EditValue_InvalidProvider_ReturnsValue(IServiceProv [CommonMemberData(typeof(CommonTestHelperEx), nameof(CommonTestHelperEx.GetITypeDescriptorContextTestData))] public void CollectionEditor_GetEditStyle_Invoke_ReturnsModal(ITypeDescriptorContext context) { - CollectionEditor editor = new(null); + CollectionEditor editor = new(typeof(string)); Assert.Equal(UITypeEditorEditStyle.Modal, editor.GetEditStyle(context)); } @@ -766,22 +718,12 @@ public void CollectionEditor_GetEditStyle_Invoke_ReturnsModal(ITypeDescriptorCon [CommonMemberData(typeof(CommonTestHelperEx), nameof(CommonTestHelperEx.GetITypeDescriptorContextTestData))] public void CollectionEditor_GetPaintValueSupported_Invoke_ReturnsFalse(ITypeDescriptorContext context) { - CollectionEditor editor = new(null); + CollectionEditor editor = new(typeof(string)); Assert.False(editor.GetPaintValueSupported(context)); } public static IEnumerable GetDisplayText_TestData() { - yield return new object[] { null, null, string.Empty }; - yield return new object[] { null, string.Empty, "String" }; - yield return new object[] { null, "string", "string" }; - - yield return new object[] { null, new ClassWithStringName { Name = "CustomName" }, "CustomName" }; - yield return new object[] { null, new ClassWithStringName { Name = string.Empty }, "ClassWithStringName" }; - yield return new object[] { null, new ClassWithStringName { Name = null }, "ClassWithStringName" }; - yield return new object[] { null, new ClassWithNonStringName { Name = 1 }, "ClassWithNonStringName" }; - yield return new object[] { null, new ClassWithNullToString(), "ClassWithNullToString" }; - yield return new object[] { typeof(int), null, string.Empty }; yield return new object[] { typeof(int), "", "String" }; yield return new object[] { typeof(int), "value", "value" }; @@ -825,7 +767,7 @@ public static IEnumerable GetItems_TestData() [MemberData(nameof(GetItems_TestData))] public void CollectionEditor_GetItems_Invoke_ReturnsExpected(object editValue, object[] expected) { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); object[] items = editor.GetItems(editValue); Assert.Equal(expected, items); Assert.IsType(expected.GetType(), items); @@ -869,12 +811,11 @@ public void CollectionEditor_GetService_WithContext_CallsContextGetService(Type Assert.Same(result, editor.GetService(serviceType)); } - [Theory] - [CommonMemberData(typeof(CommonTestHelperEx), nameof(CommonTestHelperEx.GetTypeWithNullTheoryData))] - public void CollectionEditor_GetService_InvokeWithoutContext_ReturnsNull(Type serviceType) + [Fact] + public void CollectionEditor_GetService_InvokeWithoutContext_ReturnsNull() { - SubCollectionEditor editor = new(serviceType); - Assert.Null(editor.GetService(serviceType)); + SubCollectionEditor editor = new(typeof(int)); + Assert.Null(editor.GetService(typeof(int))); } public static IEnumerable GetObjectsFromInstance_TestData() @@ -887,7 +828,7 @@ public static IEnumerable GetObjectsFromInstance_TestData() [MemberData(nameof(GetObjectsFromInstance_TestData))] public void CollectionEditor_GetObjectsFromInstance_Invoke_ReturnsExpected(object instance) { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); IList objects = editor.GetObjectsFromInstance(instance); Assert.Equal(new object[] { instance }, objects); Assert.IsType(objects); @@ -917,7 +858,7 @@ public static IEnumerable SetItems_TestData() [MemberData(nameof(SetItems_TestData))] public void CollectionEditor_SetItems_Invoke_ReturnsExpected(object editValue, object[] value, object expected) { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); object items = editor.SetItems(editValue, value); Assert.Equal(expected, items); Assert.Same(editValue, items); @@ -926,7 +867,7 @@ public void CollectionEditor_SetItems_Invoke_ReturnsExpected(object editValue, o [Fact] public void CollectionEditor_SetItems_InvokeArray_ThrowsNotSupportedException() { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); Assert.Throws(() => editor.SetItems(new object[1], new object[1])); } diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionFormTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionFormTests.cs index 85f42b7176b..2815a2e9338 100644 --- a/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionFormTests.cs +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/ComponentModel/Design/CollectionFormTests.cs @@ -455,7 +455,7 @@ public static IEnumerable CanRemoveInstance_TestData() [MemberData(nameof(CanRemoveInstance_TestData))] public void CollectionForm_CanRemoveInstance_Invoke_ReturnsExpected(object value) { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); SubCollectionForm form = new(editor); Assert.True(form.CanRemoveInstance(value)); } @@ -475,7 +475,7 @@ public void CollectionForm_CanRemoveInstance_InheritanceAttribute_ReturnsExpecte { using Component component = new(); TypeDescriptor.AddAttributes(component, attribute); - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); SubCollectionForm form = new(editor); Assert.Equal(expected, form.CanRemoveInstance(component)); } @@ -483,7 +483,7 @@ public void CollectionForm_CanRemoveInstance_InheritanceAttribute_ReturnsExpecte [Fact] public void CollectionForm_CanSelectMultipleInstances_Invoke_ReturnsFalse() { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); SubCollectionForm form = new(editor); Assert.True(form.CanSelectMultipleInstances()); } @@ -697,7 +697,7 @@ public void CollectionForm_CreateInstance_WithContextWithHostReturningComponentW [Fact] public void CollectionForm_CreateInstance_InvokeWithoutContext_ReturnsExpected() { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); SubCollectionForm form = new(editor); Assert.Equal(0, form.CreateInstance(typeof(int))); } @@ -705,7 +705,7 @@ public void CollectionForm_CreateInstance_InvokeWithoutContext_ReturnsExpected() [Fact] public void CollectionForm_CreateInstance_NullItemType_ThrowsArgumentNullException() { - SubCollectionEditor editor = new(null); + SubCollectionEditor editor = new(typeof(string)); SubCollectionForm form = new(editor); Assert.Throws("itemType", () => form.CreateInstance(null)); } @@ -791,13 +791,12 @@ public void CollectionForm_GetService_WithContext_CallsContextGetService(Type se Assert.Same(result, form.GetService(serviceType)); } - [Theory] - [CommonMemberData(typeof(CommonTestHelperEx), nameof(CommonTestHelperEx.GetTypeWithNullTheoryData))] - public void CollectionForm_GetService_InvokeWithoutContext_ReturnsNull(Type serviceType) + [Fact] + public void CollectionForm_GetService_InvokeWithoutContext_ReturnsNull() { - SubCollectionEditor editor = new(serviceType); + SubCollectionEditor editor = new(typeof(int)); SubCollectionForm form = new(editor); - Assert.Null(form.GetService(serviceType)); + Assert.Null(form.GetService(typeof(int))); } [Fact]