Skip to content

Commit 2cbd2bc

Browse files
Fix tests, remove InliningOptions
1 parent 64faeab commit 2cbd2bc

File tree

9 files changed

+32
-52
lines changed

9 files changed

+32
-52
lines changed

SharedInfrastructure.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SharedInfrastructure", "src
99
EndProject
1010
Global
1111
GlobalSection(SharedMSBuildProjectFiles) = preSolution
12+
src\SharedInfrastructure\SharedInfrastructure.projitems*{1664b46a-d99f-4c66-9424-a3a17c926a4c}*SharedItemsImports = 5
1213
src\SharedInfrastructure\SharedInfrastructure.projitems*{68a8cc40-6aed-4e96-b524-31b1158fdeea}*SharedItemsImports = 13
1314
EndGlobalSection
1415
GlobalSection(SolutionConfigurationPlatforms) = preSolution

src/SharedInfrastructure/DebugGuard.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ namespace SixLabors
1212
/// Provides methods to protect against invalid parameters for a DEBUG build.
1313
/// </summary>
1414
[DebuggerStepThrough]
15+
#pragma warning disable CS0436 // Type conflicts with imported type
1516
[ExcludeFromCodeCoverage]
17+
#pragma warning restore CS0436 // Type conflicts with imported type
1618
internal static partial class DebugGuard
1719
{
1820
/// <summary>

src/SharedInfrastructure/Guard.Numeric.tt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ for (var i = 0; i < types.Length; i++)
3232
/// <exception cref="ArgumentException">
3333
/// <paramref name="value"/> is greater than the maximum value.
3434
/// </exception>
35-
[MethodImpl(InliningOptions.ShortMethod)]
35+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3636
public static void MustBeLessThan(<#=T#> value, <#=T#> max, string parameterName)
3737
{
3838
if (value >= max)
@@ -51,7 +51,7 @@ for (var i = 0; i < types.Length; i++)
5151
/// <exception cref="ArgumentException">
5252
/// <paramref name="value"/> is greater than the maximum value.
5353
/// </exception>
54-
[MethodImpl(InliningOptions.ShortMethod)]
54+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
5555
public static void MustBeLessThanOrEqualTo(<#=T#> value, <#=T#> max, string parameterName)
5656
{
5757
if (value > max)
@@ -70,7 +70,7 @@ for (var i = 0; i < types.Length; i++)
7070
/// <exception cref="ArgumentException">
7171
/// <paramref name="value"/> is less than the minimum value.
7272
/// </exception>
73-
[MethodImpl(InliningOptions.ShortMethod)]
73+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
7474
public static void MustBeGreaterThan(<#=T#> value, <#=T#> min, string parameterName)
7575
{
7676
if (value <= min)
@@ -89,7 +89,7 @@ for (var i = 0; i < types.Length; i++)
8989
/// <exception cref="ArgumentException">
9090
/// <paramref name="value"/> is less than the minimum value.
9191
/// </exception>
92-
[MethodImpl(InliningOptions.ShortMethod)]
92+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
9393
public static void MustBeGreaterThanOrEqualTo(<#=T#> value, <#=T#> min, string parameterName)
9494
{
9595
if (value < min)
@@ -109,7 +109,7 @@ for (var i = 0; i < types.Length; i++)
109109
/// <exception cref="ArgumentException">
110110
/// <paramref name="value"/> is less than the minimum value of greater than the maximum value.
111111
/// </exception>
112-
[MethodImpl(InliningOptions.ShortMethod)]
112+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
113113
public static void MustBeBetweenOrEqualTo(<#=T#> value, <#=T#> min, <#=T#> max, string parameterName)
114114
{
115115
if (value < min || value > max)

src/SharedInfrastructure/Guard.cs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ namespace SixLabors
1212
/// Provides methods to protect against invalid parameters.
1313
/// </summary>
1414
[DebuggerStepThrough]
15+
#pragma warning disable CS0436 // Type conflicts with imported type
1516
[ExcludeFromCodeCoverage]
17+
#pragma warning restore CS0436 // Type conflicts with imported type
1618
internal static partial class Guard
1719
{
1820
/// <summary>
@@ -22,7 +24,7 @@ internal static partial class Guard
2224
/// <param name="parameterName">The name of the parameter that is to be checked.</param>
2325
/// <typeparam name="TValue">The type of the value.</typeparam>
2426
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
25-
[MethodImpl(InliningOptions.ShortMethod)]
27+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2628
public static void NotNull<TValue>(TValue value, string parameterName)
2729
where TValue : class
2830
{
@@ -39,7 +41,7 @@ public static void NotNull<TValue>(TValue value, string parameterName)
3941
/// <param name="parameterName">Name of the parameter.</param>
4042
/// <exception cref="ArgumentNullException"><paramref name="value"/> is null.</exception>
4143
/// <exception cref="ArgumentException"><paramref name="value"/> is empty or contains only blanks.</exception>
42-
[MethodImpl(InliningOptions.ShortMethod)]
44+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
4345
public static void NotNullOrWhiteSpace(string value, string parameterName)
4446
{
4547
if (string.IsNullOrWhiteSpace(value))
@@ -58,7 +60,7 @@ public static void NotNullOrWhiteSpace(string value, string parameterName)
5860
/// <exception cref="ArgumentException">
5961
/// <paramref name="value"/> is greater than the maximum value.
6062
/// </exception>
61-
[MethodImpl(InliningOptions.ShortMethod)]
63+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
6264
public static void MustBeLessThan<TValue>(TValue value, TValue max, string parameterName)
6365
where TValue : IComparable<TValue>
6466
{
@@ -79,7 +81,7 @@ public static void MustBeLessThan<TValue>(TValue value, TValue max, string param
7981
/// <exception cref="ArgumentException">
8082
/// <paramref name="value"/> is greater than the maximum value.
8183
/// </exception>
82-
[MethodImpl(InliningOptions.ShortMethod)]
84+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
8385
public static void MustBeLessThanOrEqualTo<TValue>(TValue value, TValue max, string parameterName)
8486
where TValue : IComparable<TValue>
8587
{
@@ -100,7 +102,7 @@ public static void MustBeLessThanOrEqualTo<TValue>(TValue value, TValue max, str
100102
/// <exception cref="ArgumentException">
101103
/// <paramref name="value"/> is less than the minimum value.
102104
/// </exception>
103-
[MethodImpl(InliningOptions.ShortMethod)]
105+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
104106
public static void MustBeGreaterThan<TValue>(TValue value, TValue min, string parameterName)
105107
where TValue : IComparable<TValue>
106108
{
@@ -121,7 +123,7 @@ public static void MustBeGreaterThan<TValue>(TValue value, TValue min, string pa
121123
/// <exception cref="ArgumentException">
122124
/// <paramref name="value"/> is less than the minimum value.
123125
/// </exception>
124-
[MethodImpl(InliningOptions.ShortMethod)]
126+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
125127
public static void MustBeGreaterThanOrEqualTo<TValue>(TValue value, TValue min, string parameterName)
126128
where TValue : IComparable<TValue>
127129
{
@@ -143,7 +145,7 @@ public static void MustBeGreaterThanOrEqualTo<TValue>(TValue value, TValue min,
143145
/// <exception cref="ArgumentException">
144146
/// <paramref name="value"/> is less than the minimum value of greater than the maximum value.
145147
/// </exception>
146-
[MethodImpl(InliningOptions.ShortMethod)]
148+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
147149
public static void MustBeBetweenOrEqualTo<TValue>(TValue value, TValue min, TValue max, string parameterName)
148150
where TValue : IComparable<TValue>
149151
{
@@ -163,7 +165,7 @@ public static void MustBeBetweenOrEqualTo<TValue>(TValue value, TValue min, TVal
163165
/// <exception cref="ArgumentException">
164166
/// <paramref name="target"/> is false.
165167
/// </exception>
166-
[MethodImpl(InliningOptions.ShortMethod)]
168+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
167169
public static void IsTrue(bool target, string parameterName, string message)
168170
{
169171
if (!target)
@@ -182,7 +184,7 @@ public static void IsTrue(bool target, string parameterName, string message)
182184
/// <exception cref="ArgumentException">
183185
/// <paramref name="target"/> is true.
184186
/// </exception>
185-
[MethodImpl(InliningOptions.ShortMethod)]
187+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
186188
public static void IsFalse(bool target, string parameterName, string message)
187189
{
188190
if (target)
@@ -201,7 +203,7 @@ public static void IsFalse(bool target, string parameterName, string message)
201203
/// <exception cref="ArgumentException">
202204
/// <paramref name="source"/> has less than <paramref name="minLength"/> items.
203205
/// </exception>
204-
[MethodImpl(InliningOptions.ShortMethod)]
206+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
205207
public static void MustBeSizedAtLeast<T>(ReadOnlySpan<T> source, int minLength, string parameterName)
206208
{
207209
if (source.Length < minLength)
@@ -220,7 +222,7 @@ public static void MustBeSizedAtLeast<T>(ReadOnlySpan<T> source, int minLength,
220222
/// <exception cref="ArgumentException">
221223
/// <paramref name="source"/> has less than <paramref name="minLength"/> items.
222224
/// </exception>
223-
[MethodImpl(InliningOptions.ShortMethod)]
225+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
224226
public static void MustBeSizedAtLeast<T>(Span<T> source, int minLength, string parameterName)
225227
{
226228
if (source.Length < minLength)
@@ -237,7 +239,7 @@ public static void MustBeSizedAtLeast<T>(Span<T> source, int minLength, string p
237239
/// <param name="source">The source span.</param>
238240
/// <param name="destination">The destination span.</param>
239241
/// <param name="destinationParamName">The name of the argument for 'destination'.</param>
240-
[MethodImpl(InliningOptions.ShortMethod)]
242+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
241243
public static void DestinationShouldNotBeTooShort<TSource, TDest>(
242244
ReadOnlySpan<TSource> source,
243245
Span<TDest> destination,
@@ -257,7 +259,7 @@ public static void DestinationShouldNotBeTooShort<TSource, TDest>(
257259
/// <param name="source">The source span.</param>
258260
/// <param name="destination">The destination span.</param>
259261
/// <param name="destinationParamName">The name of the argument for 'destination'.</param>
260-
[MethodImpl(InliningOptions.ShortMethod)]
262+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
261263
public static void DestinationShouldNotBeTooShort<TSource, TDest>(
262264
Span<TSource> source,
263265
Span<TDest> destination,

src/SharedInfrastructure/HashCode.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ namespace System
5757
{
5858
// xxHash32 is used for the hash code.
5959
// https://github.com/Cyan4973/xxHash
60+
#pragma warning disable CS0436 // Type conflicts with imported type
6061
[ExcludeFromCodeCoverage]
62+
#pragma warning restore CS0436 // Type conflicts with imported type
6163
internal struct HashCode
6264
{
6365
#pragma warning disable SA1311 // Static readonly fields should begin with upper-case letter

src/SharedInfrastructure/InliningOptions.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/SharedInfrastructure/MathF.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ namespace System
1414
/// Provides single-precision floating point constants and static methods for trigonometric, logarithmic, and other common mathematical functions.
1515
/// </summary>
1616
/// <remarks>MathF emulation on platforms that don't support it natively.</remarks>
17+
#pragma warning disable CS0436 // Type conflicts with imported type
1718
[ExcludeFromCodeCoverage]
19+
#pragma warning restore CS0436 // Type conflicts with imported type
1820
internal static class MathF
1921
{
2022
/// <summary>

src/SharedInfrastructure/SharedInfrastructure.projitems

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
<Compile Include="$(MSBuildThisFileDirectory)ExcludeFromCodeCoverageAttribute.cs" />
1414
<Compile Include="$(MSBuildThisFileDirectory)Guard.cs" />
1515
<Compile Include="$(MSBuildThisFileDirectory)HashCode.cs" />
16-
<Compile Include="$(MSBuildThisFileDirectory)InliningOptions.cs" />
1716
<Compile Include="$(MSBuildThisFileDirectory)MathF.cs" />
1817
<Compile Include="$(MSBuildThisFileDirectory)ThrowHelper.cs" />
1918
</ItemGroup>

tests/SharedInfrastructure.Tests/GuardTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public void MustBeLessThan_IsGreaterOrEqual_ThrowsNoException(int value, int max
137137
Assert.Throws<ArgumentOutOfRangeException>(() => Guard.MustBeLessThan(value, max, "myParamName"));
138138

139139
Assert.Equal("myParamName", exception.ParamName);
140-
Assert.Contains($"Value {value} must be less than {max}.", exception.Message);
140+
Assert.Contains($"Parameter \"myParamName\" ({typeof(int)}) must be less than {max}, was {value}", exception.Message);
141141
}
142142

143143
[Theory]
@@ -155,7 +155,7 @@ public void MustBeLessThanOrEqualTo_IsGreater_ThrowsNoException()
155155
Assert.Throws<ArgumentOutOfRangeException>(() => Guard.MustBeLessThanOrEqualTo(2, 1, "myParamName"));
156156

157157
Assert.Equal("myParamName", exception.ParamName);
158-
Assert.Contains($"Value 2 must be less than or equal to 1.", exception.Message);
158+
Assert.Contains($"Parameter \"myParamName\" ({typeof(int)}) must be less than or equal to {1}, was {2}", exception.Message);
159159
}
160160

161161
[Fact]
@@ -173,7 +173,7 @@ public void MustBeGreaterThan_IsLessOrEqual_ThrowsNoException(int value, int min
173173
Assert.Throws<ArgumentOutOfRangeException>(() => Guard.MustBeGreaterThan(value, min, "myParamName"));
174174

175175
Assert.Equal("myParamName", exception.ParamName);
176-
Assert.Contains($"Value {value} must be greater than {min}.", exception.Message);
176+
Assert.Contains($"Parameter \"myParamName\" ({typeof(int)}) must be greater than {min}, was {value}", exception.Message);
177177
}
178178

179179
[Theory]
@@ -191,7 +191,7 @@ public void MustBeGreaterThanOrEqualTo_IsLess_ThrowsNoException()
191191
Assert.Throws<ArgumentOutOfRangeException>(() => Guard.MustBeGreaterThanOrEqualTo(1, 2, "myParamName"));
192192

193193
Assert.Equal("myParamName", exception.ParamName);
194-
Assert.Contains($"Value 1 must be greater than or equal to 2.", exception.Message);
194+
Assert.Contains($"Parameter \"myParamName\" ({typeof(int)}) must be greater than or equal to {2}, was {1}", exception.Message);
195195
}
196196

197197
[Theory]
@@ -212,7 +212,7 @@ public void MustBeBetweenOrEqualTo_IsLessOrGreater_ThrowsNoException(int value,
212212
Assert.Throws<ArgumentOutOfRangeException>(() => Guard.MustBeBetweenOrEqualTo(value, min, max, "myParamName"));
213213

214214
Assert.Equal("myParamName", exception.ParamName);
215-
Assert.Contains($"Value {value} must be greater than or equal to {min} and less than or equal to {max}.", exception.Message);
215+
Assert.Contains($"Parameter \"myParamName\" ({typeof(int)}) must be between or equal to {min} and {max}, was {value}", exception.Message);
216216
}
217217

218218
[Theory]

0 commit comments

Comments
 (0)