Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class StringCollection : ICollection, IEnumerable<string>
/// <summary>
/// Initializes a new instance of the <see cref='StringCollection'/> class.
/// </summary>
public StringCollection(string[] array) => _list = new(array);
public StringCollection(string[] array) => _list = [..array];

/// <summary>
/// Gets a value indicating the number of strings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal static List<T> CreateTrimmedList<T>(this IReadOnlyList<T> readOnlyList,
}

// Fall back to just setting the count (by removing).
List<T> list = new(readOnlyList);
List<T> list = [..readOnlyList];
list.RemoveRange(count, list.Count - count);
return list;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace System.Drawing;

internal interface IIcon : IHandle<HICON>
{
public Size Size { get; }
Size Size { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ private void PerformRemove()
{
if (_listBox.SelectedItems.Count > 1)
{
List<ListItem> toBeDeleted = _listBox.SelectedItems.Cast<ListItem>().ToList();
List<ListItem> toBeDeleted = [.._listBox.SelectedItems.Cast<ListItem>()];
foreach (ListItem item in toBeDeleted)
{
RemoveInternal(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ void IDesignerLoaderHost.EndLoad(string? rootClassName, bool successful, ICollec
_state[s_stateLoading] = true;
Unload();

List<object> errorList = errorCollection is null ? [] : errorCollection.Cast<object>().ToList();
List<object> errorList = errorCollection is null ? [] : [..errorCollection.Cast<object>()];
errorList.Insert(0, ex);

errorCollection = errorList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ internal void Deserialize(IDesignerSerializationManager manager, Dictionary<stri

// We need to also ensure that for every entry in the statement table we have a
// corresponding entry in objectNames. Otherwise, we won't deserialize completely.
HashSet<string> completeNames = new(objectNames);
HashSet<string> completeNames = [..objectNames];
completeNames.UnionWith(_statementsTable.Keys);

_objectState = new(objectState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private void OnComponentAdded(object? source, ComponentEventArgs ce)
/// </summary>
private void OnBeginDrag(object? source, BehaviorDragDropEventArgs e)
{
List<IComponent> dragComps = e.DragComponents.Cast<IComponent>().ToList();
List<IComponent> dragComps = [..e.DragComponents.Cast<IComponent>()];
List<Glyph> glyphsToRemove = [];
foreach (ControlBodyGlyph g in BodyGlyphAdorner.Glyphs)
{
Expand Down Expand Up @@ -412,7 +412,7 @@ private void OnSelectionChanged(object? sender, EventArgs? e)
SelectionGlyphAdorner.Glyphs.Clear();
BodyGlyphAdorner.Glyphs.Clear();

List<IComponent> selComps = _selectionService.GetSelectedComponents().Cast<IComponent>().ToList();
List<IComponent> selComps = [.._selectionService.GetSelectedComponents().Cast<IComponent>()];
object? primarySelection = _selectionService.PrimarySelection;

// add all control glyphs to all controls on rootComp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private void GetActiveStyleCollection(bool isColumn)
{
if ((_styles is null || isColumn != _currentColumnStyles) && _table is not null)
{
_styles = ((TableLayoutStyleCollection)_changedProp.GetValue(_table)).Cast<TableLayoutStyle>().ToList();
_styles = [..((TableLayoutStyleCollection)_changedProp.GetValue(_table)).Cast<TableLayoutStyle>()];
_currentColumnStyles = isColumn;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public override void OnDragDrop(Glyph? glyph, DragEventArgs e)

if (e.Data is DropSourceBehavior.BehaviorDataObject data)
{
components = new List<IComponent>(data.DragComponents);
components = [..data.DragComponents];

foreach (IComponent dragComponent in components)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ protected virtual void OnKeyMove(object? sender, EventArgs e)
// Don't snap if we are moving a component in the ComponentTray
if (invertSnap && useSnapLines && primaryControl is not null && comp.Site is not null)
{
List<IComponent> selComps = SelectionService.GetSelectedComponents().Cast<IComponent>().ToList();
List<IComponent> selComps = [..SelectionService.GetSelectedComponents().Cast<IComponent>()];

// create our snapline engine
dragManager = new DragAssistanceManager(comp.Site, selComps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ protected override void OnDragEnter(DragEventArgs de)
// Get the sorted drag controls. We use these for an internal drag.
if (de.Data is DropSourceBehavior.BehaviorDataObject data)
{
_dragControls = data.GetSortedDragControls(out int primaryIndex).OfType<Control>().ToList();
_dragControls = [..data.GetSortedDragControls(out int primaryIndex).OfType<Control>()];
_primaryDragControl = _dragControls[primaryIndex];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public IComponent[] CreateTool(ToolboxItem tool, Control? parent, int x, int y,
{
host?.Activate();

List<IComponent> selectComps = new(comps);
List<IComponent> selectComps = [..comps];

for (int i = 0; i < comps.Length; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ private Control ExtractControlFromDragEvent(DragEventArgs de)
{
if (de.Data is DropSourceBehavior.BehaviorDataObject data)
{
_dragComponents = new List<IComponent>(data.DragComponents);
_dragComponents = [..data.DragComponents];
return _dragComponents[0] as Control;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ internal void UpdateAttributes()
return;
}

List<Attribute> attributes = new(AttributeArray!);
List<Attribute> attributes = [..AttributeArray!];
attributes.AddRange(_updateAttributes);
AttributeArray = [.. attributes];
_updateAttributes.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public override AttributeCollection Attributes

if (attributeList.Count > 0)
{
newAttributes ??= new(AttributeArray);
newAttributes ??= [..AttributeArray];

// Push any new attributes into the base type.
for (int i = 0; i < attributeList.Count; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ internal unsafe interface ICom2ExtendedBrowsingHandler
/// <summary>
/// Returns <see langword="true"/> if the given object is supported by this type.
/// </summary>
public bool ObjectSupportsInterface(object @object);
bool ObjectSupportsInterface(object @object);

/// <summary>
/// Called to setup the property handlers on a given property. In this method, the handler will add listeners
/// to the events that the <see cref="Com2PropertyDescriptor"/> surfaces that it cares about.
/// </summary>
public void RegisterEvents(Com2PropertyDescriptor[]? properties);
void RegisterEvents(Com2PropertyDescriptor[]? properties);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,7 @@ private bool InterceptAutoCompleteKeystroke(Message m)
else
{
// Remove one character from matching text and rematch
MatchingText = MatchingText.Remove(MatchingText.Length - 1);
MatchingText = MatchingText[..^1];
SelectedIndex = FindString(MatchingText);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3933,7 +3933,7 @@ internal override void ReleaseUiaProvider(HWND handle)
/// <param name="items">contains ToolStrip or ToolStripDropDown items to disconnect</param>
internal virtual void ReleaseToolStripItemsProviders(ToolStripItemCollection items)
{
ToolStripItem[] itemsArray = items.Cast<ToolStripItem>().ToArray();
ToolStripItem[] itemsArray = [..items.Cast<ToolStripItem>()];
foreach (ToolStripItem toolStripItem in itemsArray)
{
if (toolStripItem is ToolStripDropDownItem dropDownItem && dropDownItem.DropDownItems.Count > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,7 @@ private void DismissActiveDropDowns()
}
else
{
List<ToolStripDropDown> dropDowns = new(ActiveDropDowns);
List<ToolStripDropDown> dropDowns = [..ActiveDropDowns];

// We can't iterate through the active dropdown collection
// here as changing visibility changes the collection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,10 +868,10 @@ internal void Bind(
radioButtons.BoundPage = this;

// Sort the buttons.
_boundCustomButtons = buttons.Where(e => !e.IsStandardButton).ToArray();
_boundStandardButtonsByID = new Dictionary<int, TaskDialogButton>(
buttons.Where(e => e.IsStandardButton)
.Select(e => new KeyValuePair<int, TaskDialogButton>(e.ButtonID, e)));
_boundCustomButtons = [..buttons.Where(e => !e.IsStandardButton)];
_boundStandardButtonsByID = buttons
.Where(e => e.IsStandardButton)
.ToDictionary(e => e.ButtonID);

// Assign IDs to the buttons based on their index.
defaultButtonID = 0;
Expand Down