Skip to content

Commit ee751a4

Browse files
authored
Merge pull request #3 from InitialForce/cherry-pick-batch-h3xds1nz-2026-05-01
Batch cherry-pick: 9 h3xds1nz upstream PRs (clean apply onto if/main)
2 parents a105e10 + ebb958a commit ee751a4

15 files changed

Lines changed: 71 additions & 129 deletions

File tree

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/PresentationBuildTasks.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@
7373
<Compile Include="$(WpfSharedDir)\MS\Internal\ReflectionUtils.cs">
7474
<Link>Shared\MS\Internal\ReflectionUtils.cs</Link>
7575
</Compile>
76-
<Compile Include="$(WpfSharedDir)\MS\Internal\SecurityHelper.cs">
77-
<Link>Shared\MS\Internal\SecurityHelper.cs</Link>
78-
</Compile>
7976
<Compile Include="$(WpfSharedDir)\MS\Internal\TokenizerHelper.cs">
8077
<Link>Shared\MS\Internal\TokenizerHelper.cs</Link>
8178
</Compile>

src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@
714714
<Compile Include="System\Windows\Media\CultureSpecificStringDictionary.cs" />
715715
<Compile Include="System\Windows\Media\DashStyle.cs" />
716716
<Compile Include="System\Windows\Media\DashStyles.cs" />
717+
<Compile Include="System\Windows\Media\DoubleCollection.cs" />
717718
<Compile Include="System\Windows\Media\Drawing.cs" />
718719
<Compile Include="System\Windows\Media\DrawingBrush.cs" />
719720
<Compile Include="System\Windows\Media\DrawingCollection.cs" />

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/MouseActionConverter.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
namespace System.Windows.Input
88
{
99
/// <summary>
10-
/// Converter class for converting between a <see langword="string"/> and <see cref="MouseAction"/>.
10+
/// Converter class for converting between a <see cref="string"/> and <see cref="MouseAction"/>.
1111
/// </summary>
1212
public class MouseActionConverter : TypeConverter
1313
{
1414
///<summary>
15-
/// Used to check whether we can convert a <see langword="string"/> into a <see cref="MouseAction"/>.
15+
/// Used to check whether we can convert a <see cref="string"/> into a <see cref="MouseAction"/>.
1616
///</summary>
1717
///<param name="context">ITypeDescriptorContext</param>
1818
///<param name="sourceType">type to convert from</param>
@@ -24,32 +24,32 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT
2424
}
2525

2626
/// <summary>
27-
/// Used to check whether we can convert specified value to <see langword="string"/>.
27+
/// Used to check whether we can convert specified value to <see cref="string"/>.
2828
/// </summary>
2929
/// <param name="context">ITypeDescriptorContext</param>
3030
/// <param name="destinationType">Type to convert to</param>
31-
/// <returns><see langword="true"/> if conversion to <see langword="string"/> is possible, <see langword="false"/> otherwise.</returns>
31+
/// <returns><see langword="true"/> if conversion to <see cref="string"/> is possible, <see langword="false"/> otherwise.</returns>
3232
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
3333
{
3434
// We can convert to an InstanceDescriptor or to a string
3535
if (destinationType != typeof(string))
3636
return false;
3737

3838
// When invoked by the serialization engine we can convert to string only for known type
39-
if (context is null || context.Instance is null)
39+
if (context?.Instance is not MouseAction mouseAction)
4040
return false;
4141

4242
// Make sure the value falls within defined set
43-
return IsDefinedMouseAction((MouseAction)context.Instance);
43+
return IsDefinedMouseAction(mouseAction);
4444
}
4545

4646
/// <summary>
47-
/// Converts <paramref name="source"/> of <see langword="string"/> type to its <see cref="MouseAction"/> represensation.
47+
/// Converts <paramref name="source"/> of <see cref="string"/> type to its <see cref="MouseAction"/> representation.
4848
/// </summary>
4949
/// <param name="context">Parser Context</param>
5050
/// <param name="culture">Culture Info</param>
5151
/// <param name="source">MouseAction String</param>
52-
/// <returns>A <see cref="MouseAction"/> representing the <see langword="string"/> specified by <paramref name="source"/>.</returns>
52+
/// <returns>A <see cref="MouseAction"/> representing the <see cref="string"/> specified by <paramref name="source"/>.</returns>
5353
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object source)
5454
{
5555
if (source is not string mouseAction)
@@ -72,21 +72,20 @@ _ when mouseActionToken.Equals("MiddleDoubleClick", StringComparison.OrdinalIgno
7272
}
7373

7474
/// <summary>
75-
/// Converts a <paramref name="value"/> of <see cref="MouseAction"/> to its <see langword="string"/> represensation.
75+
/// Converts a <paramref name="value"/> of <see cref="MouseAction"/> to its <see cref="string"/> representation.
7676
/// </summary>
7777
/// <param name="context">Serialization Context</param>
7878
/// <param name="culture">Culture Info</param>
7979
/// <param name="value">MouseAction value </param>
8080
/// <param name="destinationType">Type to Convert</param>
81-
/// <returns>A <see langword="string"/> representing the <see cref="MouseAction"/> specified by <paramref name="value"/>.</returns>
81+
/// <returns>A <see cref="string"/> representing the <see cref="MouseAction"/> specified by <paramref name="value"/>.</returns>
8282
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
8383
{
8484
ArgumentNullException.ThrowIfNull(destinationType);
8585

86-
if (value is null || destinationType != typeof(string))
86+
if (value is not MouseAction mouseAction || destinationType != typeof(string))
8787
throw GetConvertToException(value, destinationType);
8888

89-
MouseAction mouseAction = (MouseAction)value;
9089
return mouseAction switch
9190
{
9291
MouseAction.None => string.Empty,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
4+
using MS.Utility;
5+
6+
namespace System.Windows.Media;
7+
8+
public sealed partial class DoubleCollection
9+
{
10+
/// <summary>
11+
/// Initializes a new instance using a <paramref name="values"/>. Elements are copied.
12+
/// </summary>
13+
/// <param name="values"></param>
14+
internal DoubleCollection(params ReadOnlySpan<double> values)
15+
{
16+
_collection = new FrugalStructList<double>(values.Length);
17+
18+
foreach (double item in values)
19+
{
20+
_collection.Add(item);
21+
}
22+
}
23+
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/NativeMethodsMilCoreApi.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/documents/DocumentViewerHelper.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,9 @@ private static CultureInfo GetDocumentCultureInfo(ITextContainer textContainer)
271271
/// <param name="findToolBar">FindToolBar instance.</param>
272272
internal static void ShowFindUnsuccessfulMessage(FindToolBar findToolBar)
273273
{
274-
string messageString;
275-
276274
// No, we did not find anything. Alert the user.
277-
messageString = findToolBar.SearchUp ?
278-
SR.DocumentViewerSearchUpCompleteLabel :
279-
SR.DocumentViewerSearchDownCompleteLabel;
280-
messageString = String.Format(System.Globalization.CultureInfo.CurrentCulture, messageString, findToolBar.SearchText);
275+
string messageString = findToolBar.SearchUp ? SR.DocumentViewerSearchUpCompleteLabel : SR.DocumentViewerSearchDownCompleteLabel;
276+
messageString = string.Format(CultureInfo.CurrentCulture, messageString, findToolBar.SearchText);
281277

282278
HwndSource hwndSource = PresentationSource.CriticalFromVisual(findToolBar) as HwndSource;
283279
IntPtr hwnd = (hwndSource != null) ? hwndSource.Handle : IntPtr.Zero;

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGrid.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8464,9 +8464,13 @@ private object InvalidateCellsPanelHorizontalOffset(object args)
84648464
IProvideDataGridColumn cell = GetAnyCellOrColumnHeader();
84658465
if (cell != null)
84668466
{
8467-
CellsPanelHorizontalOffset = DataGridHelper.GetParentCellsPanelHorizontalOffset(cell);
8467+
// Due to layout rounding, computation of the offset may return a negative value while computing the difference between controls,
8468+
// however since this offset is used also for Button's Width servicing the DataGrid.SelectAllCommand in all standard styles,
8469+
// we cannot accept this. Even if we could, the DataGrid[CellsPanel] layout logic depends on this offset being 0 or greater.
8470+
// See https://github.com/dotnet/wpf/pull/9983 for more information regarding this.
8471+
CellsPanelHorizontalOffset = Math.Max(0d, DataGridHelper.GetParentCellsPanelHorizontalOffset(cell));
84688472
}
8469-
else if (!Double.IsNaN(RowHeaderWidth))
8473+
else if (!double.IsNaN(RowHeaderWidth))
84708474
{
84718475
CellsPanelHorizontalOffset = RowHeaderWidth;
84728476
}

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/GridViewColumnHeader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ private bool HandleIsMouseOverChanged()
856856
(_headerGripper == null || !_headerGripper.IsMouseOver))
857857
{
858858
// Hovering over the button will click in the OnHover click mode
859-
SetValue(IsPressedPropertyKey, BooleanBoxes.Box(true));
859+
SetValue(IsPressedPropertyKey, BooleanBoxes.TrueBox);
860860
OnClick();
861861
}
862862
else

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/HwndHost.cs

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,17 @@ public event HwndSourceHook MessageHook
8585
{
8686
add
8787
{
88-
89-
if(_hooks == null)
90-
{
91-
_hooks = new ArrayList(8);
92-
}
88+
_hooks ??= new List<HwndSourceHook>(8);
9389

9490
_hooks.Add(value);
9591
}
96-
9792
remove
9893
{
99-
100-
if(_hooks != null)
94+
if (_hooks is not null)
10195
{
10296
_hooks.Remove(value);
10397

104-
if(_hooks.Count == 0)
98+
if (_hooks.Count == 0)
10599
{
106100
_hooks = null;
107101
}
@@ -1101,22 +1095,19 @@ private object AsyncDestroyWindow(object arg)
11011095

11021096
private IntPtr SubclassWndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
11031097
{
1104-
IntPtr result = IntPtr.Zero ;
1098+
// Call the virtual first
1099+
IntPtr result = WndProc(hwnd, msg, wParam, lParam, ref handled);
11051100

1106-
// Call the virtual first.
1107-
result = WndProc(hwnd, msg, wParam, lParam, ref handled);
1101+
if (_hooks is null || handled)
1102+
return result;
11081103

1109-
// Call the handlers for the MessageHook event.
1110-
if(!handled && _hooks != null)
1104+
// Call the handlers for the MessageHook event
1105+
for (int i = 0, nCount = _hooks.Count; i < nCount; i++)
11111106
{
1112-
for(int i = 0, nCount = _hooks.Count; i < nCount; i++)
1113-
{
1114-
result = ((HwndSourceHook)_hooks[i])(hwnd, msg, wParam, lParam, ref handled);
1115-
if(handled)
1116-
{
1117-
break;
1118-
}
1119-
}
1107+
result = _hooks[i].Invoke(hwnd, msg, wParam, lParam, ref handled);
1108+
1109+
if (handled)
1110+
break;
11201111
}
11211112

11221113
return result;
@@ -1132,7 +1123,7 @@ private IntPtr SubclassWndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lPara
11321123

11331124
private HandleRef _hwnd;
11341125

1135-
private ArrayList _hooks;
1126+
private List<HwndSourceHook> _hooks;
11361127
private Size _desiredSize;
11371128

11381129
/// <summary>

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XmlnsCache.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
using System.Linq;
1515
using System.Reflection;
1616
using MS.Utility;
17-
#if PBTCOMPILER
18-
using MS.Internal.PresentationBuildTasks;
19-
#else
17+
#if !PBTCOMPILER
2018
using MS.Internal.PresentationFramework;
2119
using MS.Internal.Utility; // AssemblyCacheEnum
2220
#endif

0 commit comments

Comments
 (0)