Skip to content

Commit a44f532

Browse files
authored
Remove pinned XunitAnalyzersVersion from Versions.props (#118241)
* Remove pinned XunitAnalyzersVersion from Versions.props Fixes #97088 * Fix xUnit1012: Null should not be used for value type parameters * Fix xUnit1037: There are fewer theory data type arguments than required by the parameters of the test method * Fix xUnit1041: Fixture arguments to test classes must have fixture sources * Fix xUnit1048: Avoid using 'async void' for test methods as it is deprecated in xUnit.net v3 * Fix xUnit2021: Async assertions should be awaited * Fix xUnit2027: Comparison of sets to linear containers have undefined results * Fix xUnit2029: Do not use Assert.Empty to check if a value does not exist in a collection * Fix xUnit2031: Do not use Where clause with Assert.Single * Disable test that started erroring
1 parent 636f559 commit a44f532

File tree

377 files changed

+894
-888
lines changed

Some content is hidden

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

377 files changed

+894
-888
lines changed

eng/Versions.props

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@
100100
<MicrosoftDotNetRemoteExecutorVersion>10.0.0-beta.25367.101</MicrosoftDotNetRemoteExecutorVersion>
101101
<MicrosoftDotNetPackageTestingVersion>10.0.0-beta.25367.101</MicrosoftDotNetPackageTestingVersion>
102102
<MicrosoftDotNetXliffTasksVersion>10.0.0-beta.25367.101</MicrosoftDotNetXliffTasksVersion>
103-
<!-- TODO: Remove pinned xunit.analyzers version: https://github.com/dotnet/runtime/issues/97088 -->
104-
<XUnitAnalyzersVersion>1.4.0</XUnitAnalyzersVersion>
105103
<!-- NuGet dependencies -->
106104
<NuGetBuildTasksPackVersion>6.0.0-preview.1.102</NuGetBuildTasksPackVersion>
107105
<!-- Installer dependencies -->

src/libraries/Common/tests/Extensions/TypeNameHelperTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public void Can_pretty_print_open_generics(Type type, bool fullName, string expe
176176
Assert.Equal(expected, TypeNameHelper.GetTypeDisplayName(type, fullName));
177177
}
178178

179-
public static TheoryData GetTypeDisplayName_IncludesGenericParameterNamesWhenOptionIsSetData =>
179+
public static TheoryData<Type, string> GetTypeDisplayName_IncludesGenericParameterNamesWhenOptionIsSetData =>
180180
new TheoryData<Type, string>
181181
{
182182
{ typeof(B<>),"Microsoft.Extensions.Internal.TypeNameHelperTest+B<T>" },
@@ -196,7 +196,7 @@ public void GetTypeDisplayName_IncludesGenericParameterNamesWhenOptionIsSet(Type
196196
Assert.Equal(expected, actual);
197197
}
198198

199-
public static TheoryData GetTypeDisplayName_WithoutFullName_IncludesGenericParameterNamesWhenOptionIsSetData =>
199+
public static TheoryData<Type, string> GetTypeDisplayName_WithoutFullName_IncludesGenericParameterNamesWhenOptionIsSetData =>
200200
new TheoryData<Type, string>
201201
{
202202
{ typeof(B<>),"B<T>" },

src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.Authentication.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public static IEnumerable<object[]> Authentication_TestData()
226226
[InlineData("NTLM")]
227227
[InlineData("Kerberos")]
228228
[InlineData("Negotiate")]
229-
public async Task PreAuthenticate_NoPreviousAuthenticatedRequests_NoCredentialsSent(string credCacheScheme)
229+
public async Task PreAuthenticate_NoPreviousAuthenticatedRequests_NoCredentialsSent(string? credCacheScheme)
230230
{
231231
const int NumRequests = 3;
232232
await LoopbackServer.CreateClientAndServerAsync(async uri =>
@@ -268,7 +268,7 @@ await LoopbackServer.CreateClientAndServerAsync(async uri =>
268268
[Theory]
269269
[InlineData(null, "WWW-Authenticate: Basic realm=\"hello\"\r\n")]
270270
[InlineData("Basic", "WWW-Authenticate: Basic realm=\"hello\"\r\n")]
271-
public async Task PreAuthenticate_FirstRequestNoHeaderAndAuthenticates_SecondRequestPreauthenticates(string credCacheScheme, string authResponse)
271+
public async Task PreAuthenticate_FirstRequestNoHeaderAndAuthenticates_SecondRequestPreauthenticates(string? credCacheScheme, string authResponse)
272272
{
273273
await LoopbackServer.CreateClientAndServerAsync(async uri =>
274274
{

src/libraries/Common/tests/System/Net/Http/HttpProtocolTests.cs

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -287,44 +287,33 @@ await TestHelper.WhenAllCompletedOrAnyFailed(
287287
}, new LoopbackServer.Options { StreamWrapper = GetStream });
288288
}
289289

290-
public static IEnumerable<string> GetInvalidStatusLine()
291-
{
292-
yield return "HTTP/1.1 2345";
293-
yield return "HTTP/A.1 200 OK";
294-
yield return "HTTP/X.Y.Z 200 OK";
295-
296-
yield return "HTTP/0.1 200 OK";
297-
yield return "HTTP/3.5 200 OK";
298-
yield return "HTTP/1.12 200 OK";
299-
yield return "HTTP/12.1 200 OK";
300-
yield return "HTTP/1.1 200 O\rK";
301-
302-
yield return "HTTP/1.A 200 OK";
303-
yield return "HTTP/1.1 ";
304-
yield return "HTTP/1.1 !11";
305-
yield return "HTTP/1.1 a11";
306-
yield return "HTTP/1.1 abc";
307-
yield return "HTTP/1.1\t\t";
308-
yield return "HTTP/1.1\t";
309-
yield return "HTTP/1.1 ";
310-
311-
yield return "HTTP/1.1 200OK";
312-
yield return "HTTP/1.1 20c";
313-
yield return "HTTP/1.1 23";
314-
yield return "HTTP/1.1 2bc";
315-
316-
yield return "NOTHTTP/1.1";
317-
yield return "HTTP 1.1 200 OK";
318-
yield return "ABCD/1.1 200 OK";
319-
yield return "HTTP/1.1";
320-
yield return "HTTP\\1.1 200 OK";
321-
yield return "NOTHTTP/1.1 200 OK";
322-
}
323-
324-
public static TheoryData InvalidStatusLine = GetInvalidStatusLine().ToTheoryData();
325-
326290
[Theory]
327-
[MemberData(nameof(InvalidStatusLine))]
291+
[InlineData("HTTP/1.1 2345")]
292+
[InlineData("HTTP/A.1 200 OK")]
293+
[InlineData("HTTP/X.Y.Z 200 OK")]
294+
[InlineData("HTTP/0.1 200 OK")]
295+
[InlineData("HTTP/3.5 200 OK")]
296+
[InlineData("HTTP/1.12 200 OK")]
297+
[InlineData("HTTP/12.1 200 OK")]
298+
[InlineData("HTTP/1.1 200 O\rK")]
299+
[InlineData("HTTP/1.A 200 OK")]
300+
[InlineData("HTTP/1.1 ")]
301+
[InlineData("HTTP/1.1 !11")]
302+
[InlineData("HTTP/1.1 a11")]
303+
[InlineData("HTTP/1.1 abc")]
304+
[InlineData("HTTP/1.1\t\t")]
305+
[InlineData("HTTP/1.1\t")]
306+
[InlineData("HTTP/1.1 ")]
307+
[InlineData("HTTP/1.1 200OK")]
308+
[InlineData("HTTP/1.1 20c")]
309+
[InlineData("HTTP/1.1 23")]
310+
[InlineData("HTTP/1.1 2bc")]
311+
[InlineData("NOTHTTP/1.1")]
312+
[InlineData("HTTP 1.1 200 OK")]
313+
[InlineData("ABCD/1.1 200 OK")]
314+
[InlineData("HTTP/1.1")]
315+
[InlineData("HTTP\\1.1 200 OK")]
316+
[InlineData("NOTHTTP/1.1 200 OK")]
328317
public async Task GetAsync_InvalidStatusLine_ThrowsException(string responseString)
329318
{
330319
await GetAsyncThrowsExceptionHelper(responseString);

src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ public async Task BrowserHttpHandler_StreamingRequest_ThrowFromContentCopy_Reque
497497
}
498498
}
499499

500-
public static TheoryData CancelRequestReadFunctions
500+
public static TheoryData<bool, int, bool> CancelRequestReadFunctions
501501
=> new TheoryData<bool, int, bool>
502502
{
503503
{ false, 0, false },

src/libraries/Common/tests/System/Security/Cryptography/PbeParametersTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static void EncryptionAlgorithm_NotVerified(int algId)
3131
[InlineData("Potato")]
3232
[InlineData("")]
3333
[InlineData(null)]
34-
public static void HashAlgorithm_NotVerified(string algId)
34+
public static void HashAlgorithm_NotVerified(string? algId)
3535
{
3636
HashAlgorithmName hashName = new HashAlgorithmName(algId);
3737

@@ -54,7 +54,7 @@ public static void HashAlgorithm_NotVerified_DefaultValue()
5454
[InlineData("SHA256")]
5555
[InlineData("Potato")]
5656
[InlineData(default)]
57-
public static void Pkcs12_NotVerifed_InCtor(string hashAlgName)
57+
public static void Pkcs12_NotVerifed_InCtor(string? hashAlgName)
5858
{
5959
HashAlgorithmName hashName = new HashAlgorithmName(hashAlgName);
6060

src/libraries/Common/tests/Tests/System/IO/PathInternal.Unix.Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class PathInternalTests_Unix
3333
InlineData(@"a\\", @"a\\"),
3434
]
3535
[PlatformSpecific(TestPlatforms.AnyUnix)]
36-
public void NormalizeDirectorySeparatorTests(string path, string expected)
36+
public void NormalizeDirectorySeparatorTests(string? path, string? expected)
3737
{
3838
string result = PathInternal.NormalizeDirectorySeparators(path);
3939
Assert.Equal(expected, result);

src/libraries/Common/tests/Tests/System/IO/PathInternal.Windows.Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void IsPartiallyQualifiedTest(string path, bool expected)
119119
InlineData(@" \\", @" \"),
120120
InlineData(@" //", @" \")
121121
]
122-
public void NormalizeDirectorySeparatorTests(string path, string expected)
122+
public void NormalizeDirectorySeparatorTests(string? path, string? expected)
123123
{
124124
string result = PathInternal.NormalizeDirectorySeparators(path);
125125
Assert.Equal(expected, result);

src/libraries/Common/tests/Tests/System/StringTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public static void Ctor_Char_Int_Negative_Count_ThrowsArgumentOutOfRangeExceptio
150150
[InlineData(new char[] { '\u041F', '\u0420', '\u0418', '\u0412', '\u0415', '\u0422' }, 0, 6, "\u041F\u0420\u0418\u0412\u0415\u0422")]
151151
[InlineData(new char[0], 0, 0, "")]
152152
[InlineData(null, 0, 0, "")]
153-
public static void Ctor_CharArray(char[] value, int startIndex, int length, string expected)
153+
public static void Ctor_CharArray(char[]? value, int startIndex, int length, string expected)
154154
{
155155
if (value == null)
156156
{
@@ -2556,7 +2556,7 @@ public static void GetHashCode_EmbeddedNull_ReturnsDifferentHashCodes()
25562556
[InlineData("", "", StringComparison.OrdinalIgnoreCase, true)]
25572557
[InlineData("123", 123, StringComparison.OrdinalIgnoreCase, false)] // Not a string
25582558
[InlineData("\0AAAAAAAAA", "\0BBBBBBBBBBBB", StringComparison.OrdinalIgnoreCase, false)]
2559-
public static void EqualsTest(string s1, object obj, StringComparison comparisonType, bool expected)
2559+
public static void EqualsTest(string? s1, object? obj, StringComparison comparisonType, bool expected)
25602560
{
25612561
string s2 = obj as string;
25622562
if (s1 != null)
@@ -2857,7 +2857,7 @@ public static IEnumerable<object[]> Format_Invalid_FormatExceptionFromArgs_Membe
28572857
[MemberData(nameof(Format_Invalid_FormatExceptionFromArgs_MemberData))]
28582858
[InlineData(null, "{10000000}", new object[] { null })]
28592859
[InlineData(null, "{0,10000000}", new string[] { null })]
2860-
public static void Format_Invalid_FormatExceptionFromFormatOrArgs(IFormatProvider provider, string format, object[] args)
2860+
public static void Format_Invalid_FormatExceptionFromFormatOrArgs(IFormatProvider? provider, string format, object[] args)
28612861
{
28622862
if (provider is null)
28632863
{
@@ -3805,7 +3805,7 @@ public static void Insert_Invalid()
38053805
[InlineData("", true)]
38063806
[InlineData("foo", false)]
38073807
[InlineData(" ", false)]
3808-
public static void IsNullOrEmpty(string value, bool expected)
3808+
public static void IsNullOrEmpty(string? value, bool expected)
38093809
{
38103810
Assert.Equal(expected, string.IsNullOrEmpty(value));
38113811

@@ -3970,7 +3970,7 @@ public static void MakeSureNoIsWhiteSpaceChecksGoOutOfRange()
39703970
[InlineData("$$", new string[] { "Foo", "Bar", "Baz" }, 0, 3, "Foo$$Bar$$Baz")]
39713971
[InlineData("$$", new string[] { "Foo", "Bar", "Baz" }, 3, 0, "")]
39723972
[InlineData("$$", new string[] { "Foo", "Bar", "Baz" }, 1, 1, "Bar")]
3973-
public static void Join_StringArray(string separator, string[] values, int startIndex, int count, string expected)
3973+
public static void Join_StringArray(string? separator, string[] values, int startIndex, int count, string expected)
39743974
{
39753975
if (startIndex + count == values.Length && count != 0)
39763976
{
@@ -4892,7 +4892,7 @@ public static void Replace_Char_Char_DoesntAllocateIfNothingIsReplaced(string s,
48924892
[InlineData("Aa1Bbb1Cccc1Ddddd1Eeeeee1Fffffff", "1", "23", "Aa23Bbb23Cccc23Ddddd23Eeeeee23Fffffff")]
48934893
[InlineData("11111111111111111111111", "1", "11", "1111111111111111111111111111111111111111111111")] // Checks if we handle the max # of matches
48944894
[InlineData("11111111111111111111111", "1", "", "")] // Checks if we handle the max # of matches
4895-
public static void Replace_String_String(string s, string oldValue, string newValue, string expected)
4895+
public static void Replace_String_String(string s, string oldValue, string? newValue, string expected)
48964896
{
48974897
Assert.Equal(expected, s.Replace(oldValue, newValue));
48984898
}
@@ -6149,7 +6149,7 @@ public static void ToLowerToUpperInvariant_ASCII()
61496149
[InlineData(" ", new char[] { ' ' }, "")]
61506150
[InlineData("aaaaa", new char[] { 'a' }, "")]
61516151
[InlineData("abaabaa", new char[] { 'b', 'a' }, "")]
6152-
public static void Trim(string s, char[] trimChars, string expected)
6152+
public static void Trim(string s, char[]? trimChars, string expected)
61536153
{
61546154
if (trimChars == null || trimChars.Length == 0 || (trimChars.Length == 1 && trimChars[0] == ' '))
61556155
{
@@ -6179,7 +6179,7 @@ public static void Trim(string s, char[] trimChars, string expected)
61796179
[InlineData(" ", new char[] { ' ' }, "")]
61806180
[InlineData("aaaaa", new char[] { 'a' }, "")]
61816181
[InlineData("abaabaa", new char[] { 'b', 'a' }, "")]
6182-
public static void TrimEnd(string s, char[] trimChars, string expected)
6182+
public static void TrimEnd(string s, char[]? trimChars, string expected)
61836183
{
61846184
if (trimChars == null || trimChars.Length == 0 || (trimChars.Length == 1 && trimChars[0] == ' '))
61856185
{
@@ -6209,7 +6209,7 @@ public static void TrimEnd(string s, char[] trimChars, string expected)
62096209
[InlineData(" ", new char[] { ' ' }, "")]
62106210
[InlineData("aaaaa", new char[] { 'a' }, "")]
62116211
[InlineData("abaabaa", new char[] { 'b', 'a' }, "")]
6212-
public static void TrimStart(string s, char[] trimChars, string expected)
6212+
public static void TrimStart(string s, char[]? trimChars, string expected)
62136213
{
62146214
if (trimChars == null || trimChars.Length == 0 || (trimChars.Length == 1 && trimChars[0] == ' '))
62156215
{
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Collections.Generic;
5+
46
namespace Xunit;
57

68
internal static class TheoryDataExtensions

0 commit comments

Comments
 (0)