Skip to content

Commit

Permalink
Some simple format cleanup (dotnet#10842)
Browse files Browse the repository at this point in the history
Clean up some of what hits `dotnet format` on System.Windows.Forms.
  • Loading branch information
JeremyKuhne authored Feb 7, 2024
1 parent a05dd92 commit 17fd2a3
Show file tree
Hide file tree
Showing 28 changed files with 61 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows.Forms.BinaryFormat;
using Windows.Win32.System.Com;
using Windows.Win32.System.Variant;
using Windows.Win32.System.Com.StructuredStorage;
using Windows.Win32.System.Variant;

namespace System.Windows.Forms;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections;
using System.Windows.Forms.BinaryFormat;
using Windows.Win32.System.Com;
using Windows.Win32.System.Com.StructuredStorage;
using Windows.Win32.System.Variant;
using System.Windows.Forms.BinaryFormat;

namespace System.Windows.Forms;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Drawing;
using System.Runtime.InteropServices;
using Windows.Win32.System.Com;
using Windows.Win32.System.Com.StructuredStorage;
using Windows.Win32.System.Ole;
using System.Runtime.InteropServices;
using ComIDataObject = Windows.Win32.System.Com.IDataObject;

namespace System.Windows.Forms;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Windows.Forms.Primitives;
using Microsoft.Office;
using Windows.Win32.System.Com;
using ComIMessageFilter = Windows.Win32.Media.Audio.IMessageFilter;
using ComIServiceProvider = Windows.Win32.System.Com.IServiceProvider;
using Microsoft.Office;
using System.Windows.Forms.Primitives;
using System.Runtime.ExceptionServices;

namespace System.Windows.Forms;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
using System.Reflection;
using System.Text;
using System.Windows.Forms.VisualStyles;
using Microsoft.Win32;
using Microsoft.Office;
using Microsoft.Win32;
using Directory = System.IO.Directory;

namespace System.Windows.Forms;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

using System.Reflection;
using System.Runtime.InteropServices;
using Windows.Win32.System.Variant;
using Microsoft.VisualStudio.Shell;
using Windows.Win32.System.Variant;

namespace System.Windows.Forms.ComponentModel.Com2Interop;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
using Windows.Win32.System.Ole;
using Windows.Win32.System.Variant;
using static Windows.Win32.System.Com.TYPEKIND;
using static Windows.Win32.System.Variant.VARENUM;
using static Windows.Win32.System.Com.VARFLAGS;
using static Windows.Win32.System.Variant.VARENUM;

namespace System.Windows.Forms.ComponentModel.Com2Interop;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public override HRESULT RangeFromPoint(UiaPoint point, ITextRangeProvider** pRet
// (Essentially ScreenToClient but MapWindowPoints accounts for window mirroring using WS_EX_LAYOUTRTL.)
if (PInvoke.MapWindowPoints((HWND)default, _owningChildEdit, ref clientLocation) == 0)
{
*pRetVal = ComHelpers.GetComPointer<ITextRangeProvider>(
*pRetVal = ComHelpers.GetComPointer<ITextRangeProvider>(
new UiaTextRange(
_owningComboBox.ChildEditAccessibleObject,
this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29732,7 +29732,7 @@ private void UpdateSelectedCellsBlock(

if (Columns.DisplayInOrder(oldEdgeColumnIndex, newEdgeColumnIndex)
&& (Columns.DisplayInOrder(anchorColumnIndex, oldEdgeColumnIndex) || anchorColumnIndex == oldEdgeColumnIndex)
&& oldEdgeRowIndex == newEdgeRowIndex)
&& oldEdgeRowIndex == newEdgeRowIndex)
{
// h1
DataGridViewColumn? dataGridViewColumn = Columns.GetNextColumn(Columns[oldEdgeColumnIndex], DataGridViewElementStates.Visible, DataGridViewElementStates.None);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ internal override ToggleState ToggleState
{
get
{
ToggleState toggleState= ToggleState.ToggleState_Off;
ToggleState toggleState = ToggleState.ToggleState_Off;
switch (_owningCheckedListBox.GetItemCheckState(CurrentIndex))
{
case CheckState.Checked:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ int IList.Add(object? item)
return IndexOf(Add(listViewItem));
}

if (item is {} obj)
if (item is { } obj)
{
return IndexOf(Add(obj.ToString()));
}
Expand Down Expand Up @@ -425,7 +425,7 @@ void IList.Insert(int index, object? item)
{
Insert(index, listViewItem);
}
else if (item is {} obj)
else if (item is { } obj)
{
Insert(index, obj.ToString());
}
Expand All @@ -438,15 +438,15 @@ public ListViewItem Insert(int index, string? text, string? imageKey)

public virtual ListViewItem Insert(int index, string? key, string? text, string? imageKey)
=> Insert(index, new ListViewItem(text, imageKey)
{
Name = key
});
{
Name = key
});

public virtual ListViewItem Insert(int index, string? key, string? text, int imageIndex)
=> Insert(index, new ListViewItem(text, imageIndex)
{
Name = key
});
{
Name = key
});

// END - NEW INSERT OVERLOADS IN WHIDBEY -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,14 @@ internal override VARIANT GetPropertyValue(UIA_PROPERTY_ID propertyID)
{
switch (propertyID)
{
case UIA_PROPERTY_ID.UIA_ControlTypePropertyId: return (VARIANT)(int)UIA_CONTROLTYPE_ID.UIA_ListItemControlTypeId;
case UIA_PROPERTY_ID.UIA_HasKeyboardFocusPropertyId: return (VARIANT)OwningListItemFocused;
case UIA_PROPERTY_ID.UIA_IsEnabledPropertyId: return (VARIANT)_owningListView.Enabled;
case UIA_PROPERTY_ID.UIA_IsKeyboardFocusablePropertyId: return (VARIANT)State.HasFlag(AccessibleStates.Focusable);
case UIA_PROPERTY_ID.UIA_ControlTypePropertyId:
return (VARIANT)(int)UIA_CONTROLTYPE_ID.UIA_ListItemControlTypeId;
case UIA_PROPERTY_ID.UIA_HasKeyboardFocusPropertyId:
return (VARIANT)OwningListItemFocused;
case UIA_PROPERTY_ID.UIA_IsEnabledPropertyId:
return (VARIANT)_owningListView.Enabled;
case UIA_PROPERTY_ID.UIA_IsKeyboardFocusablePropertyId:
return (VARIANT)State.HasFlag(AccessibleStates.Focusable);
case UIA_PROPERTY_ID.UIA_IsOffscreenPropertyId:
if (OwningGroup?.CollapsedState == ListViewGroupCollapsedState.Collapsed)
{
Expand All @@ -188,7 +192,8 @@ internal override VARIANT GetPropertyValue(UIA_PROPERTY_ID propertyID)
return result.IsEmpty ? VARIANT.False : result;
case UIA_PROPERTY_ID.UIA_NativeWindowHandlePropertyId:
return UIAHelper.WindowHandleToVariant(HWND.Null);
default: return base.GetPropertyValue(propertyID);
default:
return base.GetPropertyValue(propertyID);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ and not MONTH_CALDENDAR_MESSAGES_VIEW.MCMV_DECADE

internal void UpdateDisplayRange()
{
if(!this.TryGetOwnerAs(out MonthCalendar? owner))
if (!this.TryGetOwnerAs(out MonthCalendar? owner))
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3558,7 +3558,7 @@ internal void RemoveTabs(PropertyTabScope classification, bool setupToolbar)
SelectViewTabButtonDefault(selectedButton);

// Clear the component refs of the tabs.
foreach (TabInfo info in _tabs)
foreach (TabInfo info in _tabs)
{
info.Tab.Components = Array.Empty<object>();
}
Expand Down Expand Up @@ -3638,7 +3638,7 @@ internal void RemoveTab(Type tabType)

private void ResetHelpBackColor() => _helpPane.ResetBackColor();

private void ResetHelpForeColor() => _helpPane.ResetBackColor();
private void ResetHelpForeColor() => _helpPane.ResetBackColor();

/// <summary>
/// This method is intended for use in replacing a specific selected root object with another object of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5202,7 +5202,10 @@ private void TabSelection()
_dropDownHolder.FocusComponent();
return;
}
else _currentEditor?.Focus();
else
{
_currentEditor?.Focus();
}

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ private void RenderItemImageOfLowColorDepth(ToolStripItemImageRenderEventArgs e)

using ImageAttributes attrs = new();

if (IsHighContrastWhiteOnBlack() && !(FillWhenSelected && (item.Pressed || item. Selected)))
if (IsHighContrastWhiteOnBlack() && !(FillWhenSelected && (item.Pressed || item.Selected)))
{
// Translate white, black and blue to colors visible in high contrast mode.
ColorMap cm1 = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
using System.Drawing.Design;
using System.Drawing.Imaging;
using System.Windows.Forms.Layout;
using Com = Windows.Win32.System.Com;
using Windows.Win32.System.Ole;
using Com = Windows.Win32.System.Com;
using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;

namespace System.Windows.Forms;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ NavigateDirection.NavigateDirection_FirstChild or NavigateDirection.NavigateDire
=> _owningToolStripOverflowButton.DropDown.Visible
? _owningToolStripOverflowButton.DropDown.AccessibilityObject
: null,
// Don't show the inner menu while it is invisible.
// Otherwise it will affect accessibility tree,
// especially for items-controls that have not been created yet.
// Don't show the inner menu while it is invisible.
// Otherwise it will affect accessibility tree,
// especially for items-controls that have not been created yet.
_ => base.FragmentNavigate(direction),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ void IArrangedElement.PerformLayout(IArrangedElement container, string? property
}
}

#region MouseStuff
#region MouseStuff

#if DEBUG
internal static readonly TraceSwitch ToolStripPanelMouseDebug = new("ToolStripPanelMouse", "Debug ToolStrip WM_MOUSEACTIVATE code");
Expand Down Expand Up @@ -762,5 +762,5 @@ internal void LeaveRow(ToolStrip toolStripToDrag)
}
}

#endregion
#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public HtmlElement? this[string elementId]
using var nativeHtmlElementCollection = NativeHtmlElementCollection.GetInterface();
using var variantElementId = (VARIANT)elementId;
using ComScope<IDispatch> dispatch = new(null);
nativeHtmlElementCollection.Value->item(variantElementId, (VARIANT)0, dispatch).ThrowOnFailure();;
nativeHtmlElementCollection.Value->item(variantElementId, (VARIANT)0, dispatch).ThrowOnFailure();
IHTMLElement* htmlElement;
return !dispatch.IsNull && dispatch.Value->QueryInterface(IID.Get<IHTMLElement>(), (void**)&htmlElement).Succeeded
? new(_shimManager, htmlElement)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

using System.Drawing;
using Windows.Win32.System.Ole;
using MsHtml = Windows.Win32.Web.MsHtml;
using static Interop.Mshtml;
using Ole = Windows.Win32.System.Ole;
using ComTypes = System.Runtime.InteropServices.ComTypes;
using MsHtml = Windows.Win32.Web.MsHtml;
using Ole = Windows.Win32.System.Ole;

namespace System.Windows.Forms;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using System.ComponentModel.Design;
using System.Drawing;
using System.Runtime.InteropServices;
using Windows.Win32.System.Ole;
using Windows.Win32.System.Com;
using Windows.Win32.System.Ole;

namespace System.Windows.Forms;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ internal BindingManagerBase(object? dataSource)
return GetItemProperties(BindType, 0, dataSources, listAccessors);
}

protected virtual PropertyDescriptorCollection? GetItemProperties([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]Type listType, int offset, ArrayList dataSources, ArrayList listAccessors)
protected virtual PropertyDescriptorCollection? GetItemProperties(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type listType,
int offset,
ArrayList dataSources,
ArrayList listAccessors)
{
if (listAccessors.Count < offset)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using TASKDIALOGCONFIG_MainIcon = Windows.Win32.UI.Controls.TASKDIALOGCONFIG._Anonymous1_e__Union;
using TASKDIALOGCONFIG_FooterIcon = Windows.Win32.UI.Controls.TASKDIALOGCONFIG._Anonymous2_e__Union;
using TASKDIALOGCONFIG_MainIcon = Windows.Win32.UI.Controls.TASKDIALOGCONFIG._Anonymous1_e__Union;
namespace System.Windows.Forms;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using TASKDIALOGCONFIG_MainIcon = Windows.Win32.UI.Controls.TASKDIALOGCONFIG._Anonymous1_e__Union;
using TASKDIALOGCONFIG_FooterIcon = Windows.Win32.UI.Controls.TASKDIALOGCONFIG._Anonymous2_e__Union;
using TASKDIALOGCONFIG_MainIcon = Windows.Win32.UI.Controls.TASKDIALOGCONFIG._Anonymous1_e__Union;

namespace System.Windows.Forms;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public LayoutInfo(IArrangedElement element)

public int RowSpan { get; set; } = 1;

#if DEBUG
#if DEBUG
public LayoutInfo Clone() => new(Element)
{
RowStart = RowStart,
Expand Down Expand Up @@ -77,6 +77,6 @@ public override int GetHashCode()
hash.Add(ColumnPosition);
return hash.ToHashCode();
}
#endif
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ internal ToolStripMenuItem MergeItem
get
{
_mergeItem ??= new ToolStripMenuItem
{
MergeAction = MergeAction.MatchOnly
};
{
MergeAction = MergeAction.MatchOnly
};

if (_mergeItem.Owner is null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private sealed class BitmapBinder : SerializationBinder
private const string AllowedAssemblyName = "System.Drawing";

// .NET Framework PublicKeyToken=b03f5f7f11d50a3a
private static ReadOnlySpan<byte> AllowedToken => [ 0xB0, 0x3F, 0x5F, 0x7F, 0x11, 0xD5, 0x0A, 0x3A ];
private static ReadOnlySpan<byte> AllowedToken => [0xB0, 0x3F, 0x5F, 0x7F, 0x11, 0xD5, 0x0A, 0x3A];

public override Type? BindToType(string assemblyName, string typeName)
{
Expand Down

0 comments on commit 17fd2a3

Please sign in to comment.