More target-typed new and redundant paranthesis cleanup

This commit is contained in:
Kwoth
2021-12-20 00:33:11 +01:00
parent 345a9e9524
commit 1b2017024c
152 changed files with 573 additions and 580 deletions

View File

@@ -18,4 +18,15 @@ public static class ArrayExtensions
newCrs[input.Length] = added;
return newCrs;
}
/// <summary>
/// Creates a new array by applying the specified function to every element in the input array
/// </summary>
/// <param name="arr">Array to modify</param>
/// <param name="f">Function to apply</param>
/// <typeparam name="TIn">Orignal type of the elements in the array</typeparam>
/// <typeparam name="TOut">Output type of the elements of the array</typeparam>
/// <returns>New array with updated elements</returns>
public static TOut[] Map<TIn, TOut>(this TIn[] arr, Func<TIn, TOut> f)
=> Array.ConvertAll(arr, x => f(x));
}

View File

@@ -31,9 +31,7 @@ public static class Extensions
{
public static Regex UrlRegex = new Regex(@"^(https?|ftp)://(?<path>[^\s/$.?#].[^\s]*)$", RegexOptions.Compiled);
public static TOut[] Map<TIn, TOut>(this TIn[] arr, Func<TIn, TOut> f)
=> Array.ConvertAll(arr, x => f(x));
public static Task EditAsync(this IUserMessage msg, SmartText text)
=> text switch
{
@@ -217,8 +215,8 @@ public static class Extensions
reactionRemoved = _ => Task.CompletedTask;
var wrap = new ReactionEventWrapper(client, msg);
wrap.OnReactionAdded += (r) => { var _ = Task.Run(() => reactionAdded(r)); };
wrap.OnReactionRemoved += (r) => { var _ = Task.Run(() => reactionRemoved(r)); };
wrap.OnReactionAdded += r => { var _ = Task.Run(() => reactionAdded(r)); };
wrap.OnReactionRemoved += r => { var _ = Task.Run(() => reactionRemoved(r)); };
return wrap;
}
@@ -323,7 +321,7 @@ public static class Extensions
}
else
{
img.SaveAsPng(imageStream, new PngEncoder()
img.SaveAsPng(imageStream, new()
{
ColorType = PngColorType.RgbWithAlpha,
CompressionLevel = PngCompressionLevel.BestCompression

View File

@@ -10,7 +10,7 @@ public static class IMessageChannelExtensions
{
public static Task<IUserMessage> EmbedAsync(this IMessageChannel ch, IEmbedBuilder embed, string msg = "")
=> ch.SendMessageAsync(msg, embed: embed.Build(),
options: new RequestOptions() { RetryMode = RetryMode.AlwaysRetry });
options: new() { RetryMode = RetryMode.AlwaysRetry });
// this is a huge problem, because now i don't have
// access to embed builder service
@@ -82,7 +82,7 @@ public static class IMessageChannelExtensions
int currentPage, Func<int, IEmbedBuilder> pageFunc, int totalElements,
int itemsPerPage, bool addPaginatedFooter = true)
=> ctx.SendPaginatedConfirmAsync(currentPage,
(x) => Task.FromResult(pageFunc(x)), totalElements, itemsPerPage, addPaginatedFooter);
x => Task.FromResult(pageFunc(x)), totalElements, itemsPerPage, addPaginatedFooter);
/// <summary>
/// danny kamisama
/// </summary>

View File

@@ -54,7 +54,7 @@ public static class IUserExtensions
public static Uri RealAvatarUrl(this IUser usr, ushort size = 128)
{
return usr.AvatarId is null
? new Uri(usr.GetDefaultAvatarUrl())
? new(usr.GetDefaultAvatarUrl())
: new Uri(usr.GetAvatarUrl(ImageFormat.Auto, size));
}

View File

@@ -24,7 +24,7 @@ public static class Rgba32Extensions
for (var i = 0; i < imgArray.Length; i++)
{
var frame = imgArray[i].Frames.CloneFrame(frameNumber % imgArray[i].Frames.Count);
imgFrame.Mutate(x => x.DrawImage(frame, new Point(xOffset, 0), new GraphicsOptions()));
imgFrame.Mutate(x => x.DrawImage(frame, new(xOffset, 0), new GraphicsOptions()));
xOffset += imgArray[i].Bounds().Width;
}
}