Skip to content

Commit a3c04da

Browse files
committed
TypeHelper: Simplified new expression
1 parent b9caf66 commit a3c04da

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/TypeHelper.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,47 @@ public static class TypeHelper
1515
/// <param name="func">The function to call when the <see cref="IEnumerator"/> is called.</param>
1616
/// <param name="monoBehaviour">The instance of the <see cref="MonoBehaviour"/> to start the <see cref="Coroutine"/> from.</param>
1717
/// <returns>A new <see cref="Routine"/> containing the arguments provided.</returns>
18-
public static Routine ToRoutine(this Func<IEnumerator> func, MonoBehaviour monoBehaviour) => new Routine(func, monoBehaviour);
18+
public static Routine ToRoutine(this Func<IEnumerator> func, MonoBehaviour monoBehaviour) => new(func, monoBehaviour);
1919

2020
/// <summary>
2121
/// Converts arguments to a new <see cref="Routine{T}"/>.
2222
/// </summary>
2323
/// <param name="func">The function to call when the <see cref="IEnumerator"/> is called.</param>
2424
/// <param name="monoBehaviour">The instance of the <see cref="MonoBehaviour"/> to start the <see cref="Coroutine"/> from.</param>
2525
/// <returns>A new <see cref="Routine{T}"/> containing the arguments provided.</returns>
26-
public static Routine<T> ToRoutine<T>(this Func<T, IEnumerator> func, MonoBehaviour monoBehaviour) => new Routine<T>(func, monoBehaviour);
26+
public static Routine<T> ToRoutine<T>(this Func<T, IEnumerator> func, MonoBehaviour monoBehaviour) => new(func, monoBehaviour);
2727

2828
/// <summary>
2929
/// Converts arguments to a new <see cref="Routine{T1, T2}"/>.
3030
/// </summary>
3131
/// <param name="func">The function to call when the <see cref="IEnumerator"/> is called.</param>
3232
/// <param name="monoBehaviour">The instance of the <see cref="MonoBehaviour"/> to start the <see cref="Coroutine"/> from.</param>
3333
/// <returns>A new <see cref="Routine{T1, T2}"/> containing the arguments provided.</returns>
34-
public static Routine<T1, T2> ToRoutine<T1, T2>(this Func<T1, T2, IEnumerator> func, MonoBehaviour monoBehaviour) => new Routine<T1, T2>(func, monoBehaviour);
34+
public static Routine<T1, T2> ToRoutine<T1, T2>(this Func<T1, T2, IEnumerator> func, MonoBehaviour monoBehaviour) => new(func, monoBehaviour);
3535

3636
/// <summary>
3737
/// Converts arguments to a new <see cref="Routine{T1, T2, T3}"/>.
3838
/// </summary>
3939
/// <param name="func">The function to call when the <see cref="IEnumerator"/> is called.</param>
4040
/// <param name="monoBehaviour">The instance of the <see cref="MonoBehaviour"/> to start the <see cref="Coroutine"/> from.</param>
4141
/// <returns>A new <see cref="Routine{T1, T2, T3}"/> containing the arguments provided.</returns>
42-
public static Routine<T1, T2, T3> ToRoutine<T1, T2, T3>(this Func<T1, T2, T3, IEnumerator> func, MonoBehaviour monoBehaviour) => new Routine<T1, T2, T3>(func, monoBehaviour);
42+
public static Routine<T1, T2, T3> ToRoutine<T1, T2, T3>(this Func<T1, T2, T3, IEnumerator> func, MonoBehaviour monoBehaviour) => new(func, monoBehaviour);
4343

4444
/// <summary>
4545
/// Converts arguments to a new <see cref="Routine{T1, T2, T3, T4}"/>.
4646
/// </summary>
4747
/// <param name="func">The function to call when the <see cref="IEnumerator"/> is called.</param>
4848
/// <param name="monoBehaviour">The instance of the <see cref="MonoBehaviour"/> to start the <see cref="Coroutine"/> from.</param>
4949
/// <returns>A new <see cref="Routine{T1, T2, T3, T4}"/> containing the arguments provided.</returns>
50-
public static Routine<T1, T2, T3, T4> ToRoutine<T1, T2, T3, T4>(this Func<T1, T2, T3, T4, IEnumerator> func, MonoBehaviour monoBehaviour) => new Routine<T1, T2, T3, T4>(func, monoBehaviour);
50+
public static Routine<T1, T2, T3, T4> ToRoutine<T1, T2, T3, T4>(this Func<T1, T2, T3, T4, IEnumerator> func, MonoBehaviour monoBehaviour) => new(func, monoBehaviour);
5151

5252
/// <summary>
5353
/// Converts arguments to a new <see cref="Tuple{T}"/>.
5454
/// </summary>
5555
/// <typeparam name="T">The type of tuple.</typeparam>
5656
/// <param name="item">The argument to pass into the tuple.</param>
5757
/// <returns>A new <see cref="Tuple{T}"/> containing <paramref name="item"/>.</returns>
58-
public static Tuple<T> ToTuple<T>(this T item) => new Tuple<T>(item);
58+
public static Tuple<T> ToTuple<T>(this T item) => new(item);
5959

6060
/// <summary>
6161
/// Converts arguments to a new <see cref="Tuple{T1, T2}"/>.
@@ -65,7 +65,7 @@ public static class TypeHelper
6565
/// <param name="item1">The first argument to pass into the tuple.</param>
6666
/// <param name="item2">The second argument to pass into the tuple.</param>
6767
/// <returns>A new <seealso cref="Tuple{T1, T2}"/> containing <paramref name="item1"/> and <paramref name="item2"/></returns>
68-
public static Tuple<T1, T2> ToTuple<T1, T2>(this T1 item1, T2 item2) => new Tuple<T1, T2>(item1, item2);
68+
public static Tuple<T1, T2> ToTuple<T1, T2>(this T1 item1, T2 item2) => new(item1, item2);
6969

7070
/// <summary>
7171
/// Converts arguments to a new <see cref="Tuple{T1, T2, T3}"/>.
@@ -77,7 +77,7 @@ public static class TypeHelper
7777
/// <param name="item2">The second argument to pass into the tuple.</param>
7878
/// <param name="item3">The third argument to pass into the tuple.</param>
7979
/// <returns>A new <seealso cref="Tuple{T1, T2, T3}"/> containing <paramref name="item1"/>, <paramref name="item2"/>, and <paramref name="item3"/></returns>
80-
public static Tuple<T1, T2, T3> ToTuple<T1, T2, T3>(this T1 item1, T2 item2, T3 item3) => new Tuple<T1, T2, T3>(item1, item2, item3);
80+
public static Tuple<T1, T2, T3> ToTuple<T1, T2, T3>(this T1 item1, T2 item2, T3 item3) => new(item1, item2, item3);
8181

8282
/// <summary>
8383
/// Converts arguments to a new <see cref="Tuple{T1, T2, T3, T4}"/>.
@@ -91,7 +91,7 @@ public static class TypeHelper
9191
/// <param name="item3">The third argument to pass into the tuple.</param>
9292
/// <param name="item4">The fourth argument to pass into the tuple.</param>
9393
/// <returns>A new <seealso cref="Tuple{T1, T2, T3, T4}"/> containing <paramref name="item1"/>, <paramref name="item2"/>, <paramref name="item3"/>, and <paramref name="item4"/></returns>
94-
public static Tuple<T1, T2, T3, T4> ToTuple<T1, T2, T3, T4>(this T1 item1, T2 item2, T3 item3, T4 item4) => new Tuple<T1, T2, T3, T4>(item1, item2, item3, item4);
94+
public static Tuple<T1, T2, T3, T4> ToTuple<T1, T2, T3, T4>(this T1 item1, T2 item2, T3 item3, T4 item4) => new(item1, item2, item3, item4);
9595

9696
/// <summary>
9797
/// Converts argument to a new <see cref="Work"/>
@@ -100,7 +100,7 @@ public static class TypeHelper
100100
/// <param name="allowSimultaneousActive">Whether it should allow multiple of itself to be running at once.</param>
101101
/// <param name="maximumThreadsActive">The amount of threads this class, and all of its overloads can run at once.</param>
102102
/// <returns>A new <see cref="Work"/> consisting of the arguments provided.</returns>
103-
public static Work ToWork(this Action action, bool allowSimultaneousActive = false, uint maximumThreadsActive = 1) => new Work(action, allowSimultaneousActive, maximumThreadsActive);
103+
public static Work ToWork(this Action action, bool allowSimultaneousActive = false, uint maximumThreadsActive = 1) => new(action, allowSimultaneousActive, maximumThreadsActive);
104104

105105
/// <summary>
106106
/// Converts argument to a new <see cref="Work{T}"/>
@@ -109,7 +109,7 @@ public static class TypeHelper
109109
/// <param name="allowSimultaneousActive">Whether it should allow multiple of itself to be running at once.</param>
110110
/// <param name="maximumThreadsActive">The amount of threads this class, and all of its overloads can run at once.</param>
111111
/// <returns>A new <see cref="Work{T}"/> consisting of the arguments provided.</returns>
112-
public static Work<T> ToWork<T>(this Func<T> func, bool allowSimultaneousActive = false, uint maximumThreadsActive = 1) => new Work<T>(func, allowSimultaneousActive, maximumThreadsActive);
112+
public static Work<T> ToWork<T>(this Func<T> func, bool allowSimultaneousActive = false, uint maximumThreadsActive = 1) => new(func, allowSimultaneousActive, maximumThreadsActive);
113113

114114
/// <summary>
115115
/// Converts argument to a new <see cref="Work{T, TResult}"/>
@@ -118,7 +118,7 @@ public static class TypeHelper
118118
/// <param name="allowSimultaneousActive">Whether it should allow multiple of itself to be running at once.</param>
119119
/// <param name="maximumThreadsActive">The amount of threads this class, and all of its overloads can run at once.</param>
120120
/// <returns>A new <see cref="Work{T, TResult}"/> consisting of the arguments provided.</returns>
121-
public static Work<T, TResult> ToWork<T, TResult>(this Func<T, TResult> func, bool allowSimultaneousActive = false, uint maximumThreadsActive = 1) => new Work<T, TResult>(func, allowSimultaneousActive, maximumThreadsActive);
121+
public static Work<T, TResult> ToWork<T, TResult>(this Func<T, TResult> func, bool allowSimultaneousActive = false, uint maximumThreadsActive = 1) => new(func, allowSimultaneousActive, maximumThreadsActive);
122122

123123
/// <summary>
124124
/// Converts argument to a new <see cref="Work{T1, T2, TResult}"/>
@@ -127,7 +127,7 @@ public static class TypeHelper
127127
/// <param name="allowSimultaneousActive">Whether it should allow multiple of itself to be running at once.</param>
128128
/// <param name="maximumThreadsActive">The amount of threads this class, and all of its overloads can run at once.</param>
129129
/// <returns>A new <see cref="Work{T1, T2, TResult}"/> consisting of the arguments provided.</returns>
130-
public static Work<T1, T2, TResult> ToWork<T1, T2, TResult>(this Func<T1, T2, TResult> func, bool allowSimultaneousActive = false, uint maximumThreadsActive = 1) => new Work<T1, T2, TResult>(func, allowSimultaneousActive, maximumThreadsActive);
130+
public static Work<T1, T2, TResult> ToWork<T1, T2, TResult>(this Func<T1, T2, TResult> func, bool allowSimultaneousActive = false, uint maximumThreadsActive = 1) => new(func, allowSimultaneousActive, maximumThreadsActive);
131131

132132
/// <summary>
133133
/// Converts argument to a new <see cref="Work{T1, T2, T3, TResult}"/>
@@ -136,7 +136,7 @@ public static class TypeHelper
136136
/// <param name="allowSimultaneousActive">Whether it should allow multiple of itself to be running at once.</param>
137137
/// <param name="maximumThreadsActive">The amount of threads this class, and all of its overloads can run at once.</param>
138138
/// <returns>A new <see cref="Work{T1, T2, T3, TResult}"/> consisting of the arguments provided.</returns>
139-
public static Work<T1, T2, T3, TResult> ToWork<T1, T2, T3, TResult>(this Func<T1, T2, T3, TResult> func, bool allowSimultaneousActive = false, uint maximumThreadsActive = 1) => new Work<T1, T2, T3, TResult>(func, allowSimultaneousActive, maximumThreadsActive);
139+
public static Work<T1, T2, T3, TResult> ToWork<T1, T2, T3, TResult>(this Func<T1, T2, T3, TResult> func, bool allowSimultaneousActive = false, uint maximumThreadsActive = 1) => new(func, allowSimultaneousActive, maximumThreadsActive);
140140

141141
/// <summary>
142142
/// Converts argument to a new <see cref="Work{T1, T2, T3, T4, TResult}"/>
@@ -145,6 +145,6 @@ public static class TypeHelper
145145
/// <param name="allowSimultaneousActive">Whether it should allow multiple of itself to be running at once.</param>
146146
/// <param name="maximumThreadsActive">The amount of threads this class, and all of its overloads can run at once.</param>
147147
/// <returns>A new <see cref="Work{T1, T2, T3, T4, TResult}"/> consisting of the arguments provided.</returns>
148-
public static Work<T1, T2, T3, T4, TResult> ToWork<T1, T2, T3, T4, TResult>(this Func<T1, T2, T3, T4, TResult> func, bool allowSimultaneousActive = false, uint maximumThreadsActive = 1) => new Work<T1, T2, T3, T4, TResult>(func, allowSimultaneousActive, maximumThreadsActive);
148+
public static Work<T1, T2, T3, T4, TResult> ToWork<T1, T2, T3, T4, TResult>(this Func<T1, T2, T3, T4, TResult> func, bool allowSimultaneousActive = false, uint maximumThreadsActive = 1) => new(func, allowSimultaneousActive, maximumThreadsActive);
149149
}
150150
}

0 commit comments

Comments
 (0)