Skip to content

Commit e585856

Browse files
committed
Minor code refactoring for new class structure
1 parent 525be0c commit e585856

9 files changed

+177
-177
lines changed

Microsoft.Toolkit/Diagnostics/Generated/ThrowHelper.Collection.g.cs

Lines changed: 88 additions & 88 deletions
Large diffs are not rendered by default.

Microsoft.Toolkit/Diagnostics/Generated/ThrowHelper.Collection.tt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ GenerateTextForItems(EnumerableTypes, item =>
2424
[DoesNotReturn]
2525
internal static void ThrowArgumentExceptionForIsEmpty<T>(<#=item.Type#> <#=item.Name#>, string name)
2626
{
27-
throw new ArgumentException($"Parameter {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must be empty, had a size of {<#=item.Name#>.<#=item.Size#>.ToAssertString()}", name);
27+
throw new ArgumentException($"Parameter {AssertString(name)} ({typeof(<#=item.Type#>).ToTypeString()}) must be empty, had a size of {AssertString(<#=item.Name#>.<#=item.Size#>)}", name);
2828
}
2929

3030
/// <summary>
@@ -33,7 +33,7 @@ GenerateTextForItems(EnumerableTypes, item =>
3333
[DoesNotReturn]
3434
internal static void ThrowArgumentExceptionForHasSizeEqualTo<T>(<#=item.Type#> <#=item.Name#>, int size, string name)
3535
{
36-
throw new ArgumentException($"Parameter {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size equal to {size}, had a size of {<#=item.Name#>.<#=item.Size#>.ToAssertString()}", name);
36+
throw new ArgumentException($"Parameter {AssertString(name)} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size equal to {size}, had a size of {AssertString(<#=item.Name#>.<#=item.Size#>)}", name);
3737
}
3838

3939
/// <summary>
@@ -42,7 +42,7 @@ GenerateTextForItems(EnumerableTypes, item =>
4242
[DoesNotReturn]
4343
internal static void ThrowArgumentExceptionForHasSizeNotEqualTo<T>(<#=item.Type#> <#=item.Name#>, int size, string name)
4444
{
45-
throw new ArgumentException($"Parameter {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size not equal to {size}, had a size of {<#=item.Name#>.<#=item.Size#>.ToAssertString()}", name);
45+
throw new ArgumentException($"Parameter {AssertString(name)} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size not equal to {size}, had a size of {AssertString(<#=item.Name#>.<#=item.Size#>)}", name);
4646
}
4747

4848
/// <summary>
@@ -51,7 +51,7 @@ GenerateTextForItems(EnumerableTypes, item =>
5151
[DoesNotReturn]
5252
internal static void ThrowArgumentExceptionForHasSizeGreaterThan<T>(<#=item.Type#> <#=item.Name#>, int size, string name)
5353
{
54-
throw new ArgumentException($"Parameter {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size over {size}, had a size of {<#=item.Name#>.<#=item.Size#>.ToAssertString()}", name);
54+
throw new ArgumentException($"Parameter {AssertString(name)} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size over {size}, had a size of {AssertString(<#=item.Name#>.<#=item.Size#>)}", name);
5555
}
5656

5757
/// <summary>
@@ -60,7 +60,7 @@ GenerateTextForItems(EnumerableTypes, item =>
6060
[DoesNotReturn]
6161
internal static void ThrowArgumentExceptionForHasSizeGreaterThanOrEqualTo<T>(<#=item.Type#> <#=item.Name#>, int size, string name)
6262
{
63-
throw new ArgumentException($"Parameter {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size of at least {size}, had a size of {<#=item.Name#>.<#=item.Size#>.ToAssertString()}", name);
63+
throw new ArgumentException($"Parameter {AssertString(name)} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size of at least {size}, had a size of {AssertString(<#=item.Name#>.<#=item.Size#>)}", name);
6464
}
6565

6666
/// <summary>
@@ -69,7 +69,7 @@ GenerateTextForItems(EnumerableTypes, item =>
6969
[DoesNotReturn]
7070
internal static void ThrowArgumentExceptionForHasSizeLessThan<T>(<#=item.Type#> <#=item.Name#>, int size, string name)
7171
{
72-
throw new ArgumentException($"Parameter {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size less than {size}, had a size of {<#=item.Name#>.<#=item.Size#>.ToAssertString()}", name);
72+
throw new ArgumentException($"Parameter {AssertString(name)} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size less than {size}, had a size of {AssertString(<#=item.Name#>.<#=item.Size#>)}", name);
7373
}
7474

7575
/// <summary>
@@ -78,7 +78,7 @@ GenerateTextForItems(EnumerableTypes, item =>
7878
[DoesNotReturn]
7979
internal static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo<T>(<#=item.Type#> <#=item.Name#>, int size, string name)
8080
{
81-
throw new ArgumentException($"Parameter {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size less than or equal to {size}, had a size of {<#=item.Name#>.<#=item.Size#>.ToAssertString()}", name);
81+
throw new ArgumentException($"Parameter {AssertString(name)} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size less than or equal to {size}, had a size of {AssertString(<#=item.Name#>.<#=item.Size#>)}", name);
8282
}
8383

8484
/// <summary>
@@ -87,7 +87,7 @@ GenerateTextForItems(EnumerableTypes, item =>
8787
[DoesNotReturn]
8888
internal static void ThrowArgumentExceptionForHasSizeEqualTo<T>(<#=item.Type#> source, <#=item.DestinationType#> destination, string name)
8989
{
90-
throw new ArgumentException($"The source {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size equal to {destination.<#=item.Size#>.ToAssertString()} (the destination), had a size of {source.<#=item.Size#>.ToAssertString()}", name);
90+
throw new ArgumentException($"The source {AssertString(name)} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size equal to {AssertString(destination.<#=item.Size#>)} (the destination), had a size of {AssertString(source.<#=item.Size#>)}", name);
9191
}
9292

9393
/// <summary>
@@ -96,7 +96,7 @@ GenerateTextForItems(EnumerableTypes, item =>
9696
[DoesNotReturn]
9797
internal static void ThrowArgumentExceptionForHasSizeLessThanOrEqualTo<T>(<#=item.Type#> source, <#=item.DestinationType#> destination, string name)
9898
{
99-
throw new ArgumentException($"The source {name.ToAssertString()} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size less than or equal to {destination.<#=item.Size#>.ToAssertString()} (the destination), had a size of {source.<#=item.Size#>.ToAssertString()}", name);
99+
throw new ArgumentException($"The source {AssertString(name)} ({typeof(<#=item.Type#>).ToTypeString()}) must have a size less than or equal to {AssertString(destination.<#=item.Size#>)} (the destination), had a size of {AssertString(source.<#=item.Size#>)}", name);
100100
}
101101

102102
/// <summary>
@@ -105,7 +105,7 @@ GenerateTextForItems(EnumerableTypes, item =>
105105
[DoesNotReturn]
106106
internal static void ThrowArgumentOutOfRangeExceptionForIsInRangeFor<T>(int index, <#=item.Type#> <#=item.Name#>, string name)
107107
{
108-
throw new ArgumentOutOfRangeException(name, index, $"Parameter {name.ToAssertString()} (int) must be in the range given by <0> and {<#=item.Name#>.<#=item.Size#>.ToAssertString()} to be a valid index for the target collection ({typeof(<#=item.Type#>).ToTypeString()}), was {index.ToAssertString()}");
108+
throw new ArgumentOutOfRangeException(name, index, $"Parameter {AssertString(name)} (int) must be in the range given by <0> and {AssertString(<#=item.Name#>.<#=item.Size#>)} to be a valid index for the target collection ({typeof(<#=item.Type#>).ToTypeString()}), was {AssertString(index)}");
109109
}
110110

111111
/// <summary>
@@ -114,7 +114,7 @@ GenerateTextForItems(EnumerableTypes, item =>
114114
[DoesNotReturn]
115115
internal static void ThrowArgumentOutOfRangeExceptionForIsNotInRangeFor<T>(int index, <#=item.Type#> <#=item.Name#>, string name)
116116
{
117-
throw new ArgumentOutOfRangeException(name, index, $"Parameter {name.ToAssertString()} (int) must not be in the range given by <0> and {<#=item.Name#>.<#=item.Size#>.ToAssertString()} to be an invalid index for the target collection ({typeof(<#=item.Type#>).ToTypeString()}), was {index.ToAssertString()}");
117+
throw new ArgumentOutOfRangeException(name, index, $"Parameter {AssertString(name)} (int) must not be in the range given by <0> and {AssertString(<#=item.Name#>.<#=item.Size#>)} to be an invalid index for the target collection ({typeof(<#=item.Type#>).ToTypeString()}), was {AssertString(index)}");
118118
}
119119
<#
120120
});

Microsoft.Toolkit/Diagnostics/Internals/Guard.Collection.Generic.ThrowHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static partial class ThrowHelper
2121
[DoesNotReturn]
2222
internal static void ThrowArgumentExceptionForIsNotEmptyWithSpan<T>(string name)
2323
{
24-
throw new ArgumentException($"Parameter {name.ToAssertString()} ({typeof(Span<T>).ToTypeString()}) must not be empty", name);
24+
throw new ArgumentException($"Parameter {AssertString(name)} ({typeof(Span<T>).ToTypeString()}) must not be empty", name);
2525
}
2626

2727
/// <summary>
@@ -32,7 +32,7 @@ internal static void ThrowArgumentExceptionForIsNotEmptyWithSpan<T>(string name)
3232
[DoesNotReturn]
3333
internal static void ThrowArgumentExceptionForIsNotEmptyWithReadOnlySpan<T>(string name)
3434
{
35-
throw new ArgumentException($"Parameter {name.ToAssertString()} ({typeof(ReadOnlySpan<T>).ToTypeString()}) must not be empty", name);
35+
throw new ArgumentException($"Parameter {AssertString(name)} ({typeof(ReadOnlySpan<T>).ToTypeString()}) must not be empty", name);
3636
}
3737

3838
/// <summary>
@@ -42,7 +42,7 @@ internal static void ThrowArgumentExceptionForIsNotEmptyWithReadOnlySpan<T>(stri
4242
[DoesNotReturn]
4343
internal static void ThrowArgumentExceptionForIsNotEmpty<T>(string name)
4444
{
45-
throw new ArgumentException($"Parameter {name.ToAssertString()} ({typeof(T).ToTypeString()}) must not be empty", name);
45+
throw new ArgumentException($"Parameter {AssertString(name)} ({typeof(T).ToTypeString()}) must not be empty", name);
4646
}
4747
}
4848
}

0 commit comments

Comments
 (0)