Skip to content

Commit

Permalink
Merge branch 'dotnet:main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
PWagner1 authored May 27, 2024
2 parents 19f4a11 + b546fbd commit 4cc8b2b
Show file tree
Hide file tree
Showing 9 changed files with 517 additions and 141 deletions.
172 changes: 86 additions & 86 deletions eng/Version.Details.xml

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,35 @@
</PropertyGroup>
<!-- Below have corresponding entries in Versions.Details.XML because they are updated via Maestro -->
<PropertyGroup>
<VSRedistCommonNetCoreSharedFrameworkx6490PackageVersion>9.0.0-preview.5.24273.1</VSRedistCommonNetCoreSharedFrameworkx6490PackageVersion>
<SystemDiagnosticsEventLogPackageVersion>9.0.0-preview.5.24273.1</SystemDiagnosticsEventLogPackageVersion>
<SystemDirectoryServicesPackageVersion>9.0.0-preview.5.24273.1</SystemDirectoryServicesPackageVersion>
<SystemReflectionMetadataLoadContextPackageVersion>9.0.0-preview.5.24273.1</SystemReflectionMetadataLoadContextPackageVersion>
<SystemSecurityCryptographyXmlPackageVersion>9.0.0-preview.5.24273.1</SystemSecurityCryptographyXmlPackageVersion>
<SystemIOHashingPackageVersion>9.0.0-preview.5.24273.1</SystemIOHashingPackageVersion>
<SystemIOPackagingPackageVersion>9.0.0-preview.5.24273.1</SystemIOPackagingPackageVersion>
<VSRedistCommonNetCoreSharedFrameworkx6490PackageVersion>9.0.0-preview.5.24274.15</VSRedistCommonNetCoreSharedFrameworkx6490PackageVersion>
<SystemDiagnosticsEventLogPackageVersion>9.0.0-preview.5.24274.15</SystemDiagnosticsEventLogPackageVersion>
<SystemDirectoryServicesPackageVersion>9.0.0-preview.5.24274.15</SystemDirectoryServicesPackageVersion>
<SystemReflectionMetadataLoadContextPackageVersion>9.0.0-preview.5.24274.15</SystemReflectionMetadataLoadContextPackageVersion>
<SystemSecurityCryptographyXmlPackageVersion>9.0.0-preview.5.24274.15</SystemSecurityCryptographyXmlPackageVersion>
<SystemIOHashingPackageVersion>9.0.0-preview.5.24274.15</SystemIOHashingPackageVersion>
<SystemIOPackagingPackageVersion>9.0.0-preview.5.24274.15</SystemIOPackagingPackageVersion>
<MicrosoftNETCoreRuntimeCoreCLRPackageVersion>5.0.0-preview.7.20320.5</MicrosoftNETCoreRuntimeCoreCLRPackageVersion>
<MicrosoftNETCoreILDAsmPackageVersion>9.0.0-preview.5.24273.1</MicrosoftNETCoreILDAsmPackageVersion>
<SystemDiagnosticsPerformanceCounterPackageVersion>9.0.0-preview.5.24273.1</SystemDiagnosticsPerformanceCounterPackageVersion>
<MicrosoftNETCoreILDAsmPackageVersion>9.0.0-preview.5.24274.15</MicrosoftNETCoreILDAsmPackageVersion>
<SystemDiagnosticsPerformanceCounterPackageVersion>9.0.0-preview.5.24274.15</SystemDiagnosticsPerformanceCounterPackageVersion>
<SystemRuntimeCompilerServicesUnsafePackageVersion>6.0.0</SystemRuntimeCompilerServicesUnsafePackageVersion>
<SystemSecurityCryptographyPkcsPackageVersion>9.0.0-preview.5.24273.1</SystemSecurityCryptographyPkcsPackageVersion>
<SystemSecurityCryptographyProtectedDataPackageVersion>9.0.0-preview.5.24273.1</SystemSecurityCryptographyProtectedDataPackageVersion>
<SystemTextEncodingsWebPackageVersion>9.0.0-preview.5.24273.1</SystemTextEncodingsWebPackageVersion>
<SystemTextJsonPackageVersion>9.0.0-preview.5.24273.1</SystemTextJsonPackageVersion>
<SystemThreadingAccessControlPackageVersion>9.0.0-preview.5.24273.1</SystemThreadingAccessControlPackageVersion>
<MicrosoftWin32RegistryAccessControlPackageVersion>9.0.0-preview.5.24273.1</MicrosoftWin32RegistryAccessControlPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>9.0.0-preview.5.24273.1</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftNETCoreAppRuntimewinx64PackageVersion>9.0.0-preview.5.24273.1</MicrosoftNETCoreAppRuntimewinx64PackageVersion>
<MicrosoftNETCorePlatformsPackageVersion>9.0.0-preview.5.24273.1</MicrosoftNETCorePlatformsPackageVersion>
<MicrosoftWin32SystemEventsPackageVersion>9.0.0-preview.5.24273.1</MicrosoftWin32SystemEventsPackageVersion>
<SystemCodeDomPackageVersion>9.0.0-preview.5.24273.1</SystemCodeDomPackageVersion>
<SystemConfigurationConfigurationManagerPackageVersion>9.0.0-preview.5.24273.1</SystemConfigurationConfigurationManagerPackageVersion>
<SystemResourcesExtensionsPackageVersion>9.0.0-preview.5.24273.1</SystemResourcesExtensionsPackageVersion>
<SystemSecurityPermissionsPackageVersion>9.0.0-preview.5.24273.1</SystemSecurityPermissionsPackageVersion>
<SystemWindowsExtensionsPackageVersion>9.0.0-preview.5.24273.1</SystemWindowsExtensionsPackageVersion>
<MicrosoftNETCoreILAsmPackageVersion>9.0.0-preview.5.24273.1</MicrosoftNETCoreILAsmPackageVersion>
<runtimewinx64MicrosoftNETCoreILAsmPackageVersion>9.0.0-preview.5.24273.1</runtimewinx64MicrosoftNETCoreILAsmPackageVersion>
<runtimewinx86MicrosoftNETCoreILAsmPackageVersion>9.0.0-preview.5.24273.1</runtimewinx86MicrosoftNETCoreILAsmPackageVersion>
<SystemSecurityCryptographyPkcsPackageVersion>9.0.0-preview.5.24274.15</SystemSecurityCryptographyPkcsPackageVersion>
<SystemSecurityCryptographyProtectedDataPackageVersion>9.0.0-preview.5.24274.15</SystemSecurityCryptographyProtectedDataPackageVersion>
<SystemTextEncodingsWebPackageVersion>9.0.0-preview.5.24274.15</SystemTextEncodingsWebPackageVersion>
<SystemTextJsonPackageVersion>9.0.0-preview.5.24274.15</SystemTextJsonPackageVersion>
<SystemThreadingAccessControlPackageVersion>9.0.0-preview.5.24274.15</SystemThreadingAccessControlPackageVersion>
<MicrosoftWin32RegistryAccessControlPackageVersion>9.0.0-preview.5.24274.15</MicrosoftWin32RegistryAccessControlPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>9.0.0-preview.5.24274.15</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftNETCoreAppRuntimewinx64PackageVersion>9.0.0-preview.5.24274.15</MicrosoftNETCoreAppRuntimewinx64PackageVersion>
<MicrosoftNETCorePlatformsPackageVersion>9.0.0-preview.5.24274.15</MicrosoftNETCorePlatformsPackageVersion>
<MicrosoftWin32SystemEventsPackageVersion>9.0.0-preview.5.24274.15</MicrosoftWin32SystemEventsPackageVersion>
<SystemCodeDomPackageVersion>9.0.0-preview.5.24274.15</SystemCodeDomPackageVersion>
<SystemConfigurationConfigurationManagerPackageVersion>9.0.0-preview.5.24274.15</SystemConfigurationConfigurationManagerPackageVersion>
<SystemResourcesExtensionsPackageVersion>9.0.0-preview.5.24274.15</SystemResourcesExtensionsPackageVersion>
<SystemSecurityPermissionsPackageVersion>9.0.0-preview.5.24274.15</SystemSecurityPermissionsPackageVersion>
<SystemWindowsExtensionsPackageVersion>9.0.0-preview.5.24274.15</SystemWindowsExtensionsPackageVersion>
<MicrosoftNETCoreILAsmPackageVersion>9.0.0-preview.5.24274.15</MicrosoftNETCoreILAsmPackageVersion>
<runtimewinx64MicrosoftNETCoreILAsmPackageVersion>9.0.0-preview.5.24274.15</runtimewinx64MicrosoftNETCoreILAsmPackageVersion>
<runtimewinx86MicrosoftNETCoreILAsmPackageVersion>9.0.0-preview.5.24274.15</runtimewinx86MicrosoftNETCoreILAsmPackageVersion>
<!--
Microsoft.NET.Sdk.IL.targets requires definition of MicrosoftNETCoreILAsmVersion
-->
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"Microsoft.DotNet.CMake.Sdk": "9.0.0-beta.24272.5",
"Microsoft.DotNet.Helix.Sdk": "9.0.0-beta.24272.5",
"FIX-85B6-MERGE-9C38-CONFLICT": "1.0.0",
"Microsoft.NET.Sdk.IL": "9.0.0-preview.5.24273.1"
"Microsoft.NET.Sdk.IL": "9.0.0-preview.5.24274.15"
},
"native-tools": {
"cmake": "latest"
Expand Down
Original file line number Diff line number Diff line change
@@ -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

using System.ComponentModel;
using System.Drawing.Design;

Expand All @@ -12,7 +10,10 @@ internal partial class DesignBindingValueUIHandler
{
private class LocalUIItem : PropertyValueUIItem
{
internal LocalUIItem(DesignBindingValueUIHandler handler, Binding binding) : base(handler.DataBitmap, new PropertyValueUIItemInvokeHandler(OnPropertyValueUIItemInvoke), GetToolTip(binding))
internal LocalUIItem(DesignBindingValueUIHandler handler, Binding binding)
: base(
handler.DataBitmap,
new PropertyValueUIItemInvokeHandler(OnPropertyValueUIItemInvoke), GetToolTip(binding))
{
Binding = binding;
}
Expand All @@ -21,13 +22,10 @@ private class LocalUIItem : PropertyValueUIItem

private static string GetToolTip(Binding binding)
{
string name = "";
if (binding.DataSource is IComponent comp)
string name = string.Empty;
if (binding.DataSource is IComponent comp && comp.Site is { } site)
{
if (comp.Site is not null)
{
name = comp.Site.Name;
}
name = site.Name ?? string.Empty;
}

if (name.Length == 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -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

using System.Collections;
using System.ComponentModel;
using System.Drawing.Design;
Expand All @@ -15,7 +13,7 @@ namespace System.Windows.Forms.Design;
/// </summary>
internal partial class DesignBindingValueUIHandler : IDisposable
{
private Bitmap _dataBitmap;
private Bitmap? _dataBitmap;

internal Bitmap DataBitmap
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,49 @@ public void CheckedIndexCollection_Methods_ThrowNotSupportedException()
}

[WinFormsTheory]
[InlineData([new string[] { "item1", "item2" }, new bool[] { true, false }, 0, true])]
[InlineData([new string[] { "item1", "item2" }, new bool[] { true, false }, 1, false])]
[InlineData([new string[] { "item1", "item2" }, new bool[] { false, false }, 0, false])]
public void CheckedIndexCollection_Contains_ReturnsExpected(string[] items, bool[] checkedStatus, int index, bool expected)
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { true, false, true }, 0, true)]
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { true, false, true }, 1, false)]
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { false, true, false }, 1, true)]
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { false, false, false }, 0, false)]
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { true, false, true }, "invalid", false)]
public void CheckedIndexCollection_ContainsIntAndObject_ReturnsExpected(string[] items, bool[] checkedStates, object index, bool expected)
{
for (int i = 0; i < items.Length; i++)
{
_checkedListBox.Items.Add(items[i], checkedStatus[i]);
_checkedListBox.Items.Add(items[i], checkedStates[i]);
}

// Test Contains method
_collection.Contains(index).Should().Be(expected);
// Test Contains(int index) method
if (index is int @int)
{
_collection.Contains(@int).Should().Be(expected);
}

// Test IList.Contains(object? index) method
((IList)_collection).Contains(index).Should().Be(expected);
}

[WinFormsTheory]
[InlineData(true, 0)]
[InlineData(false, -1)]
public void CheckedIndexCollection_IndexOf_ReturnsExpected(bool isChecked, int expectedIndex)
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { true, false, true }, 0, 0)]
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { true, false, true }, 1, -1)]
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { false, true, false }, 1, 0)]
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { false, false, false }, 0, -1)]
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { true, false, true }, "invalid", -1)]
public void CheckedIndexCollection_IndexOfIntAndObject_ReturnsExpected(string[] items, bool[] checkedStates, object index, int expected)
{
_checkedListBox.Items.Add("item1", isChecked);
for (int i = 0; i < items.Length; i++)
{
_checkedListBox.Items.Add(items[i], checkedStates[i]);
}

// Test IndexOf(int index) method
if (index is int @int)
{
_collection.IndexOf(@int).Should().Be(expected);
}

// Test IndexOf method
_collection.IndexOf(0).Should().Be(expectedIndex);
((IList)_collection).IndexOf(0).Should().Be(expectedIndex);
((IList)_collection).IndexOf("invalid").Should().Be(-1);
// Test IList.IndexOf(object? index) method
((IList)_collection).IndexOf(index).Should().Be(expected);
}

[WinFormsTheory]
Expand Down Expand Up @@ -122,4 +139,19 @@ public void CheckedIndexCollection_GetEnumerator_ReturnsExpected(string[] items,

enumerator.MoveNext().Should().BeFalse();
}

[WinFormsTheory]
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { true, false, true }, 0, 0)]
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { true, false, true }, 1, 2)]
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { false, true, false }, 0, 1)]
public void CheckedIndexCollection_ItemGet_ReturnsExpected(string[] items, bool[] checkedStates, int index, int expected)
{
for (int i = 0; i < items.Length; i++)
{
_checkedListBox.Items.Add(items[i], checkedStates[i]);
}

int result = (int)((IList)_collection)[index];
result.Should().Be(expected);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections;

namespace System.Windows.Forms.Tests;

public class CheckedListBox_CheckedItemCollectionTests : IDisposable
{
private readonly CheckedListBox _checkedListBox;
private readonly CheckedListBox.CheckedItemCollection _collection;

public CheckedListBox_CheckedItemCollectionTests()
{
_checkedListBox = new CheckedListBox();
_collection = new CheckedListBox.CheckedItemCollection(_checkedListBox);
}

public void Dispose()
{
_checkedListBox.Items.Clear();
_checkedListBox.Dispose();
}

[WinFormsFact]
public void CheckedItemCollection_Properties_ReturnExpected()
{
// Test properties: Count, SyncRoot, IsSynchronized, IsFixedSize, IsReadOnly
_collection.Count.Should().Be(0);
((ICollection)_collection).SyncRoot.Should().BeSameAs(_collection);
((ICollection)_collection).IsSynchronized.Should().BeFalse();
((IList)_collection).IsFixedSize.Should().BeTrue();
_collection.IsReadOnly.Should().BeTrue();
}

[WinFormsFact]
public void CheckedItemCollection_Methods_ThrowNotSupportedException()
{
// Test methods: Add, Clear, Insert, Remove, RemoveAt that should throw NotSupportedException
((Action)(() => ((IList)_collection)[0] = 1)).Should().Throw<NotSupportedException>();
((IList)_collection).Invoking(c => c.Add(1)).Should().Throw<NotSupportedException>();
((IList)_collection).Invoking(c => c.Clear()).Should().Throw<NotSupportedException>();
((IList)_collection).Invoking(c => c.Insert(0, 1)).Should().Throw<NotSupportedException>();
((IList)_collection).Invoking(c => c.Remove(1)).Should().Throw<NotSupportedException>();
((IList)_collection).Invoking(c => c.RemoveAt(0)).Should().Throw<NotSupportedException>();
}

[WinFormsFact]
public void CheckedItemCollection_ItemGet_ReturnsExpected()
{
_checkedListBox.Items.Add("item1", true);
_checkedListBox.Items.Add("item2", false);

_collection.Count.Should().Be(1);
_collection[0].Should().Be("item1");
}

private void AddItemsToCheckedListBox(string[] items, bool[] checkedStates)
{
for (int i = 0; i < items.Length; i++)
{
_checkedListBox.Items.Add(items[i], checkedStates[i]);
}
}

[WinFormsTheory]
[InlineData(new string[] { "item1", "item2" }, new bool[] { true, false }, "item1", true)]
[InlineData(new string[] { "item1", "item2" }, new bool[] { false, true }, "item2", true)]
[InlineData(new string[] { "item1", "item2" }, new bool[] { false, false }, "item1", false)]
public void CheckedItemCollection_Contains_ReturnsExpected(string[] items, bool[] checkedStates, string item, bool expected)
{
AddItemsToCheckedListBox(items, checkedStates);

_collection.Contains(item).Should().Be(expected);
}

[WinFormsTheory]
[InlineData(new string[] { "item1", "item2" }, new bool[] { true, false }, "item1", 0)]
[InlineData(new string[] { "item1", "item2" }, new bool[] { false, true }, "item2", 0)]
[InlineData(new string[] { "item1", "item2" }, new bool[] { false, false }, "item1", -1)]
public void CheckedItemCollection_IndexOf_ReturnsExpected(string[] items, bool[] checkedStates, string item, int expected)
{
AddItemsToCheckedListBox(items, checkedStates);

_collection.IndexOf(item).Should().Be(expected);
}

[WinFormsTheory]
[InlineData(new string[] { "item1", "item2" }, new bool[] { true, false }, new object[] { "item1", null })]
[InlineData(new string[] { "item1", "item2" }, new bool[] { false, true }, new object[] { "item2", null })]
[InlineData(new string[] { "item1", "item2" }, new bool[] { false, false }, new object[] { null, null })]
public void CheckedItemCollection_CopyTo_CopiesExpectedValues(string[] items, bool[] checkedStates, object[] expected)
{
AddItemsToCheckedListBox(items, checkedStates);

object[] array = new object[items.Length];
((ICollection)_collection).CopyTo(array, 0);

array.Should().Equal(expected);
}

[WinFormsTheory]
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { true, false, true }, new object[] { "item1", "item3" })]
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { false, true, false }, new object[] { "item2" })]
[InlineData(new string[] { "item1", "item2", "item3" }, new bool[] { false, false, false }, new object[] { })]
public void CheckedItemCollection_GetEnumerator_ReturnsExpected(string[] items, bool[] checkedStates, object[] expected)
{
AddItemsToCheckedListBox(items, checkedStates);

IEnumerator enumerator = _collection.GetEnumerator();
List<object> result = new List<object>();
while (enumerator.MoveNext())
{
result.Add(enumerator.Current);
}

result.Should().Equal(expected);
}
}
Loading

0 comments on commit 4cc8b2b

Please sign in to comment.