Skip to content

Commit

Permalink
Use params IEnumerable<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
ltrzesniewski committed Nov 16, 2024
1 parent baecf8f commit 2a8c595
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 1 addition & 5 deletions src/InlineIL.Fody/Extensions/FrameworkExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace InlineIL.Fody.Extensions;

Expand Down Expand Up @@ -30,15 +29,12 @@ public static TValue GetOrAddNew<TKey, TValue>(this IDictionary<TKey, TValue> di
return value;
}

public static void AddRange<T>(this ICollection<T> collection, IEnumerable<T> items)
public static void AddRange<T>(this ICollection<T> collection, params IEnumerable<T> items)
{
foreach (var item in items)
collection.Add(item);
}

public static void AddRange<T>(this ICollection<T> collection, params T[] items)
=> AddRange(collection, items.AsEnumerable());

public static int IndexOfFirst<T>(this IEnumerable<T> items, Func<T, bool> predicate)
{
var index = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/InlineIL.Fody/Processing/WeaverILProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void Remove(Instruction instruction)
UpdateReferences(instruction, newRef);
}

public void Remove(params Instruction[] instructions)
public void Remove(params IEnumerable<Instruction> instructions)
{
foreach (var instruction in instructions)
Remove(instruction);
Expand Down Expand Up @@ -129,7 +129,7 @@ private void EnsureSameBasicBlock(Instruction instruction, int basicBlock)
throw new InstructionWeavingException(instruction, "An unconditional expression was expected.");
}

public bool TryMergeBasicBlocks(Instruction sourceBasicBlock, params Instruction[] basicBlocksToUpdate)
public bool TryMergeBasicBlocks(Instruction sourceBasicBlock, params IEnumerable<Instruction> basicBlocksToUpdate)
{
var sourceBlock = GetBasicBlock(sourceBasicBlock);
var targetBlocks = basicBlocksToUpdate.Select(GetBasicBlock).ToHashSet();
Expand Down
3 changes: 2 additions & 1 deletion src/InlineIL.Tests/Processing/MethodLocalsTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using InlineIL.Fody.Model;
using InlineIL.Fody.Processing;
using InlineIL.Tests.Support;
Expand Down Expand Up @@ -49,7 +50,7 @@ public void should_not_log_warning_for_used_named_locals()
_logger.LoggedWarnings.ShouldBeEmpty();
}

private MethodLocals CreateLocals(params LocalVarBuilder[] localVarBuilders)
private MethodLocals CreateLocals(params IEnumerable<LocalVarBuilder> localVarBuilders)
{
var methodLocals = new MethodLocals(new MethodDefinition("test", default, _module.TypeSystem.Void), _logger);
methodLocals.DeclareLocals(localVarBuilders, null);
Expand Down

0 comments on commit 2a8c595

Please sign in to comment.