Skip to content

Commit c0eabaf

Browse files
authored
Merge pull request #110 from feO2x/features/throw-breakup
Refactor: Throw class is now in own namespace called ExceptionFactory
2 parents 6d05edb + 894c331 commit c0eabaf

File tree

115 files changed

+1961
-741
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+1961
-741
lines changed

Code/Light.GuardClauses.Performance/CollectionAssertions/SpanMustHaveLengthBenchmark.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Runtime.CompilerServices;
33
using System.Text;
44
using BenchmarkDotNet.Attributes;
5+
using Light.GuardClauses.ExceptionFactory;
56
using Light.GuardClauses.Exceptions;
67

78
namespace Light.GuardClauses.Performance.CollectionAssertions
@@ -47,23 +48,23 @@ public static class SpanMustHaveLengthExtensions
4748
public static Span<T> MustHaveLengthCopyByValue<T>(this Span<T> parameter, int length, string parameterName = null, string message = null)
4849
{
4950
if (parameter.Length != length)
50-
Throw.InvalidSpanLength(parameter, length, parameterName, message);
51+
Throw.InvalidSpanLength((ReadOnlySpan<T>) parameter, length, parameterName, message);
5152
return parameter;
5253
}
5354

5455
[MethodImpl(MethodImplOptions.AggressiveInlining)]
5556
public static Span<T> MustHaveLengthInParameter<T>(in this Span<T> parameter, int length, string parameterName = null, string message = null)
5657
{
5758
if (parameter.Length != length)
58-
Throw.InvalidSpanLength(parameter, length, parameterName, message);
59+
Throw.InvalidSpanLength((ReadOnlySpan<T>) parameter, length, parameterName, message);
5960
return parameter;
6061
}
6162

6263
[MethodImpl(MethodImplOptions.AggressiveInlining)]
6364
public static ref Span<T> MustHaveLengthInOut<T>(ref this Span<T> parameter, int length, string parameterName = null, string message = null)
6465
{
6566
if (parameter.Length != length)
66-
Throw.InvalidSpanLength(parameter, length, parameterName, message);
67+
Throw.InvalidSpanLength((ReadOnlySpan<T>) parameter, length, parameterName, message);
6768
return ref parameter;
6869
}
6970
}

Code/Light.GuardClauses.Performance/CommonAssertions/InvalidArgumentBenchmark.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using BenchmarkDotNet.Attributes;
3+
using Light.GuardClauses.ExceptionFactory;
34

45
namespace Light.GuardClauses.Performance.CommonAssertions
56
{
@@ -34,7 +35,7 @@ public bool LightGuardClausesCustomException()
3435
public bool LightGuardClausesCustomExceptionManualInlining()
3536
{
3637
if (Condition)
37-
Exceptions.Throw.CustomException(() => new ArgumentException(Message, ParameterName));
38+
Throw.CustomException(() => new ArgumentException(Message, ParameterName));
3839
return Condition;
3940
}
4041

Code/Light.GuardClauses.Performance/CommonAssertions/MustHaveValueBenchmark.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Runtime.CompilerServices;
33
using BenchmarkDotNet.Attributes;
4+
using Light.GuardClauses.ExceptionFactory;
45
using Light.GuardClauses.Exceptions;
56

67
namespace Light.GuardClauses.Performance.CommonAssertions

Code/Light.GuardClauses.Performance/CommonAssertions/MustNotBeNullReferenceBenchmark.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Runtime.CompilerServices;
33
using BenchmarkDotNet.Attributes;
4-
using Light.GuardClauses.Exceptions;
4+
using Light.GuardClauses.ExceptionFactory;
55

66
namespace Light.GuardClauses.Performance.CommonAssertions
77
{
@@ -56,7 +56,7 @@ public static T MustNotBeNullReferenceV1<T>(this T parameter, string parameterNa
5656
return parameter;
5757

5858
Throw.ArgumentNull(parameterName, message);
59-
return default(T);
59+
return default;
6060
}
6161

6262
return parameter;
@@ -71,7 +71,7 @@ public static T MustNotBeNullReferenceV2<T>(this T parameter, string parameterNa
7171
return parameter;
7272

7373
Throw.ArgumentNull(parameterName, message);
74-
return default(T);
74+
return default;
7575
}
7676
}
7777
}

Code/Light.GuardClauses/Check.Equals.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Runtime.CompilerServices;
3-
using Light.GuardClauses.Exceptions;
3+
using Light.GuardClauses.ExceptionFactory;
44
using Light.GuardClauses.FrameworkExtensions;
55

66
namespace Light.GuardClauses;

Code/Light.GuardClauses/Check.InvalidArgument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Runtime.CompilerServices;
33
using JetBrains.Annotations;
4-
using Light.GuardClauses.Exceptions;
4+
using Light.GuardClauses.ExceptionFactory;
55

66
namespace Light.GuardClauses;
77

Code/Light.GuardClauses/Check.InvalidOperation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Runtime.CompilerServices;
3-
using Light.GuardClauses.Exceptions;
3+
using Light.GuardClauses.ExceptionFactory;
44

55
namespace Light.GuardClauses;
66

Code/Light.GuardClauses/Check.InvalidState.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Runtime.CompilerServices;
2+
using Light.GuardClauses.ExceptionFactory;
23
using Light.GuardClauses.Exceptions;
34

45
namespace Light.GuardClauses;

Code/Light.GuardClauses/Check.MustBe.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Runtime.CompilerServices;
44
using JetBrains.Annotations;
5+
using Light.GuardClauses.ExceptionFactory;
56
using Light.GuardClauses.Exceptions;
67

78
namespace Light.GuardClauses;

Code/Light.GuardClauses/Check.MustBeAbsoluteUri.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Runtime.CompilerServices;
33
using JetBrains.Annotations;
4+
using Light.GuardClauses.ExceptionFactory;
45
using Light.GuardClauses.Exceptions;
56
using NotNullAttribute = System.Diagnostics.CodeAnalysis.NotNullAttribute;
67

0 commit comments

Comments
 (0)