Skip to content

Commit 7839c1b

Browse files
committed
Fixed position of disabled warnings
1 parent c31b45f commit 7839c1b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Microsoft.Toolkit/Diagnostics/Guard.String.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public static void IsNotNullOrEmpty([NotNull] string? text, string name)
4343
{
4444
if (!string.IsNullOrEmpty(text))
4545
{
46+
#pragma warning disable CS8777 // Does not return when text is null
4647
return;
48+
#pragma warning restore CS8777
4749
}
4850

4951
ThrowHelper.ThrowArgumentExceptionForIsNotNullOrEmpty(text, name);
50-
#pragma warning disable CS8777 // Does not return when text is null (.NET Standard 2.0 string.IsNullOrEmpty lacks flow attribute)
5152
}
52-
#pragma warning restore CS8777
5353

5454
/// <summary>
5555
/// Asserts that the input <see cref="string"/> instance must be <see langword="null"/> or whitespace.
@@ -97,13 +97,13 @@ public static void IsNotNullOrWhiteSpace([NotNull] string? text, string name)
9797
{
9898
if (!string.IsNullOrWhiteSpace(text))
9999
{
100+
#pragma warning disable CS8777 // Does not return when text is null
100101
return;
102+
#pragma warning restore CS8777
101103
}
102104

103105
ThrowHelper.ThrowArgumentExceptionForIsNotNullOrWhiteSpace(text, name);
104-
#pragma warning disable CS8777 // Does not return when text is null
105106
}
106-
#pragma warning restore CS8777
107107

108108
/// <summary>
109109
/// Asserts that the input <see cref="string"/> instance must not be <see langword="null"/> or whitespace.
@@ -117,13 +117,13 @@ public static void IsNotNullOrWhitespace([NotNull] string? text, string name)
117117
{
118118
if (!string.IsNullOrWhiteSpace(text))
119119
{
120+
#pragma warning disable CS8777 // Does not return when text is null
120121
return;
122+
#pragma warning restore CS8777
121123
}
122124

123125
ThrowHelper.ThrowArgumentExceptionForIsNotNullOrWhiteSpace(text, name);
124-
#pragma warning disable CS8777 // Does not return when text is null
125126
}
126-
#pragma warning restore CS8777
127127

128128
/// <summary>
129129
/// Asserts that the input <see cref="string"/> instance must be empty.

0 commit comments

Comments
 (0)