Skip to content

Commit 823897b

Browse files
committed
Cleanup
1 parent 972f843 commit 823897b

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

Main/src/OptionExtensions.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ public static class OptionExtensions
1616
/// </summary>
1717
public static void Match<T>(
1818
this Option<T> option,
19-
[InstantHandle]Action<Option<T>> someAction,
20-
[InstantHandle]Action noneAction)
19+
[NotNull, InstantHandle]Action<Option<T>> someAction,
20+
[NotNull, InstantHandle]Action noneAction)
2121
{
22+
Code.NotNull(someAction, nameof(someAction));
23+
Code.NotNull(noneAction, nameof(noneAction));
24+
2225
if (option.HasValue)
2326
someAction(option);
2427
else
@@ -32,9 +35,14 @@ public static void Match<T>(
3235
[Pure]
3336
public static TResult Match<T, TResult>(
3437
this Option<T> option,
35-
[InstantHandle] Func<Option<T>, TResult> someFunc,
36-
[InstantHandle] Func<TResult> noneFunc) =>
37-
option.HasValue ? someFunc(option) : noneFunc();
38+
[NotNull, InstantHandle] Func<Option<T>, TResult> someFunc,
39+
[NotNull, InstantHandle] Func<TResult> noneFunc)
40+
{
41+
Code.NotNull(someFunc, nameof(someFunc));
42+
Code.NotNull(noneFunc, nameof(noneFunc));
43+
44+
return option.HasValue ? someFunc(option) : noneFunc();
45+
}
3846

3947
/// <summary>
4048
/// Returns value of <paramref name="option"/>, or <paramref name="defaultValue"/> if <paramref name="option"/>
@@ -50,7 +58,11 @@ public static TResult Match<T, TResult>(
5058
[Pure]
5159
public static Option<TResult> Map<T, TResult>(
5260
this Option<T> option,
53-
[InstantHandle] Func<T, TResult> selectFunc) =>
54-
option.HasValue ? new Option<TResult>(selectFunc(option.Value)) : new Option<TResult>();
61+
[InstantHandle] Func<T, TResult> selectFunc)
62+
{
63+
Code.NotNull(selectFunc, nameof(selectFunc));
64+
65+
return option.HasValue ? new Option<TResult>(selectFunc(option.Value)) : new Option<TResult>();
66+
}
5567
}
5668
}

Main/src/Structures/ObjectPools/PooledObject.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace CodeJam.ObjectPools
99
/// <summary>
1010
/// The RAII object to automatically release pooled object when its owning pool.
1111
/// </summary>
12+
// BASEDON: https://github.com/dotnet/roslyn/blob/56f605c41915317ccdb925f66974ee52282609e7/src/Workspaces/Core/Portable/Utilities/ObjectPools/PooledObject.cs
1213
[PublicAPI]
1314
public struct PooledObject<T> : IDisposable where T : class
1415
{

Main/src/Structures/ObjectPools/SharedPoolExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace CodeJam.ObjectPools
1111
/// <summary>
1212
/// The <see cref="ObjectPool{T}"/> extension.
1313
/// </summary>
14+
// BASEDON: https://github.com/dotnet/roslyn/blob/56f605c41915317ccdb925f66974ee52282609e7/src/Workspaces/Core/Portable/Utilities/ObjectPools/Extensions.cs
1415
[PublicAPI]
1516
public static class SharedPoolExtensions
1617
{

Main/src/Structures/ObjectPools/SharedPools.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace CodeJam.ObjectPools
1515
/// For example, if you want to create a million of small objects within a second,
1616
/// use the ObjectPool directly. it should have much less overhead than using this.
1717
/// </summary>
18+
// BASEDON: https://github.com/dotnet/roslyn/blob/56f605c41915317ccdb925f66974ee52282609e7/src/Workspaces/Core/Portable/Utilities/ObjectPools/SharedPools.cs
1819
[PublicAPI]
1920
public static class SharedPools
2021
{

0 commit comments

Comments
 (0)