Skip to content

Commit f56c40a

Browse files
committed
Merge branch 'master' into WFI-585-port-system-windows-forms-design-components
2 parents 904b27e + 25e6260 commit f56c40a

File tree

7 files changed

+203
-72
lines changed

7 files changed

+203
-72
lines changed

eng/Version.Details.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ Note: if the Uri is a new place, you will need to add a subscription from that p
3939
<Uri>https://github.com/dotnet/corefx</Uri>
4040
<Sha>d6a30736858f91b297fdd3ed4e3d1dfde67bdbdb</Sha>
4141
</Dependency>
42-
<Dependency Name="Microsoft.NETCore.App" Version="3.0.0-preview4-27525-01">
42+
<Dependency Name="Microsoft.NETCore.App" Version="3.0.0-preview4-27525-14">
4343
<Uri>https://github.com/dotnet/core-setup</Uri>
44-
<Sha>c521a89c14023a08d9cd6fb4b47dc13ca3c5e1f7</Sha>
44+
<Sha>36f75eb9d513d79acbd84b8137e5f4c10b38f5a1</Sha>
4545
</Dependency>
4646
</ProductDependencies>
4747
<ToolsetDependencies>
@@ -65,14 +65,14 @@ Note: if the Uri is a new place, you will need to add a subscription from that p
6565
<Uri>https://github.com/dotnet/arcade</Uri>
6666
<Sha>443dea11f8649fe12fedf60cfab0a4b2b20bd153</Sha>
6767
</Dependency>
68-
<Dependency Name="Microsoft.NET.Sdk.IL" Version="3.0.0-preview4-27525-71" CoherentParentDependency="Microsoft.NETCore.App">
68+
<Dependency Name="Microsoft.NET.Sdk.IL" Version="3.0.0-preview4-27525-72" CoherentParentDependency="Microsoft.NETCore.App">
6969
<Uri>https://github.com/dotnet/coreclr</Uri>
70-
<Sha>a593024b85a6e074770c88867491f4f30cc6fc8a</Sha>
70+
<Sha>2520798548b0c414f513aaaf708399f8ef5a4f6c</Sha>
7171
<SourceBuildId>5596</SourceBuildId>
7272
</Dependency>
73-
<Dependency Name="Microsoft.NETCore.ILAsm" Version="3.0.0-preview4-27525-71" CoherentParentDependency="Microsoft.NETCore.App">
73+
<Dependency Name="Microsoft.NETCore.ILAsm" Version="3.0.0-preview4-27525-72" CoherentParentDependency="Microsoft.NETCore.App">
7474
<Uri>https://github.com/dotnet/coreclr</Uri>
75-
<Sha>a593024b85a6e074770c88867491f4f30cc6fc8a</Sha>
75+
<Sha>2520798548b0c414f513aaaf708399f8ef5a4f6c</Sha>
7676
<SourceBuildId>5596</SourceBuildId>
7777
</Dependency>
7878
</ToolsetDependencies>

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</PropertyGroup>
2727
<!-- CoreCLR-updated dependencies -->
2828
<PropertyGroup>
29-
<MicrosoftNETCoreILAsmPackageVersion>3.0.0-preview4-27525-71</MicrosoftNETCoreILAsmPackageVersion>
29+
<MicrosoftNETCoreILAsmPackageVersion>3.0.0-preview4-27525-72</MicrosoftNETCoreILAsmPackageVersion>
3030
</PropertyGroup>
3131
<!-- Arcade-updated dependencies -->
3232
<PropertyGroup>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"msbuild-sdks": {
1212
"Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19162.7",
1313
"Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19162.7",
14-
"Microsoft.NET.Sdk.IL": "3.0.0-preview4-27525-71"
14+
"Microsoft.NET.Sdk.IL": "3.0.0-preview4-27525-72"
1515
}
1616
}

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

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,20 @@ public class DesignerActionItemCollection : CollectionBase
1010
{
1111
public DesignerActionItem this[int index]
1212
{
13-
get => throw new NotImplementedException(SR.NotImplementedByDesign);
14-
set => throw new NotImplementedException(SR.NotImplementedByDesign);
13+
get => (DesignerActionItem)(List[index]);
14+
set => List[index] = value;
1515
}
1616

17-
public int Add(DesignerActionItem value)
18-
{
19-
throw new NotImplementedException(SR.NotImplementedByDesign);
20-
}
21-
22-
public bool Contains(DesignerActionItem value)
23-
{
24-
throw new NotImplementedException(SR.NotImplementedByDesign);
25-
}
26-
27-
public void CopyTo(DesignerActionItem[] array, int index)
28-
{
29-
throw new NotImplementedException(SR.NotImplementedByDesign);
30-
}
17+
public int Add(DesignerActionItem value) => List.Add(value);
3118

32-
public int IndexOf(DesignerActionItem value)
33-
{
34-
throw new NotImplementedException(SR.NotImplementedByDesign);
35-
}
19+
public bool Contains(DesignerActionItem value) => List.Contains(value);
3620

37-
public void Insert(int index, DesignerActionItem value)
38-
{
39-
throw new NotImplementedException(SR.NotImplementedByDesign);
40-
}
21+
public void CopyTo(DesignerActionItem[] array, int index) => List.CopyTo(array, index);
4122

42-
public void Remove(DesignerActionItem value)
43-
{
44-
throw new NotImplementedException(SR.NotImplementedByDesign);
45-
}
23+
public int IndexOf(DesignerActionItem value) => List.IndexOf(value);
24+
25+
public void Insert(int index, DesignerActionItem value) => List.Insert(index, value);
26+
27+
public void Remove(DesignerActionItem value) => List.Remove(value);
4628
}
4729
}

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

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System.Collections;
6+
using System.Diagnostics;
67
using System.Runtime.InteropServices;
78

89
namespace System.ComponentModel.Design
@@ -21,50 +22,50 @@ public DesignerActionListCollection(DesignerActionList[] value)
2122

2223
public DesignerActionList this[int index]
2324
{
24-
get => throw new NotImplementedException(SR.NotImplementedByDesign);
25-
set => throw new NotImplementedException(SR.NotImplementedByDesign);
25+
get => (DesignerActionList)(List[index]);
26+
set => List[index] = value;
2627
}
2728

2829
public int Add(DesignerActionList value)
2930
{
30-
throw new NotImplementedException(SR.NotImplementedByDesign);
31+
return List.Add(value);
3132
}
3233

3334
public void AddRange(DesignerActionList[] value)
3435
{
35-
throw new NotImplementedException(SR.NotImplementedByDesign);
36+
if (value == null)
37+
{
38+
throw new ArgumentNullException(nameof(value));
39+
}
40+
for (int i = 0; i < value.Length; i++)
41+
{
42+
Add(value[i]);
43+
}
3644
}
3745

3846
public void AddRange(DesignerActionListCollection value)
3947
{
40-
throw new NotImplementedException(SR.NotImplementedByDesign);
41-
}
42-
43-
public void Insert(int index, DesignerActionList value)
44-
{
45-
throw new NotImplementedException(SR.NotImplementedByDesign);
46-
}
47-
48-
public int IndexOf(DesignerActionList value)
49-
{
50-
throw new NotImplementedException(SR.NotImplementedByDesign);
51-
}
52-
53-
public bool Contains(DesignerActionList value)
54-
{
55-
throw new NotImplementedException(SR.NotImplementedByDesign);
56-
}
57-
58-
public void Remove(DesignerActionList value)
59-
{
60-
throw new NotImplementedException(SR.NotImplementedByDesign);
61-
}
62-
63-
public void CopyTo(DesignerActionList[] array, int index)
64-
{
65-
throw new NotImplementedException(SR.NotImplementedByDesign);
66-
}
67-
48+
if (value == null)
49+
{
50+
throw new ArgumentNullException(nameof(value));
51+
}
52+
int currentCount = value.Count;
53+
for (int i = 0; i < currentCount; i++)
54+
{
55+
Add(value[i]);
56+
}
57+
}
58+
59+
public void Insert(int index, DesignerActionList value) => List.Insert(index, value);
60+
61+
public int IndexOf(DesignerActionList value) => List.IndexOf(value);
62+
63+
public bool Contains(DesignerActionList value) => List.Contains(value);
64+
65+
public void Remove(DesignerActionList value) => List.Remove(value);
66+
67+
public void CopyTo(DesignerActionList[] array, int index) => List.CopyTo(array, index);
68+
6869
protected override void OnSet(int index, object oldValue, object newValue)
6970
{
7071
}
@@ -81,9 +82,6 @@ protected override void OnRemove(int index, object value)
8182
{
8283
}
8384

84-
protected override void OnValidate(object value)
85-
{
86-
throw new NotImplementedException(SR.NotImplementedByDesign);
87-
}
85+
protected override void OnValidate(object value) => Debug.Assert(value != null, "Don't add null actionlist!");
8886
}
8987
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.ComponentModel.Design;
6+
using Xunit;
7+
8+
namespace System.Windows.Forms.Design.Tests
9+
{
10+
public class DesignerActionItemCollectionTests
11+
{
12+
[Fact]
13+
public void DesignerActionItemCollection_Constructor()
14+
{
15+
DesignerActionItemCollection underTest = new DesignerActionItemCollection();
16+
Assert.NotNull(underTest);
17+
Assert.Empty(underTest);
18+
}
19+
20+
[Fact]
21+
public void DesignerActionItemCollection_Add_Contains_IndexOf()
22+
{
23+
DesignerActionItemCollection underTest = new DesignerActionItemCollection();
24+
25+
DesignerActionItem item1 = new DesignerActionItemTest("name", "category", "description");
26+
underTest.Add(item1);
27+
Assert.True(underTest.Contains(item1));
28+
Assert.Equal(0, underTest.IndexOf(item1));
29+
30+
DesignerActionItem item2 = new DesignerActionItemTest("name1", "category1", "description1");
31+
underTest.Add(item2);
32+
Assert.True(underTest.Contains(item2));
33+
Assert.Equal(1, underTest.IndexOf(item2));
34+
}
35+
36+
[Fact]
37+
public void DesignerActionItemCollection_Insert_Remove_Count()
38+
{
39+
DesignerActionItemCollection underTest = new DesignerActionItemCollection();
40+
DesignerActionItem item1 = new DesignerActionItemTest("name", "category", "description");
41+
DesignerActionItem item2 = new DesignerActionItemTest("name1", "category1", "description1");
42+
DesignerActionItem item3 = new DesignerActionItemTest("name2", "category2", "description2");
43+
DesignerActionItem item4 = new DesignerActionItemTest("name3", "category3", "description3");
44+
45+
underTest.Add(item1);
46+
underTest.Add(item2);
47+
48+
underTest.Add(item3);
49+
Assert.Equal(2, underTest.IndexOf(item3));
50+
51+
underTest.Insert(2, item4);
52+
Assert.Equal(3, underTest.IndexOf(item3));
53+
Assert.Equal(2, underTest.IndexOf(item4));
54+
55+
underTest.Remove(item4);
56+
Assert.False(underTest.Contains(item4));
57+
Assert.Equal(2, underTest.IndexOf(item3));
58+
Assert.Equal(3, underTest.Count);
59+
}
60+
61+
private class DesignerActionItemTest : DesignerActionItem
62+
{
63+
public DesignerActionItemTest(string displayName, string category, string description) : base(displayName, category, description)
64+
{
65+
}
66+
}
67+
}
68+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.ComponentModel.Design;
6+
using WinForms.Common.Tests;
7+
using Xunit;
8+
9+
namespace System.Windows.Forms.Design.Tests
10+
{
11+
public class DesignerActionListCollectionTests
12+
{
13+
[Fact]
14+
public void DesignerActionListCollection_Constructor()
15+
{
16+
DesignerActionListCollection underTest = new DesignerActionListCollection();
17+
Assert.NotNull(underTest);
18+
}
19+
20+
[Fact]
21+
public void DesignerActionListCollection_Constructor_DesignerActionList()
22+
{
23+
DesignerActionListCollection underTest = CreateNewCollectionOfItems();
24+
Assert.NotNull(underTest);
25+
}
26+
27+
[Fact]
28+
public void DesignerActionItemCollection_Add_AddRange()
29+
{
30+
DesignerActionListCollection underTest = CreateNewCollectionOfItems(5);
31+
Assert.Equal(5, underTest.Count);
32+
33+
Button button = new Button();
34+
DesignerActionList list = new DesignerActionList(button);
35+
underTest.Add(list);
36+
Assert.Equal(6, underTest.Count);
37+
38+
DesignerActionListCollection other = CreateNewCollectionOfItems(3);
39+
underTest.AddRange(other);
40+
Assert.Equal(9, underTest.Count);
41+
}
42+
43+
44+
[Fact]
45+
public void DesignerActionItemCollection_Insert_Contains_IndexOf()
46+
{
47+
DesignerActionListCollection underTest = CreateNewCollectionOfItems(5);
48+
49+
Button button = new Button();
50+
DesignerActionList list = new DesignerActionList(button);
51+
underTest.Insert(3, list);
52+
Assert.True(underTest.Contains(list));
53+
Assert.Equal(3, underTest.IndexOf(list));
54+
}
55+
56+
[Fact]
57+
public void DesignerActionItemCollection_Remove()
58+
{
59+
DesignerActionListCollection underTest = CreateNewCollectionOfItems(5);
60+
61+
Button button = new Button();
62+
DesignerActionList list = new DesignerActionList(button);
63+
underTest.Insert(3, list);
64+
underTest.Remove(list);
65+
Assert.False(underTest.Contains(list));
66+
Assert.Equal(5, underTest.Count);
67+
}
68+
69+
private DesignerActionListCollection CreateNewCollectionOfItems(int numberOfItems = 1)
70+
{
71+
Button button = new Button();
72+
DesignerActionList[] list = new DesignerActionList[] { new DesignerActionList(button) };
73+
DesignerActionListCollection underTest = new DesignerActionListCollection(list);
74+
75+
for (int i = 1; i < numberOfItems; i++)
76+
{
77+
underTest.Add(new DesignerActionList(button));
78+
}
79+
80+
return underTest;
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)