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 @@ -135,10 +135,10 @@ public void ArrayEditor_GetDisplayText_ValueDoesntMatchCollectionType_ThrowsTarg

public static IEnumerable<object[]> GetItems_TestData()
{
yield return new object[] { null, new object[0] };
yield return new object[] { new object(), new object[0] };
yield return new object[] { null, Array.Empty<object>() };
yield return new object[] { new object(), Array.Empty<object>() };
yield return new object[] { new int[] { 1, 2, 3 }, new object[] { 1, 2, 3, } };
yield return new object[] { new ArrayList { 1, 2, 3 }, new object[0] };
yield return new object[] { new ArrayList { 1, 2, 3 }, Array.Empty<object>() };
}

[Theory]
Expand All @@ -154,7 +154,7 @@ public void ArrayEditor_GetItems_Invoke_ReturnsExpected(object editValue, object

public static IEnumerable<object[]> SetItems_Array_TestData()
{
yield return new object[] { null, new object[0], new object[0] };
yield return new object[] { null, Array.Empty<object>(), Array.Empty<object>() };
yield return new object[] { null, new object[] { 1, 2, 3 }, new object[] { 1, 2, 3 } };
yield return new object[] { new object[] { 4, 5 }, new object[] { 1, 2, 3 }, new object[] { 1, 2, 3 } };
yield return new object[] { new object[] { 4, 5, 6 }, new object[] { 1, 2, 3 }, new object[] { 1, 2, 3 } };
Expand All @@ -175,8 +175,8 @@ public static IEnumerable<object[]> SetItems_NonArray_TestData()
{
var editValue = new object();
yield return new object[] { editValue, null, editValue };
yield return new object[] { editValue, new object[0], editValue };
yield return new object[] { new object[0], null, null };
yield return new object[] { editValue, Array.Empty<object>(), editValue };
yield return new object[] { Array.Empty<object>(), null, null };
yield return new object[] { null, null, null };
}

Expand All @@ -195,8 +195,8 @@ public void ArrayEditor_SetItems_NullCollectionItemType_ThrowsArgumentNullExcept
{
var editor = new SubArrayEditor(type);
Assert.Null(editor.CollectionItemType);
Assert.Throws<ArgumentNullException>("elementType", () => editor.SetItems(null, new object[0]));
Assert.Throws<ArgumentNullException>("elementType", () => editor.SetItems(new object[0], new object[0]));
Assert.Throws<ArgumentNullException>("elementType", () => editor.SetItems(null, Array.Empty<object>()));
Assert.Throws<ArgumentNullException>("elementType", () => editor.SetItems(Array.Empty<object>(), Array.Empty<object>()));
}

private class SubArrayEditor : ArrayEditor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,8 +835,8 @@ public void CollectionEditor_GetDisplayText_ValueDoesntMatchCollectionType_Throw

public static IEnumerable<object[]> GetItems_TestData()
{
yield return new object[] { null, new object[0] };
yield return new object[] { new object(), new object[0] };
yield return new object[] { null, Array.Empty<object>() };
yield return new object[] { new object(), Array.Empty<object>() };
yield return new object[] { new int[] { 1, 2, 3 }, new object[] { 1, 2, 3, } };
yield return new object[] { new ArrayList { 1, 2, 3 }, new object[] { 1, 2, 3, } };
}
Expand Down Expand Up @@ -917,20 +917,20 @@ public void CollectionEditor_GetObjectsFromInstance_Invoke_ReturnsExpected(objec
public static IEnumerable<object[]> SetItems_TestData()
{
yield return new object[] { null, new object[] { 1, 2, 3 }, null };
yield return new object[] { null, new object[0], null };
yield return new object[] { null, Array.Empty<object>(), null };
yield return new object[] { null, null, null };

var o = new object();
yield return new object[] { o, new object[] { 1, 2, 3 }, o };
yield return new object[] { o, new object[0], o };
yield return new object[] { o, Array.Empty<object>(), o };
yield return new object[] { o, null, o };

yield return new object[] { new int[] { 1, 2, 3 }, new object[0], new object[] { 0, 0, 0 } };
yield return new object[] { new int[] { 1, 2, 3 }, Array.Empty<object>(), new object[] { 0, 0, 0 } };
yield return new object[] { new int[] { 1, 2, 3 }, null, new object[] { 0, 0, 0 } };

yield return new object[] { new ArrayList { 1, 2, 3 }, new object[] { 1 }, new object[] { 1 } };
yield return new object[] { new ArrayList { 1, 2, 3 }, new object[0], new object[0] };
yield return new object[] { new ArrayList { 1, 2, 3 }, null, new object[0] };
yield return new object[] { new ArrayList { 1, 2, 3 }, Array.Empty<object>(), Array.Empty<object>() };
yield return new object[] { new ArrayList { 1, 2, 3 }, null, Array.Empty<object>() };
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void CollectionForm_EditValue_Set_GetReturnsExpected(object value)
public static IEnumerable<object[]> Items_Set_TestData()
{
yield return new object[] { null };
yield return new object[] { new object[0] };
yield return new object[] { Array.Empty<object>() };
yield return new object[] { new object[] { 1, 2, 3 } };
}

Expand Down Expand Up @@ -205,16 +205,16 @@ public void CollectionForm_Items_SetWithContextWithEditValue_GetReturnsExpected(
form.OnEditValueChangedCallCount = 0;

form.Items = value;
Assert.Equal(value ?? new object[0], form.EditValue);
Assert.Equal(value ?? new object[0], form.Items);
Assert.Equal(value ?? Array.Empty<object>(), form.EditValue);
Assert.Equal(value ?? Array.Empty<object>(), form.Items);
Assert.Equal(0, form.OnEditValueChangedCallCount);
mockContext.Verify(c => c.OnComponentChanging(), Times.Once());
mockContext.Verify(c => c.OnComponentChanged(), Times.Once());

// Set same.
form.Items = value;
Assert.Equal(value ?? new object[0], form.EditValue);
Assert.Equal(value ?? new object[0], form.Items);
Assert.Equal(value ?? Array.Empty<object>(), form.EditValue);
Assert.Equal(value ?? Array.Empty<object>(), form.Items);
Assert.Equal(0, form.OnEditValueChangedCallCount);
mockContext.Verify(c => c.OnComponentChanging(), Times.Exactly(2));
mockContext.Verify(c => c.OnComponentChanged(), Times.Exactly(2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ImageEditorTests
public static IEnumerable<object[]> CreateExtensionsString_TestData()
{
yield return new object[] { null, ",", null };
yield return new object[] { new string[0], ",", null };
yield return new object[] { Array.Empty<string>(), ",", null };
yield return new object[] { new string[] { "a", "b", "c" }, ",", "*.a,*.b,*.c" };
yield return new object[] { new string[] { "a", "b", "c" }, "", "*.a*.b*.c" };
yield return new object[] { new string[] { "a", "b", "c" }, null, "*.a*.b*.c" };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public virtual DesignerActionListCollection ActionLists
/// </summary>
public virtual ICollection AssociatedComponents
{
get => new IComponent[0];
get => Array.Empty<IComponent>();
}

internal virtual bool CanBeAssociatedWith(IDesigner parentDesigner) => true;
Expand Down Expand Up @@ -258,7 +258,7 @@ void IDesignerFilter.PreFilterProperties(IDictionary properties)
{
if (properties[SettingsKeyName] is PropertyDescriptor prop)
{
properties[SettingsKeyName] = TypeDescriptor.CreateProperty(typeof(ComponentDesigner), prop, new Attribute[0]);
properties[SettingsKeyName] = TypeDescriptor.CreateProperty(typeof(ComponentDesigner), prop, Array.Empty<Attribute>());
}
}
}
Expand Down Expand Up @@ -318,7 +318,7 @@ ICollection ITreeDesigner.Children

return designers;
}
return new object[0];
return Array.Empty<object>();
}
}

Expand Down Expand Up @@ -873,7 +873,7 @@ protected virtual void PreFilterProperties(IDictionary properties)
{
if (properties[SettingsKeyName] is PropertyDescriptor prop)
{
properties[SettingsKeyName] = TypeDescriptor.CreateProperty(typeof(ComponentDesigner), prop, new Attribute[0]);
properties[SettingsKeyName] = TypeDescriptor.CreateProperty(typeof(ComponentDesigner), prop, Array.Empty<Attribute>());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public ICollection LoadErrors
{
return _loadErrors;
}
return new object[0];
return Array.Empty<object>();
}
}

Expand Down Expand Up @@ -325,10 +325,10 @@ protected internal virtual object CreateInstance(Type type)

// Locate an appropriate constructor for IComponents.
object instance = null;
ConstructorInfo ctor = TypeDescriptor.GetReflectionType(type).GetConstructor(new Type[0]);
ConstructorInfo ctor = TypeDescriptor.GetReflectionType(type).GetConstructor(Array.Empty<Type>());
if (ctor != null)
{
instance = TypeDescriptor.CreateInstance(this, type, new Type[0], new object[0]);
instance = TypeDescriptor.CreateInstance(this, type, Array.Empty<Type>(), Array.Empty<object>());
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ IExtenderProvider[] IExtenderListService.GetExtenderProviders()
_providers.CopyTo(providers, 0);
return providers;
}
return new IExtenderProvider[0];
return Array.Empty<IExtenderProvider>();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ ICollection ISelectionService.GetSelectedComponents()
_selection.CopyTo(selectedValues, 0);
return selectedValues;
}
return new object[0];
return Array.Empty<object>();
}

/// <summary>
Expand All @@ -389,7 +389,7 @@ void ISelectionService.SetSelectedComponents(ICollection components, SelectionTy
// We always want to allow NULL arrays coming in.
if (components == null)
{
components = new object[0];
components = Array.Empty<object>();
}
// If toggle, replace, remove or add are not specifically specified, infer them from the state of the modifer keys. This creates the "Auto" selection type for us by default.
if (fAuto)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public override ICollection Errors
{
if (_errors == null)
{
_errors = new object[0];
_errors = Array.Empty<object>();
}

object[] errors = new object[_errors.Count];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2367,11 +2367,11 @@ protected CodeExpression SerializeCreationExpression(IDesignerSerializationManag
}

// No instance descriptor. See if we can get to a public constructor that takes no arguments
ConstructorInfo ctor = GetReflectionTypeHelper(manager, value).GetConstructor(new Type[0]);
ConstructorInfo ctor = GetReflectionTypeHelper(manager, value).GetConstructor(Array.Empty<Type>());
if (ctor != null)
{
isComplete = false;
return new CodeObjectCreateExpression(TypeDescriptor.GetClassName(value), new CodeExpression[0]);
return new CodeObjectCreateExpression(TypeDescriptor.GetClassName(value), Array.Empty<CodeExpression>());
}
// Nothing worked.
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ private bool ShouldClearCollection(IDesignerSerializationManager manager, IColle

if (shouldClear)
{
MethodInfo clearMethod = TypeDescriptor.GetReflectionType(collection).GetMethod("Clear", BindingFlags.Public | BindingFlags.Instance, null, new Type[0], null);
MethodInfo clearMethod = TypeDescriptor.GetReflectionType(collection).GetMethod("Clear", BindingFlags.Public | BindingFlags.Instance, null, Array.Empty<Type>(), null);
if (clearMethod == null || !MethodSupportsSerialization(clearMethod))
{
shouldClear = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected override CodeMemberMethod[] GetInitializeMethods(IDesignerSerializatio
}
}

return new CodeMemberMethod[0];
return Array.Empty<CodeMemberMethod>();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ PropertyDescriptorCollection IDesignerSerializationManager.Properties
PropertyDescriptor[] propArray;
if (propObject == null)
{
propArray = new PropertyDescriptor[0];
propArray = Array.Empty<PropertyDescriptor>();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ protected virtual CodeMemberMethod[] GetInitializeMethods(IDesignerSerialization
return new CodeMemberMethod[] { ctor };
}
}
return new CodeMemberMethod[0];
return Array.Empty<CodeMemberMethod>();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ internal sealed class DragAssistanceManager
//T hese are cleared and populated on every mouse move. These lists contain all the new vertical and horizontal lines we need to draw. At the end of each mouse move - these lines are stored off in the vertLines and horzLines arrays. This way - we can keep track of old snap lines and can avoid erasing and redrawing the same line. HA.
private readonly ArrayList _tempVertLines = new ArrayList();
private readonly ArrayList _tempHorzLines = new ArrayList();
private Line[] _vertLines = new Line[0];
private Line[] _horzLines = new Line[0];
private Line[] _vertLines = Array.Empty<Line>();
private Line[] _horzLines = Array.Empty<Line>();
// When we draw snap lines - we only draw lines from the targetControl to the control we're snapping to. To do this, we'll keep a hashtable... format: snapLineToBounds[SnapLine]=ControlBounds.
private readonly Hashtable _snapLineToBounds = new Hashtable();
// We remember the last set of (vert & horz) lines we draw so that we can push them to the beh. svc. From there, if we receive a test hook message requesting these - we got 'em
Expand Down Expand Up @@ -315,7 +315,7 @@ private Line[] EraseOldSnapLines(Line[] lines, ArrayList tempLines)
}
else
{
lines = new Line[0];
lines = Array.Empty<Line>();
}
return lines;
}
Expand All @@ -335,7 +335,7 @@ internal Line[] GetRecentLines()
{
return _recentLines;
}
return new Line[0];
return Array.Empty<Line>();
}

private void IdentifyAndStoreValidLines(ArrayList snapLines, int[] distances, Rectangle dragBounds, int smallestDistance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private object[] FilterSelection(object[] components, SelectionRules selectionRu
object[] selection = null;
if (components == null)
{
return new object[0];
return Array.Empty<object>();
}
// Mask off any selection object that doesn't adhere to the given ruleset. We can ignore this if the ruleset is zero, as all components would be accepted.
if (selectionRules != SelectionRules.None)
Expand All @@ -334,7 +334,7 @@ private object[] FilterSelection(object[] components, SelectionRules selectionRu
selection = list.ToArray();
}
}
return selection ?? (new object[0]);
return selection ?? (Array.Empty<object>());
}

/// <summary>
Expand Down Expand Up @@ -1326,7 +1326,7 @@ protected void OnMenuCut(object sender, EventArgs e)
{
trans = host.CreateTransaction(string.Format(SR.CommandSetCutMultiple, cutCount));
// clear the selected components so we aren't browsing them
SelectionService.SetSelectedComponents(new object[0], SelectionTypes.Replace);
SelectionService.SetSelectedComponents(Array.Empty<object>(), SelectionTypes.Replace);
object[] selComps = new object[selectedComponents.Count];
selectedComponents.CopyTo(selComps, 0);
for (int i = 0; i < selComps.Length; i++)
Expand Down Expand Up @@ -1463,7 +1463,7 @@ protected void OnMenuDelete(object sender, EventArgs e)
try
{
trans = host.CreateTransaction(desc);
SelectionService.SetSelectedComponents(new object[0], SelectionTypes.Replace);
SelectionService.SetSelectedComponents(Array.Empty<object>(), SelectionTypes.Replace);
foreach (object obj in comps)
{
if (!(obj is IComponent comp) || comp.Site == null)
Expand Down Expand Up @@ -2030,7 +2030,7 @@ protected void OnMenuSelectAll(object sender, EventArgs e)
object[] selComps;
if (components == null || components.Count == 0)
{
selComps = new IComponent[0];
selComps = Array.Empty<IComponent>();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,7 @@ protected override void OnMouseUp(MouseEventArgs e)
}
else
{
comps = new object[0];
comps = Array.Empty<object>();
}

if (comps.Length == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,7 @@ protected override void PreFilterProperties(IDictionary properties)
// Handle shadowed properties
string[] shadowProps = new string[] { "Visible", "Enabled", "ContextMenu", "AllowDrop", "Location", "Name" };

Attribute[] empty = new Attribute[0];
Attribute[] empty = Array.Empty<Attribute>();
for (int i = 0; i < shadowProps.Length; i++)
{
prop = (PropertyDescriptor)properties[shadowProps[i]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ protected override void PreFilterProperties(IDictionary properties)
base.PreFilterProperties(properties);
// Handle shadowed properties
string[] shadowProps = new string[] { "Opacity", "Menu", "IsMdiContainer", "Size", "ShowInTaskBar", "WindowState", "AutoSize", "AcceptButton", "CancelButton" };
Attribute[] empty = new Attribute[0];
Attribute[] empty = Array.Empty<Attribute>();
for (int i = 0; i < shadowProps.Length; i++)
{
prop = (PropertyDescriptor)properties[shadowProps[i]];
Expand Down
Loading