diff --git a/wawa.Modules/Source/Sounds/Sound.EffectTypes.cs b/wawa.Modules/Source/Sounds/Sound.EffectTypes.cs index d1f7eba..f671329 100755 --- a/wawa.Modules/Source/Sounds/Sound.EffectTypes.cs +++ b/wawa.Modules/Source/Sounds/Sound.EffectTypes.cs @@ -7,8 +7,7 @@ public sealed partial class Sound /// Gets all vanilla sounds from the base game. [NotNull, PublicAPI] public static ReadOnlyCollection Vanillas { [Pure] get; } = new( - new[] - { + [ AlarmClockBeep, AlarmClockSnooze, BigButtonPress, @@ -37,7 +36,7 @@ public sealed partial class Sound TypewriterKey, WireSequenceMechanism, WireSnip, - } + ] ); /// Gets the sound that plays when the alarm clock goes off. This sound loops. diff --git a/wawa.Recall/Source/Abstractions/Domains/Generator.cs b/wawa.Recall/Source/Abstractions/Domains/Generator.cs index 065ac88..1937a9f 100755 --- a/wawa.Recall/Source/Abstractions/Domains/Generator.cs +++ b/wawa.Recall/Source/Abstractions/Domains/Generator.cs @@ -22,9 +22,6 @@ static readonly MethodInfo s_combine = ((Func)Delegate.Combine).Method, s_remove = ((Delegate)Delegate.Remove).Method; - [NotNull] - static readonly ParameterExpression[] s_parameterless = new ParameterExpression[0]; - /// [PublicAPI] public static bool TrySet( @@ -530,7 +527,7 @@ static Func Caster([NotNull] this Type type) var exParameter = Expression.Parameter(typeof(T), nameof(T)); var method = type.GetMethod(nameof(Action.Invoke))!; var exArgs = method.GetParameters().Select((x, i) => Expression.Parameter(x.ParameterType, $"a{i}")).ToArray(); - var exDest = typeof(T).GetMethod(nameof(Action.Invoke))!.GetParameters().Length is 0 ? s_parameterless : exArgs; + var exDest = typeof(T).GetMethod(nameof(Action.Invoke))!.GetParameters().Length is 0 ? [] : exArgs; var exInvoke = Expression.Invoke(exParameter, exDest.Cast()); var exLambda = Expression.Lambda(type, exInvoke, exArgs); var exIsNull = Expression.Equal(exParameter, exNull); diff --git a/wawa.Recall/Source/Internals/Globals.cs b/wawa.Recall/Source/Internals/Globals.cs index fdf87f8..8e1a3d3 100755 --- a/wawa.Recall/Source/Internals/Globals.cs +++ b/wawa.Recall/Source/Internals/Globals.cs @@ -21,7 +21,7 @@ public static class Lot public static Func Id => x => x; /// Gets the empty set. - public static ReadOnlyCollection Empty { [Pure] get; } = new(new T[0]); + public static ReadOnlyCollection Empty { [Pure] get; } = new([]); } /// Gets the of the caller that invoked the method calling this. diff --git a/wawa.TwitchPlays/Source/Domains/Instruction.cs b/wawa.TwitchPlays/Source/Domains/Instruction.cs index c22dcbc..4ed3979 100755 --- a/wawa.TwitchPlays/Source/Domains/Instruction.cs +++ b/wawa.TwitchPlays/Source/Domains/Instruction.cs @@ -44,7 +44,7 @@ public Instruction([ItemCanBeNull, NotNull] IEnumerable enumerator) /// For the camera side view. The second one in the form of Quaternion.Euler(x, y, z). /// [CLSCompliant(false), PublicAPI] - public Instruction(Quaternion first, Quaternion second) => Value = new[] { first, second }; + public Instruction(Quaternion first, Quaternion second) => Value = (Quaternion[])[first, second]; /// Initializes a new instance of the class. /// The value to pass in. diff --git a/wawa.TwitchPlays/Source/Twitch{TMod}.cs b/wawa.TwitchPlays/Source/Twitch{TMod}.cs index f3816ab..e717e86 100755 --- a/wawa.TwitchPlays/Source/Twitch{TMod}.cs +++ b/wawa.TwitchPlays/Source/Twitch{TMod}.cs @@ -427,16 +427,14 @@ object Field() => if (type == typeof(string) || type == typeof(object)) return value; - var arr = new[] { typeof(string), type.MakeByRefType() }; + Type[] signature = [typeof(string), type.MakeByRefType()]; - if (type.GetMethod(nameof(int.TryParse), arr) is not { IsStatic: true } method || + if (type.GetMethod(nameof(int.TryParse), signature) is not { IsStatic: true } method || method.ReturnType != typeof(bool)) return Field(); - var args = new object[] { value, null }; - var ret = (bool)method.Invoke(null, args); - - return ret ? args[1] : ParseError.NoMatch; + object[] args = [value, null]; + return method.Invoke(null, args) is true ? args[1] : ParseError.NoMatch; } [ItemNotNull, NotNull]