Skip to content

Commit 6bbde13

Browse files
committed
Fix ifdefs for nullability attributes
1 parent ed5fe5f commit 6bbde13

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/Shared/ThrowHelpers/ArgumentNullThrowHelper.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ internal static partial class ArgumentNullThrowHelper
1414
/// <summary>Throws an <see cref="ArgumentNullException"/> if <paramref name="argument"/> is null.</summary>
1515
/// <param name="argument">The reference type argument to validate as non-null.</param>
1616
/// <param name="paramName">The name of the parameter with which <paramref name="argument"/> corresponds.</param>
17-
public static void ThrowIfNull([NotNull] object? argument, [CallerArgumentExpression("argument")] string? paramName = null)
17+
public static void ThrowIfNull(
18+
#if INTERNAL_NULLABLE_ATTRIBUTES || NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
19+
[NotNull]
20+
#endif
21+
object? argument, [CallerArgumentExpression("argument")] string? paramName = null)
1822
{
1923
#if !NET7_0_OR_GREATER || NETSTANDARD || NETFRAMEWORK
2024
if (argument is null)
@@ -27,7 +31,7 @@ public static void ThrowIfNull([NotNull] object? argument, [CallerArgumentExpres
2731
}
2832

2933
#if !NET7_0_OR_GREATER || NETSTANDARD || NETFRAMEWORK
30-
#if !NETFRAMEWORK
34+
#if INTERNAL_NULLABLE_ATTRIBUTES || NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
3135
[DoesNotReturn]
3236
#endif
3337
internal static void Throw(string? paramName) =>

src/Shared/ThrowHelpers/ArgumentThrowHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal static partial class ArgumentThrowHelper
1919
/// <param name="argument">The reference type argument to validate as neither null nor empty.</param>
2020
/// <param name="paramName">The name of the parameter with which <paramref name="argument"/> corresponds.</param>
2121
public static void ThrowIfNullOrEmpty(
22-
#if !NETFRAMEWORK
22+
#if INTERNAL_NULLABLE_ATTRIBUTES || NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
2323
[NotNull]
2424
#endif
2525
string? argument, [CallerArgumentExpression("argument")] string? paramName = null)
@@ -36,7 +36,7 @@ public static void ThrowIfNullOrEmpty(
3636
}
3737

3838
#if !NET7_0_OR_GREATER || NETSTANDARD || NETFRAMEWORK
39-
#if !NETFRAMEWORK
39+
#if INTERNAL_NULLABLE_ATTRIBUTES || NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
4040
[DoesNotReturn]
4141
#endif
4242
internal static void Throw(string? paramName) =>

src/SiteExtensions/Microsoft.Web.Xdt.Extensions/src/Microsoft.Web.Xdt.Extensions.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
<ItemGroup>
1919
<Compile Include="$(SharedSourceRoot)ThrowHelpers\ArgumentThrowHelper.cs" LinkBase="Shared" />
20+
<Compile Include="$(SharedSourceRoot)ThrowHelpers\ArgumentNullThrowHelper.cs" LinkBase="Shared" />
2021
<Compile Include="$(SharedSourceRoot)CallerArgument\CallerArgumentExpressionAttribute.cs" LinkBase="Shared" />
2122
</ItemGroup>
2223
</Project>

0 commit comments

Comments
 (0)