diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/ClassDataAttributeMustPointAtValidClassTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/ClassDataAttributeMustPointAtValidClassTests.cs index 356d3b1a..ea38849a 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/ClassDataAttributeMustPointAtValidClassTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/ClassDataAttributeMustPointAtValidClassTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; @@ -13,7 +14,7 @@ public void TestMethod() { } }"; [Fact] - public async void SuccessCase() + public async Task SuccessCase() { var dataClassSource = @" using System.Collections; @@ -81,7 +82,7 @@ private DataClass() { } [Theory] [MemberData(nameof(FailureCases))] - public async void FailureCase(string dataClassSource) + public async Task FailureCase(string dataClassSource) { var expected = Verify diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/CollectionDefinitionClassesMustBePublicTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/CollectionDefinitionClassesMustBePublicTests.cs index 44827e68..0db73515 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/CollectionDefinitionClassesMustBePublicTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/CollectionDefinitionClassesMustBePublicTests.cs @@ -1,10 +1,11 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; public class CollectionDefinitionClassesMustBePublicTests { [Fact] - public async void ForPublicClass_DoesNotFindError() + public async Task ForPublicClass_DoesNotFindError() { var source = @" [Xunit.CollectionDefinition(""MyCollection"")] @@ -16,7 +17,7 @@ public class CollectionDefinitionClass { }"; [Theory] [InlineData("")] [InlineData("internal ")] - public async void ForFriendOrInternalClass_FindsError(string classAccessModifier) + public async Task ForFriendOrInternalClass_FindsError(string classAccessModifier) { var source = $@" [Xunit.CollectionDefinition(""MyCollection"")] @@ -32,7 +33,7 @@ public async void ForFriendOrInternalClass_FindsError(string classAccessModifier [Theory] [InlineData("")] [InlineData("public ")] - public async void ForPartialClassInSameFile_WhenClassIsPublic_DoesNotFindError(string otherPartAccessModifier) + public async Task ForPartialClassInSameFile_WhenClassIsPublic_DoesNotFindError(string otherPartAccessModifier) { var source = $@" [Xunit.CollectionDefinition(""MyCollection"")] @@ -46,7 +47,7 @@ public partial class CollectionDefinitionClass {{ }} [InlineData("", "")] [InlineData("", "internal ")] [InlineData("internal ", "internal ")] - public async void ForPartialClassInSameFile_WhenClassIsNonPublic_FindsError( + public async Task ForPartialClassInSameFile_WhenClassIsNonPublic_FindsError( string part1AccessModifier, string part2AccessModifier) { diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/ConstructorsOnFactAttributeSubclassShouldBePublicTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/ConstructorsOnFactAttributeSubclassShouldBePublicTests.cs index 4829d0b4..378a95c0 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/ConstructorsOnFactAttributeSubclassShouldBePublicTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/ConstructorsOnFactAttributeSubclassShouldBePublicTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class ConstructorsOnFactAttributeSubclassShouldBePublicTests { [Fact] - public async void DefaultConstructor_DoesNotTrigger() + public async Task DefaultConstructor_DoesNotTrigger() { var source = @" using System; @@ -26,7 +27,7 @@ public void TestFact() { } } [Fact] - public async void ParameterlessPublicConstructor_DoesNotTrigger() + public async Task ParameterlessPublicConstructor_DoesNotTrigger() { var source = @" using System; @@ -51,7 +52,7 @@ public void TestFact() { } } [Fact] - public async void PublicConstructorWithParameters_DoesNotTrigger() + public async Task PublicConstructorWithParameters_DoesNotTrigger() { var source = @" using System; @@ -76,7 +77,7 @@ public void TestFact() { } } [Fact] - public async void PublicConstructorWithOtherConstructors_DoesNotTrigger() + public async Task PublicConstructorWithOtherConstructors_DoesNotTrigger() { var source = @" using System; @@ -105,7 +106,7 @@ public void TestFact() { } } [Fact] - public async void InternalConstructor_Triggers() + public async Task InternalConstructor_Triggers() { var source = @" using System; @@ -134,7 +135,7 @@ public void TestFact() { } } [Fact] - public async void ProtectedInternalConstructor_Triggers() + public async Task ProtectedInternalConstructor_Triggers() { var source = @" using System; diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/DataAttributeShouldBeUsedOnATheoryTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/DataAttributeShouldBeUsedOnATheoryTests.cs index 9015714e..6d49dfbc 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/DataAttributeShouldBeUsedOnATheoryTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/DataAttributeShouldBeUsedOnATheoryTests.cs @@ -1,10 +1,11 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; public class DataAttributeShouldBeUsedOnATheoryTests { [Fact] - public async void DoesNotFindErrorForFactMethodWithNoDataAttributes() + public async Task DoesNotFindErrorForFactMethodWithNoDataAttributes() { var source = @" public class TestClass { @@ -19,7 +20,7 @@ public void TestMethod() { } [InlineData("InlineData")] [InlineData("MemberData(\"\")")] [InlineData("ClassData(typeof(string))")] - public async void DoesNotFindErrorForFactMethodWithDataAttributes(string dataAttribute) + public async Task DoesNotFindErrorForFactMethodWithDataAttributes(string dataAttribute) { var source = $@" public class TestClass {{ @@ -35,7 +36,7 @@ public void TestMethod() {{ }} [InlineData("InlineData")] [InlineData("MemberData(\"\")")] [InlineData("ClassData(typeof(string))")] - public async void DoesNotFindErrorForTheoryMethodWithDataAttributes(string dataAttribute) + public async Task DoesNotFindErrorForTheoryMethodWithDataAttributes(string dataAttribute) { var source = $@" public class TestClass {{ @@ -51,7 +52,7 @@ public void TestMethod() {{ }} [InlineData("InlineData")] [InlineData("MemberData(\"\")")] [InlineData("ClassData(typeof(string))")] - public async void FindsErrorForMethodsWithDataAttributesButNotFactOrTheory(string dataAttribute) + public async Task FindsErrorForMethodsWithDataAttributesButNotFactOrTheory(string dataAttribute) { var source = $@" public class TestClass {{ diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/DoNotUseBlockingTaskOperationsTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/DoNotUseBlockingTaskOperationsTests.cs index d51487c3..decb6b9d 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/DoNotUseBlockingTaskOperationsTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/DoNotUseBlockingTaskOperationsTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Xunit; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class DoNotUseBlockingTaskOperationsTests { [Fact] - public async void SuccessCase() + public async Task SuccessCase() { var source = @" using System.Threading.Tasks; @@ -24,7 +25,7 @@ public async Task TestMethod() { public class IValueTaskSource_NonGeneric { [Fact] - public async void FailureCase_GetResult() + public async Task FailureCase_GetResult() { var source = @" using System; @@ -49,7 +50,7 @@ void LocalFunction() { public class IValueTaskSource_Generic { [Fact] - public async void FailureCase_GetResult() + public async Task FailureCase_GetResult() { var source = @" using System; @@ -76,7 +77,7 @@ public class Task_NonGeneric public class Wait { [Fact] - public async void FailureCase() + public async Task FailureCase() { var source = @" using System; @@ -98,7 +99,7 @@ void LocalFunction() { } [Fact] - public async void FailureCase_BeforeWhenAll() + public async Task FailureCase_BeforeWhenAll() { var source = @" using System.Threading.Tasks; @@ -106,7 +107,7 @@ public async void FailureCase_BeforeWhenAll() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task = Task.Delay(1); task.[|Wait()|]; @@ -119,7 +120,7 @@ public async void TestMethod() { } [Fact] - public async void FailureCase_WhenAllForOtherTask() + public async Task FailureCase_WhenAllForOtherTask() { var source = @" using System.Threading.Tasks; @@ -127,7 +128,7 @@ public async void FailureCase_WhenAllForOtherTask() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task1 = Task.Delay(1); var task2 = Task.Delay(2); @@ -142,7 +143,7 @@ public async void TestMethod() { } [Fact] - public async void SuccessCase_InContinueWithLambda() + public async Task SuccessCase_InContinueWithLambda() { var source = @" using System.Threading.Tasks; @@ -159,7 +160,7 @@ public void TestMethod() { } [Fact] - public async void SuccessCase_AfterWhenAll() + public async Task SuccessCase_AfterWhenAll() { var source = @" using System.Threading.Tasks; @@ -167,7 +168,7 @@ public async void SuccessCase_AfterWhenAll() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task1 = Task.Delay(1); var task2 = Task.Delay(2); @@ -182,7 +183,7 @@ public async void TestMethod() { } [Fact] - public async void SuccessCase_AfterWhenAny() + public async Task SuccessCase_AfterWhenAny() { var source = @" using System.Threading.Tasks; @@ -190,7 +191,7 @@ public async void SuccessCase_AfterWhenAny() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task1 = Task.Delay(1); var task2 = Task.Delay(2); @@ -209,7 +210,7 @@ public class WaitAny_WaitAll [Theory] [InlineData("WaitAny")] [InlineData("WaitAll")] - public async void FailureCase(string waitMethod) + public async Task FailureCase(string waitMethod) { var source = @$" using System; @@ -233,7 +234,7 @@ void LocalFunction() {{ [Theory] [InlineData("WaitAny")] [InlineData("WaitAll")] - public async void FailureCase_BeforeWhenAll(string waitMethod) + public async Task FailureCase_BeforeWhenAll(string waitMethod) { var source = @$" using System.Threading.Tasks; @@ -241,7 +242,7 @@ public async void FailureCase_BeforeWhenAll(string waitMethod) public class TestClass {{ [Fact] - public async void TestMethod() {{ + public async Task TestMethod() {{ var task = Task.Delay(1); Task.[|{waitMethod}(task)|]; @@ -256,7 +257,7 @@ public async void TestMethod() {{ [Theory] [InlineData("WaitAny")] [InlineData("WaitAll")] - public async void FailureCase_WhenAllForOtherTask(string waitMethod) + public async Task FailureCase_WhenAllForOtherTask(string waitMethod) { var source = @$" using System.Threading.Tasks; @@ -264,7 +265,7 @@ public async void FailureCase_WhenAllForOtherTask(string waitMethod) public class TestClass {{ [Fact] - public async void TestMethod() {{ + public async Task TestMethod() {{ var task1 = Task.Delay(1); var task2 = Task.Delay(2); @@ -282,7 +283,7 @@ public async void TestMethod() {{ [Theory] [InlineData("WaitAny")] [InlineData("WaitAll")] - public async void SuccessCase_InContinueWithLambda(string waitMethod) + public async Task SuccessCase_InContinueWithLambda(string waitMethod) { var source = @$" using System.Threading.Tasks; @@ -301,7 +302,7 @@ public void TestMethod() {{ [Theory] [InlineData("WaitAny")] [InlineData("WaitAll")] - public async void SuccessCase_AfterWhenAll(string waitMethod) + public async Task SuccessCase_AfterWhenAll(string waitMethod) { var source = @$" using System.Threading.Tasks; @@ -309,7 +310,7 @@ public async void SuccessCase_AfterWhenAll(string waitMethod) public class TestClass {{ [Fact] - public async void TestMethod() {{ + public async Task TestMethod() {{ var task1 = Task.Delay(1); var task2 = Task.Delay(2); @@ -327,7 +328,7 @@ public async void TestMethod() {{ [Theory] [InlineData("WaitAny")] [InlineData("WaitAll")] - public async void SuccessCase_AfterWhenAny(string waitMethod) + public async Task SuccessCase_AfterWhenAny(string waitMethod) { var source = @$" using System.Threading.Tasks; @@ -335,7 +336,7 @@ public async void SuccessCase_AfterWhenAny(string waitMethod) public class TestClass {{ [Fact] - public async void TestMethod() {{ + public async Task TestMethod() {{ var task1 = Task.Delay(1); var task2 = Task.Delay(2); @@ -352,7 +353,7 @@ public async void TestMethod() {{ public class GetAwaiterGetResult { [Fact] - public async void FailureCase() + public async Task FailureCase() { var source = @" using System; @@ -374,7 +375,7 @@ void LocalFunction() { } [Fact] - public async void FailureCase_BeforeWhenAll() + public async Task FailureCase_BeforeWhenAll() { var source = @" using System.Threading.Tasks; @@ -382,7 +383,7 @@ public async void FailureCase_BeforeWhenAll() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task = Task.Delay(1); task.GetAwaiter().[|GetResult()|]; @@ -395,7 +396,7 @@ public async void TestMethod() { } [Fact] - public async void FailureCase_WhenAllForOtherTask() + public async Task FailureCase_WhenAllForOtherTask() { var source = @" using System.Threading.Tasks; @@ -403,7 +404,7 @@ public async void FailureCase_WhenAllForOtherTask() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task1 = Task.Delay(1); var task2 = Task.Delay(2); @@ -418,7 +419,7 @@ public async void TestMethod() { } [Fact] - public async void SuccessCase_InContinueWithLambda() + public async Task SuccessCase_InContinueWithLambda() { var source = @" using System.Threading.Tasks; @@ -435,7 +436,7 @@ public void TestMethod() { } [Fact] - public async void SuccessCase_AfterWhenAll() + public async Task SuccessCase_AfterWhenAll() { var source = @" using System.Threading.Tasks; @@ -443,7 +444,7 @@ public async void SuccessCase_AfterWhenAll() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task1 = Task.Delay(1); var task2 = Task.Delay(2); @@ -458,7 +459,7 @@ public async void TestMethod() { } [Fact] - public async void SuccessCase_AfterWhenAny() + public async Task SuccessCase_AfterWhenAny() { var source = @" using System.Threading.Tasks; @@ -466,7 +467,7 @@ public async void SuccessCase_AfterWhenAny() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task1 = Task.Delay(1); var task2 = Task.Delay(2); @@ -486,7 +487,7 @@ public class Task_Generic public class Result { [Fact] - public async void FailureCase() + public async Task FailureCase() { var source = @" using System; @@ -508,7 +509,7 @@ void LocalFunction() { } [Fact] - public async void FailureCase_BeforeWhenAll() + public async Task FailureCase_BeforeWhenAll() { var source = @" using System.Threading.Tasks; @@ -516,7 +517,7 @@ public async void FailureCase_BeforeWhenAll() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task = Task.FromResult(42); Assert.Equal(42, task.[|Result|]); @@ -529,7 +530,7 @@ public async void TestMethod() { } [Fact] - public async void FailureCase_WhenAllForOtherTask() + public async Task FailureCase_WhenAllForOtherTask() { var source = @" using System.Threading.Tasks; @@ -537,7 +538,7 @@ public async void FailureCase_WhenAllForOtherTask() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task1 = Task.FromResult(42); var task2 = Task.FromResult(2112); @@ -553,7 +554,7 @@ public async void TestMethod() { } [Fact] - public async void SuccessCase_InContinueWithLambda() + public async Task SuccessCase_InContinueWithLambda() { var source = @" using System.Threading.Tasks; @@ -570,7 +571,7 @@ public void TestMethod() { } [Fact] - public async void SuccessCase_AfterWhenAll() + public async Task SuccessCase_AfterWhenAll() { var source = @" using System.Threading.Tasks; @@ -578,7 +579,7 @@ public async void SuccessCase_AfterWhenAll() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task1 = Task.FromResult(42); var task2 = Task.FromResult(2112); @@ -594,7 +595,7 @@ public async void TestMethod() { } [Fact] - public async void SuccessCase_AfterWhenAny() + public async Task SuccessCase_AfterWhenAny() { var source = @" using System.Threading.Tasks; @@ -602,7 +603,7 @@ public async void SuccessCase_AfterWhenAny() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task1 = Task.FromResult(42); var task2 = Task.FromResult(2112); @@ -619,7 +620,7 @@ public async void TestMethod() { public class GetAwaiterGetResult { [Fact] - public async void FailureCase() + public async Task FailureCase() { var source = @" using System; @@ -641,7 +642,7 @@ void LocalFunction() { } [Fact] - public async void FailureCase_BeforeWhenAll() + public async Task FailureCase_BeforeWhenAll() { var source = @" using System.Threading.Tasks; @@ -649,7 +650,7 @@ public async void FailureCase_BeforeWhenAll() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task = Task.FromResult(42); Assert.Equal(42, task.GetAwaiter().[|GetResult()|]); @@ -662,7 +663,7 @@ public async void TestMethod() { } [Fact] - public async void FailureCase_WhenAllForOtherTask() + public async Task FailureCase_WhenAllForOtherTask() { var source = @" using System.Threading.Tasks; @@ -670,7 +671,7 @@ public async void FailureCase_WhenAllForOtherTask() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task1 = Task.FromResult(42); var task2 = Task.FromResult(2112); @@ -686,7 +687,7 @@ public async void TestMethod() { } [Fact] - public async void SuccessCase_InContinueWithLambda() + public async Task SuccessCase_InContinueWithLambda() { var source = @" using System.Threading.Tasks; @@ -703,7 +704,7 @@ public void TestMethod() { } [Fact] - public async void SuccessCase_AfterWhenAll() + public async Task SuccessCase_AfterWhenAll() { var source = @" using System.Threading.Tasks; @@ -711,7 +712,7 @@ public async void SuccessCase_AfterWhenAll() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task1 = Task.FromResult(42); var task2 = Task.FromResult(2112); @@ -727,7 +728,7 @@ public async void TestMethod() { } [Fact] - public async void SuccessCase_AfterWhenAny() + public async Task SuccessCase_AfterWhenAny() { var source = @" using System.Threading.Tasks; @@ -735,7 +736,7 @@ public async void SuccessCase_AfterWhenAny() public class TestClass { [Fact] - public async void TestMethod() { + public async Task TestMethod() { var task1 = Task.FromResult(42); var task2 = Task.FromResult(2112); @@ -753,7 +754,7 @@ public async void TestMethod() { public class ValueTask_NonGeneric { [Fact] - public async void FailureCase_GetAwaiterGetResult() + public async Task FailureCase_GetAwaiterGetResult() { var source = @" using System; @@ -778,7 +779,7 @@ void LocalFunction() { public class ValueTask_Generic { [Fact] - public async void FailureCase_Result() + public async Task FailureCase_Result() { var source = @" using System; @@ -800,7 +801,7 @@ void LocalFunction() { } [Fact] - public async void FailureCase_GetAwaiterGetResult() + public async Task FailureCase_GetAwaiterGetResult() { var source = @" using System; diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/DoNotUseConfigureAwaitTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/DoNotUseConfigureAwaitTests.cs index bf10732a..f2323167 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/DoNotUseConfigureAwaitTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/DoNotUseConfigureAwaitTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Xunit; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class DoNotUseConfigureAwaitTests { [Fact] - public async void NoCall_DoesNotTrigger() + public async Task NoCall_DoesNotTrigger() { var source = @" using System.Threading.Tasks; @@ -24,7 +25,7 @@ public async Task TestMethod() { public class ConfigureAwait_Boolean { [Fact] - public async void NonTestMethod_DoesNotTrigger() + public async Task NonTestMethod_DoesNotTrigger() { var source = @" using System.Threading.Tasks; @@ -40,7 +41,7 @@ public async Task NonTestMethod() { } [Fact] - public async void True_DoesNotTrigger() + public async Task True_DoesNotTrigger() { var source = @" using System.Threading.Tasks; @@ -66,7 +67,7 @@ public async Task TestMethod() { [Theory] [MemberData(nameof(InvalidValues))] - public async void InvalidValue_InsideLambda_DoesNotTrigger(string argumentValue) + public async Task InvalidValue_InsideLambda_DoesNotTrigger(string argumentValue) { var source = @$" using System.Threading.Tasks; @@ -88,7 +89,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(InvalidValues))] - public async void InvalidValue_InsideLocalFunction_DoesNotTrigger(string argumentValue) + public async Task InvalidValue_InsideLocalFunction_DoesNotTrigger(string argumentValue) { var source = @$" using System.Threading.Tasks; @@ -109,7 +110,7 @@ async Task AssertEventStateAsync() {{ [Theory] [MemberData(nameof(InvalidValues))] - public async void InvalidValue_TaskWithAwait_Triggers(string argumentValue) + public async Task InvalidValue_TaskWithAwait_Triggers(string argumentValue) { var source = @$" using System.Threading.Tasks; @@ -133,7 +134,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(InvalidValues))] - public async void InvalidValue_TaskWithoutAwait_Triggers(string argumentValue) + public async Task InvalidValue_TaskWithoutAwait_Triggers(string argumentValue) { var source = @$" using System.Threading.Tasks; @@ -157,7 +158,7 @@ public void TestMethod() {{ [Theory] [MemberData(nameof(InvalidValues))] - public async void InvalidValue_TaskOfT_Triggers(string argumentValue) + public async Task InvalidValue_TaskOfT_Triggers(string argumentValue) { var source = @$" using System.Threading.Tasks; @@ -182,7 +183,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(InvalidValues))] - public async void InvalidValue_ValueTask_Triggers(string argumentValue) + public async Task InvalidValue_ValueTask_Triggers(string argumentValue) { var source = @$" using System.Threading.Tasks; @@ -207,7 +208,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(InvalidValues))] - public async void InvalidValue_ValueTaskOfT_Triggers(string argumentValue) + public async Task InvalidValue_ValueTaskOfT_Triggers(string argumentValue) { var source = @$" using System.Threading.Tasks; @@ -236,7 +237,7 @@ public async Task TestMethod() {{ public class ConfigureAwait_ConfigureAwaitOptions { [Fact] - public async void NonTestMethod_DoesNotTrigger() + public async Task NonTestMethod_DoesNotTrigger() { var source = @" using System.Threading.Tasks; @@ -255,7 +256,7 @@ public async Task NonTestMethod() { [InlineData("ConfigureAwaitOptions.ContinueOnCapturedContext")] [InlineData("ConfigureAwaitOptions.SuppressThrowing | ConfigureAwaitOptions.ContinueOnCapturedContext")] [InlineData("ConfigureAwaitOptions.ForceYielding | ConfigureAwaitOptions.SuppressThrowing | ConfigureAwaitOptions.ContinueOnCapturedContext")] - public async void ValidValue_DoesNotTrigger(string enumValue) + public async Task ValidValue_DoesNotTrigger(string enumValue) { var source = $@" using System.Threading.Tasks; @@ -283,7 +284,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(InvalidValues))] - public async void InvalidValue_InsideLambda_DoesNotTrigger(string argumentValue) + public async Task InvalidValue_InsideLambda_DoesNotTrigger(string argumentValue) { var source = @$" using System.Threading.Tasks; @@ -305,7 +306,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(InvalidValues))] - public async void InvalidValue_InsideLocalFunction_DoesNotTrigger(string argumentValue) + public async Task InvalidValue_InsideLocalFunction_DoesNotTrigger(string argumentValue) { var source = @$" using System.Threading.Tasks; @@ -326,7 +327,7 @@ async Task AssertEventStateAsync() {{ [Theory] [MemberData(nameof(InvalidValues))] - public async void InvalidValue_TaskWithAwait_Triggers(string enumValue) + public async Task InvalidValue_TaskWithAwait_Triggers(string enumValue) { var source = $@" using System.Threading.Tasks; @@ -350,7 +351,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(InvalidValues))] - public async void InvalidValue_TaskWithoutAwait_Triggers(string argumentValue) + public async Task InvalidValue_TaskWithoutAwait_Triggers(string argumentValue) { var source = @$" using System.Threading.Tasks; @@ -374,7 +375,7 @@ public void TestMethod() {{ [Theory] [MemberData(nameof(InvalidValues))] - public async void InvalidValue_TaskOfT_Triggers(string argumentValue) + public async Task InvalidValue_TaskOfT_Triggers(string argumentValue) { var source = @$" using System.Threading.Tasks; diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/EnsureFixturesHaveASourceTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/EnsureFixturesHaveASourceTests.cs index e037031a..8a226ec9 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/EnsureFixturesHaveASourceTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/EnsureFixturesHaveASourceTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; @@ -6,7 +7,7 @@ public class EnsureFixturesHaveASourceTests public class NonTestClass { [Fact] - public async void DoesNotTrigger() + public async Task DoesNotTrigger() { var source = @" public class NonTestClass { @@ -22,7 +23,7 @@ public class SupportedNonFixtureData [Theory] [InlineData("")] [InlineData("[Collection(\"TestCollection\")]")] - public async void V2SupportedTypes(string attribute) + public async Task V2SupportedTypes(string attribute) { var source = $@" using Xunit; @@ -40,7 +41,7 @@ [Fact] public void TestMethod() {{ }} [Theory] [InlineData("")] [InlineData("[Collection(\"TestCollection\")]")] - public async void V3SupportedTypes(string attribute) + public async Task V3SupportedTypes(string attribute) { // TODO: This will need to be updated when v3 names are finalized var source = $@" @@ -57,7 +58,7 @@ [Fact] public void TestMethod() {{ }} } [Fact] - public async void OptionalParameter_DoesNotTrigger() + public async Task OptionalParameter_DoesNotTrigger() { var source = @" using Xunit; @@ -91,7 +92,7 @@ public class ClassFixtures [InlineData( "[Collection(\"TestCollection\")]", "", "", ", IClassFixture")] - public async void SupportsDerivation( + public async Task SupportsDerivation( string baseAttribute, string baseInterface, string derivedAttribute, @@ -115,7 +116,7 @@ [Fact] public void TestMethod() {{ }} } [Fact] - public async void ClassFixtureOnCollectionDefinition_DoesNotTrigger() + public async Task ClassFixtureOnCollectionDefinition_DoesNotTrigger() { var source = @" using Xunit; @@ -134,7 +135,7 @@ [Fact] public void TestMethod() { } } [Fact] - public async void MissingClassFixtureDefinition_Triggers() + public async Task MissingClassFixtureDefinition_Triggers() { var source = @" using Xunit; @@ -159,7 +160,7 @@ public class CollectionFixtures [Theory] [InlineData("")] [InlineData("[CollectionDefinition(nameof(TestCollection))]")] - public async void NoFixture_DoesNotTrigger(string definitionAttribute) + public async Task NoFixture_DoesNotTrigger(string definitionAttribute) { var source = $@" using Xunit; @@ -176,7 +177,7 @@ [Fact] public void TestMethod() {{ }} } [Fact] - public async void WithInheritedFixture_DoesNotTrigger() + public async Task WithInheritedFixture_DoesNotTrigger() { var source = @" using Xunit; @@ -202,7 +203,7 @@ public void TestMethod() { } } [Fact] - public async void WithGenericFixture_TriggersWithV2_DoesNotTriggerWithV3() + public async Task WithGenericFixture_TriggersWithV2_DoesNotTriggerWithV3() { var source = @" using Xunit; @@ -231,7 +232,7 @@ public void TestMethod() { } } [Fact] - public async void WithInheritedGenericFixture_TriggersWithV2_DoesNotTriggerWithV3() + public async Task WithInheritedGenericFixture_TriggersWithV2_DoesNotTriggerWithV3() { var source = @" using Xunit; @@ -266,7 +267,7 @@ public void TestMethod() { } [Theory] [InlineData("[Collection(nameof(TestCollection))]", "")] [InlineData("", "[Collection(nameof(TestCollection))]")] - public async void WithFixture_SupportsDerivation( + public async Task WithFixture_SupportsDerivation( string baseAttribute, string derivedAttribute) { @@ -289,7 +290,7 @@ public TestClass(object _) {{ }} } [Fact] - public async void WithFixture_WithDefinition_DoesNotTrigger() + public async Task WithFixture_WithDefinition_DoesNotTrigger() { var source = @" using Xunit; @@ -310,7 +311,7 @@ [Fact] public void TestMethod() { } [Theory] [InlineData("")] [InlineData("[CollectionDefinition(nameof(TestCollection))]")] - public async void WithFixture_WithoutCollectionFixtureInterface_Triggers(string definitionAttribute) + public async Task WithFixture_WithoutCollectionFixtureInterface_Triggers(string definitionAttribute) { var source = @$" using Xunit; @@ -337,7 +338,7 @@ [Fact] public void TestMethod() {{ }} public class AssemblyFixtures { [Fact] - public async void WithAssemblyFixture_DoesNotTrigger() + public async Task WithAssemblyFixture_DoesNotTrigger() { var source = @" using Xunit; @@ -359,7 +360,7 @@ public class MixedFixtures [Theory] [InlineData("")] [InlineData("[CollectionDefinition(nameof(TestCollection))]")] - public async void WithClassFixture_WithCollection_DoesNotTrigger(string definitionAttribute) + public async Task WithClassFixture_WithCollection_DoesNotTrigger(string definitionAttribute) { var source = $@" using Xunit; @@ -378,7 +379,7 @@ [Fact] public void TestMethod() {{ }} } [Fact] - public async void WithMixedClassAndCollectionFixture_AndSupportedNonFixture_DoesNotTrigger() + public async Task WithMixedClassAndCollectionFixture_AndSupportedNonFixture_DoesNotTrigger() { var source = @" using Xunit; @@ -401,7 +402,7 @@ [Fact] public void TestMethod() {{ }} } [Fact] - public async void MissingClassFixture_Triggers() + public async Task MissingClassFixture_Triggers() { var source = @" using Xunit; @@ -428,7 +429,7 @@ [Fact] public void TestMethod() { } } [Fact] - public async void MissingCollectionFixture_Triggers() + public async Task MissingCollectionFixture_Triggers() { var source = @" using Xunit; diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/FactMethodMustNotHaveParametersTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/FactMethodMustNotHaveParametersTests.cs index e228433b..15c5d65f 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/FactMethodMustNotHaveParametersTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/FactMethodMustNotHaveParametersTests.cs @@ -1,10 +1,11 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; public class FactMethodMustNotHaveParametersTests { [Fact] - public async void DoesNotFindErrorForFactWithNoParameters() + public async Task DoesNotFindErrorForFactWithNoParameters() { var source = @" public class TestClass { @@ -16,7 +17,7 @@ public void TestMethod() { } } [Fact] - public async void DoesNotFindErrorForTheoryWithParameters() + public async Task DoesNotFindErrorForTheoryWithParameters() { var source = @" public class TestClass { @@ -28,7 +29,7 @@ public void TestMethod(string p) { } } [Fact] - public async void FindsErrorForFactWithParameter() + public async Task FindsErrorForFactWithParameter() { var source = @" public class TestClass { diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/FactMethodShouldNotHaveTestDataTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/FactMethodShouldNotHaveTestDataTests.cs index 71845ad9..c87d3cb1 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/FactMethodShouldNotHaveTestDataTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/FactMethodShouldNotHaveTestDataTests.cs @@ -1,10 +1,11 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; public class FactMethodShouldNotHaveTestDataTests { [Fact] - public async void DoesNotFindErrorForFactMethodWithNoDataAttributes() + public async Task DoesNotFindErrorForFactMethodWithNoDataAttributes() { var source = @" public class TestClass { @@ -19,7 +20,7 @@ public void TestMethod() { } [InlineData("InlineData")] [InlineData("MemberData(\"\")")] [InlineData("ClassData(typeof(string))")] - public async void DoesNotFindErrorForTheoryMethodWithDataAttributes(string dataAttribute) + public async Task DoesNotFindErrorForTheoryMethodWithDataAttributes(string dataAttribute) { var source = $@" public class TestClass {{ @@ -35,7 +36,7 @@ public void TestMethod() {{ }} [InlineData("InlineData")] [InlineData("MemberData(\"\")")] [InlineData("ClassData(typeof(string))")] - public async void DoesNotFindErrorForDerivedFactMethodWithDataAttributes(string dataAttribute) + public async Task DoesNotFindErrorForDerivedFactMethodWithDataAttributes(string dataAttribute) { var source1 = "public class DerivedFactAttribute: Xunit.FactAttribute {}"; var source2 = $@" @@ -52,7 +53,7 @@ public void TestMethod() {{ }} [InlineData("InlineData")] [InlineData("MemberData(\"\")")] [InlineData("ClassData(typeof(string))")] - public async void FindsErrorForFactMethodsWithDataAttributes(string dataAttribute) + public async Task FindsErrorForFactMethodsWithDataAttributes(string dataAttribute) { var source = $@" public class TestClass {{ diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/InlineDataMustMatchTheoryParametersTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/InlineDataMustMatchTheoryParametersTests.cs index f7161327..52d2f803 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/InlineDataMustMatchTheoryParametersTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/InlineDataMustMatchTheoryParametersTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; @@ -14,7 +15,7 @@ public class InlineDataMustMatchTheoryParametersTests public class NonErrors { [Fact] - public async void MethodUsingParamsArgument() + public async Task MethodUsingParamsArgument() { var source = @" public class TestClass { @@ -27,7 +28,7 @@ public void TestMethod(params string[] args) { } } [Fact] - public async void MethodUsingNormalAndParamsArgument() + public async Task MethodUsingNormalAndParamsArgument() { var source = @" public class TestClass { @@ -40,7 +41,7 @@ public void TestMethod(string first, params string[] args) { } } [Fact] - public async void MethodUsingNormalAndUnusedParamsArgument() + public async Task MethodUsingNormalAndUnusedParamsArgument() { var source = @" public class TestClass { @@ -53,7 +54,7 @@ public void TestMethod(string first, params string[] args) { } } [Fact] - public async void MethodUsingEmptyArrayForParams() + public async Task MethodUsingEmptyArrayForParams() { var source = @" public class TestClass { @@ -66,7 +67,7 @@ public void VariableArgumentsTest(params int[] sq) { } } [Fact] - public async void MethodUsingMixedArgumentsAndEmptyArrayForParams() + public async Task MethodUsingMixedArgumentsAndEmptyArrayForParams() { var source = @" public class TestClass { @@ -79,7 +80,7 @@ public void VariableArgumentsTest(double d, params int[] sq) { } } [Fact] - public async void MethodUsingNonEmptyArrayForParams() + public async Task MethodUsingNonEmptyArrayForParams() { var source = @" public class TestClass { @@ -92,7 +93,7 @@ public void VariableArgumentsTest(params int[] sq) { } } [Fact] - public async void MethodUsingMixedArgumentsAndNonEmptyArrayForParams() + public async Task MethodUsingMixedArgumentsAndNonEmptyArrayForParams() { var source = @" public class TestClass { @@ -105,7 +106,7 @@ public void VariableArgumentsTest(double d, params int[] sq) { } } [Fact] - public async void MethodUsingIncompatibleExplicitArrayForParams() + public async Task MethodUsingIncompatibleExplicitArrayForParams() { var source = @" public class TestClass { @@ -118,7 +119,7 @@ public void VariableArgumentsTest(double d, params int[] sq) { } } [Fact] - public async void UsingParameters() + public async Task UsingParameters() { var source = @" public class TestClass { @@ -131,7 +132,7 @@ public void TestMethod(string a, int b, object c) { } } [Fact] - public async void UsingParametersWithDefaultValues() + public async Task UsingParametersWithDefaultValues() { var source = @" public class TestClass { @@ -144,7 +145,7 @@ public void TestMethod(string a, string b = ""default"", string c = null) { } } [Fact] - public async void UsingParametersWithDefaultValuesAndParamsArgument() + public async Task UsingParametersWithDefaultValuesAndParamsArgument() { var source = @" public class TestClass { @@ -157,7 +158,7 @@ public void TestMethod(string a, string b = ""default"", string c = null, params } [Fact] - public async void UsingParameterWithOptionalAttribute() + public async Task UsingParameterWithOptionalAttribute() { var source = @" public class TestClass { @@ -170,7 +171,7 @@ public void TestMethod(string a, [System.Runtime.InteropServices.Optional] strin } [Fact] - public async void UsingMultipleParametersWithOptionalAttributes() + public async Task UsingMultipleParametersWithOptionalAttributes() { var source = @" public class TestClass { @@ -186,7 +187,7 @@ public void TestMethod([System.Runtime.InteropServices.Optional] string a, } [Fact] - public async void UsingExplicitArray() + public async Task UsingExplicitArray() { var source = @" public class TestClass { @@ -199,7 +200,7 @@ public void TestMethod(string a, int b, object c) { } } [Fact] - public async void UsingExplicitNamedArray() + public async Task UsingExplicitNamedArray() { var source = @" public class TestClass { @@ -212,7 +213,7 @@ public void TestMethod(string a, int b, object c) { } } [Fact] - public async void UsingImplicitArray() + public async Task UsingImplicitArray() { var source = @" public class TestClass { @@ -225,7 +226,7 @@ public void TestMethod(string a, int b, object c) { } } [Fact] - public async void UsingImplicitNamedArray() + public async Task UsingImplicitNamedArray() { var source = @" public class TestClass { @@ -238,7 +239,7 @@ public void TestMethod(string a, int b, object c) { } } [Fact] - public async void EmptyArray() + public async Task EmptyArray() { var source = @" public class TestClass { @@ -254,7 +255,7 @@ public void TestMethod(byte[] input) { } public class X1009_TooFewValues { [Fact] - public async void IgnoresFact() + public async Task IgnoresFact() { var source = @" public class TestClass { @@ -269,7 +270,7 @@ public void TestMethod(string a) { } [Theory] [InlineData("Xunit.InlineData()")] [InlineData("Xunit.InlineData")] - public async void NoArguments(string attribute) + public async Task NoArguments(string attribute) { var source = $@" public class TestClass {{ @@ -287,7 +288,7 @@ public void TestMethod(int a) {{ }} } [Fact] - public async void TooFewArguments() + public async Task TooFewArguments() { var source = @" public class TestClass { @@ -305,7 +306,7 @@ public void TestMethod(int a, int b, string c) { } } [Fact] - public async void TooFewArguments_WithParams() + public async Task TooFewArguments_WithParams() { var source = @" public class TestClass { @@ -354,7 +355,7 @@ from type in NumericTypes [Theory] [MemberData(nameof(NumericValuesAndNumericTypes))] - public async void CompatibleNumericValue_NonNullableType( + public async Task CompatibleNumericValue_NonNullableType( string value, string type) { @@ -370,7 +371,7 @@ public void TestMethod({type} a) {{ }} [Theory] [MemberData(nameof(NumericValuesAndNumericTypes))] - public async void CompatibleNumericValue_NullableType( + public async Task CompatibleNumericValue_NullableType( string value, string type) { @@ -386,7 +387,7 @@ public void TestMethod({type}? a) {{ }} [Theory] [MemberData(nameof(BoolValuesAndNumericTypes))] - public async void BooleanValue_NumericType( + public async Task BooleanValue_NumericType( string value, string type) { @@ -407,7 +408,7 @@ public void TestMethod({type} a) {{ }} [Theory] [MemberData(nameof(NumericTypes))] - public async void CharValue_NumericType(string type) + public async Task CharValue_NumericType(string type) { var source = $@" public class TestClass {{ @@ -421,7 +422,7 @@ public void TestMethod({type} a) {{ }} [Theory] [MemberData(nameof(NumericTypes))] - public async void EnumValue_NumericType(string type) + public async Task EnumValue_NumericType(string type) { var source = $@" public class TestClass {{ @@ -443,7 +444,7 @@ public class BooleanParameter : X1010_IncompatibleValueType { [Theory] [MemberData(nameof(BoolValues))] - public async void FromBooleanValue_ToNonNullable(string value) + public async Task FromBooleanValue_ToNonNullable(string value) { var source = $@" public class TestClass {{ @@ -457,7 +458,7 @@ public void TestMethod(bool a) {{ }} [Theory] [MemberData(nameof(BoolValues))] - public async void FromBooleanValue_ToNullable(string value) + public async Task FromBooleanValue_ToNullable(string value) { var source = $@" public class TestClass {{ @@ -475,7 +476,7 @@ public void TestMethod(bool? a) {{ }} [InlineData("'a'")] [InlineData("\"abc\"")] [InlineData("typeof(string)")] - public async void FromIncompatibleValue(string value) + public async Task FromIncompatibleValue(string value) { var source = $@" public class TestClass {{ @@ -498,7 +499,7 @@ public class CharParameter : X1010_IncompatibleValueType [Theory] [InlineData("'a'")] [MemberData(nameof(IntegerValues))] - public async void FromCharOrIntegerValue_ToNonNullable(string value) + public async Task FromCharOrIntegerValue_ToNonNullable(string value) { var source = $@" public class TestClass {{ @@ -513,7 +514,7 @@ public void TestMethod(char a) {{ }} [Theory] [InlineData("'a'")] [MemberData(nameof(IntegerValues))] - public async void FromCharOrIntegerValue_ToNullable(string value) + public async Task FromCharOrIntegerValue_ToNullable(string value) { var source = $@" public class TestClass {{ @@ -531,7 +532,7 @@ public void TestMethod(char? a) {{ }} [InlineData("\"abc\"")] [InlineData("System.StringComparison.Ordinal")] [InlineData("typeof(string)")] - public async void FromIncompatibleValue(string value) + public async Task FromIncompatibleValue(string value) { var source = $@" public class TestClass {{ @@ -552,7 +553,7 @@ public void TestMethod(char a) {{ }} public class EnumParameter : X1010_IncompatibleValueType { [Fact] - public async void FromEnumValue_ToNonNullable() + public async Task FromEnumValue_ToNonNullable() { var source = @" public class TestClass { @@ -565,7 +566,7 @@ public void TestMethod(System.StringComparison a) { } } [Fact] - public async void FromEnumValue_ToNullable() + public async Task FromEnumValue_ToNullable() { var source = @" public class TestClass { @@ -583,7 +584,7 @@ public void TestMethod(System.StringComparison? a) { } [InlineData("'a'")] [InlineData("\"abc\"")] [InlineData("typeof(string)")] - public async void FromIncompatibleValue(string value) + public async Task FromIncompatibleValue(string value) { var source = $@" public class TestClass {{ @@ -606,7 +607,7 @@ public class TypeParameter : X1010_IncompatibleValueType [Theory] [InlineData("typeof(string)")] [InlineData("null")] - public async void FromTypeValue(string value) + public async Task FromTypeValue(string value) { var source = $@" public class TestClass {{ @@ -621,7 +622,7 @@ public void TestMethod(System.Type a) {{ }} [Theory] [InlineData("typeof(string)")] [InlineData("null")] - public async void FromTypeValue_ToParams(string value) + public async Task FromTypeValue_ToParams(string value) { var source = $@" public class TestClass {{ @@ -639,7 +640,7 @@ public void TestMethod(params System.Type[] a) {{ }} [InlineData("'a'")] [InlineData("\"abc\"")] [InlineData("System.StringComparison.Ordinal")] - public async void FromIncompatibleValue(string value) + public async Task FromIncompatibleValue(string value) { var source = $@" public class TestClass {{ @@ -663,7 +664,7 @@ public void TestMethod(System.Type a) {{ }} [InlineData("'a'")] [InlineData("\"abc\"")] [InlineData("System.StringComparison.Ordinal")] - public async void FromIncompatibleValue_ToParams(string value) + public async Task FromIncompatibleValue_ToParams(string value) { var source = $@" public class TestClass {{ @@ -686,7 +687,7 @@ public class StringParameter : X1010_IncompatibleValueType [Theory] [InlineData("\"abc\"")] [InlineData("null")] - public async void FromStringValue(string value) + public async Task FromStringValue(string value) { var source = $@" public class TestClass {{ @@ -704,7 +705,7 @@ public void TestMethod(string a) {{ }} [InlineData("System.StringComparison.Ordinal")] [InlineData("'a'")] [InlineData("typeof(string)")] - public async void FromIncompatibleValue(string value) + public async Task FromIncompatibleValue(string value) { var source = $@" public class TestClass {{ @@ -728,7 +729,7 @@ public class InterfaceParameter : X1010_IncompatibleValueType [MemberData(nameof(NumericValues))] [InlineData("System.StringComparison.Ordinal")] [InlineData("null")] - public async void FromTypeImplementingInterface(string value) + public async Task FromTypeImplementingInterface(string value) { var source = $@" public class TestClass {{ @@ -747,7 +748,7 @@ public void TestMethod(System.IFormattable a) {{ }} [InlineData("\"abc\"")] [InlineData("typeof(string)")] [MemberData(nameof(BoolValues))] - public async void FromIncompatibleValue(string value) + public async Task FromIncompatibleValue(string value) { var source = $@" public class TestClass {{ @@ -775,7 +776,7 @@ public class ObjectParameter : X1010_IncompatibleValueType [InlineData("\"abc\"")] [InlineData("null")] [InlineData("typeof(string)")] - public async void FromAnyValue(string value) + public async Task FromAnyValue(string value) { var source = $@" public class TestClass {{ @@ -795,7 +796,7 @@ public void TestMethod(object a) {{ }} [InlineData("\"abc\"")] [InlineData("null")] [InlineData("typeof(string)")] - public async void FromAnyValue_ToParams(string value) + public async Task FromAnyValue_ToParams(string value) { var source = $@" public class TestClass {{ @@ -818,7 +819,7 @@ public class GenericParameter : X1010_IncompatibleValueType [InlineData("\"abc\"")] [InlineData("null")] [InlineData("typeof(string)")] - public async void FromAnyValue_NoConstraint(string value) + public async Task FromAnyValue_NoConstraint(string value) { var source = $@" public class TestClass {{ @@ -835,7 +836,7 @@ public void TestMethod(T a) {{ }} [MemberData(nameof(NumericValues))] [InlineData("System.StringComparison.Ordinal")] [InlineData("'a'")] - public async void FromValueTypeValue_WithStructConstraint(string value) + public async Task FromValueTypeValue_WithStructConstraint(string value) { var source = $@" public class TestClass {{ @@ -850,7 +851,7 @@ public void TestMethod(T a) where T: struct {{ }} [Theory] [InlineData("\"abc\"")] [InlineData("typeof(string)")] - public async void FromReferenceTypeValue_WithStructConstraint(string value) + public async Task FromReferenceTypeValue_WithStructConstraint(string value) { var source = $@" public class TestClass {{ @@ -871,7 +872,7 @@ public void TestMethod(T a) where T: struct {{ }} [InlineData("\"abc\"")] [InlineData("typeof(string)")] [InlineData("null")] - public async void FromReferenceTypeValue_WithClassConstraint(string value) + public async Task FromReferenceTypeValue_WithClassConstraint(string value) { var source = $@" public class TestClass {{ @@ -888,7 +889,7 @@ public void TestMethod(T a) where T: class {{ }} [MemberData(nameof(NumericValues))] [InlineData("System.StringComparison.Ordinal")] [InlineData("'a'")] - public async void FromValueTypeValue_WithClassConstraint(string value) + public async Task FromValueTypeValue_WithClassConstraint(string value) { var source = $@" public class TestClass {{ @@ -909,7 +910,7 @@ public void TestMethod(T a) where T: class {{ }} [InlineData("null")] [InlineData("System.StringComparison.Ordinal")] [MemberData(nameof(NumericValues))] - public async void FromCompatibleValue_WithTypeConstraint(string value) + public async Task FromCompatibleValue_WithTypeConstraint(string value) { var source = $@" public class TestClass {{ @@ -928,7 +929,7 @@ public void TestMethod(T a) where T: System.IConvertible, System.IFormattable [InlineData("\"abc\"")] [InlineData("typeof(string)")] [MemberData(nameof(BoolValues))] - public async void FromIncompatibleValue_WithTypeConstraint(string value) + public async Task FromIncompatibleValue_WithTypeConstraint(string value) { var source = $@" public class TestClass {{ @@ -946,7 +947,7 @@ public void TestMethod(T a) where T: System.IConvertible, System.IFormattable } [Fact] - public async void FromIncompatibleArray() + public async Task FromIncompatibleArray() { var source = @" public class TestClass { @@ -964,7 +965,7 @@ public void TestMethod(T a) where T: System.IConvertible, System.IFormattable } [Fact] - public async void FromCompatibleArray() + public async Task FromCompatibleArray() { var source = @" public class TestClass { @@ -998,7 +999,7 @@ public class DateTimeLikeParameter : X1010_IncompatibleValueType [MemberData(nameof(ValueTypedArgumentsCombinedWithDateTimeLikeTypes))] [InlineData("MyConstInt", "System.DateTime")] [InlineData("MyConstInt", "System.DateTimeOffset")] - public async void NonStringValue( + public async Task NonStringValue( string data, string parameterType) { @@ -1022,7 +1023,7 @@ public void TestMethod({parameterType} parameter) {{ }} [Theory] [MemberData(nameof(ValidDateTimeStrings))] - public async void StringValue_ToDateTime(string data) + public async Task StringValue_ToDateTime(string data) { var source = CreateSourceWithStringConst(data, "System.DateTime"); @@ -1031,7 +1032,7 @@ public async void StringValue_ToDateTime(string data) [Theory] [MemberData(nameof(ValidDateTimeStrings))] - public async void StringValue_ToDateTimeOffset(string data) + public async Task StringValue_ToDateTimeOffset(string data) { var source = CreateSourceWithStringConst(data, "System.DateTimeOffset"); @@ -1040,7 +1041,7 @@ public async void StringValue_ToDateTimeOffset(string data) [Theory] [MemberData(nameof(ValidDateTimeStrings))] - public async void StringValue_ToDateTimeOffset_Pre240(string data) + public async Task StringValue_ToDateTimeOffset_Pre240(string data) { var source = CreateSourceWithStringConst(data, "System.DateTimeOffset"); var expected = @@ -1079,7 +1080,7 @@ public class GuidParameter : X1010_IncompatibleValueType [Theory] [MemberData(nameof(ValueTypedValues))] [InlineData("MyConstInt")] - public async void NonStringValue(string data) + public async Task NonStringValue(string data) { var source = $@" public class TestClass @@ -1101,7 +1102,7 @@ public void TestMethod(System.Guid parameter) {{ }} [Theory] [MemberData(nameof(ValidGuidStrings))] - public async void StringValue(string inlineData) + public async Task StringValue(string inlineData) { var source = CreateSource(inlineData); @@ -1110,7 +1111,7 @@ public async void StringValue(string inlineData) [Theory] [MemberData(nameof(ValidGuidStrings))] - public async void StringValue_Pre240(string data) + public async Task StringValue_Pre240(string data) { var source = CreateSource(data); var expected = @@ -1134,7 +1135,7 @@ public void TestMethod(System.Guid parameter) {{ }} public class UserDefinedConversionOperators : X1010_IncompatibleValueType { [Fact] - public async void SupportsImplicitConversion() + public async Task SupportsImplicitConversion() { var source = @" using Xunit; @@ -1155,7 +1156,7 @@ public class Implicit { } [Fact] - public async void SupportsExplicitConversion() + public async Task SupportsExplicitConversion() { var source = @" using Xunit; @@ -1224,7 +1225,7 @@ public static IEnumerable ValueTypedValues() public class X1011_ExtraValue { [Fact] - public async void IgnoresFact() + public async Task IgnoresFact() { var source = @" public class TestClass { @@ -1237,7 +1238,7 @@ public void TestMethod(int a) { } } [Fact] - public async void ExtraArguments() + public async Task ExtraArguments() { var source = @" public class TestClass { @@ -1266,7 +1267,7 @@ public void TestMethod(int a) { } public class X1012_NullShouldNotBeUsedForIncompatibleParameter { [Fact] - public async void IgnoresFact() + public async Task IgnoresFact() { var source = @" public class TestClass { @@ -1281,7 +1282,7 @@ public void TestMethod(int a) { } [Theory] [InlineData("int")] [InlineData("params int[]")] - public async void SingleNullValue(string type) + public async Task SingleNullValue(string type) { var source = $@" public class TestClass {{ @@ -1301,7 +1302,7 @@ public void TestMethod({type} a) {{ }} [Theory] [MemberData(nameof(ValueTypes))] - public async void NonNullableValueTypes(string type) + public async Task NonNullableValueTypes(string type) { var source = $@" public class TestClass {{ @@ -1328,7 +1329,7 @@ public void TestMethod(int a, {type} b, params {type}[] c) {{ }} [Theory] [MemberData(nameof(ValueTypes))] - public async void NullableValueTypes(string type) + public async Task NullableValueTypes(string type) { var source = $@" public class TestClass {{ @@ -1344,7 +1345,7 @@ public void TestMethod(int a, {type}? b) {{ }} [InlineData("object")] [InlineData("string")] [InlineData("System.Exception")] - public async void ReferenceTypes(string type) + public async Task ReferenceTypes(string type) { var source = $@" public class TestClass {{ @@ -1360,7 +1361,7 @@ public void TestMethod(int a, {type} b) {{ }} [InlineData("object")] [InlineData("string")] [InlineData("System.Exception")] - public async void NonNullableReferenceTypes(string type) + public async Task NonNullableReferenceTypes(string type) { var source = $@" #nullable enable @@ -1387,7 +1388,7 @@ public void TestMethod(int a, {type} b) {{ }} [InlineData("object")] [InlineData("string")] [InlineData("System.Exception")] - public async void NullableReferenceTypes(string type) + public async Task NullableReferenceTypes(string type) { var source = $@" #nullable enable @@ -1404,7 +1405,7 @@ public void TestMethod(int a, {type}? b) {{ }} [Theory] [InlineData("1", "object")] [InlineData("\"bob\"", "string")] - public async void NullableParamsReferenceTypes(string param, string type) + public async Task NullableParamsReferenceTypes(string param, string type) { var source = $@" #nullable enable @@ -1421,7 +1422,7 @@ public void TestMethod(int a, params {type}?[] b) {{ }} [Theory] [InlineData("1", "object")] [InlineData("\"bob\"", "string")] - public async void NonNullableParamsReferenceTypes(string param, string type) + public async Task NonNullableParamsReferenceTypes(string param, string type) { var source = $@" #nullable enable diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/InlineDataShouldBeUniqueWithinTheoryTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/InlineDataShouldBeUniqueWithinTheoryTests.cs index 1d458932..bc5e7f40 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/InlineDataShouldBeUniqueWithinTheoryTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/InlineDataShouldBeUniqueWithinTheoryTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Verify = CSharpVerifier; @@ -7,7 +8,7 @@ public abstract class InlineDataShouldBeUniqueWithinTheoryTests public class ForNonRelatedToInlineDataMethod : InlineDataShouldBeUniqueWithinTheoryTests { [Fact] - public async void DoesNotFindError_WhenNoDataAttributes() + public async Task DoesNotFindError_WhenNoDataAttributes() { var source = @" public class TestClass { @@ -21,7 +22,7 @@ public void TestMethod() { } [Theory] [InlineData("MemberData(\"\")")] [InlineData("ClassData(typeof(string))")] - public async void DoesNotFindError_WhenDataAttributesOtherThanInline( + public async Task DoesNotFindError_WhenDataAttributesOtherThanInline( string dataAttribute) { var source = $@" @@ -38,7 +39,7 @@ public void TestMethod() {{ }} public class ForUniqueInlineDataMethod : InlineDataShouldBeUniqueWithinTheoryTests { [Fact] - public async void DoesNotFindError_WhenNonTheorySingleInlineData() + public async Task DoesNotFindError_WhenNonTheorySingleInlineData() { var source = @" public class TestClass { @@ -51,7 +52,7 @@ public void TestMethod(int x) { } } [Fact] - public async void DoesNotFindError_WhenNonTheoryDoubledInlineData() + public async Task DoesNotFindError_WhenNonTheoryDoubledInlineData() { var source = @" public class TestClass { @@ -65,7 +66,7 @@ public void TestMethod(int x) { } } [Fact] - public async void DoesNotFindError_WhenSingleInlineDataContainingValue() + public async Task DoesNotFindError_WhenSingleInlineDataContainingValue() { var source = @" public class TestClass { @@ -78,7 +79,7 @@ public void TestMethod(int x) { } } [Fact] - public async void DoesNotFindError_WhenInlineDataAttributesHaveDifferentParameterValues() + public async Task DoesNotFindError_WhenInlineDataAttributesHaveDifferentParameterValues() { var source = @" public class TestClass { @@ -92,7 +93,7 @@ public void TestMethod(int x) { } } [Fact] - public async void DoesNotFindError_WhenInlineDataAttributesDifferAtLastParameterValue() + public async Task DoesNotFindError_WhenInlineDataAttributesDifferAtLastParameterValue() { var source = @" public class TestClass { @@ -110,7 +111,7 @@ public void TestMethod(int x, string y) { } [InlineData("data: new object[] { 1, 3 }")] [InlineData("new object[] { }")] [InlineData("data: new object[] { 1 }")] - public async void DoesNotFindError_WhenUniquenessProvidedWithParamsInitializerValues(string data) + public async Task DoesNotFindError_WhenUniquenessProvidedWithParamsInitializerValues(string data) { var source = $@" public class TestClass {{ @@ -124,7 +125,7 @@ public void TestMethod(params int[] args) {{ }} } [Fact] - public async void DoesNotFindError_WhenUniquenessProvidedWithOverridingDefaultValues() + public async Task DoesNotFindError_WhenUniquenessProvidedWithOverridingDefaultValues() { var source = @" public class TestClass { @@ -138,7 +139,7 @@ public void TestMethod(int x, string a = ""default-val"") { } } [Fact] - public async void DoesNotFindError_WhenNullAndEmptyInlineDataAttributes() + public async Task DoesNotFindError_WhenNullAndEmptyInlineDataAttributes() { var source = @" public class TestClass { @@ -152,7 +153,7 @@ public void TestMethod(string s) { } } [Fact] - public async void DoesNotFindError_WhenNewArrayAndNullDataAttributes() + public async Task DoesNotFindError_WhenNewArrayAndNullDataAttributes() { var source = @" public class TestClass{ @@ -166,7 +167,7 @@ public void TestMethod(int[] arr) { } } [Fact] - public async void DoesNotFindError_WhenFirstArrayIsEqualAndEmptyArraysAreUsed() + public async Task DoesNotFindError_WhenFirstArrayIsEqualAndEmptyArraysAreUsed() { // Specially crafted InlineData values that will cause the InlineDataUniquenessComparer // to return same hashcodes, because GetFlattenedArgumentPrimitives ignores empty arrays. @@ -187,7 +188,7 @@ public static void Test(int[] x, int[] y, int[] z) { } public class ForDuplicatedInlineDataMethod : InlineDataShouldBeUniqueWithinTheoryTests { [Fact] - public async void FindsError_WhenEmptyInlineDataRepeatedTwice() + public async Task FindsError_WhenEmptyInlineDataRepeatedTwice() { var source = @" public class TestClass { @@ -207,7 +208,7 @@ public void TestMethod(int x) { } } [Fact] - public async void FindsError_WhenNullInlineDataRepeatedTwice() + public async Task FindsError_WhenNullInlineDataRepeatedTwice() { var source = @" public class TestClass { @@ -227,7 +228,7 @@ public void TestMethod(string x) { } } [Fact] - public async void FindsError_WhenInlineDataAttributesHaveExactlySameDeclarations() + public async Task FindsError_WhenInlineDataAttributesHaveExactlySameDeclarations() { var source = @" public class TestClass { @@ -247,7 +248,7 @@ public void TestMethod(int x) { } } [Fact] - public async void FindsError_WhenInlineDataAttributesHaveSameCompilationTimeEvaluation() + public async Task FindsError_WhenInlineDataAttributesHaveSameCompilationTimeEvaluation() { var source = @" public class TestClass { @@ -270,7 +271,7 @@ public void TestMethod(int x) { } [Theory] [InlineData("new object[] { 10, 20 }")] [InlineData("data: new object[] { 10, 20 }")] - public async void FindsError_WhenInlineDataHaveSameParameterValuesButDeclaredArrayCollectionOfArguments(string data) + public async Task FindsError_WhenInlineDataHaveSameParameterValuesButDeclaredArrayCollectionOfArguments(string data) { var source = $@" public class TestClass {{ @@ -292,7 +293,7 @@ public void TestMethod(int x, int y) {{ }} [Theory] [InlineData("new object[] { 10, 20 }")] [InlineData("data: new object[] { 10, 20 }")] - public async void FindsError_WhenTestMethodIsDefinedWithParamsArrayOfArguments(string data) + public async Task FindsError_WhenTestMethodIsDefinedWithParamsArrayOfArguments(string data) { var source = $@" public class TestClass {{ @@ -312,7 +313,7 @@ public void TestMethod(params int[] args) {{ }} } [Fact] - public async void FindsError_WhenBothInlineDataHaveObjectArrayCollectionOfArguments() + public async Task FindsError_WhenBothInlineDataHaveObjectArrayCollectionOfArguments() { var source = @" public class TestClass { @@ -332,7 +333,7 @@ public void TestMethod(int x, int y) { } } [Fact] - public async void FindsError_WhenArgumentsAreArrayOfValues() + public async Task FindsError_WhenArgumentsAreArrayOfValues() { var source = @" public class TestClass { @@ -352,7 +353,7 @@ public void TestMethod(object x, object y) { } } [Fact] - public async void FindsError_WhenArgumentsAreArrayOfValuesAndTestMethodOffersDefaultParameterValues() + public async Task FindsError_WhenArgumentsAreArrayOfValuesAndTestMethodOffersDefaultParameterValues() { var source = @" public class TestClass { @@ -378,7 +379,7 @@ public void TestMethod(object x, object y, int z = 40) { } [Theory] [MemberData(nameof(DefaultValueData))] - public async void FindsError_WhenFirstDuplicatedByDefaultValueOfParameter_DefaultInlineDataFirst(int defaultValue) + public async Task FindsError_WhenFirstDuplicatedByDefaultValueOfParameter_DefaultInlineDataFirst(int defaultValue) { var source = $@" public class TestClass {{ @@ -399,7 +400,7 @@ public void TestMethod(int y = {defaultValue}) {{ }} [Theory] [MemberData(nameof(DefaultValueData))] - public async void FindsError_WhenSecondDuplicatedByDefaultValueOfParameter(int defaultValue) + public async Task FindsError_WhenSecondDuplicatedByDefaultValueOfParameter(int defaultValue) { var source = $@" public class TestClass {{ @@ -420,7 +421,7 @@ public void TestMethod(int y = {defaultValue}) {{ }} [Theory] [MemberData(nameof(DefaultValueData))] - public async void FindsError_WhenTwoDuplicatedByDefaultValueOfParameter(int defaultValue) + public async Task FindsError_WhenTwoDuplicatedByDefaultValueOfParameter(int defaultValue) { var source = $@" public class TestClass {{ @@ -444,7 +445,7 @@ public void TestMethod(int y = {defaultValue}) {{ }} [InlineData("null", "")] [InlineData("", "null")] [InlineData("", "")] - public async void FindsError_WhenBothNullEntirelyOrBySingleDefaultParameterNullValue( + public async Task FindsError_WhenBothNullEntirelyOrBySingleDefaultParameterNullValue( string firstArg, string secondArg) { @@ -466,7 +467,7 @@ public void TestMethod(string x = null) {{ }} } [Fact] - public async void FindsError_WhenDuplicateContainsNulls() + public async Task FindsError_WhenDuplicateContainsNulls() { var source = @" public class TestClass { @@ -490,7 +491,7 @@ public void TestMethod(object x, object y) { } [InlineData("", ", null")] [InlineData(", null", "")] [InlineData(", null", ", null")] - public async void FindsError_WhenDuplicateContainsDefaultOfStruct( + public async Task FindsError_WhenDuplicateContainsDefaultOfStruct( string firstDefaultOverride, string secondDefaultOverride) { @@ -516,7 +517,7 @@ public class TestClass {{ [InlineData("", ", null")] [InlineData(", null", "")] [InlineData(", null", ", null")] - public async void FindsError_WhenDuplicateContainsDefaultOfString( + public async Task FindsError_WhenDuplicateContainsDefaultOfString( string firstDefaultOverride, string secondDefaultOverride) { @@ -538,7 +539,7 @@ public void TestMethod(int x, string y = null) {{ }} } [Fact] - public async void FindsError_WhenInlineDataDuplicateAndOriginalAreItemsOfDistinctAttributesLists() + public async Task FindsError_WhenInlineDataDuplicateAndOriginalAreItemsOfDistinctAttributesLists() { var source = @" public class TestClass { @@ -560,7 +561,7 @@ public void TestMethod(int x, int y) { } } [Fact] - public async void FindsErrorsTwiceOnCorrectLinesReferringToInitialOccurence_WhenThreeInlineDataAttributesConstituteDuplication() + public async Task FindsErrorsTwiceOnCorrectLinesReferringToInitialOccurence_WhenThreeInlineDataAttributesConstituteDuplication() { var source = @" public class TestClass { @@ -588,7 +589,7 @@ public void TestMethod(int x) { } } [Fact] - public async void FindsErrorOnCorrectLineReferringToInitialOccurence_WhenDuplicateIsSeparatedByOtherNonDuplicateData() + public async Task FindsErrorOnCorrectLineReferringToInitialOccurence_WhenDuplicateIsSeparatedByOtherNonDuplicateData() { var source = @" public class TestClass { @@ -609,7 +610,7 @@ public void TestMethod(int x) { } } [Fact] - public async void FindsErrorOnCorrectLineReferringToInitialOccurence_WhenTwoDuplicationEquivalenceSetsExistWithinTheory() + public async Task FindsErrorOnCorrectLineReferringToInitialOccurence_WhenTwoDuplicationEquivalenceSetsExistWithinTheory() { var source = @" public class TestClass { diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/LocalFunctionsCannotBeTestFunctionsTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/LocalFunctionsCannotBeTestFunctionsTests.cs index 839199fa..5d72823e 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/LocalFunctionsCannotBeTestFunctionsTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/LocalFunctionsCannotBeTestFunctionsTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Xunit; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class LocalFunctionsCannotBeTestFunctionsTests { [Fact] - public async void DoesNotTriggerOnLocalFunctionWithoutAttributes() + public async Task DoesNotTriggerOnLocalFunctionWithoutAttributes() { var source = @" using Xunit; @@ -26,7 +27,7 @@ void LocalFunction() { [InlineData("InlineData(42)")] [InlineData("MemberData(nameof(MyData))")] [InlineData("ClassData(typeof(TestClass))")] - public async void LocalFunctionsCannotHaveTestAttributes(string attribute) + public async Task LocalFunctionsCannotHaveTestAttributes(string attribute) { var source = $@" using System.Collections.Generic; diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/MemberDataShouldReferenceValidMemberTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/MemberDataShouldReferenceValidMemberTests.cs index 9a94e4b0..221dc474 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/MemberDataShouldReferenceValidMemberTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/MemberDataShouldReferenceValidMemberTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; @@ -21,7 +22,7 @@ public class OtherClass { }"; [Fact] - public async void NameofOnSameClass_DoesNotTrigger() + public async Task NameofOnSameClass_DoesNotTrigger() { var source = @" public partial class TestClass { @@ -33,7 +34,7 @@ public void TestMethod(int _) { } } [Fact] - public async void NameofOnOtherClass_DoesNotTrigger() + public async Task NameofOnOtherClass_DoesNotTrigger() { var source = @" public partial class TestClass { @@ -45,7 +46,7 @@ public void TestMethod(int _) { } } [Fact] - public async void StringNameOnSameClass_Triggers() + public async Task StringNameOnSameClass_Triggers() { var source = @" public partial class TestClass { @@ -62,7 +63,7 @@ public void TestMethod(int _) { } } [Fact] - public async void StringNameOnOtherClass_Triggers() + public async Task StringNameOnOtherClass_Triggers() { var source = @" public partial class TestClass { @@ -84,7 +85,7 @@ public class X1015_MemberDataMustReferenceExistingMember [Theory] [InlineData("")] [InlineData(", MemberType = typeof(TestClass)")] - public async void InvalidStringNameOnSameClass_Triggers(string memberType) + public async Task InvalidStringNameOnSameClass_Triggers(string memberType) { var source = @$" public class TestClass {{ @@ -102,7 +103,7 @@ public void TestMethod() {{ }} } [Fact] - public async void InvalidStringNameOnOtherClass_Triggers() + public async Task InvalidStringNameOnOtherClass_Triggers() { var source1 = @" public class TestClass { @@ -121,7 +122,7 @@ public void TestMethod() { } } [Fact] - public async void InvalidNameofOnOtherClass_Triggers() + public async Task InvalidNameofOnOtherClass_Triggers() { var source1 = @" public class TestClass { @@ -143,7 +144,7 @@ public void TestMethod() { } public class X1016_MemberDataMustReferencePublicMember { [Fact] - public async void PublicMember_DoesNotTrigger() + public async Task PublicMember_DoesNotTrigger() { var source = @" public class TestClass { @@ -164,7 +165,7 @@ public void TestMethod(int _) { } [Theory] [MemberData(nameof(NonPublicTestData))] - public async void NonPublicNameExpression_Triggers( + public async Task NonPublicNameExpression_Triggers( string accessModifier, string dataNameExpression) { @@ -195,7 +196,7 @@ public void TestMethod(int _) {{ }} public class X1017_MemberDataMustReferenceStaticMember { [Fact] - public async void StaticMember_DoesNotTrigger() + public async Task StaticMember_DoesNotTrigger() { var source = @" public class TestClass { @@ -209,7 +210,7 @@ public void TestMethod(int _) { } } [Fact] - public async void InstanceMember_Triggers() + public async Task InstanceMember_Triggers() { var source = @" public class TestClass { @@ -234,7 +235,7 @@ public class X1018_MemberDataMustReferenceValidMemberKind [InlineData("Data;")] [InlineData("Data { get; set; }")] [InlineData("Data() { return null; }")] - public async void ValidMemberKind_DoesNotTrigger(string member) + public async Task ValidMemberKind_DoesNotTrigger(string member) { var source = $@" public class TestClass {{ @@ -251,7 +252,7 @@ public void TestMethod(int _) {{ }} [InlineData("public delegate System.Collections.Generic.IEnumerable Data();")] [InlineData("public static class Data { }")] [InlineData("public static event System.EventHandler Data;")] - public async void InvalidMemberKind_Triggers(string member) + public async Task InvalidMemberKind_Triggers(string member) { var source = $@" public class TestClass {{ @@ -277,7 +278,7 @@ public class X1019_MemberDataMustReferenceMemberOfValidType // test TheoryData<> and IEnumerable here. [Fact] - public async void TheoryData_DoesNotTrigger() + public async Task TheoryData_DoesNotTrigger() { var source = @" using System.Collections.Generic; @@ -294,7 +295,7 @@ public void TestMethod(int _) { } } [Fact] - public async void ITheoryDataRow_DoesNotTrigger() + public async Task ITheoryDataRow_DoesNotTrigger() { var source = @" using System.Collections.Generic; @@ -325,7 +326,7 @@ public static List DataRowSource() => [InlineData("object")] [InlineData("System.Tuple")] [InlineData("System.Tuple[]")] - public async void InvalidMemberType_Triggers(string memberType) + public async Task InvalidMemberType_Triggers(string memberType) { var source = $@" public class TestClass {{ @@ -357,7 +358,7 @@ public void TestMethod() {{ }} public class X1020_MemberDataPropertyMustHaveGetter { [Fact] - public async void PropertyWithoutGetter_Triggers() + public async Task PropertyWithoutGetter_Triggers() { var source = @" public class TestClass { @@ -379,7 +380,7 @@ public void TestMethod(int _) { } [InlineData("internal")] [InlineData("protected")] [InlineData("private")] - public async void PropertyWithNonPublicGetter_Triggers(string visibility) + public async Task PropertyWithNonPublicGetter_Triggers(string visibility) { var source = $@" public class TestClass {{ @@ -403,7 +404,7 @@ public class X1021_MemberDataNonMethodShouldNotHaveParameters [Theory] [InlineData("1")] // implicit params [InlineData("new object[] { 1 }")] // explicit params - public async void MethodMemberWithParameters_DoesNotTrigger(string parameter) + public async Task MethodMemberWithParameters_DoesNotTrigger(string parameter) { var source = @$" public class TestClass {{ @@ -421,7 +422,7 @@ public void TestMethod(int n) {{ }} [Theory] [InlineData("1, 2")] // implicit params [InlineData("new object[] { 1, 2 }")] // explicit params - public async void MethodMemberWithParamsArrayParameters_DoesNotTrigger(string parameters) + public async Task MethodMemberWithParamsArrayParameters_DoesNotTrigger(string parameters) { var source = @$" public class TestClass {{ @@ -437,7 +438,7 @@ public void TestMethod(int n) {{ }} [Theory] [InlineData("1")] // implicit params [InlineData("new object[] { 1 }")] // explicit params - public async void MethodMemberOnBaseType_DoesNotTrigger(string parameter) + public async Task MethodMemberOnBaseType_DoesNotTrigger(string parameter) { var source = $@" public class TestClassBase {{ @@ -458,7 +459,7 @@ public void TestMethod(int n) {{ }} [InlineData("'a', 123")] [InlineData("new object[] {{ 'a', 123 }}")] [InlineData("{0}: new object[] {{ 'a', 123 }}")] - public async void FieldMemberWithParameters_Triggers(string paramsArgument) + public async Task FieldMemberWithParameters_Triggers(string paramsArgument) { var sourceTemplate = @" public class TestClass {{ @@ -493,7 +494,7 @@ public void TestMethod(int _) {{ }} [InlineData("'a', 123")] [InlineData("new object[] {{ 'a', 123 }}")] [InlineData("{0}: new object[] {{ 'a', 123 }}")] - public async void PropertyMemberWithParameters_Triggers(string paramsArgument) + public async Task PropertyMemberWithParameters_Triggers(string paramsArgument) { var sourceTemplate = @" public class TestClass {{ @@ -530,7 +531,7 @@ public class X1034_MemberDataArgumentsMustMatchMethodParameters_NullShouldNotBeU [Theory] [InlineData("", "string")] [InlineData("#nullable enable", "string?")] - public async void PassingNullForNullableReferenceType_DoesNotTrigger( + public async Task PassingNullForNullableReferenceType_DoesNotTrigger( string header, string argumentType) { @@ -547,7 +548,7 @@ public void TestMethod(int _) {{ }} } [Fact] - public async void PassingNullForStructType_Triggers() + public async Task PassingNullForStructType_Triggers() { var source = @" public class TestClass { @@ -568,7 +569,7 @@ public void TestMethod(int _) { } } [Fact] - public async void PassingNullForNonNullableReferenceType_Triggers() + public async Task PassingNullForNonNullableReferenceType_Triggers() { var source = @" #nullable enable @@ -597,7 +598,7 @@ public class X1035_MemberDataArgumentsMustMatchMethodParameters_IncompatibleValu [Theory] [InlineData("Foo.Bar")] [InlineData("(Foo)42")] - public async void ValidEnumValue_DoesNotTrigger(string enumValue) + public async Task ValidEnumValue_DoesNotTrigger(string enumValue) { var source = $@" using System; @@ -621,7 +622,7 @@ public enum Foo {{ Bar }} [Theory] [InlineData("")] [InlineData("#nullable enable")] - public async void ArrayInitializerWithCorrectType_DoesNotTrigger(string header) + public async Task ArrayInitializerWithCorrectType_DoesNotTrigger(string header) { var source = $@" {header} @@ -643,7 +644,7 @@ public void Test(int value) {{ }} [Theory] [InlineData("")] [InlineData("#nullable enable")] - public async void ArrayInitializerWithIncorrectType_Triggers(string header) + public async Task ArrayInitializerWithIncorrectType_Triggers(string header) { var source = $@" {header} @@ -668,7 +669,7 @@ public void Test(int value) {{ }} } [Fact] - public async void ValidMemberWithIncorrectArgumentTypes_Triggers() + public async Task ValidMemberWithIncorrectArgumentTypes_Triggers() { var source = @" public class TestClass { @@ -688,7 +689,7 @@ public void TestMethod(int n) { } } [Fact] - public async void ValidMemberWithIncorrectArgumentTypesParams_Triggers() + public async Task ValidMemberWithIncorrectArgumentTypesParams_Triggers() { var source = @" public class TestClass { @@ -713,7 +714,7 @@ public class X1036_MemberDataArgumentsMustMatchMethodParameters_ExtraValue [Theory] [InlineData("1")] [InlineData("new object[] { 1 }")] - public async void ValidArgumentCount_DoesNotTrigger(string parameter) + public async Task ValidArgumentCount_DoesNotTrigger(string parameter) { var source = $@" public class TestClass {{ @@ -731,7 +732,7 @@ public void TestMethod(int n) {{ }} [Theory] [InlineData("1")] [InlineData("new object[] { 1 }")] - public async void ValidArgumentCount_InNullableContext_DoesNotTrigger(string parameter) + public async Task ValidArgumentCount_InNullableContext_DoesNotTrigger(string parameter) { var source = $@" #nullable enable @@ -749,7 +750,7 @@ public void TestMethod(int n) {{ }} [Theory] [InlineData("1, 2", 44)] [InlineData("new object[] { 1, 2 }", 59)] - public async void TooManyArguments_Triggers( + public async Task TooManyArguments_Triggers( string parameters, int startColumn) { @@ -783,7 +784,7 @@ public class X1037_MemberDataTheoryDataTypeArgumentsMustMatchTestMethodParameter [Theory] [MemberData(nameof(MemberSyntaxAndArgs))] - public async void ValidTheoryDataMemberWithNotEnoughTypeParameters_Triggers( + public async Task ValidTheoryDataMemberWithNotEnoughTypeParameters_Triggers( string memberSyntax, string memberArgs) { @@ -806,7 +807,7 @@ public void TestMethod(int n, string f) {{ }} [Theory] [MemberData(nameof(MemberSyntaxAndArgs))] - public async void ValidSubclassedTheoryDataMemberWithNotEnoughTypeParameters_Triggers( + public async Task ValidSubclassedTheoryDataMemberWithNotEnoughTypeParameters_Triggers( string memberSyntax, string memberArgs) { @@ -853,7 +854,7 @@ public class X1038_MemberDataTheoryDataTypeArgumentsMustMatchTestMethodParameter [Theory] [MemberData(nameof(MemberSyntaxAndArgs_WithTheoryDataType), "int", DisableDiscoveryEnumeration = true)] - public async void ValidTheoryData_DoesNotTrigger( + public async Task ValidTheoryData_DoesNotTrigger( (string syntax, string args) member, string theoryDataType) { @@ -875,7 +876,7 @@ public void TestMethod(int n) {{ }} [Theory] [MemberData(nameof(MemberSyntaxAndArgs_WithTheoryDataType), "int", DisableDiscoveryEnumeration = true)] - public async void ValidTheoryDataWithOptionalParameters_DoesNotTrigger( + public async Task ValidTheoryDataWithOptionalParameters_DoesNotTrigger( (string syntax, string args) member, string theoryDataType) { @@ -897,7 +898,7 @@ public void TestMethod(int n, int a = 0) {{ }} [Theory] [MemberData(nameof(MemberSyntaxAndArgs_WithTheoryDataType), "int", DisableDiscoveryEnumeration = true)] - public async void ValidTheoryDataWithNoValuesForParamsArray_DoesNotTrigger( + public async Task ValidTheoryDataWithNoValuesForParamsArray_DoesNotTrigger( (string syntax, string args) member, string theoryDataType) { @@ -919,7 +920,7 @@ public void TestMethod(int n, params int[] a) {{ }} [Theory] [MemberData(nameof(MemberSyntaxAndArgs_WithTheoryDataType), "int, int", DisableDiscoveryEnumeration = true)] - public async void ValidTheoryDataWithSingleValueForParamsArray_DoesNotTrigger( + public async Task ValidTheoryDataWithSingleValueForParamsArray_DoesNotTrigger( (string syntax, string args) member, string theoryDataType) { @@ -941,7 +942,7 @@ public void TestMethod(int n, params int[] a) {{ }} [Theory] [MemberData(nameof(MemberSyntaxAndArgs_WithTheoryDataType), "int", DisableDiscoveryEnumeration = true)] - public async void ValidTheoryDataWithGenericTestParameter_DoesNotTrigger( + public async Task ValidTheoryDataWithGenericTestParameter_DoesNotTrigger( (string syntax, string args) member, string theoryDataType) { @@ -963,7 +964,7 @@ public void TestMethod(T n) {{ }} [Theory] [MemberData(nameof(MemberSyntaxAndArgs_WithTheoryDataType), "int", DisableDiscoveryEnumeration = true)] - public async void ValidTheoryDataWithNullableGenericTestParameter_DoesNotTrigger( + public async Task ValidTheoryDataWithNullableGenericTestParameter_DoesNotTrigger( (string syntax, string args) member, string theoryDataType) { @@ -990,7 +991,7 @@ public void TestMethod(T? n) {{ }} [InlineData(" => ", "")] // Property [InlineData("() => ", "")] // Method w/o args [InlineData("(int n) => ", ", 42")] // Method w/ args - public async void ValidTheoryDataDoubleGenericSubclassMember_DoesNotTrigger( + public async Task ValidTheoryDataDoubleGenericSubclassMember_DoesNotTrigger( string memberSyntax, string memberArgs) { @@ -1010,7 +1011,7 @@ public void TestMethod(int n) {{ }} } [Fact] - public async void WithIntArrayArguments_DoesNotTrigger() + public async Task WithIntArrayArguments_DoesNotTrigger() { var source = @" using System.Collections.Generic; @@ -1032,7 +1033,7 @@ public void Test(IEnumerable seq) { [Theory] [MemberData(nameof(MemberSyntaxAndArgs_WithTheoryDataType), "int, string", DisableDiscoveryEnumeration = true)] - public async void ValidSubclassTheoryDataMemberWithTooManyTypeParameters_Triggers( + public async Task ValidSubclassTheoryDataMemberWithTooManyTypeParameters_Triggers( (string syntax, string args) member, string theoryDataType) { @@ -1060,7 +1061,7 @@ public void TestMethod(int n) {{ }} [Theory] [MemberData(nameof(MemberSyntaxAndArgs_WithTheoryDataType), "int, string[], string", DisableDiscoveryEnumeration = true)] - public async void ExtraTypeExistsPastArrayForParamsArray_Triggers( + public async Task ExtraTypeExistsPastArrayForParamsArray_Triggers( (string syntax, string args) member, string theoryDataType) { @@ -1106,7 +1107,7 @@ public class X1039_MemberDataTheoryDataTypeArgumentsMustMatchTestMethodParameter ); [Fact] - public async void DoesNotFindWarning_WhenPassingMultipleValuesForParamsArray() + public async Task DoesNotFindWarning_WhenPassingMultipleValuesForParamsArray() { var source = @" using Xunit; @@ -1122,7 +1123,7 @@ public void PuzzleOne(int _1, params string[] _2) { } } [Fact] - public async void DoesNotFindWarning_WhenPassingArrayForParamsArray() + public async Task DoesNotFindWarning_WhenPassingArrayForParamsArray() { var source = @" using Xunit; @@ -1138,7 +1139,7 @@ public void PuzzleOne(int _1, params string[] _2) { } } [Fact] - public async void DoesNotFindWarning_WhenPassingTupleWithoutFieldNames() + public async Task DoesNotFindWarning_WhenPassingTupleWithoutFieldNames() { var source = @" using Xunit; @@ -1154,7 +1155,7 @@ public void TestMethod((int a, int b) x) { } } [Fact] - public async void DoesNotFindWarning_WhenPassingTupleWithDifferentFieldNames() + public async Task DoesNotFindWarning_WhenPassingTupleWithDifferentFieldNames() { var source = @" using Xunit; @@ -1170,7 +1171,7 @@ public void TestMethod((int a, int b) x) { } } [Fact] - public async void FindWarning_WithExtraValueNotCompatibleWithParamsArray() + public async Task FindWarning_WithExtraValueNotCompatibleWithParamsArray() { var source = @" using Xunit; @@ -1194,7 +1195,7 @@ public void PuzzleOne(int _1, params string[] _2) { } [Theory] [MemberData(nameof(TypeWithMemberSyntaxAndArgs), DisableDiscoveryEnumeration = true)] - public async void FindWarning_IfHasValidTheoryDataMemberWithIncompatibleTypeParameters( + public async Task FindWarning_IfHasValidTheoryDataMemberWithIncompatibleTypeParameters( (string syntax, string args) member, string type) { @@ -1231,7 +1232,7 @@ public class X1040_MemberDataTheoryDataTypeArgumentsMustMatchTestMethodParameter [Theory] [MemberData(nameof(MemberSyntaxAndArgs))] - public async void ValidTheoryDataMemberWithMismatchedNullability_Triggers( + public async Task ValidTheoryDataMemberWithMismatchedNullability_Triggers( string memberSyntax, string memberArgs) { @@ -1261,7 +1262,7 @@ public void TestMethod(string f) {{ }} public class X1042_MemberDataTheoryDataIsRecommendedForStronglyTypedAnalysis { [Fact] - public async void TheoryData_DoesNotTrigger() + public async Task TheoryData_DoesNotTrigger() { var source = @" using System.Collections.Generic; @@ -1278,7 +1279,7 @@ public void TestMethod(int _) { } } [Fact] - public async void MatrixTheoryData_DoesNotTrigger() + public async Task MatrixTheoryData_DoesNotTrigger() { var source = @" using System.Collections.Generic; @@ -1298,7 +1299,7 @@ public void TestMethod(int _1, string _2) { } [InlineData("IEnumerable")] [InlineData("List")] [InlineData("ITheoryDataRow[]")] - public async void TheoryDataRow_DoesNotTrigger(string memberType) + public async Task TheoryDataRow_DoesNotTrigger(string memberType) { var source = $@" using System.Collections.Generic; @@ -1318,7 +1319,7 @@ public void TestMethod(int _) {{ }} [Theory] [InlineData("IEnumerable")] [InlineData("List")] - public async void ValidTypesWhichAreNotTheoryData_Trigger(string memberType) + public async Task ValidTypesWhichAreNotTheoryData_Trigger(string memberType) { var source = $@" using System.Collections.Generic; diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/PublicMethodShouldBeMarkedAsTestTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/PublicMethodShouldBeMarkedAsTestTests.cs index 92ac3ea1..bdd29f64 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/PublicMethodShouldBeMarkedAsTestTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/PublicMethodShouldBeMarkedAsTestTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class PublicMethodShouldBeMarkedAsTestTests { [Fact] - public async void DoesNotFindErrorForPublicMethodInNonTestClass() + public async Task DoesNotFindErrorForPublicMethodInNonTestClass() { var source = @" public class TestClass { @@ -18,7 +19,7 @@ public void TestMethod() { } [Theory] [InlineData("Xunit.Fact")] [InlineData("Xunit.Theory")] - public async void DoesNotFindErrorForTestMethods(string attribute) + public async Task DoesNotFindErrorForTestMethods(string attribute) { var source = $@" public class TestClass {{ @@ -30,7 +31,7 @@ public void TestMethod() {{ }} } [Fact] - public async void DoesNotFindErrorForIDisposableDisposeMethod() + public async Task DoesNotFindErrorForIDisposableDisposeMethod() { var source = @" public class TestClass: System.IDisposable { @@ -44,7 +45,7 @@ public void Dispose() { } } [Fact] - public async void DoesNotFindErrorForPublicAbstractMethod() + public async Task DoesNotFindErrorForPublicAbstractMethod() { var source = @" public abstract class TestClass { @@ -58,7 +59,7 @@ public void TestMethod() { } } [Fact] - public async void DoesNotFindErrorForDerivedMethodWithFactOnBaseAbstractMethod() + public async Task DoesNotFindErrorForDerivedMethodWithFactOnBaseAbstractMethod() { var source = @" public abstract class BaseClass { @@ -77,7 +78,7 @@ public void TestMethod2() { } } [Fact] - public async void DoesNotFindErrorForPublicAbstractMethodMarkedWithFact() + public async Task DoesNotFindErrorForPublicAbstractMethodMarkedWithFact() { var source = @" public abstract class TestClass { @@ -92,7 +93,7 @@ public void TestMethod() { } } [Fact] - public async void DoesNotFindErrorForIDisposableDisposeMethodOverrideFromParentClass() + public async Task DoesNotFindErrorForIDisposableDisposeMethodOverrideFromParentClass() { var source = @" public class BaseClass: System.IDisposable { @@ -110,7 +111,7 @@ public override void Dispose() { } } [Fact] - public async void DoesNotFindErrorForIDisposableDisposeMethodOverrideFromParentClassWithRepeatedInterfaceDeclaration() + public async Task DoesNotFindErrorForIDisposableDisposeMethodOverrideFromParentClassWithRepeatedInterfaceDeclaration() { var source = @" public class BaseClass: System.IDisposable { @@ -128,7 +129,7 @@ public override void Dispose() { } } [Fact] - public async void DoesNotFindErrorForIDisposableDisposeMethodOverrideFromGrandParentClass() + public async Task DoesNotFindErrorForIDisposableDisposeMethodOverrideFromGrandParentClass() { var source = @" public abstract class BaseClass: System.IDisposable { @@ -148,7 +149,7 @@ public override void Dispose() { } } [Fact] - public async void DoesNotFindErrorForIAsyncLifetimeMethods_V2() + public async Task DoesNotFindErrorForIAsyncLifetimeMethods_V2() { var source = @" public class TestClass: Xunit.IAsyncLifetime { @@ -170,7 +171,7 @@ public System.Threading.Tasks.Task InitializeAsync() } [Fact] - public async void DoesNotFindErrorForIAsyncLifetimeMethods_V3() + public async Task DoesNotFindErrorForIAsyncLifetimeMethods_V3() { var source = @" public class TestClass: Xunit.IAsyncLifetime { @@ -192,7 +193,7 @@ public System.Threading.Tasks.ValueTask InitializeAsync() } [Fact] - public async void DoesNotFindErrorForPublicMethodMarkedWithAttributeWhichIsMarkedWithIgnoreXunitAnalyzersRule1013() + public async Task DoesNotFindErrorForPublicMethodMarkedWithAttributeWhichIsMarkedWithIgnoreXunitAnalyzersRule1013() { var source = @" public class IgnoreXunitAnalyzersRule1013Attribute: System.Attribute { } @@ -212,7 +213,7 @@ public void CustomTestMethod() { } } [Fact] - public async void FindsWarningForPublicMethodMarkedWithAttributeWhichInheritsFromAttributeMarkedWithIgnoreXunitAnalyzersRule1013() + public async Task FindsWarningForPublicMethodMarkedWithAttributeWhichInheritsFromAttributeMarkedWithIgnoreXunitAnalyzersRule1013() { var source = @" public class IgnoreXunitAnalyzersRule1013Attribute: System.Attribute { } @@ -242,7 +243,7 @@ public void CustomTestMethod() { } [Theory] [InlineData("Xunit.Fact")] [InlineData("Xunit.Theory")] - public async void FindsWarningForPublicMethodWithoutParametersInTestClass(string attribute) + public async Task FindsWarningForPublicMethodWithoutParametersInTestClass(string attribute) { var source = $@" public class TestClass {{ @@ -264,7 +265,7 @@ public void Method() {{ }} [Theory] [InlineData("Xunit.Fact")] [InlineData("Xunit.Theory")] - public async void FindsWarningForPublicMethodWithParametersInTestClass(string attribute) + public async Task FindsWarningForPublicMethodWithParametersInTestClass(string attribute) { var source = $@" public class TestClass {{ @@ -286,7 +287,7 @@ public void Method(int a) {{ }} [Theory] [InlineData("Xunit.Fact")] [InlineData("Xunit.Theory")] - public async void DoesNotFindErrorForOverridenMethod(string attribute) + public async Task DoesNotFindErrorForOverridenMethod(string attribute) { var source = $@" public class TestClass {{ diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/TestClassMustBePublicTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/TestClassMustBePublicTests.cs index 7d3ecf80..c7ab515c 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/TestClassMustBePublicTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/TestClassMustBePublicTests.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; @@ -11,7 +12,7 @@ public class TestClassMustBePublicTests select new[] { attribute, modifier }; [Fact] - public async void ForPublicClass_DoesNotFindError() + public async Task ForPublicClass_DoesNotFindError() { var source = @" public class TestClass { @@ -24,7 +25,7 @@ public void TestMethod() { } [Theory] [MemberData(nameof(CreateFactsInNonPublicClassCases))] - public async void ForFriendOrInternalClass_FindsError( + public async Task ForFriendOrInternalClass_FindsError( string attribute, string modifier) { @@ -44,7 +45,7 @@ public void TestMethod() {{ }} [Theory] [InlineData("")] [InlineData("public")] - public async void ForPartialClassInSameFile_WhenClassIsPublic_DoesNotFindError(string modifier) + public async Task ForPartialClassInSameFile_WhenClassIsPublic_DoesNotFindError(string modifier) { var source = $@" public partial class TestClass {{ @@ -63,7 +64,7 @@ public void Test2() {{ }} [Theory] [InlineData("")] [InlineData("public")] - public async void ForPartialClassInOtherFiles_WhenClassIsPublic_DoesNotFindError(string modifier) + public async Task ForPartialClassInOtherFiles_WhenClassIsPublic_DoesNotFindError(string modifier) { var source1 = @" public partial class TestClass { @@ -83,7 +84,7 @@ public void Test2() {{ }} [InlineData("", "")] [InlineData("", "internal")] [InlineData("internal", "internal")] - public async void ForPartialClassInSameFile_WhenClassIsNonPublic_FindsError( + public async Task ForPartialClassInSameFile_WhenClassIsNonPublic_FindsError( string modifier1, string modifier2) { @@ -110,7 +111,7 @@ public void Test2() {{ }} [InlineData("", "")] [InlineData("", "internal")] [InlineData("internal", "internal")] - public async void ForPartialClassInOtherFiles_WhenClassIsNonPublic_FindsError( + public async Task ForPartialClassInOtherFiles_WhenClassIsNonPublic_FindsError( string modifier1, string modifier2) { diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/TestClassShouldHaveTFixtureArgumentTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/TestClassShouldHaveTFixtureArgumentTests.cs index ee5f86f6..ad33f9ac 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/TestClassShouldHaveTFixtureArgumentTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/TestClassShouldHaveTFixtureArgumentTests.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; @@ -12,7 +13,7 @@ public class TestClassShouldHaveTFixtureArgumentTests [Theory] [MemberData(nameof(CreateFactsInNonPublicClassCases))] - public async void ForClassWithIClassFixtureWithoutConstructorArg_FindsInfo( + public async Task ForClassWithIClassFixtureWithoutConstructorArg_FindsInfo( string attribute, string @interface) { @@ -34,7 +35,7 @@ public void TestMethod() {{ }} [Theory] [MemberData(nameof(CreateFactsInNonPublicClassCases))] - public async void ForClassWithIClassFixtureWithConstructorArg_DonnotFindInfo( + public async Task ForClassWithIClassFixtureWithConstructorArg_DonnotFindInfo( string attribute, string @interface) { @@ -53,7 +54,7 @@ public void TestMethod() {{ }} [Theory] [MemberData(nameof(CreateFactsInNonPublicClassCases))] - public async void ForClassWithIClassFixtureWithConstructorMultipleArg_DonnotFindInfo( + public async Task ForClassWithIClassFixtureWithConstructorMultipleArg_DonnotFindInfo( string attribute, string @interface) { diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodCannotHaveOverloadsTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodCannotHaveOverloadsTests.cs index 45ce8423..3697d02b 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodCannotHaveOverloadsTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodCannotHaveOverloadsTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class TestMethodCannotHaveOverloadsTests { [Fact] - public async void FindsErrors_ForInstanceMethodOverloads_InSameInstanceClass() + public async Task FindsErrors_ForInstanceMethodOverloads_InSameInstanceClass() { var source = @" public class TestClass { @@ -33,7 +34,7 @@ public void TestMethod(int a) { } } [Fact] - public async void FindsErrors_ForStaticMethodOverloads_InSameStaticClass() + public async Task FindsErrors_ForStaticMethodOverloads_InSameStaticClass() { var source = @" public static class TestClass { @@ -61,7 +62,7 @@ public static void TestMethod(int a) { } } [Fact] - public async void FindsErrors_ForInstanceMethodOverload_InDerivedClass() + public async Task FindsErrors_ForInstanceMethodOverload_InDerivedClass() { var source1 = @" public class TestClass : BaseClass { @@ -93,7 +94,7 @@ public void TestMethod() { } } [Fact] - public async void FindsError_ForStaticAndInstanceMethodOverload() + public async Task FindsError_ForStaticAndInstanceMethodOverload() { var source1 = @" public class TestClass : BaseClass { @@ -116,7 +117,7 @@ public static void TestMethod() { } } [Fact] - public async void DoesNotFindError_ForMethodOverrides() + public async Task DoesNotFindError_ForMethodOverrides() { var source1 = @" public class BaseClass { diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodMustNotHaveMultipleFactAttributesTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodMustNotHaveMultipleFactAttributesTests.cs index 6b45d97f..2a9259fe 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodMustNotHaveMultipleFactAttributesTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodMustNotHaveMultipleFactAttributesTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; @@ -6,7 +7,7 @@ public class TestMethodMustNotHaveMultipleFactAttributesTests [Theory] [InlineData("Fact")] [InlineData("Theory")] - public async void DoesNotFindErrorForMethodWithSingleAttribute(string attribute) + public async Task DoesNotFindErrorForMethodWithSingleAttribute(string attribute) { var source = $@" public class TestClass {{ @@ -18,7 +19,7 @@ public void TestMethod() {{ }} } [Fact] - public async void FindsErrorForMethodWithTheoryAndFact() + public async Task FindsErrorForMethodWithTheoryAndFact() { var source = @" public class TestClass { @@ -35,7 +36,7 @@ public void TestMethod() { } } [Fact] - public async void FindsErrorForMethodWithCustomFactAttribute() + public async Task FindsErrorForMethodWithCustomFactAttribute() { var source1 = @" public class TestClass { diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodShouldNotBeSkippedTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodShouldNotBeSkippedTests.cs index d2eaa451..4143b9ef 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodShouldNotBeSkippedTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodShouldNotBeSkippedTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Verify = CSharpVerifier; @@ -7,7 +8,7 @@ public class TestMethodShouldNotBeSkippedTests [Theory] [InlineData("Fact")] [InlineData("Theory")] - public async void DoesNotFindErrorForNotSkippedTest(string attribute) + public async Task DoesNotFindErrorForNotSkippedTest(string attribute) { var source = $@" public class TestClass {{ @@ -21,7 +22,7 @@ public void TestMethod() {{ }} [Theory] [InlineData("Fact")] [InlineData("Theory")] - public async void FindsErrorForSkippedTests(string attribute) + public async Task FindsErrorForSkippedTests(string attribute) { var source = $@" class TestClass {{ diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodSupportedReturnTypeTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodSupportedReturnTypeTests.cs index f8a2da8f..b5a81528 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodSupportedReturnTypeTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/TestMethodSupportedReturnTypeTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Xunit; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class TestMethodSupportedReturnTypeTests { [Fact] - public async void NonTestMethod() + public async Task NonTestMethod() { var source = @" public class NonTestClass { @@ -20,7 +21,7 @@ public int Add(int x, int y) { [Theory] [InlineData("int")] [InlineData("object")] - public async void InvalidReturnType(string returnType) + public async Task InvalidReturnType(string returnType) { var sourceTemplate = @" using Xunit; @@ -54,7 +55,7 @@ public class TestClass {{ } [Fact] - public async void V2DoesNotSupportValueTask() + public async Task V2DoesNotSupportValueTask() { var source = @" using System.Threading.Tasks; @@ -80,7 +81,7 @@ public ValueTask TestMethod() { [Theory] [InlineData("MyTest")] [InlineData("MyTestAttribute")] - public async void CustomTestAttribute(string attribute) + public async Task CustomTestAttribute(string attribute) { var sourceTemplate = @" using Xunit; diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/TheoryDataRowArgumentsShouldBeSerializableTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/TheoryDataRowArgumentsShouldBeSerializableTests.cs index fa423d91..f59f7440 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/TheoryDataRowArgumentsShouldBeSerializableTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/TheoryDataRowArgumentsShouldBeSerializableTests.cs @@ -50,7 +50,7 @@ public void TestMethod() { [InlineData("DateOnly.MinValue", "DateOnly")] [InlineData("TimeOnly.MinValue", "TimeOnly")] #endif - public async void IntrinsicallySerializableValue_DoesNotTrigger( + public async Task IntrinsicallySerializableValue_DoesNotTrigger( string value, string type) { @@ -80,7 +80,7 @@ public IEnumerable MyMethod() {{ [Theory] [InlineData("SerializableClass")] [InlineData("SerializableStruct")] - public async void IXunitSerializableValue_DoesNotTrigger(string type) + public async Task IXunitSerializableValue_DoesNotTrigger(string type) { var source = $@" #nullable enable @@ -120,7 +120,7 @@ public void Serialize(IXunitSerializationInfo info) {{ }} [InlineData("Func", "Func?", "Func?")] [InlineData("NonSerializableSealedClass", "NonSerializableSealedClass?", "NonSerializableSealedClass?")] [InlineData("NonSerializableStruct", "NonSerializableStruct", "NonSerializableStruct?")] - public async void KnownNonSerializableValue_Triggers1046( + public async Task KnownNonSerializableValue_Triggers1046( string type, string defaultValueType, string nullValueType) @@ -186,7 +186,7 @@ public struct NonSerializableStruct {{ }}"; [InlineData("Dictionary")] [InlineData("IPossiblySerializableInterface")] [InlineData("PossiblySerializableUnsealedClass")] - public async void MaybeNonSerializableValue_Triggers1047(string type) + public async Task MaybeNonSerializableValue_Triggers1047(string type) { var source = $@" #nullable enable diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/TheoryDataTypeArgumentsShouldBeSerializableTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/TheoryDataTypeArgumentsShouldBeSerializableTests.cs index e291cd42..b74b418f 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/TheoryDataTypeArgumentsShouldBeSerializableTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/TheoryDataTypeArgumentsShouldBeSerializableTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; @@ -68,7 +69,7 @@ public static TheoryData TheoryDataMembersWithDiscoveryE public sealed class NoDiagnostic : TheoryDataTypeArgumentsShouldBeSerializableTests { [Fact] - public async void GivenMethodWithoutAttributes_FindsNoDiagnostic() + public async Task GivenMethodWithoutAttributes_FindsNoDiagnostic() { var source = @" public class TestClass { @@ -79,7 +80,7 @@ public void TestMethod() { } } [Fact] - public async void GivenFact_FindsNoDiagnostic() + public async Task GivenFact_FindsNoDiagnostic() { var source = @" public class TestClass { @@ -91,7 +92,7 @@ public void TestMethod() { } } [Fact] - public async void GivenTheory_WithoutTheoryDataAsDataSource_FindsNoDiagnostic() + public async Task GivenTheory_WithoutTheoryDataAsDataSource_FindsNoDiagnostic() { var source = @" using System; @@ -178,7 +179,7 @@ public class DataSource : IEnumerable { #endif - public async void GivenTheory_WithSerializableTheoryDataMember_FindsNoDiagnostic( + public async Task GivenTheory_WithSerializableTheoryDataMember_FindsNoDiagnostic( string member, string attribute, string type) @@ -213,7 +214,7 @@ public enum SerializableEnumeration {{ Zero }}"; [MemberData(nameof(TheoryDataMembers), "SerializableStruct[]")] [MemberData(nameof(TheoryDataMembers), "SerializableStruct?")] [MemberData(nameof(TheoryDataMembers), "SerializableStruct?[]")] - public async void GivenTheory_WithIXunitSerializableTheoryDataMember_FindsNoDiagnostic( + public async Task GivenTheory_WithIXunitSerializableTheoryDataMember_FindsNoDiagnostic( string member, string attribute, string type) @@ -261,7 +262,7 @@ public void Serialize(IXunitSerializationInfo info) {{ }} [MemberData(nameof(TheoryDataMembers), "object[]")] [MemberData(nameof(TheoryDataMembers), "IPossiblySerializableInterface")] [MemberData(nameof(TheoryDataMembers), "PossiblySerializableUnsealedClass")] - public async void GivenTheory_WithNonSerializableTheoryDataMember_WithDiscoveryEnumerationDisabledForTheory_FindsNoDiagnostic( + public async Task GivenTheory_WithNonSerializableTheoryDataMember_WithDiscoveryEnumerationDisabledForTheory_FindsNoDiagnostic( string member, string attribute, string type) @@ -298,7 +299,7 @@ public class PossiblySerializableUnsealedClass {{ }}"; [MemberData(nameof(TheoryDataMembersWithDiscoveryEnumerationDisabled), "object[]")] [MemberData(nameof(TheoryDataMembersWithDiscoveryEnumerationDisabled), "IPossiblySerializableInterface")] [MemberData(nameof(TheoryDataMembersWithDiscoveryEnumerationDisabled), "PossiblySerializableUnsealedClass")] - public async void GivenTheory_WithNonSerializableTheoryDataMember_WithDiscoveryEnumerationDisabledForMemberData_FindsNoDiagnostic( + public async Task GivenTheory_WithNonSerializableTheoryDataMember_WithDiscoveryEnumerationDisabledForMemberData_FindsNoDiagnostic( string member, string attribute, string type) @@ -328,7 +329,7 @@ public class PossiblySerializableUnsealedClass {{ }}"; [Theory] [MemberData(nameof(TheoryDataClass), "int", "double", "string")] - public async void GivenTheory_WithSerializableTheoryDataClass_FindsNoDiagnostic( + public async Task GivenTheory_WithSerializableTheoryDataClass_FindsNoDiagnostic( string source, string _1, string _2, @@ -340,7 +341,7 @@ public async void GivenTheory_WithSerializableTheoryDataClass_FindsNoDiagnostic( [Theory] [MemberData(nameof(TheoryDataClass), "Theory(DisableDiscoveryEnumeration = true)", "Action", "TimeZoneInfo", "TimeZoneInfo.TransitionTime")] [MemberData(nameof(TheoryDataClass), "Theory(DisableDiscoveryEnumeration = true)", "object[]", "Array", "IDisposable")] - public async void GivenTheory_WithNonSerializableTheoryDataClass_WithDiscoveryEnumerationDisabled_FindsNoDiagnostic( + public async Task GivenTheory_WithNonSerializableTheoryDataClass_WithDiscoveryEnumerationDisabled_FindsNoDiagnostic( string source, string _1, string _2, @@ -365,7 +366,7 @@ public sealed class X1044_AvoidUsingTheoryDataTypeArgumentsThatAreNotSerializabl [MemberData(nameof(TheoryDataMembers), "NonSerializableStruct[]")] [MemberData(nameof(TheoryDataMembers), "NonSerializableStruct?")] [MemberData(nameof(TheoryDataMembers), "NonSerializableStruct?[]")] - public async void GivenTheory_WithNonSerializableTheoryDataMember_FindsDiagnostic( + public async Task GivenTheory_WithNonSerializableTheoryDataMember_FindsDiagnostic( string member, string attribute, string type) @@ -398,7 +399,7 @@ public struct NonSerializableStruct {{ }}"; [Theory] [MemberData(nameof(TheoryDataClass), "Action", "TimeZoneInfo", "TimeZoneInfo.TransitionTime")] - public async void GivenTheory_WithNonSerializableTheoryDataClass_FindsDiagnostic( + public async Task GivenTheory_WithNonSerializableTheoryDataClass_FindsDiagnostic( string source, string type1, string type2, @@ -452,7 +453,7 @@ public sealed class X1045_AvoidUsingTheoryDataTypeArgumentsThatMightNotBeSeriali [MemberData(nameof(TheoryDataMembers), "IPossiblySerializableInterface[]")] [MemberData(nameof(TheoryDataMembers), "PossiblySerializableUnsealedClass")] [MemberData(nameof(TheoryDataMembers), "PossiblySerializableUnsealedClass[]")] - public async void GivenTheory_WithPossiblySerializableTheoryDataMember_FindsDiagnostic( + public async Task GivenTheory_WithPossiblySerializableTheoryDataMember_FindsDiagnostic( string member, string attribute, string type) @@ -486,7 +487,7 @@ public class PossiblySerializableUnsealedClass {{ }}"; [Theory] [MemberData(nameof(TheoryDataClass), "object[]", "Array", "IDisposable")] - public async void GivenTheory_WithPossiblySerializableTheoryDataClass_FindsDiagnostic( + public async Task GivenTheory_WithPossiblySerializableTheoryDataClass_FindsDiagnostic( string source, string type1, string type2, diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/TheoryMethodMustHaveTestDataTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/TheoryMethodMustHaveTestDataTests.cs index 2141cfa3..5a09b952 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/TheoryMethodMustHaveTestDataTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/TheoryMethodMustHaveTestDataTests.cs @@ -1,10 +1,11 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; public class TheoryMethodMustHaveTestDataTests { [Fact] - public async void DoesNotFindErrorForFactMethod() + public async Task DoesNotFindErrorForFactMethod() { var source = @" public class TestClass { @@ -19,7 +20,7 @@ public void TestMethod() { } [InlineData("InlineData")] [InlineData("MemberData(\"\")")] [InlineData("ClassData(typeof(string))")] - public async void DoesNotFindErrorForTheoryMethodWithDataAttributes(string dataAttribute) + public async Task DoesNotFindErrorForTheoryMethodWithDataAttributes(string dataAttribute) { var source = $@" public class TestClass {{ @@ -32,7 +33,7 @@ public void TestMethod() {{ }} } [Fact] - public async void FindsErrorForTheoryMethodMissingData() + public async Task FindsErrorForTheoryMethodMissingData() { var source = @" class TestClass { diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/TheoryMethodShouldHaveParametersTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/TheoryMethodShouldHaveParametersTests.cs index 3a880d1e..3c0a246a 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/TheoryMethodShouldHaveParametersTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/TheoryMethodShouldHaveParametersTests.cs @@ -1,10 +1,11 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; public class TheoryMethodShouldHaveParametersTests { [Fact] - public async void DoesNotFindErrorForFactMethod() + public async Task DoesNotFindErrorForFactMethod() { var source = @" public class TestClass { @@ -16,7 +17,7 @@ public void TestMethod() { } } [Fact] - public async void DoesNotFindErrorForTheoryMethodWithParameters() + public async Task DoesNotFindErrorForTheoryMethodWithParameters() { var source = @" public class TestClass { @@ -28,7 +29,7 @@ public void TestMethod(string s) { } } [Fact] - public async void FindsErrorForTheoryMethodWithoutParameters() + public async Task FindsErrorForTheoryMethodWithoutParameters() { var source = @" class TestClass { diff --git a/src/xunit.analyzers.tests/Analyzers/X1000/TheoryMethodShouldUseAllParametersTests.cs b/src/xunit.analyzers.tests/Analyzers/X1000/TheoryMethodShouldUseAllParametersTests.cs index d1f7f02a..9b5df85e 100644 --- a/src/xunit.analyzers.tests/Analyzers/X1000/TheoryMethodShouldUseAllParametersTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X1000/TheoryMethodShouldUseAllParametersTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class TheoryMethodShouldUseAllParametersTests { [Fact] - public async void FindsWarning_ParameterNotReferenced() + public async Task FindsWarning_ParameterNotReferenced() { var source = @" using Xunit; @@ -25,7 +26,7 @@ void TestMethod(int unused) { } } [Fact] - public async void FindsWarning_ParameterUnread() + public async Task FindsWarning_ParameterUnread() { var source = @" using System; @@ -49,7 +50,7 @@ void TestMethod(int unused) { } [Fact] - public async void FindsWarning_MultipleUnreadParameters() + public async Task FindsWarning_MultipleUnreadParameters() { var source = @" using Xunit; @@ -81,7 +82,7 @@ void TestMethod(int foo, int bar, int baz) { } } [Fact] - public async void FindsWarning_SomeUnreadParameters() + public async Task FindsWarning_SomeUnreadParameters() { var source = @" using System; @@ -112,7 +113,7 @@ void TestMethod(int foo, int bar, int baz) { } [Fact] - public async void FindsWarning_ExpressionBodiedMethod() + public async Task FindsWarning_ExpressionBodiedMethod() { var source = @" using Xunit; @@ -132,7 +133,7 @@ class TestClass { } [Fact] - public async void DoesNotFindWarning_ParameterRead() + public async Task DoesNotFindWarning_ParameterRead() { var source = @" using System; @@ -149,7 +150,7 @@ void TestMethod(int used) { } [Fact] - public async void DoesNotFindWarning_ParameterCapturedAsOutParameterInMockSetup() + public async Task DoesNotFindWarning_ParameterCapturedAsOutParameterInMockSetup() { var source = @" using System; @@ -169,7 +170,7 @@ void TestMethod(string used, int usedOut) { } [Fact] - public async void DoesNotFindWarning_ExpressionBodiedMethod() + public async Task DoesNotFindWarning_ExpressionBodiedMethod() { var source = @" using Xunit; @@ -183,7 +184,7 @@ class TestClass { } [Fact] - public async void DoesNotFindWarning_WhenParameterIsDiscardNamed() + public async Task DoesNotFindWarning_WhenParameterIsDiscardNamed() { var source = @" using System; @@ -209,7 +210,7 @@ void TestMethod(int used, string _, object _1, DateTime _42, double _a) } [Fact] - public async void DoesNotCrash_MethodWithoutBody() + public async Task DoesNotCrash_MethodWithoutBody() { var source = @" using Xunit; diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertCollectionContainsShouldNotUseBoolCheckTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertCollectionContainsShouldNotUseBoolCheckTests.cs index 73979b21..1b8900e2 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertCollectionContainsShouldNotUseBoolCheckTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertCollectionContainsShouldNotUseBoolCheckTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers; using Verify = CSharpVerifier; @@ -18,7 +19,7 @@ public class AssertCollectionContainsShouldNotUseBoolCheckTests [Theory] [MemberData(nameof(Collections))] - public async void FindsWarningForTrueCollectionContainsCheck(string collection) + public async Task FindsWarningForTrueCollectionContainsCheck(string collection) { var source = $@" class TestClass {{ @@ -37,7 +38,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Collections))] - public async void FindsWarningForFalseCollectionContainsCheck(string collection) + public async Task FindsWarningForFalseCollectionContainsCheck(string collection) { var source = $@" class TestClass {{ @@ -56,7 +57,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Enumerables))] - public async void FindsWarningForTrueLinqContainsCheck(string enumerable) + public async Task FindsWarningForTrueLinqContainsCheck(string enumerable) { var source = $@" using System.Linq; @@ -77,7 +78,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Enumerables))] - public async void FindsWarningForTrueLinqContainsCheckWithEqualityComparer(string enumerable) + public async Task FindsWarningForTrueLinqContainsCheckWithEqualityComparer(string enumerable) { var source = $@" using System.Linq; @@ -98,7 +99,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Enumerables))] - public async void FindsWarningForFalseLinqContainsCheck(string enumerable) + public async Task FindsWarningForFalseLinqContainsCheck(string enumerable) { var source = $@" using System.Linq; @@ -119,7 +120,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Enumerables))] - public async void FindsWarningForFalseLinqContainsCheckWithEqualityComparer(string enumerable) + public async Task FindsWarningForFalseLinqContainsCheckWithEqualityComparer(string enumerable) { var source = $@" using System.Linq; @@ -140,7 +141,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Collections))] - public async void DoesNotFindWarningForTrueCollectionContainsCheckWithAssertionMessage(string collection) + public async Task DoesNotFindWarningForTrueCollectionContainsCheckWithAssertionMessage(string collection) { var source = $@" class TestClass {{ @@ -154,7 +155,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Collections))] - public async void DoesNotFindWarningForFalseCollectionContainsCheckWithAssertionMessage(string collection) + public async Task DoesNotFindWarningForFalseCollectionContainsCheckWithAssertionMessage(string collection) { var source = $@" class TestClass {{ @@ -168,7 +169,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Enumerables))] - public async void DoesNotFindWarningForTrueLinqContainsCheckWithAssertionMessage(string enumerable) + public async Task DoesNotFindWarningForTrueLinqContainsCheckWithAssertionMessage(string enumerable) { var source = $@" using System.Linq; @@ -184,7 +185,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Enumerables))] - public async void DoesNotFindWarningForFalseLinqContainsCheckWithAssertionMessage(string enumerable) + public async Task DoesNotFindWarningForFalseLinqContainsCheckWithAssertionMessage(string enumerable) { var source = $@" using System.Linq; @@ -199,7 +200,7 @@ void TestMethod() {{ } [Fact] - public async void DoesNotCrashForCollectionWithDifferentTypeParametersThanICollectionImplementation_ZeroParameters() + public async Task DoesNotCrashForCollectionWithDifferentTypeParametersThanICollectionImplementation_ZeroParameters() { var source = @" using System.Collections.Generic; @@ -216,7 +217,7 @@ void TestMethod() { } [Fact] - public async void DoesNotCrashForCollectionWithDifferentTypeParametersThanICollectionImplementation_TwoParameters() + public async Task DoesNotCrashForCollectionWithDifferentTypeParametersThanICollectionImplementation_TwoParameters() { var source = @" using System.Collections.Generic; diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEmptyCollectionCheckShouldNotBeUsedTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEmptyCollectionCheckShouldNotBeUsedTests.cs index 061e76c1..b53014b4 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEmptyCollectionCheckShouldNotBeUsedTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEmptyCollectionCheckShouldNotBeUsedTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; @@ -17,7 +18,7 @@ public class AssertEmptyCollectionCheckShouldNotBeUsedTests [Theory] [MemberData(nameof(Collections))] - public async void FindsWarningForCollectionCheckWithoutAction(string collection) + public async Task FindsWarningForCollectionCheckWithoutAction(string collection) { var source = $@" class TestClass {{ @@ -32,7 +33,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Collections))] - public async void DoesNotFindWarningForCollectionCheckWithAction(string collection) + public async Task DoesNotFindWarningForCollectionCheckWithAction(string collection) { var source = $@" class TestClass {{ diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEnumerableAnyCheckShouldNotBeUsedForCollectionContainsCheckTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEnumerableAnyCheckShouldNotBeUsedForCollectionContainsCheckTests.cs index 834fab68..7e01323b 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEnumerableAnyCheckShouldNotBeUsedForCollectionContainsCheckTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEnumerableAnyCheckShouldNotBeUsedForCollectionContainsCheckTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers; using Verify = CSharpVerifier; @@ -12,7 +13,7 @@ public class AssertEnumerableAnyCheckShouldNotBeUsedForCollectionContainsCheckTe [Theory] [MemberData(nameof(Methods))] - public async void FindsWarning_ForLinqAnyCheck(string method) + public async Task FindsWarning_ForLinqAnyCheck(string method) { var source = $@" using System.Linq; diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualGenericShouldNotBeUsedForStringValueTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualGenericShouldNotBeUsedForStringValueTests.cs index bcd22e95..c0274113 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualGenericShouldNotBeUsedForStringValueTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualGenericShouldNotBeUsedForStringValueTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; @@ -16,7 +17,7 @@ public class AssertEqualGenericShouldNotBeUsedForStringValueTests [Theory] [MemberData(nameof(Data))] - public async void DoesNotFindWarningForStringEqualityCheckWithoutGenericType( + public async Task DoesNotFindWarningForStringEqualityCheckWithoutGenericType( string expected, string value) { @@ -32,7 +33,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Data))] - public async void FindsWarningForStringEqualityCheckWithGenericType( + public async Task FindsWarningForStringEqualityCheckWithGenericType( string expected, string value) { @@ -48,7 +49,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Data))] - public async void FindsWarningForStrictStringEqualityCheck( + public async Task FindsWarningForStrictStringEqualityCheck( string expected, string value) { @@ -64,7 +65,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Data))] - public async void FindsWarningForStrictStringEqualityCheckWithGenericType( + public async Task FindsWarningForStrictStringEqualityCheckWithGenericType( string expected, string value) { diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualLiteralValueShouldBeFirstTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualLiteralValueShouldBeFirstTests.cs index dac50526..273101a3 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualLiteralValueShouldBeFirstTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualLiteralValueShouldBeFirstTests.cs @@ -1,10 +1,11 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; public class AssertEqualLiteralValueShouldBeFirstTests { [Fact] - public async void DoesNotFindWarningWhenConstantOrLiteralUsedForBothArguments() + public async Task DoesNotFindWarningWhenConstantOrLiteralUsedForBothArguments() { var source = @" class TestClass { @@ -31,7 +32,7 @@ void TestMethod() { [Theory] [MemberData(nameof(TypesAndValues))] - public async void DoesNotFindWarningForExpectedConstantOrLiteralValueAsFirstArgument( + public async Task DoesNotFindWarningForExpectedConstantOrLiteralValueAsFirstArgument( string type, string value) { @@ -47,7 +48,7 @@ void TestMethod() {{ } [Fact] - public async void DoesNotFindWarningForConstantsUsedInStringConstructorAsFirstArgument() + public async Task DoesNotFindWarningForConstantsUsedInStringConstructorAsFirstArgument() { var source = @" class TestClass { @@ -61,7 +62,7 @@ void TestMethod() { [Theory] [MemberData(nameof(TypesAndValues))] - public async void FindsWarningForExpectedConstantOrLiteralValueAsSecondArgument( + public async Task FindsWarningForExpectedConstantOrLiteralValueAsSecondArgument( string type, string value) { @@ -84,7 +85,7 @@ void TestMethod() {{ [Theory] [InlineData(true)] [InlineData(false)] - public async void DoesNotFindWarningForExpectedConstantOrLiteralValueAsNamedExpectedArgument(bool useAlternateForm) + public async Task DoesNotFindWarningForExpectedConstantOrLiteralValueAsNamedExpectedArgument(bool useAlternateForm) { var prefix = useAlternateForm ? "@" : ""; var source = $@" @@ -100,7 +101,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(TypesAndValues))] - public async void FindsWarningForExpectedConstantOrLiteralValueAsNamedExpectedArgument( + public async Task FindsWarningForExpectedConstantOrLiteralValueAsNamedExpectedArgument( string type, string value) { @@ -125,7 +126,7 @@ void TestMethod() {{ [InlineData("{|CS1501:Equal|}", "expected", "expected")] [InlineData("{|CS1501:Equal|}", "actual", "actual")] [InlineData("Equal", "{|CS1739:foo|}", "bar")] - public async void DoesNotFindWarningWhenArgumentsAreNotNamedCorrectly( + public async Task DoesNotFindWarningWhenArgumentsAreNotNamedCorrectly( string methodName, string firstArgumentName, string secondArgumentName) diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualPrecisionShouldBeInRangeTest.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualPrecisionShouldBeInRangeTest.cs index 7521d40b..254c9d9d 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualPrecisionShouldBeInRangeTest.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualPrecisionShouldBeInRangeTest.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Verify = CSharpVerifier; @@ -17,7 +18,7 @@ void TestMethod() {{ [InlineData(8)] [InlineData(14)] [InlineData(15)] - public async void DoesNotFindError_ForDoubleArgumentWithPrecisionProvidedInRange(int precision) + public async Task DoesNotFindError_ForDoubleArgumentWithPrecisionProvidedInRange(int precision) { var source = string.Format( Template, @@ -34,7 +35,7 @@ public async void DoesNotFindError_ForDoubleArgumentWithPrecisionProvidedInRange [InlineData(16)] [InlineData(17000)] [InlineData(int.MaxValue)] - public async void FindsError_ForDoubleArgumentWithPrecisionProvidedOutOfRange(int precision) + public async Task FindsError_ForDoubleArgumentWithPrecisionProvidedOutOfRange(int precision) { var source = string.Format( Template, @@ -56,7 +57,7 @@ public async void FindsError_ForDoubleArgumentWithPrecisionProvidedOutOfRange(in [InlineData(14)] [InlineData(27)] [InlineData(28)] - public async void DoesNotFindError_ForDecimalArgumentWithPrecisionProvidedInRange(int precision) + public async Task DoesNotFindError_ForDecimalArgumentWithPrecisionProvidedInRange(int precision) { var source = string.Format( Template, @@ -73,7 +74,7 @@ public async void DoesNotFindError_ForDecimalArgumentWithPrecisionProvidedInRang [InlineData(29)] [InlineData(30000)] [InlineData(int.MaxValue)] - public async void FindsError_ForDecimalArgumentWithPrecisionProvidedOutOfRange(int precision) + public async Task FindsError_ForDecimalArgumentWithPrecisionProvidedOutOfRange(int precision) { var source = string.Format( Template, diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualShouldNotBeUsedForBoolLiteralCheckTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualShouldNotBeUsedForBoolLiteralCheckTests.cs index 26107a51..23012129 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualShouldNotBeUsedForBoolLiteralCheckTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualShouldNotBeUsedForBoolLiteralCheckTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Xunit.Analyzers; @@ -18,7 +19,7 @@ public class AssertEqualShouldNotBeUsedForBoolLiteralCheckTests [InlineData(Constants.Asserts.StrictEqual, Constants.Asserts.True)] [InlineData(Constants.Asserts.NotEqual, Constants.Asserts.False)] [InlineData(Constants.Asserts.NotStrictEqual, Constants.Asserts.False)] - public async void FindsWarning_ForFirstBoolLiteral( + public async Task FindsWarning_ForFirstBoolLiteral( string method, string replacement) { @@ -42,7 +43,7 @@ void TestMethod() {{ [Theory] [InlineData(Constants.Asserts.Equal, Constants.Asserts.False)] [InlineData(Constants.Asserts.NotEqual, Constants.Asserts.True)] - public async void FindsWarning_ForFirstBoolLiteral_WithCustomComparer( + public async Task FindsWarning_ForFirstBoolLiteral_WithCustomComparer( string method, string replacement) { @@ -65,7 +66,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForFirstBoolLiteral_ObjectOverload(string method) + public async Task DoesNotFindWarning_ForFirstBoolLiteral_ObjectOverload(string method) { var source = $@" class TestClass {{ @@ -80,7 +81,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForOtherLiteral(string method) + public async Task DoesNotFindWarning_ForOtherLiteral(string method) { var source = $@" class TestClass {{ @@ -95,7 +96,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForSecondBoolLiteral(string method) + public async Task DoesNotFindWarning_ForSecondBoolLiteral(string method) { var source = $@" class TestClass {{ diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualShouldNotBeUsedForCollectionSizeCheckTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualShouldNotBeUsedForCollectionSizeCheckTests.cs index 989761d3..2d8035ee 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualShouldNotBeUsedForCollectionSizeCheckTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualShouldNotBeUsedForCollectionSizeCheckTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Xunit.Analyzers; @@ -32,7 +33,7 @@ public class AssertEqualShouldNotBeUsedForCollectionSizeCheckTests [Theory] [MemberData(nameof(AllowedCollections))] - public async void AllowedCollection_DoesNotTrigger(string collection) + public async Task AllowedCollection_DoesNotTrigger(string collection) { var source = $@" using System.Linq; @@ -51,7 +52,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(AllowedCollections))] [MemberData(nameof(DisallowedCollections))] - public async void AllowedCheck_DoesNotTrigger(string collection) + public async Task AllowedCheck_DoesNotTrigger(string collection) { // Anything that's non-zero for Equal/NotEqual and non-one for Equal is allowed var source = $@" @@ -71,7 +72,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(DisallowedCollections))] - public async void InvalidCheckWithConcreteType_Triggers(string collection) + public async Task InvalidCheckWithConcreteType_Triggers(string collection) { var source = $@" using System.Linq; @@ -107,7 +108,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(DisallowedCollectionInterfaces))] - public async void InvalidCheckWithInterfaceType_Triggers(string @interface) + public async Task InvalidCheckWithInterfaceType_Triggers(string @interface) { var source = $@" using System.Collections; @@ -144,7 +145,7 @@ void TestMethod() {{ } [Fact] - public async void InvalidCheckWithCustomNonGenericCollection_Triggers() + public async Task InvalidCheckWithCustomNonGenericCollection_Triggers() { var source = @" using System.Collections; @@ -193,7 +194,7 @@ void TestMethod() { } [Fact] - public async void OverridingCountMethod_DoesNotTrigger() + public async Task OverridingCountMethod_DoesNotTrigger() { var source = @" using System.Collections.Generic; @@ -222,7 +223,7 @@ void TestMethod() { } [Fact] - public async void DoesNotCrash_ForNonIntArguments() + public async Task DoesNotCrash_ForNonIntArguments() { var source = @" class TestClass { diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualShouldNotBeUsedForNullCheckTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualShouldNotBeUsedForNullCheckTests.cs index 38c2bf31..ddc4abf4 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualShouldNotBeUsedForNullCheckTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualShouldNotBeUsedForNullCheckTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Xunit.Analyzers; @@ -22,7 +23,7 @@ public class AssertEqualShouldNotBeUsedForNullCheckTests [Theory] [MemberData(nameof(Methods_Equal_WithReplacement))] - public async void FindsWarning_ForFirstNullLiteral_StringOverload( + public async Task FindsWarning_ForFirstNullLiteral_StringOverload( string method, string replacement) { @@ -45,7 +46,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods_Equal_WithReplacement))] - public async void FindsWarning_ForFirstNullLiteral_StringOverload_WithCustomComparer( + public async Task FindsWarning_ForFirstNullLiteral_StringOverload_WithCustomComparer( string method, string replacement) { @@ -73,7 +74,7 @@ void TestMethod() {{ [InlineData(Constants.Asserts.NotEqual, Constants.Asserts.NotNull)] [InlineData(Constants.Asserts.NotStrictEqual, Constants.Asserts.NotNull)] [InlineData(Constants.Asserts.NotSame, Constants.Asserts.NotNull)] - public async void FindsWarning_ForFirstNullLiteral_ObjectOverload( + public async Task FindsWarning_ForFirstNullLiteral_ObjectOverload( string method, string replacement) { @@ -96,7 +97,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods_Equal_WithReplacement))] - public async void FindsWarning_ForFirstNullLiteral_ObjectOverload_WithCustomComparer( + public async Task FindsWarning_ForFirstNullLiteral_ObjectOverload_WithCustomComparer( string method, string replacement) { @@ -122,7 +123,7 @@ void TestMethod() {{ [InlineData(Constants.Asserts.NotEqual, Constants.Asserts.NotNull)] [InlineData(Constants.Asserts.StrictEqual, Constants.Asserts.Null)] [InlineData(Constants.Asserts.NotStrictEqual, Constants.Asserts.NotNull)] - public async void FindsWarning_ForFirstNullLiteral_GenericOverload( + public async Task FindsWarning_ForFirstNullLiteral_GenericOverload( string method, string replacement) { @@ -145,7 +146,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods_Equal_WithReplacement))] - public async void FindsWarning_ForFirstNullLiteral_GenericOverload_WithCustomComparer( + public async Task FindsWarning_ForFirstNullLiteral_GenericOverload_WithCustomComparer( string method, string replacement) { @@ -168,7 +169,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods_All))] - public async void DoesNotFindWarning_ForOtherLiteral(string method) + public async Task DoesNotFindWarning_ForOtherLiteral(string method) { var source = $@" class TestClass {{ @@ -183,7 +184,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods_All))] - public async void DoesNotFindWarning_ForSecondNullLiteral(string method) + public async Task DoesNotFindWarning_ForSecondNullLiteral(string method) { var source = $@" class TestClass {{ diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualsShouldNotBeUsedTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualsShouldNotBeUsedTests.cs index 8cd62495..57221740 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualsShouldNotBeUsedTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertEqualsShouldNotBeUsedTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Xunit.Analyzers; @@ -8,7 +9,7 @@ public class AssertEqualsShouldNotBeUsedTests [Theory] [InlineData(nameof(object.Equals), Constants.Asserts.Equal)] [InlineData(nameof(object.ReferenceEquals), Constants.Asserts.Same)] - public async void FindsHiddenDiagnosticWhenProhibitedMethodIsUsed( + public async Task FindsHiddenDiagnosticWhenProhibitedMethodIsUsed( string method, string replacement) { diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertIsTypeShouldNotBeUsedForAbstractTypeTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertIsTypeShouldNotBeUsedForAbstractTypeTests.cs index 3e4d244b..00b37865 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertIsTypeShouldNotBeUsedForAbstractTypeTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertIsTypeShouldNotBeUsedForAbstractTypeTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Verify = CSharpVerifier; @@ -12,7 +13,7 @@ public class AssertIsTypeShouldNotBeUsedForAbstractTypeTests [Theory] [MemberData(nameof(Methods))] - public async void FindsError_Interface( + public async Task FindsError_Interface( string method, string replacement) { @@ -37,7 +38,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void FindsError_AbstractClass( + public async Task FindsError_AbstractClass( string method, string replacement) { @@ -62,7 +63,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void FindsError_UsingStatic( + public async Task FindsError_UsingStatic( string method, string replacement) { @@ -87,7 +88,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindError_NonAbstractClass( + public async Task DoesNotFindError_NonAbstractClass( string method, string _) { diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertIsTypeShouldUseGenericOverloadTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertIsTypeShouldUseGenericOverloadTests.cs index 86a977c8..2e9bd5a5 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertIsTypeShouldUseGenericOverloadTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertIsTypeShouldUseGenericOverloadTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Verify = CSharpVerifier; @@ -13,7 +14,7 @@ public class AssertIsTypeShouldUseGenericOverloadTests [Theory] [MemberData(nameof(Methods))] - public async void FindsWarning_ForNonGenericCall(string method) + public async Task FindsWarning_ForNonGenericCall(string method) { var source = $@" class TestClass {{ @@ -33,7 +34,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForGenericCall(string method) + public async Task DoesNotFindWarning_ForGenericCall(string method) { var source = $@" class TestClass {{ diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertIsTypeShouldUseGenericOverloadTypeTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertIsTypeShouldUseGenericOverloadTypeTests.cs index 3b789ebe..d1789150 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertIsTypeShouldUseGenericOverloadTypeTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertIsTypeShouldUseGenericOverloadTypeTests.cs @@ -1,5 +1,6 @@ #if NETCOREAPP && ROSLYN_4_4_OR_GREATER // Static abstract methods are only supported on .NET with C# 11 +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Xunit; using Verify = CSharpVerifier; @@ -34,7 +35,7 @@ public void TestMethod() {{ }}"; [Fact] - public async void DoesNotFindWarning_ForStaticAbstractInterfaceMembers() + public async Task DoesNotFindWarning_ForStaticAbstractInterfaceMembers() { string source = string.Format(codeTemplate, string.Empty, methodCode); @@ -42,7 +43,7 @@ public async void DoesNotFindWarning_ForStaticAbstractInterfaceMembers() } [Fact] - public async void DoesNotFindWarning_ForNestedStaticAbstractInterfaceMembers() + public async Task DoesNotFindWarning_ForNestedStaticAbstractInterfaceMembers() { string source = string.Format(codeTemplate, methodCode, string.Empty); @@ -52,7 +53,7 @@ public async void DoesNotFindWarning_ForNestedStaticAbstractInterfaceMembers() [Theory] [InlineData("static", "", "{ }")] [InlineData("", "abstract", ";")] - public async void FindsWarning_ForNotStaticAbstractInterfaceMembers(string staticModifier, string abstractModifier, string methodBody) + public async Task FindsWarning_ForNotStaticAbstractInterfaceMembers(string staticModifier, string abstractModifier, string methodBody) { string source = $@" using Xunit; diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertNullShouldNotBeCalledOnValueTypesTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertNullShouldNotBeCalledOnValueTypesTests.cs index a46098d1..39bc9914 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertNullShouldNotBeCalledOnValueTypesTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertNullShouldNotBeCalledOnValueTypesTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Verify = CSharpVerifier; @@ -12,7 +13,7 @@ public class AssertNullShouldNotBeCalledOnValueTypesTests [Theory] [MemberData(nameof(Methods))] - public async void FindsWarning_ForValueType(string method) + public async Task FindsWarning_ForValueType(string method) { var source = $@" class TestClass {{ @@ -33,7 +34,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForNullableValueType(string method) + public async Task DoesNotFindWarning_ForNullableValueType(string method) { var source = $@" class TestClass {{ @@ -48,7 +49,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForNullableReferenceType(string method) + public async Task DoesNotFindWarning_ForNullableReferenceType(string method) { var source = $@" class TestClass {{ @@ -63,7 +64,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForClassConstrainedGenericTypes(string method) + public async Task DoesNotFindWarning_ForClassConstrainedGenericTypes(string method) { var source = $@" class Class where T : class {{ @@ -77,7 +78,7 @@ public void Method(T arg) {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForInterfaceConstrainedGenericTypes(string method) + public async Task DoesNotFindWarning_ForInterfaceConstrainedGenericTypes(string method) { var source = $@" interface IDo {{ }} @@ -95,7 +96,7 @@ public void Method(System.Collections.Generic.IEnumerable collection) {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForUnconstrainedGenericTypes(string method) + public async Task DoesNotFindWarning_ForUnconstrainedGenericTypes(string method) { var source = $@" class Class {{ @@ -112,7 +113,7 @@ public void Method(System.Collections.Generic.IEnumerable collection) {{ [Theory] [MemberData(nameof(Methods))] // https://github.com/xunit/xunit/issues/2395 - public async void DoesNotFindWarning_ForUserDefinedImplicitConversion(string method) + public async Task DoesNotFindWarning_ForUserDefinedImplicitConversion(string method) { var source = $@" public class TestClass diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertRegexMatchShouldNotUseBoolLiteralCheckTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertRegexMatchShouldNotUseBoolLiteralCheckTests.cs index f932f1df..9e9ea69a 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertRegexMatchShouldNotUseBoolLiteralCheckTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertRegexMatchShouldNotUseBoolLiteralCheckTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Xunit.Analyzers; @@ -13,7 +14,7 @@ public class AssertRegexMatchShouldNotUseBoolLiteralCheckTests [Theory] [MemberData(nameof(Methods_WithReplacement))] - public async void FindsWarning_ForStaticRegexIsMatch( + public async Task FindsWarning_ForStaticRegexIsMatch( string method, string replacement) { @@ -35,7 +36,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods_WithReplacement))] - public async void FindsWarning_ForInstanceRegexIsMatchWithInlineConstructedRegex( + public async Task FindsWarning_ForInstanceRegexIsMatchWithInlineConstructedRegex( string method, string replacement) { @@ -57,7 +58,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods_WithReplacement))] - public async void FindsWarning_ForInstanceRegexIsMatchWithConstructedRegexVariable( + public async Task FindsWarning_ForInstanceRegexIsMatchWithConstructedRegexVariable( string method, string replacement) { diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertSameShouldNotBeCalledOnValueTypesTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertSameShouldNotBeCalledOnValueTypesTests.cs index f302a04b..7c3af4d0 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertSameShouldNotBeCalledOnValueTypesTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertSameShouldNotBeCalledOnValueTypesTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Xunit.Analyzers; @@ -13,7 +14,7 @@ public class AssertSameShouldNotBeCalledOnValueTypesTests [Theory] [MemberData(nameof(Methods_WithReplacement))] - public async void FindsWarningForTwoValueParameters( + public async Task FindsWarningForTwoValueParameters( string method, string replacement) { @@ -36,7 +37,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods_WithReplacement))] - public async void FindsWarningForFirstValueParameters( + public async Task FindsWarningForFirstValueParameters( string method, string replacement) { @@ -59,7 +60,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods_WithReplacement))] - public async void FindsWarningForSecondValueParameters( + public async Task FindsWarningForSecondValueParameters( string method, string replacement) { @@ -83,7 +84,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods_WithReplacement))] // https://github.com/xunit/xunit/issues/2395 - public async void DoesNotFindWarningForUserDefinedImplicitConversion( + public async Task DoesNotFindWarningForUserDefinedImplicitConversion( string method, string replacement) { @@ -125,7 +126,7 @@ public MyBuggyInt() [Theory] [MemberData(nameof(Methods_WithReplacement))] - public async void FindsWarningForFirstValueParametersIfSecondIsNull( + public async Task FindsWarningForFirstValueParametersIfSecondIsNull( string method, string replacement) { @@ -147,7 +148,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods_WithReplacement))] - public async void FindsWarningForSecondValueParametersIfFirstIsNull( + public async Task FindsWarningForSecondValueParametersIfFirstIsNull( string method, string replacement) { diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertSingleShouldBeUsedForSingleParameterTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertSingleShouldBeUsedForSingleParameterTests.cs index 046720d9..56f18384 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertSingleShouldBeUsedForSingleParameterTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertSingleShouldBeUsedForSingleParameterTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; @@ -8,7 +9,7 @@ public class AssertSingleShouldBeUsedForSingleParameterTests #if NETCOREAPP3_0_OR_GREATER [InlineData("default(IAsyncEnumerable)")] #endif - public async void FindsInfo_ForSingleItemCollectionCheck(string collection) + public async Task FindsInfo_ForSingleItemCollectionCheck(string collection) { var code = @$" using Xunit; @@ -35,7 +36,7 @@ public void TestMethod() {{ #if NETCOREAPP3_0_OR_GREATER [InlineData("default(IAsyncEnumerable)")] #endif - public async void DoesNotFindInfo_ForMultipleItemCollectionCheck(string collection) + public async Task DoesNotFindInfo_ForMultipleItemCollectionCheck(string collection) { var code = @$" using Xunit; diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertStringEqualityCheckShouldNotUseBoolCheckTest.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertStringEqualityCheckShouldNotUseBoolCheckTest.cs index 28f8933c..59b0631c 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertStringEqualityCheckShouldNotUseBoolCheckTest.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertStringEqualityCheckShouldNotUseBoolCheckTest.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Xunit.Analyzers; @@ -35,7 +36,7 @@ public class AssertStringEqualityCheckShouldNotUseBoolCheckTest [Theory] [MemberData(nameof(Methods_WithReplacement))] - public async void FindsWarning_ForInstanceEqualsCheck( + public async Task FindsWarning_ForInstanceEqualsCheck( string method, string replacement) { @@ -57,7 +58,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(SupportedStringComparisons))] - public async void FindsWarning_ForTrueInstanceEqualsCheck_WithSupportedStringComparison(StringComparison comparison) + public async Task FindsWarning_ForTrueInstanceEqualsCheck_WithSupportedStringComparison(StringComparison comparison) { var source = $@" class TestClass {{ @@ -77,7 +78,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(UnsupportedStringComparisons))] - public async void DoesNotFindWarning_ForTrueInstanceEqualsCheck_WithUnsupportedStringComparison(StringComparison comparison) + public async Task DoesNotFindWarning_ForTrueInstanceEqualsCheck_WithUnsupportedStringComparison(StringComparison comparison) { var source = $@" class TestClass {{ @@ -91,7 +92,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(AllStringComparisons))] - public async void DoesNotFindWarning_ForFalseInstanceEqualsCheck_WithStringComparison(StringComparison comparison) + public async Task DoesNotFindWarning_ForFalseInstanceEqualsCheck_WithStringComparison(StringComparison comparison) { var source = $@" class TestClass {{ @@ -105,7 +106,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods_WithReplacement))] - public async void FindsWarning_ForStaticEqualsCheck( + public async Task FindsWarning_ForStaticEqualsCheck( string method, string replacement) { @@ -127,7 +128,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(SupportedStringComparisons))] - public async void FindsWarning_ForTrueStaticEqualsCheck_WithSupportedStringComparison(StringComparison comparison) + public async Task FindsWarning_ForTrueStaticEqualsCheck_WithSupportedStringComparison(StringComparison comparison) { var source = $@" class TestClass {{ @@ -147,7 +148,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(UnsupportedStringComparisons))] - public async void DoesNotFindWarning_ForTrueStaticEqualsCheck_WithUnsupportedStringComparison(StringComparison comparison) + public async Task DoesNotFindWarning_ForTrueStaticEqualsCheck_WithUnsupportedStringComparison(StringComparison comparison) { var source = $@" class TestClass {{ @@ -161,7 +162,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(AllStringComparisons))] - public async void DoesNotFindWarning_ForFalseStaticEqualsCheck_WithStringComparison(StringComparison comparison) + public async Task DoesNotFindWarning_ForFalseStaticEqualsCheck_WithStringComparison(StringComparison comparison) { var source = $@" class TestClass {{ diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertSubstringCheckShouldNotUseBoolCheckTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertSubstringCheckShouldNotUseBoolCheckTests.cs index afb2f397..a95cd007 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertSubstringCheckShouldNotUseBoolCheckTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertSubstringCheckShouldNotUseBoolCheckTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Xunit.Analyzers; @@ -14,7 +15,7 @@ public class AssertSubstringCheckShouldNotUseBoolCheckTests [Theory] [InlineData(Constants.Asserts.True, Constants.Asserts.Contains)] [InlineData(Constants.Asserts.False, Constants.Asserts.DoesNotContain)] - public async void FindsWarning_ForBooleanContainsCheck( + public async Task FindsWarning_ForBooleanContainsCheck( string method, string replacement) { @@ -36,7 +37,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForBooleanContainsCheck_WithUserMessage(string method) + public async Task DoesNotFindWarning_ForBooleanContainsCheck_WithUserMessage(string method) { var source = $@" class TestClass {{ @@ -49,7 +50,7 @@ void TestMethod() {{ } [Fact] - public async void FindsWarning_ForBooleanTrueStartsWithCheck() + public async Task FindsWarning_ForBooleanTrueStartsWithCheck() { var source = @" class TestClass { @@ -68,7 +69,7 @@ void TestMethod() { } [Fact] - public async void FindsWarning_ForBooleanTrueStartsWithCheck_WithStringComparison() + public async Task FindsWarning_ForBooleanTrueStartsWithCheck_WithStringComparison() { var source = @" class TestClass { @@ -87,7 +88,7 @@ void TestMethod() { } [Fact] - public async void DoesNotFindWarning_ForBooleanFalseStartsWithCheck() + public async Task DoesNotFindWarning_ForBooleanFalseStartsWithCheck() { var source = @" class TestClass { @@ -100,7 +101,7 @@ void TestMethod() { } [Fact] - public async void DoesNotFindWarning_ForBooleanFalseStartsWithCheck_WithStringComparison() + public async Task DoesNotFindWarning_ForBooleanFalseStartsWithCheck_WithStringComparison() { var source = @" class TestClass { @@ -114,7 +115,7 @@ void TestMethod() { [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForBooleanStartsWithCheck_WithUserMessage(string method) + public async Task DoesNotFindWarning_ForBooleanStartsWithCheck_WithUserMessage(string method) { var source = $@" class TestClass {{ @@ -128,7 +129,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForBooleanStartsWithCheck_WithStringComparison_AndUserMessage(string method) + public async Task DoesNotFindWarning_ForBooleanStartsWithCheck_WithStringComparison_AndUserMessage(string method) { var source = $@" class TestClass {{ @@ -142,7 +143,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForBooleanStartsWithCheck_WithBoolAndCulture(string method) + public async Task DoesNotFindWarning_ForBooleanStartsWithCheck_WithBoolAndCulture(string method) { var source = $@" class TestClass {{ @@ -156,7 +157,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForBooleanStartsWithCheck_WithBoolAndCulture_AndUserMessage(string method) + public async Task DoesNotFindWarning_ForBooleanStartsWithCheck_WithBoolAndCulture_AndUserMessage(string method) { var source = $@" class TestClass {{ @@ -169,7 +170,7 @@ void TestMethod() {{ } [Fact] - public async void FindsWarning_ForBooleanTrueEndsWithCheck() + public async Task FindsWarning_ForBooleanTrueEndsWithCheck() { var source = @" class TestClass { @@ -188,7 +189,7 @@ void TestMethod() { } [Fact] - public async void FindsWarning_ForBooleanTrueEndsWithCheck_WithStringComparison() + public async Task FindsWarning_ForBooleanTrueEndsWithCheck_WithStringComparison() { var source = @" class TestClass { @@ -207,7 +208,7 @@ void TestMethod() { } [Fact] - public async void DoesNotFindWarning_ForBooleanFalseEndsWithCheck() + public async Task DoesNotFindWarning_ForBooleanFalseEndsWithCheck() { var source = @" class TestClass { @@ -220,7 +221,7 @@ void TestMethod() { } [Fact] - public async void DoesNotFindWarning_ForBooleanFalseEndsWithCheck_WithStringComparison() + public async Task DoesNotFindWarning_ForBooleanFalseEndsWithCheck_WithStringComparison() { var source = @" class TestClass { @@ -234,7 +235,7 @@ void TestMethod() { [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForBooleanEndsWithCheck_WithUserMessage(string method) + public async Task DoesNotFindWarning_ForBooleanEndsWithCheck_WithUserMessage(string method) { var source = $@" class TestClass {{ @@ -248,7 +249,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForBooleanEndsWithCheck_WithStringComparison_AndUserMessage(string method) + public async Task DoesNotFindWarning_ForBooleanEndsWithCheck_WithStringComparison_AndUserMessage(string method) { var source = $@" class TestClass {{ @@ -262,7 +263,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForBooleanEndsWithCheck_WithBoolAndCulture(string method) + public async Task DoesNotFindWarning_ForBooleanEndsWithCheck_WithBoolAndCulture(string method) { var source = $@" class TestClass {{ @@ -276,7 +277,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(Methods))] - public async void DoesNotFindWarning_ForBooleanEndsWithCheck_WithBoolAndCulture_AndUserMessage(string method) + public async Task DoesNotFindWarning_ForBooleanEndsWithCheck_WithBoolAndCulture_AndUserMessage(string method) { var source = $@" class TestClass {{ diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertThrowsShouldNotBeUsedForAsyncThrowsCheckTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertThrowsShouldNotBeUsedForAsyncThrowsCheckTests.cs index 506424a0..b9f7113a 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertThrowsShouldNotBeUsedForAsyncThrowsCheckTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertThrowsShouldNotBeUsedForAsyncThrowsCheckTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; using Xunit; @@ -22,7 +23,7 @@ public class AssertThrowsShouldNotBeUsedForAsyncThrowsCheckTests [Theory] [MemberData(nameof(NonAsyncLambdas))] - public async void Throws_NonGeneric_WithNonAsyncLambda_FindsNoDiagnostics(string lambda) + public async Task Throws_NonGeneric_WithNonAsyncLambda_FindsNoDiagnostics(string lambda) { var source = $@" class TestClass {{ @@ -40,7 +41,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(NonAsyncLambdas))] - public async void Throws_Generic_WithNonAsyncLambda_FindsNoDiagnostics(string lambda) + public async Task Throws_Generic_WithNonAsyncLambda_FindsNoDiagnostics(string lambda) { var source = $@" class TestClass {{ @@ -58,7 +59,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(NonAsyncLambdas))] - public async void Throws_Generic_WithNamedArgumentException_WithNonAsyncLambda_FindsNoDiagnostics(string lambda) + public async Task Throws_Generic_WithNamedArgumentException_WithNonAsyncLambda_FindsNoDiagnostics(string lambda) { var source = $@" class TestClass {{ @@ -76,7 +77,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(AsyncLambdas))] - public async void Throws_NonGeneric_WithAsyncLambda_FindsDiagnostic(string lambda) + public async Task Throws_NonGeneric_WithAsyncLambda_FindsDiagnostic(string lambda) { var source = $@" class TestClass {{ @@ -106,7 +107,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(AsyncLambdas))] - public async void Throws_Generic_WithAsyncLambda_FindsDiagnostic(string lambda) + public async Task Throws_Generic_WithAsyncLambda_FindsDiagnostic(string lambda) { var source = $@" class TestClass {{ @@ -136,7 +137,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(AsyncLambdas))] - public async void Throws_Generic_WithNamedArgumentException_WithAsyncLambda_FindsDiagnostic(string lambda) + public async Task Throws_Generic_WithNamedArgumentException_WithAsyncLambda_FindsDiagnostic(string lambda) { var source = $@" class TestClass {{ @@ -166,7 +167,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(AsyncLambdas))] - public async void ThrowsAsync_NonGeneric_WithAsyncLambda_FindsNoDiagnostics(string lambda) + public async Task ThrowsAsync_NonGeneric_WithAsyncLambda_FindsNoDiagnostics(string lambda) { var source = $@" class TestClass {{ @@ -184,7 +185,7 @@ async System.Threading.Tasks.Task TestMethod() {{ [Theory] [MemberData(nameof(AsyncLambdas))] - public async void ThrowsAsync_Generic_WithAsyncLambda_FindsNoDiagnostics(string lambda) + public async Task ThrowsAsync_Generic_WithAsyncLambda_FindsNoDiagnostics(string lambda) { var source = $@" class TestClass {{ @@ -202,7 +203,7 @@ async void TestMethod() {{ [Theory] [MemberData(nameof(NonAsyncLambdas))] - public async void ThrowsAny_WithNonAsyncLambda_FindsNoDiagnostics(string lambda) + public async Task ThrowsAny_WithNonAsyncLambda_FindsNoDiagnostics(string lambda) { var source = $@" class TestClass {{ @@ -220,7 +221,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(AsyncLambdas))] - public async void ThrowsAny_WithAsyncLambda_FindsDiagnostic(string lambda) + public async Task ThrowsAny_WithAsyncLambda_FindsDiagnostic(string lambda) { var source = $@" class TestClass {{ @@ -250,7 +251,7 @@ void TestMethod() {{ [Theory] [MemberData(nameof(AsyncLambdas))] - public async void ThrowsAnyAsync_WithAsyncLambda_FindsNoDiagnostics(string lambda) + public async Task ThrowsAnyAsync_WithAsyncLambda_FindsNoDiagnostics(string lambda) { var source = $@" class TestClass {{ diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AssertThrowsShouldUseGenericOverloadCheckTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AssertThrowsShouldUseGenericOverloadCheckTests.cs index dc521360..e9e090c3 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AssertThrowsShouldUseGenericOverloadCheckTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AssertThrowsShouldUseGenericOverloadCheckTests.cs @@ -79,7 +79,7 @@ void TestMethod() {{ } [Fact] - public async void FindsCompilerError_ForThrowsCheck_WithExceptionTypeArgument_OnThrowingMethod() + public async Task FindsCompilerError_ForThrowsCheck_WithExceptionTypeArgument_OnThrowingMethod() { var source = @" class TestClass { @@ -101,7 +101,7 @@ void TestMethod() { } [Fact] - public async void DoesNotFindWarning_ForThrowsAsyncCheck_WithExceptionTypeArgument_OnThrowingMethod() + public async Task DoesNotFindWarning_ForThrowsAsyncCheck_WithExceptionTypeArgument_OnThrowingMethod() { var source = @" class TestClass { @@ -118,7 +118,7 @@ async System.Threading.Tasks.Task TestMethod() { } [Fact] - public async void FindsCompilerError_ForThrowsCheck_WithExceptionTypeArgument_OnThrowingLambda() + public async Task FindsCompilerError_ForThrowsCheck_WithExceptionTypeArgument_OnThrowingLambda() { var source = @" class TestClass { @@ -136,7 +136,7 @@ void TestMethod() { } [Fact] - public async void DoesNotFindWarning_ForThrowsAsyncCheck_WithExceptionTypeArgument_OnThrowingLambda() + public async Task DoesNotFindWarning_ForThrowsAsyncCheck_WithExceptionTypeArgument_OnThrowingLambda() { var source = @" class TestClass { diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/AsyncAssertsShouldBeAwaitedTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/AsyncAssertsShouldBeAwaitedTests.cs index c2214da8..5d56e55f 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/AsyncAssertsShouldBeAwaitedTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/AsyncAssertsShouldBeAwaitedTests.cs @@ -1,4 +1,5 @@ using System.Globalization; +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Xunit; @@ -7,7 +8,7 @@ public class AsyncAssertsShouldBeAwaitedTests { [Fact] - public async void UnawaitedNonAssertionDoesNotTrigger() + public async Task UnawaitedNonAssertionDoesNotTrigger() { var code = @" using System.Threading.Tasks; @@ -38,7 +39,7 @@ public class TestClass : INotifyPropertyChanged {{ public event EventHandler? SimpleIntEvent; [Fact] - public async void TestMethod() {{ + public async Task TestMethod() {{ {0} }} }} @@ -69,7 +70,7 @@ public static void ConsumeTask(this Task t) {{ }} [Theory] [MemberData(nameof(AsyncAssertions))] - public async void AwaitedAssertDoesNotTrigger( + public async Task AwaitedAssertDoesNotTrigger( string _, string assertion) { @@ -80,7 +81,7 @@ public async void AwaitedAssertDoesNotTrigger( [Theory] [MemberData(nameof(AsyncAssertions))] - public async void AssertionWithConsumptionNotTrigger( + public async Task AssertionWithConsumptionNotTrigger( string _, string assertion) { @@ -91,7 +92,7 @@ public async void AssertionWithConsumptionNotTrigger( [Theory] [MemberData(nameof(AsyncAssertions))] - public async void AssertionWithConsumptionViaExtensionNotTrigger( + public async Task AssertionWithConsumptionViaExtensionNotTrigger( string _, string assertion) { @@ -102,7 +103,7 @@ public async void AssertionWithConsumptionViaExtensionNotTrigger( [Theory] [MemberData(nameof(AsyncAssertions))] - public async void AssertionWithStoredTaskDoesNotTrigger( + public async Task AssertionWithStoredTaskDoesNotTrigger( string _, string assertion) { @@ -113,7 +114,7 @@ public async void AssertionWithStoredTaskDoesNotTrigger( [Theory] [MemberData(nameof(AsyncAssertions))] - public async void AssertionWithoutAwaitTriggers( + public async Task AssertionWithoutAwaitTriggers( string assertionName, string assertion) { @@ -130,7 +131,7 @@ public async void AssertionWithoutAwaitTriggers( [Theory] [MemberData(nameof(AsyncAssertions))] - public async void AssertionWithUnawaitedContinuationTriggers( + public async Task AssertionWithUnawaitedContinuationTriggers( string assertionName, string assertion) { diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/BooleanAssertsShouldNotBeNegatedTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/BooleanAssertsShouldNotBeNegatedTests.cs index 7a85f111..6fcddd53 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/BooleanAssertsShouldNotBeNegatedTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/BooleanAssertsShouldNotBeNegatedTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Verify = CSharpVerifier; @@ -6,7 +7,7 @@ public class BooleanAssertsShouldNotBeNegatedTests [Theory] [InlineData("False", "True")] [InlineData("True", "False")] - public async void NegatedBooleanAssertionTriggers( + public async Task NegatedBooleanAssertionTriggers( string assertion, string replacement) { diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/BooleanAssertsShouldNotBeUsedForSimpleEqualityCheckTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/BooleanAssertsShouldNotBeUsedForSimpleEqualityCheckTests.cs index d5ee3ac2..d296b20c 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/BooleanAssertsShouldNotBeUsedForSimpleEqualityCheckTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/BooleanAssertsShouldNotBeUsedForSimpleEqualityCheckTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; @@ -17,7 +18,7 @@ public class X2024_BooleanAssertionsShouldNotBeUsedForSimpleEqualityCheck [Theory] [MemberData(nameof(MethodOperator))] - public async void ComparingAgainstNonLiteral_DoesNotTrigger( + public async Task ComparingAgainstNonLiteral_DoesNotTrigger( string method, string @operator) { @@ -47,7 +48,7 @@ public void TestMethod() {{ [Theory] [MemberData(nameof(MethodOperatorValue))] - public async void ComparingAgainstLiteral_WithMessage_DoesNotTrigger( + public async Task ComparingAgainstLiteral_WithMessage_DoesNotTrigger( string method, string @operator, string value) @@ -71,7 +72,7 @@ public void TestMethod() {{ [Theory] [MemberData(nameof(MethodOperatorValue))] - public async void ComparingAgainstLiteral_WithoutMessage_Triggers( + public async Task ComparingAgainstLiteral_WithoutMessage_Triggers( string method, string @operator, string value) @@ -121,7 +122,7 @@ public void TestMethod() {{ [Theory] [MemberData(nameof(MethodOperatorType))] - public async void ComparingAgainstNull_WithMessage_DoesNotTrigger( + public async Task ComparingAgainstNull_WithMessage_DoesNotTrigger( string method, string @operator, string type) @@ -145,7 +146,7 @@ public void TestMethod() {{ [Theory] [MemberData(nameof(MethodOperatorType))] - public async void ComparingAgainstNull_WithoutMessage_Triggers( + public async Task ComparingAgainstNull_WithoutMessage_Triggers( string method, string @operator, string type) @@ -198,7 +199,7 @@ public class X2025_BooleanAssertionCanBeSimplified [Theory] [MemberData(nameof(MethodOperatorValue))] - public async void ComparingAgainstBooleanLiteral_Triggers( + public async Task ComparingAgainstBooleanLiteral_Triggers( string method, string @operator, string value) diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/SetEqualityAnalyzerTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/SetEqualityAnalyzerTests.cs index fd0d6a9b..23789535 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/SetEqualityAnalyzerTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/SetEqualityAnalyzerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Xunit; using Verify = CSharpVerifier; @@ -48,7 +49,7 @@ public class X2026_SetsMustBeComparedWithEqualityComparer [Theory] [MemberData(nameof(MethodWithCollectionCreationData))] - public async void WithCollectionComparer_DoesNotTrigger( + public async Task WithCollectionComparer_DoesNotTrigger( string method, string collection1, string collection2) @@ -73,7 +74,7 @@ public void TestMethod() {{ [Theory] [MemberData(nameof(MethodWithCollectionCreationData))] - public async void WithEqualityComparer_DoesNotTrigger( + public async Task WithEqualityComparer_DoesNotTrigger( string method, string collection1, string collection2) @@ -111,7 +112,7 @@ public void TestMethod() {{ [Theory] [MemberData(nameof(MethodWithCollectionCreationData))] - public async void WithComparerLambda_Triggers( + public async Task WithComparerLambda_Triggers( string method, string collection1, string collection2) @@ -152,7 +153,7 @@ public static MatrixTheoryData ComparerFunctionD [Theory] [MemberData(nameof(ComparerFunctionData))] - public async void WithComparerFunction_Triggers( + public async Task WithComparerFunction_Triggers( string method, string comparerFuncSyntax, string collection1, @@ -210,7 +211,7 @@ public class X2027_SetsShouldNotBeComparedToLinearContainers [Theory] [MemberData(nameof(MethodAndLinearContainers))] - public async void LinearContainers_DoesNotTrigger( + public async Task LinearContainers_DoesNotTrigger( string method, string collection) { @@ -235,7 +236,7 @@ public void TestMethod() {{ } [Fact] - public async void CastedSet_DoesNotTrigger() + public async Task CastedSet_DoesNotTrigger() { var code = @" using Xunit; @@ -269,7 +270,7 @@ public void TestMethod() { [Theory] [MemberData(nameof(MethodAndTypeAndInitializer), DisableDiscoveryEnumeration = true)] - public async void SetWithLinearContainer_Triggers( + public async Task SetWithLinearContainer_Triggers( string method, (string type, string initializer) collection) { diff --git a/src/xunit.analyzers.tests/Analyzers/X2000/UseAssertFailInsteadOfBooleanAssertTests.cs b/src/xunit.analyzers.tests/Analyzers/X2000/UseAssertFailInsteadOfBooleanAssertTests.cs index 58900841..ff180ab3 100644 --- a/src/xunit.analyzers.tests/Analyzers/X2000/UseAssertFailInsteadOfBooleanAssertTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X2000/UseAssertFailInsteadOfBooleanAssertTests.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Xunit.Analyzers; @@ -18,7 +19,7 @@ public void TestMethod() {{ [Theory] [InlineData(Constants.Asserts.True, "false")] [InlineData(Constants.Asserts.False, "true")] - public async void SignalsFor25( + public async Task SignalsFor25( string assertion, string targetValue) { @@ -35,7 +36,7 @@ public async void SignalsFor25( [Theory] [InlineData(Constants.Asserts.True, "true")] [InlineData(Constants.Asserts.False, "false")] - public async void DoesNotSignalForNonFailure( + public async Task DoesNotSignalForNonFailure( string assertion, string targetValue) { @@ -45,7 +46,7 @@ public async void DoesNotSignalForNonFailure( } [Fact] - public async void DoesNotSignalForNonConstantInvocation() + public async Task DoesNotSignalForNonConstantInvocation() { var source = @" public class TestClass { @@ -62,7 +63,7 @@ public void TestMethod() { [Theory] [InlineData(Constants.Asserts.True, "false")] [InlineData(Constants.Asserts.False, "true")] - public async void DoNotSignalForPre25( + public async Task DoNotSignalForPre25( string assertion, string targetValue) { diff --git a/src/xunit.analyzers.tests/Analyzers/X3000/CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.cs b/src/xunit.analyzers.tests/Analyzers/X3000/CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.cs index 60ceb66b..ad8230dd 100644 --- a/src/xunit.analyzers.tests/Analyzers/X3000/CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X3000/CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Xunit.Analyzers; @@ -49,7 +50,7 @@ public static IEnumerable Interfaces } [Fact] - public async void SuccessCase_NoInterfaces() + public async Task SuccessCase_NoInterfaces() { var source = "public class Foo { }"; @@ -58,7 +59,7 @@ public async void SuccessCase_NoInterfaces() [Theory] [MemberData(nameof(Interfaces))] - public async void FailureCase_InterfaceWithoutBaseClass(string @interface) + public async Task FailureCase_InterfaceWithoutBaseClass(string @interface) { var source = string.Format(Template, @interface); var expected = @@ -114,7 +115,7 @@ public static TheoryData InterfacesWithBaseClasses } [Fact] - public async void SuccessCase_NoInterfaces() + public async Task SuccessCase_NoInterfaces() { var source = "public class Foo { }"; @@ -122,7 +123,7 @@ public async void SuccessCase_NoInterfaces() } [Fact] - public async void SuccessCase_WithXunitTestCase() + public async Task SuccessCase_WithXunitTestCase() { var source = string.Format(Template, "Xunit.Sdk.XunitTestCase"); @@ -131,7 +132,7 @@ public async void SuccessCase_WithXunitTestCase() [Theory] [MemberData(nameof(InterfacesWithBaseClasses))] - public async void SuccessCase_CompatibleBaseClass( + public async Task SuccessCase_CompatibleBaseClass( string @interface, string baseClass) { @@ -142,7 +143,7 @@ public async void SuccessCase_CompatibleBaseClass( [Theory] [MemberData(nameof(Interfaces))] - public async void FailureCase_InterfaceWithoutBaseClass(string @interface) + public async Task FailureCase_InterfaceWithoutBaseClass(string @interface) { var source = string.Format(Template, @interface); var expected = @@ -156,7 +157,7 @@ public async void FailureCase_InterfaceWithoutBaseClass(string @interface) [Theory] [MemberData(nameof(Interfaces))] - public async void FailureCase_IncompatibleBaseClass(string @interface) + public async Task FailureCase_IncompatibleBaseClass(string @interface) { var source = string.Format(Template, $"Foo, {@interface}"); var expected = @@ -204,7 +205,7 @@ public static TheoryData InterfacesWithBaseClasses } [Fact] - public async void SuccessCase_NoInterfaces() + public async Task SuccessCase_NoInterfaces() { var source = "public class Foo { }"; @@ -213,7 +214,7 @@ public async void SuccessCase_NoInterfaces() [Theory] [MemberData(nameof(InterfacesWithBaseClasses))] - public async void SuccessCase_CompatibleBaseClass( + public async Task SuccessCase_CompatibleBaseClass( string @interface, string baseClass) { @@ -224,7 +225,7 @@ public async void SuccessCase_CompatibleBaseClass( [Theory] [MemberData(nameof(Interfaces))] - public async void FailureCase_InterfaceWithoutBaseClass(string @interface) + public async Task FailureCase_InterfaceWithoutBaseClass(string @interface) { var source = string.Format(Template, @interface); var expected = @@ -238,7 +239,7 @@ public async void FailureCase_InterfaceWithoutBaseClass(string @interface) [Theory] [MemberData(nameof(Interfaces))] - public async void FailureCase_IncompatibleBaseClass(string @interface) + public async Task FailureCase_IncompatibleBaseClass(string @interface) { var source = string.Format(Template, $"Foo, {@interface}"); var expected = diff --git a/src/xunit.analyzers.tests/Analyzers/X3000/SerializableClassMustHaveParameterlessConstructorTests.cs b/src/xunit.analyzers.tests/Analyzers/X3000/SerializableClassMustHaveParameterlessConstructorTests.cs index b5d6ab01..902267f7 100644 --- a/src/xunit.analyzers.tests/Analyzers/X3000/SerializableClassMustHaveParameterlessConstructorTests.cs +++ b/src/xunit.analyzers.tests/Analyzers/X3000/SerializableClassMustHaveParameterlessConstructorTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Xunit.Analyzers; @@ -23,7 +24,7 @@ public void Serialize(IXunitSerializationInfo info) {{ }} [Theory] [MemberData(nameof(Interfaces))] - public async void ImplicitConstructors_NoDiagnostics(string @interface) + public async Task ImplicitConstructors_NoDiagnostics(string @interface) { var source = string.Format(Template, @interface, ""); @@ -32,7 +33,7 @@ public async void ImplicitConstructors_NoDiagnostics(string @interface) [Theory] [MemberData(nameof(Interfaces))] - public async void WrongConstructor_ReturnsError(string @interface) + public async Task WrongConstructor_ReturnsError(string @interface) { var source = string.Format(Template, @interface, "public Foo(int x) { }"); var expected = @@ -46,7 +47,7 @@ public async void WrongConstructor_ReturnsError(string @interface) [Theory] [MemberData(nameof(Interfaces))] - public async void NonPublicConstructor_ReturnsError(string @interface) + public async Task NonPublicConstructor_ReturnsError(string @interface) { var source = string.Format(Template, @interface, "protected Foo() { }"); var expected = @@ -60,7 +61,7 @@ public async void NonPublicConstructor_ReturnsError(string @interface) [Theory] [MemberData(nameof(Interfaces))] - public async void PublicParameterlessConstructor_NoDiagnostics(string @interface) + public async Task PublicParameterlessConstructor_NoDiagnostics(string @interface) { var source = string.Format(Template, @interface, "public Foo() { }"); diff --git a/src/xunit.analyzers.tests/Fixes/X1000/ClassDataAttributeMustPointAtValidClassFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/ClassDataAttributeMustPointAtValidClassFixerTests.cs index 81658367..46306ca8 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/ClassDataAttributeMustPointAtValidClassFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/ClassDataAttributeMustPointAtValidClassFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class ClassDataAttributeMustPointAtValidClassFixerTests { [Fact] - public async void AddsIEnumerable() + public async Task AddsIEnumerable() { var before = @" using System.Collections.Generic; @@ -38,7 +39,7 @@ public void TestMethod(int _) { } } [Fact] - public async void ConvertsParameterlessConstructorToPublic() + public async Task ConvertsParameterlessConstructorToPublic() { var before = @" using System.Collections; @@ -80,7 +81,7 @@ public void TestMethod(int _) { } } [Fact] - public async void AddsPublicParameterlessConstructor() + public async Task AddsPublicParameterlessConstructor() { var before = @" using System.Collections; @@ -126,7 +127,7 @@ public void TestMethod(int _) { } } [Fact] - public async void RemovesAbstractModifierFromDataClass() + public async Task RemovesAbstractModifierFromDataClass() { var before = @" using System.Collections; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/CollectionDefinitionClassesMustBePublicFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/CollectionDefinitionClassesMustBePublicFixerTests.cs index 200b27e1..bd5e8335 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/CollectionDefinitionClassesMustBePublicFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/CollectionDefinitionClassesMustBePublicFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -7,7 +8,7 @@ public class CollectionDefinitionClassesMustBePublicFixerTests [Theory] [InlineData("")] [InlineData("internal ")] - public async void MakesClassPublic(string modifier) + public async Task MakesClassPublic(string modifier) { var before = $@" [Xunit.CollectionDefinition(""MyCollection"")] @@ -23,7 +24,7 @@ public class CollectionDefinitionClass { }"; [Theory] [InlineData("")] [InlineData("internal ")] - public async void ForPartialClassDeclarations_MakesSingleDeclarationPublic(string modifier) + public async Task ForPartialClassDeclarations_MakesSingleDeclarationPublic(string modifier) { var before = $@" [Xunit.CollectionDefinition(""MyCollection"")] diff --git a/src/xunit.analyzers.tests/Fixes/X1000/ConvertToFactFixTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/ConvertToFactFixTests.cs index 17496498..651abb0d 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/ConvertToFactFixTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/ConvertToFactFixTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify_X1003 = CSharpVerifier; @@ -6,7 +7,7 @@ public class ConvertToFactFixTests { [Fact] - public async void From_X1003() + public async Task From_X1003() { var before = @" using Xunit; @@ -28,7 +29,7 @@ public void TestMethod(int a) { } } [Fact] - public async void From_X1006() + public async Task From_X1006() { var before = @" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/ConvertToTheoryFixTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/ConvertToTheoryFixTests.cs index cb277be7..b48706d8 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/ConvertToTheoryFixTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/ConvertToTheoryFixTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify_X1001 = CSharpVerifier; @@ -6,7 +7,7 @@ public class ConvertToTheoryFixTests { [Fact] - public async void From_X1001() + public async Task From_X1001() { var before = @" using Xunit; @@ -28,7 +29,7 @@ public void TestMethod(int a) { } } [Fact] - public async void From_X1005() + public async Task From_X1005() { var before = @" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/DataAttributeShouldBeUsedOnATheoryFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/DataAttributeShouldBeUsedOnATheoryFixerTests.cs index ef7820eb..d4860acc 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/DataAttributeShouldBeUsedOnATheoryFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/DataAttributeShouldBeUsedOnATheoryFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class DataAttributeShouldBeUsedOnATheoryFixerTests { [Fact] - public async void AddsMissingTheoryAttribute() + public async Task AddsMissingTheoryAttribute() { var before = @" using Xunit; @@ -28,7 +29,7 @@ public void TestMethod() { } } [Fact] - public async void RemovesDataAttributes() + public async Task RemovesDataAttributes() { var before = @" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/DoNotUseConfigureAwaitFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/DoNotUseConfigureAwaitFixerTests.cs index c9f314ef..13cff60e 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/DoNotUseConfigureAwaitFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/DoNotUseConfigureAwaitFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -18,7 +19,7 @@ public class RemoveConfigureAwait { [Theory] [MemberData(nameof(InvalidValues), MemberType = typeof(ConfigureAwait_Boolean))] - public async void Task_Async(string argumentValue) + public async Task Task_Async(string argumentValue) { var before = @$" using System.Threading.Tasks; @@ -49,7 +50,7 @@ public async Task TestMethod() { [Theory] [MemberData(nameof(InvalidValues), MemberType = typeof(ConfigureAwait_Boolean))] - public async void Task_NonAsync(string argumentValue) + public async Task Task_NonAsync(string argumentValue) { var before = @$" using System.Threading.Tasks; @@ -80,7 +81,7 @@ public void TestMethod() { [Theory] [MemberData(nameof(InvalidValues), MemberType = typeof(ConfigureAwait_Boolean))] - public async void TaskOfT(string argumentValue) + public async Task TaskOfT(string argumentValue) { var before = @$" using System.Threading.Tasks; @@ -113,7 +114,7 @@ public async Task TestMethod() { [Theory] [MemberData(nameof(InvalidValues), MemberType = typeof(ConfigureAwait_Boolean))] - public async void ValueTask(string argumentValue) + public async Task ValueTask(string argumentValue) { var before = @$" using System.Threading.Tasks; @@ -146,7 +147,7 @@ public async Task TestMethod() { [Theory] [MemberData(nameof(InvalidValues), MemberType = typeof(ConfigureAwait_Boolean))] - public async void ValueTaskOfT(string argumentValue) + public async Task ValueTaskOfT(string argumentValue) { var before = @$" using System.Threading.Tasks; @@ -182,7 +183,7 @@ public class ReplaceConfigureAwait { [Theory] [MemberData(nameof(InvalidValues), MemberType = typeof(ConfigureAwait_Boolean))] - public async void Task_Async(string argumentValue) + public async Task Task_Async(string argumentValue) { var before = @$" using System.Threading.Tasks; @@ -213,7 +214,7 @@ public async Task TestMethod() { [Theory] [MemberData(nameof(InvalidValues), MemberType = typeof(ConfigureAwait_Boolean))] - public async void Task_NonAsync(string argumentValue) + public async Task Task_NonAsync(string argumentValue) { var before = @$" using System.Threading.Tasks; @@ -244,7 +245,7 @@ public void TestMethod() { [Theory] [MemberData(nameof(InvalidValues), MemberType = typeof(ConfigureAwait_Boolean))] - public async void TaskOfT(string argumentValue) + public async Task TaskOfT(string argumentValue) { var before = @$" using System.Threading.Tasks; @@ -277,7 +278,7 @@ public async Task TestMethod() { [Theory] [MemberData(nameof(InvalidValues), MemberType = typeof(ConfigureAwait_Boolean))] - public async void ValueTask(string argumentValue) + public async Task ValueTask(string argumentValue) { var before = @$" using System.Threading.Tasks; @@ -310,7 +311,7 @@ public async Task TestMethod() { [Theory] [MemberData(nameof(InvalidValues), MemberType = typeof(ConfigureAwait_Boolean))] - public async void ValueTaskOfT(string argumentValue) + public async Task ValueTaskOfT(string argumentValue) { var before = @$" using System.Threading.Tasks; @@ -359,7 +360,7 @@ public class ConfigureAwait_ConfigureAwaitOptions [Theory] [MemberData(nameof(InvalidValues))] - public async void Task_Async(string argumentValue) + public async Task Task_Async(string argumentValue) { var before = @$" using System.Threading.Tasks; @@ -390,7 +391,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(InvalidValues))] - public async void Task_NonAsync(string argumentValue) + public async Task Task_NonAsync(string argumentValue) { var before = @$" using System.Threading.Tasks; @@ -421,7 +422,7 @@ public void TestMethod() {{ [Theory] [MemberData(nameof(InvalidValues))] - public async void TaskOfT(string argumentValue) + public async Task TaskOfT(string argumentValue) { var before = @$" using System.Threading.Tasks; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/FactMethodMustNotHaveParametersFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/FactMethodMustNotHaveParametersFixerTests.cs index dd559db2..3f24e755 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/FactMethodMustNotHaveParametersFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/FactMethodMustNotHaveParametersFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class FactMethodMustNotHaveParametersFixerTests { [Fact] - public async void RemovesParameter() + public async Task RemovesParameter() { var before = @" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/FactMethodShouldNotHaveTestDataFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/FactMethodShouldNotHaveTestDataFixerTests.cs index 5973144d..9eb2dc31 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/FactMethodShouldNotHaveTestDataFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/FactMethodShouldNotHaveTestDataFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class FactMethodShouldNotHaveTestDataFixerTests { [Fact] - public async void RemovesDataAttribute() + public async Task RemovesDataAttribute() { var before = @" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/InlineDataMustMatchTheoryParameters_ExtraValueFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/InlineDataMustMatchTheoryParameters_ExtraValueFixerTests.cs index 49f42f43..d210cb78 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/InlineDataMustMatchTheoryParameters_ExtraValueFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/InlineDataMustMatchTheoryParameters_ExtraValueFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class InlineDataMustMatchTheoryParameters_ExtraValueFixerTests { [Fact] - public async void RemovesUnusedData() + public async Task RemovesUnusedData() { var before = @" using Xunit; @@ -31,7 +32,7 @@ public void TestMethod(int a) { } [Theory] [InlineData("21.12", "double")] [InlineData(@"""Hello world""", "string")] - public async void AddsParameterWithCorrectType( + public async Task AddsParameterWithCorrectType( string value, string valueType) { @@ -57,7 +58,7 @@ public void TestMethod(int a, {valueType} p) {{ }} } [Fact] - public async void AddsParameterWithNonConflictingName() + public async Task AddsParameterWithNonConflictingName() { var before = $@" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/InlineDataMustMatchTheoryParameters_NullShouldNotBeUsedForIncompatibleParameterFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/InlineDataMustMatchTheoryParameters_NullShouldNotBeUsedForIncompatibleParameterFixerTests.cs index 19ccf903..7525c4f3 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/InlineDataMustMatchTheoryParameters_NullShouldNotBeUsedForIncompatibleParameterFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/InlineDataMustMatchTheoryParameters_NullShouldNotBeUsedForIncompatibleParameterFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Xunit; using Xunit.Analyzers.Fixes; @@ -6,7 +7,7 @@ public class InlineDataMustMatchTheoryParameters_NullShouldNotBeUsedForIncompatibleParameterFixerTests { [Fact] - public async void MakesParameterNullable() + public async Task MakesParameterNullable() { var before = @" using Xunit; @@ -30,7 +31,7 @@ public void TestMethod(int a, int? b) { } } [Fact] - public async void MakesReferenceParameterNullable() + public async Task MakesReferenceParameterNullable() { var before = @" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/InlineDataMustMatchTheoryParameters_TooFewValuesFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/InlineDataMustMatchTheoryParameters_TooFewValuesFixerTests.cs index e2d5935c..328bed28 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/InlineDataMustMatchTheoryParameters_TooFewValuesFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/InlineDataMustMatchTheoryParameters_TooFewValuesFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -13,7 +14,7 @@ public class InlineDataMustMatchTheoryParameters_TooFewValuesFixerTests [InlineData("string", "\"\"")] [InlineData("object", "null")] [InlineData("Color", "default(Color)")] - public async void MakesParameterNullable( + public async Task MakesParameterNullable( string valueType, string defaultValue) { diff --git a/src/xunit.analyzers.tests/Fixes/X1000/InlineDataShouldBeUniqueWithinTheoryFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/InlineDataShouldBeUniqueWithinTheoryFixerTests.cs index 6293f876..7adbd740 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/InlineDataShouldBeUniqueWithinTheoryFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/InlineDataShouldBeUniqueWithinTheoryFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class InlineDataShouldBeUniqueWithinTheoryFixerTests { [Fact] - public async void RemovesDuplicateData() + public async Task RemovesDuplicateData() { var before = @" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/LocalFunctionsCannotBeTestFunctionsFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/LocalFunctionsCannotBeTestFunctionsFixerTests.cs index 6fdb57f4..63637751 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/LocalFunctionsCannotBeTestFunctionsFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/LocalFunctionsCannotBeTestFunctionsFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Xunit; using Xunit.Analyzers.Fixes; @@ -8,7 +9,7 @@ public class LocalFunctionsCannotBeTestFunctionsFixerTests [Theory] [InlineData("Fact")] [InlineData("Theory")] - public async void LocalFunctionsCannotHaveTestAttributes(string attribute) + public async Task LocalFunctionsCannotHaveTestAttributes(string attribute) { var before = $@" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_ExtraValueFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_ExtraValueFixerTests.cs index 7f905f58..5fbdc172 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_ExtraValueFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_ExtraValueFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class MemberDataShouldReferenceValidMember_ExtraValueFixerTests { [Fact] - public async void RemovesUnusedData() + public async Task RemovesUnusedData() { var before = @" using Xunit; @@ -35,7 +36,7 @@ public void TestMethod(int a) { } [Theory] [InlineData("21.12", "double")] [InlineData(@"""Hello world""", "string")] - public async void AddsParameterWithCorrectType( + public async Task AddsParameterWithCorrectType( string value, string valueType) { @@ -65,7 +66,7 @@ public void TestMethod(int a) {{ }} } [Fact] - public async void AddsParameterWithNonConflictingName() + public async Task AddsParameterWithNonConflictingName() { var before = $@" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_NameOfFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_NameOfFixerTests.cs index 021a9227..604c6b3f 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_NameOfFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_NameOfFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class MemberDataShouldReferenceValidMember_NameOfFixerTests { [Fact] - public async void ConvertStringToNameOf() + public async Task ConvertStringToNameOf() { var before = @" using System; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_NullShouldNotBeUsedForIncompatibleParameterFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_NullShouldNotBeUsedForIncompatibleParameterFixerTests.cs index 10d200c0..c4afdda4 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_NullShouldNotBeUsedForIncompatibleParameterFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_NullShouldNotBeUsedForIncompatibleParameterFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Xunit; using Xunit.Analyzers.Fixes; @@ -6,7 +7,7 @@ public class MemberDataShouldReferenceValidMember_NullShouldNotBeUsedForIncompatibleParameterFixerTests { [Fact] - public async void MakesParameterNullable() + public async Task MakesParameterNullable() { var before = @" using Xunit; @@ -34,7 +35,7 @@ public void TestMethod(int a) { } } [Fact] - public async void MakesReferenceParameterNullable() + public async Task MakesReferenceParameterNullable() { var before = @" #nullable enable diff --git a/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_ParamsForNonMethodFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_ParamsForNonMethodFixerTests.cs index 1244fd4a..04a60889 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_ParamsForNonMethodFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_ParamsForNonMethodFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class MemberDataShouldReferenceValidMember_ParamsForNonMethodFixerTests { [Fact] - public async void RemovesParametersFromNonMethodMemberData() + public async Task RemovesParametersFromNonMethodMemberData() { var before = @" using System; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_ReturnTypeFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_ReturnTypeFixerTests.cs index 96c7c4b5..774d7881 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_ReturnTypeFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_ReturnTypeFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class MemberDataShouldReferenceValidMember_ReturnTypeFixerTests { [Fact] - public async void ChangesReturnType_ObjectArray() + public async Task ChangesReturnType_ObjectArray() { var before = @" using System.Collections.Generic; @@ -35,7 +36,7 @@ public void TestMethod(int a) { } } [Fact] - public async void ChangesReturnType_TheoryDataRow() + public async Task ChangesReturnType_TheoryDataRow() { var before = @" using System.Collections.Generic; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_StaticFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_StaticFixerTests.cs index 9605c37f..1a2c5ca5 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_StaticFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_StaticFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class MemberDataShouldReferenceValidMember_StaticFixerTests { [Fact] - public async void MarksDataMemberAsStatic() + public async Task MarksDataMemberAsStatic() { var before = @" using System.Collections.Generic; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_VisibilityFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_VisibilityFixerTests.cs index 094a912c..43d5916e 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_VisibilityFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/MemberDataShouldReferenceValidMember_VisibilityFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -8,7 +9,7 @@ public class MemberDataShouldReferenceValidMember_VisibilityFixerTests [InlineData("")] [InlineData("protected ")] [InlineData("internal ")] - public async void SetsPublicModifier(string badModifier) + public async Task SetsPublicModifier(string badModifier) { var before = $@" using System.Collections.Generic; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/PublicMethodShouldBeMarkedAsTestFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/PublicMethodShouldBeMarkedAsTestFixerTests.cs index 64ef98d9..4cac3900 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/PublicMethodShouldBeMarkedAsTestFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/PublicMethodShouldBeMarkedAsTestFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -24,7 +25,7 @@ public void TestMethod() { } }"; [Fact] - public async void AddsFactToPublicMethodWithoutParameters() + public async Task AddsFactToPublicMethodWithoutParameters() { var after = @" using Xunit; @@ -41,7 +42,7 @@ public void TestMethod2() { } } [Fact] - public async void AddsFactToPublicMethodWithParameters() + public async Task AddsFactToPublicMethodWithParameters() { var after = @" using Xunit; @@ -60,7 +61,7 @@ public void TestMethod2(int _) { } [Theory] [InlineData(beforeNoParams)] [InlineData(beforeWithParams)] - public async void MarksMethodAsInternal(string before) + public async Task MarksMethodAsInternal(string before) { var after = before.Replace("public void [|TestMethod2|]", "internal void TestMethod2"); diff --git a/src/xunit.analyzers.tests/Fixes/X1000/RemoveMethodParameterFixTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/RemoveMethodParameterFixTests.cs index beb28ca9..5598d8de 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/RemoveMethodParameterFixTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/RemoveMethodParameterFixTests.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Xunit.Analyzers; @@ -9,7 +10,7 @@ public class RemoveMethodParameterFixTests { [Fact] - public async void X1022_RemoveParamsArray() + public async Task X1022_RemoveParamsArray() { var before = @" using Xunit; @@ -33,7 +34,7 @@ public void TestMethod() { } } [Fact] - public async void X1026_RemovesUnusedParameter() + public async Task X1026_RemovesUnusedParameter() { var before = @" using Xunit; @@ -57,7 +58,7 @@ public void TestMethod() { } } [Fact] - public async void X1026_DoesNotCrashWhenParameterDeclarationIsMissing() + public async Task X1026_DoesNotCrashWhenParameterDeclarationIsMissing() { var before = @" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/TestClassCannotBeNestedInGenericClassFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/TestClassCannotBeNestedInGenericClassFixerTests.cs index 88eddafe..e2eb4e48 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/TestClassCannotBeNestedInGenericClassFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/TestClassCannotBeNestedInGenericClassFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class TestClassCannotBeNestedInGenericClassFixerTests { [Fact] - public async void MovesTestClassOutOfGenericParent() + public async Task MovesTestClassOutOfGenericParent() { const string before = @" public abstract class OpenGenericType diff --git a/src/xunit.analyzers.tests/Fixes/X1000/TestClassMustBePublicFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/TestClassMustBePublicFixerTests.cs index 82039337..6fa3ed18 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/TestClassMustBePublicFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/TestClassMustBePublicFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -7,7 +8,7 @@ public class TestClassMustBePublicFixerTests [Theory] [InlineData("")] [InlineData("internal")] - public async void MakesClassPublic(string nonPublicAccessModifier) + public async Task MakesClassPublic(string nonPublicAccessModifier) { var before = $@" {nonPublicAccessModifier} class [|TestClass|] {{ @@ -25,7 +26,7 @@ public void TestMethod() { } } [Fact] - public async void ForPartialClassDeclarations_MakesSingleDeclarationPublic() + public async Task ForPartialClassDeclarations_MakesSingleDeclarationPublic() { var before = @" partial class [|TestClass|] { diff --git a/src/xunit.analyzers.tests/Fixes/X1000/TestClassShouldHaveTFixtureArgumentFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/TestClassShouldHaveTFixtureArgumentFixerTests.cs index a19687d0..2f1aef7c 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/TestClassShouldHaveTFixtureArgumentFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/TestClassShouldHaveTFixtureArgumentFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class TestClassShouldHaveTFixtureArgumentFixerTests { [Fact] - public async void ForClassWithoutField_GenerateFieldAndConstructor() + public async Task ForClassWithoutField_GenerateFieldAndConstructor() { var before = @" public class FixtureData { } @@ -34,7 +35,7 @@ public void TestMethod() { } } [Fact] - public async void ForGenericTFixture_GenerateFieldAndConstructor() + public async Task ForGenericTFixture_GenerateFieldAndConstructor() { var before = @" public class FixtureData { } diff --git a/src/xunit.analyzers.tests/Fixes/X1000/TestMethodMustNotHaveMultipleFactAttributesFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/TestMethodMustNotHaveMultipleFactAttributesFixerTests.cs index a9b08a54..b470f2c7 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/TestMethodMustNotHaveMultipleFactAttributesFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/TestMethodMustNotHaveMultipleFactAttributesFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class TestMethodMustNotHaveMultipleFactAttributesFixerTests { [Fact] - public async void RemovesSecondAttribute() + public async Task RemovesSecondAttribute() { var before = $@" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/TestMethodShouldNotBeSkippedFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/TestMethodShouldNotBeSkippedFixerTests.cs index 6405e8d5..a8a48925 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/TestMethodShouldNotBeSkippedFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/TestMethodShouldNotBeSkippedFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class TestMethodShouldNotBeSkippedFixerTests { [Fact] - public async void RemovesSkipProperty() + public async Task RemovesSkipProperty() { var before = @" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X1000/TheoryMethodCannotHaveDefaultParameterFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X1000/TheoryMethodCannotHaveDefaultParameterFixerTests.cs index 1c483f2c..74b3ecb5 100644 --- a/src/xunit.analyzers.tests/Fixes/X1000/TheoryMethodCannotHaveDefaultParameterFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X1000/TheoryMethodCannotHaveDefaultParameterFixerTests.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Xunit.Analyzers; @@ -8,7 +9,7 @@ public class TheoryMethodCannotHaveDefaultParameterFixerTests { [Fact] - public async void RemovesDefaultParameterValue() + public async Task RemovesDefaultParameterValue() { var before = @" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertCollectionContainsShouldNotUseBoolCheckFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertCollectionContainsShouldNotUseBoolCheckFixerTests.cs index 2b157c1a..97f05408 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertCollectionContainsShouldNotUseBoolCheckFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertCollectionContainsShouldNotUseBoolCheckFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -31,7 +32,7 @@ public void TestMethod() {{ [InlineData( @"[|Assert.False(items.Contains(""b"", StringComparer.Ordinal))|]", @"Assert.DoesNotContain(""b"", items, StringComparer.Ordinal)")] - public async void ReplacesBooleanAssert( + public async Task ReplacesBooleanAssert( string beforeAssert, string afterAssert) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertEmptyCollectionCheckShouldNotBeUsedFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertEmptyCollectionCheckShouldNotBeUsedFixerTests.cs index 82495c51..a54f01ba 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertEmptyCollectionCheckShouldNotBeUsedFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertEmptyCollectionCheckShouldNotBeUsedFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -17,7 +18,7 @@ public void TestMethod() { }"; [Fact] - public async void UseEmptyCheck() + public async Task UseEmptyCheck() { var after = @" using Xunit; @@ -35,7 +36,7 @@ public void TestMethod() { } [Fact] - public async void AddElementInspector() + public async Task AddElementInspector() { var after = @" using Xunit; diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertEnumerableAnyCheckShouldNotBeUsedForCollectionContainsCheckFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertEnumerableAnyCheckShouldNotBeUsedForCollectionContainsCheckFixerTests.cs index 36678bc9..066191c3 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertEnumerableAnyCheckShouldNotBeUsedForCollectionContainsCheckFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertEnumerableAnyCheckShouldNotBeUsedForCollectionContainsCheckFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -24,7 +25,7 @@ public void TestMethod() {{ [InlineData( "[|Assert.False(collection.Any(x => x == 2))|]", "Assert.DoesNotContain(collection, x => x == 2)")] - public async void ReplacesAssert( + public async Task ReplacesAssert( string beforeAssert, string afterAssert) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualGenericShouldNotBeUsedForStringValueFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualGenericShouldNotBeUsedForStringValueFixerTests.cs index 894e665a..ac93006b 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualGenericShouldNotBeUsedForStringValueFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualGenericShouldNotBeUsedForStringValueFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers; using Xunit.Analyzers.Fixes; @@ -20,7 +21,7 @@ public void TestMethod() {{ [Theory] [InlineData(Constants.Asserts.Equal)] [InlineData(Constants.Asserts.StrictEqual)] - public async void RemovesGeneric(string assert) + public async Task RemovesGeneric(string assert) { var before = string.Format(template, $@"[|Assert.{assert}(""foo"", result)|]"); var after = string.Format(template, @"Assert.Equal(""foo"", result)"); diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualLiteralValueShouldBeFirstFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualLiteralValueShouldBeFirstFixerTests.cs index 123d674d..95f16a18 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualLiteralValueShouldBeFirstFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualLiteralValueShouldBeFirstFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Xunit; using Xunit.Analyzers.Fixes; @@ -23,7 +24,7 @@ public void TestMethod() {{ [InlineData("Assert.Equal(comparer: default(IEqualityComparer), actual: 0, expected: i)", "Assert.Equal(comparer: default(IEqualityComparer), actual: i, expected: 0)")] [InlineData("Assert.Equal(comparer: (x, y) => true, actual: 0, expected: i)", "Assert.Equal(comparer: (x, y) => true, actual: i, expected: 0)")] [InlineData("Assert.Equal(expected: i, 0)", "Assert.Equal(expected: 0, i)", LanguageVersion.CSharp7_2)] - public async void SwapArguments( + public async Task SwapArguments( string beforeAssert, string afterAssert, LanguageVersion? languageVersion = null) diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualPrecisionShouldBeInRangeFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualPrecisionShouldBeInRangeFixerTests.cs index 5a6cd680..034f11aa 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualPrecisionShouldBeInRangeFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualPrecisionShouldBeInRangeFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -21,7 +22,7 @@ public void TestMethod() {{ // decimal = [0..28] [InlineData("Assert.Equal(10.1m, 10.2m, [|-1|])", "Assert.Equal(10.1m, 10.2m, 0)")] [InlineData("Assert.Equal(10.1m, 10.2m, [|29|])", "Assert.Equal(10.1m, 10.2m, 28)")] - public async void ChangesPrecisionToZero( + public async Task ChangesPrecisionToZero( string beforeAssert, string afterAssert) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualShouldNotBeUsedForBoolLiteralCheckFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualShouldNotBeUsedForBoolLiteralCheckFixerTests.cs index 99efa4d5..9fe17243 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualShouldNotBeUsedForBoolLiteralCheckFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualShouldNotBeUsedForBoolLiteralCheckFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -25,7 +26,7 @@ public void TestMethod() {{ [InlineData("[|Assert.NotEqual(true, actual)|]", "Assert.False(actual)")] [InlineData("[|Assert.NotStrictEqual(false, actual)|]", "Assert.True(actual)")] [InlineData("[|Assert.NotStrictEqual(true, actual)|]", "Assert.False(actual)")] - public async void ConvertsToBooleanAssert( + public async Task ConvertsToBooleanAssert( string beforeAssert, string afterAssert) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualShouldNotBeUsedForCollectionSizeCheckFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualShouldNotBeUsedForCollectionSizeCheckFixerTests.cs index 83ae198e..ba493b1c 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualShouldNotBeUsedForCollectionSizeCheckFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualShouldNotBeUsedForCollectionSizeCheckFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -21,7 +22,7 @@ public void TestMethod() {{ [InlineData("[|Assert.Equal(1, data.Count())|]", "Assert.Single(data)")] [InlineData("[|Assert.Equal(0, data.Count())|]", "Assert.Empty(data)")] [InlineData("[|Assert.NotEqual(0, data.Count())|]", "Assert.NotEmpty(data)")] - public async void ReplacesCollectionCountWithAppropriateAssert( + public async Task ReplacesCollectionCountWithAppropriateAssert( string beforeAssert, string afterAssert) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualShouldNotBeUsedForNullCheckFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualShouldNotBeUsedForNullCheckFixerTests.cs index 52d4661c..f73c5d6e 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualShouldNotBeUsedForNullCheckFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualShouldNotBeUsedForNullCheckFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -21,7 +22,7 @@ public void TestMethod() {{ [InlineData("[|Assert.StrictEqual(null, data)|]", "Assert.Null(data)")] [InlineData("[|Assert.NotEqual(null, data)|]", "Assert.NotNull(data)")] [InlineData("[|Assert.NotStrictEqual(null, data)|]", "Assert.NotNull(data)")] - public async void ConvertsToAppropriateNullAssert( + public async Task ConvertsToAppropriateNullAssert( string beforeAssert, string afterAssert) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualsShouldNotBeUsedFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualsShouldNotBeUsedFixerTests.cs index 9854f941..99e150d4 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualsShouldNotBeUsedFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertEqualsShouldNotBeUsedFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -19,7 +20,7 @@ public void TestMethod() {{ [Theory] [InlineData("{|CS0619:[|Assert.Equals(1, data)|]|}", "Assert.Equal(1, data)")] [InlineData("{|CS0619:[|Assert.ReferenceEquals(1, data)|]|}", "Assert.Same(1, data)")] - public async void ConvertsObjectCallToAssert( + public async Task ConvertsObjectCallToAssert( string beforeAssert, string afterAssert) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertIsTypeShouldNotBeUsedForAbstractTypeFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertIsTypeShouldNotBeUsedForAbstractTypeFixerTests.cs index 046a2cf8..90da2c57 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertIsTypeShouldNotBeUsedForAbstractTypeFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertIsTypeShouldNotBeUsedForAbstractTypeFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -22,7 +23,7 @@ public void TestMethod() {{ [InlineData("[|Assert.IsType(data)|]", "Assert.IsAssignableFrom(data)")] [InlineData("[|Assert.IsNotType(data)|]", "Assert.IsNotAssignableFrom(data)")] [InlineData("[|Assert.IsNotType(data)|]", "Assert.IsNotAssignableFrom(data)")] - public async void Conversions( + public async Task Conversions( string beforeAssert, string afterAssert) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertNullShouldNotBeCalledOnValueTypesFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertNullShouldNotBeCalledOnValueTypesFixerTests.cs index 0e37b4e9..ab2cc807 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertNullShouldNotBeCalledOnValueTypesFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertNullShouldNotBeCalledOnValueTypesFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class AssertNullShouldNotBeCalledOnValueTypesFixerTests { [Fact] - public async void ForValueTypeNullAssert_RemovesAssertion() + public async Task ForValueTypeNullAssert_RemovesAssertion() { const string before = @" using Xunit; @@ -33,7 +34,7 @@ public void TestMethod() { [Fact] // https://github.com/xunit/xunit/issues/1753 - public async void ForAssertionWithTrivia_RemovesAssertionAndLeavesLeadingTriviaInPlace() + public async Task ForAssertionWithTrivia_RemovesAssertionAndLeavesLeadingTriviaInPlace() { const string before = @" using System; diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertRegexMatchShouldNotUseBoolLiteralCheckFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertRegexMatchShouldNotUseBoolLiteralCheckFixerTests.cs index f3c3f4fc..6a984669 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertRegexMatchShouldNotUseBoolLiteralCheckFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertRegexMatchShouldNotUseBoolLiteralCheckFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -20,7 +21,7 @@ public void TestMethod() {{ [Theory] [InlineData(@"[|Assert.True(Regex.IsMatch(result, ""foo (.*?) baz""))|]", @"Assert.Matches(""foo (.*?) baz"", result)")] [InlineData(@"[|Assert.False(Regex.IsMatch(result, ""foo (.*?) baz""))|]", @"Assert.DoesNotMatch(""foo (.*?) baz"", result)")] - public async void ConvertsBooleanAssertToRegexAssert( + public async Task ConvertsBooleanAssertToRegexAssert( string beforeAssert, string afterAssert) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertSameShouldNotBeCalledOnValueTypesFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertSameShouldNotBeCalledOnValueTypesFixerTests.cs index 5571331a..cc18e7e8 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertSameShouldNotBeCalledOnValueTypesFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertSameShouldNotBeCalledOnValueTypesFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -19,7 +20,7 @@ public void TestMethod() {{ [Theory] [InlineData("[|Assert.Same(1, data)|]", "Assert.Equal(1, data)")] [InlineData("[|Assert.NotSame(1, data)|]", "Assert.NotEqual(1, data)")] - public async void ConvertsSameToEqual( + public async Task ConvertsSameToEqual( string beforeAssert, string afterAssert) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertSingleShouldBeUsedForSingleParameterFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertSingleShouldBeUsedForSingleParameterFixerTests.cs index 51d00361..ffebbb4e 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertSingleShouldBeUsedForSingleParameterFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertSingleShouldBeUsedForSingleParameterFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Xunit; using Xunit.Analyzers.Fixes; @@ -123,7 +124,7 @@ private void ElementInspector(object obj) [Theory] [MemberData(nameof(Statements))] - public async void ReplacesCollectionMethod( + public async Task ReplacesCollectionMethod( string statementBefore, string statementAfter) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertStringEqualityCheckShouldNotUseBoolCheckFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertStringEqualityCheckShouldNotUseBoolCheckFixerTests.cs index 4dea04ed..8f04cf04 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertStringEqualityCheckShouldNotUseBoolCheckFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertStringEqualityCheckShouldNotUseBoolCheckFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -30,7 +31,7 @@ public void TestMethod() {{ [InlineData(@"[|Assert.False(""foo bar baz"".Equals(data))|]", @"Assert.NotEqual(""foo bar baz"", data)")] // Static Equals (false) [InlineData(@"[|Assert.False(string.Equals(""foo bar baz"", data))|]", @"Assert.NotEqual(""foo bar baz"", data)")] - public async void ConvertsBooleanAssertToEqualityAssert( + public async Task ConvertsBooleanAssertToEqualityAssert( string beforeAssert, string afterAssert) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertSubstringCheckShouldNotUseBoolCheckFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertSubstringCheckShouldNotUseBoolCheckFixerTests.cs index 38cba16a..8ec7c6c2 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertSubstringCheckShouldNotUseBoolCheckFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertSubstringCheckShouldNotUseBoolCheckFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -24,7 +25,7 @@ public void TestMethod() {{ [InlineData(@"[|Assert.True(data.EndsWith(""foo""))|]", @"Assert.EndsWith(""foo"", data)")] [InlineData(@"[|Assert.True(data.EndsWith(""foo"", StringComparison.OrdinalIgnoreCase))|]", @"Assert.EndsWith(""foo"", data, StringComparison.OrdinalIgnoreCase)")] [InlineData(@"[|Assert.False(data.Contains(""foo""))|]", @"Assert.DoesNotContain(""foo"", data)")] - public async void ConvertsBooleanAssertToStringSpecificAssert( + public async Task ConvertsBooleanAssertToStringSpecificAssert( string beforeAssert, string afterAssert) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AssertThrowsShouldNotBeUsedForAsyncThrowsCheckFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AssertThrowsShouldNotBeUsedForAsyncThrowsCheckFixerTests.cs index d8e6962f..d395cb69 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AssertThrowsShouldNotBeUsedForAsyncThrowsCheckFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AssertThrowsShouldNotBeUsedForAsyncThrowsCheckFixerTests.cs @@ -56,7 +56,7 @@ static TheoryData GenerateAssertions() [Theory] [MemberData(nameof(Assertions))] - public async void GivenAssertionInMethod_ReplacesWithAsyncAssertion( + public async Task GivenAssertionInMethod_ReplacesWithAsyncAssertion( string assertion, string replacement) { @@ -75,7 +75,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(Assertions))] - public async void GivenAssertionInInvokedAnonymousFunction_ReplacesWithAsyncAssertion( + public async Task GivenAssertionInInvokedAnonymousFunction_ReplacesWithAsyncAssertion( string assertion, string replacement) { @@ -106,7 +106,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(Assertions))] - public async void GivenAssertionInInvokedAnonymousFunctionWithAssignment_ReplacesWithAsyncAssertion( + public async Task GivenAssertionInInvokedAnonymousFunctionWithAssignment_ReplacesWithAsyncAssertion( string assertion, string replacement) { @@ -141,7 +141,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(Assertions))] - public async void GivenAssertionInInvokedAnonymousFunctionWithVar_ReplacesWithAsyncAssertion( + public async Task GivenAssertionInInvokedAnonymousFunctionWithVar_ReplacesWithAsyncAssertion( string assertion, string replacement) { @@ -174,7 +174,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(Assertions))] - public async void GivenAssertionInUninvokedAnonymousFunction_ReplacesWithAsyncAssertion( + public async Task GivenAssertionInUninvokedAnonymousFunction_ReplacesWithAsyncAssertion( string assertion, string replacement) { @@ -199,7 +199,7 @@ public void TestMethod() {{ [Theory] [MemberData(nameof(Assertions))] - public async void GivenAssertionInInvokedNestedAnonymousFunction_ReplacesWithAsyncAssertion( + public async Task GivenAssertionInInvokedNestedAnonymousFunction_ReplacesWithAsyncAssertion( string assertion, string replacement) { @@ -238,7 +238,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(Assertions))] - public async void GivenAssertionInExplicitlyInvokedNestedAnonymousFunction_ReplacesWithAsyncAssertion( + public async Task GivenAssertionInExplicitlyInvokedNestedAnonymousFunction_ReplacesWithAsyncAssertion( string assertion, string replacement) { @@ -275,7 +275,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(Assertions))] - public async void GivenAssertionInConditionallyInvokedNestedAnonymousFunction_ReplacesWithAsyncAssertion( + public async Task GivenAssertionInConditionallyInvokedNestedAnonymousFunction_ReplacesWithAsyncAssertion( string assertion, string replacement) { @@ -312,7 +312,7 @@ public async Task TestMethod() {{ [Theory] [MemberData(nameof(Assertions))] - public async void GivenAssertionInUninvokedNestedAnonymousFunction_ReplacesWithAsyncAssertion( + public async Task GivenAssertionInUninvokedNestedAnonymousFunction_ReplacesWithAsyncAssertion( string assertion, string replacement) { @@ -341,7 +341,7 @@ public void TestMethod() {{ [Theory] [MemberData(nameof(Assertions))] - public async void GivenAssertionInInvokedLocalFunction_ReplacesWithAsyncAssertion( + public async Task GivenAssertionInInvokedLocalFunction_ReplacesWithAsyncAssertion( string assertion, string replacement) { @@ -372,7 +372,7 @@ async Task Function() {{ [Theory] [MemberData(nameof(Assertions))] - public async void GivenAssertionInUninvokedLocalFunction_ReplacesWithAsyncAssertion( + public async Task GivenAssertionInUninvokedLocalFunction_ReplacesWithAsyncAssertion( string assertion, string replacement) { @@ -397,7 +397,7 @@ async Task Function() {{ [Theory] [MemberData(nameof(Assertions))] - public async void GivenAssertionInInvokedNestedLocalFunction_ReplacesWithAsyncAssertion( + public async Task GivenAssertionInInvokedNestedLocalFunction_ReplacesWithAsyncAssertion( string assertion, string replacement) { @@ -440,7 +440,7 @@ async Task InnerFunction() {{ [Theory] [MemberData(nameof(Assertions))] - public async void GivenAssertionInUninvokedNestedLocalFunction_ReplacesWithAsyncAssertion( + public async Task GivenAssertionInUninvokedNestedLocalFunction_ReplacesWithAsyncAssertion( string assertion, string replacement) { @@ -473,7 +473,7 @@ async Task InnerFunction() {{ [Theory] [MemberData(nameof(Assertions))] - public async void GivenAssertionInMixedNestedFunctions_ReplacesWithAsyncAssertion( + public async Task GivenAssertionInMixedNestedFunctions_ReplacesWithAsyncAssertion( string assertion, string replacement) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/AsyncAssertsShouldBeAwaitedFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/AsyncAssertsShouldBeAwaitedFixerTests.cs index 970ebd5a..aa015570 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/AsyncAssertsShouldBeAwaitedFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/AsyncAssertsShouldBeAwaitedFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Xunit; using Xunit.Analyzers.Fixes; @@ -42,7 +43,7 @@ public static void ConsumeTask(this Task t) {{ }} [Theory] [MemberData(nameof(AsyncAssertions))] - public async void AddsAsyncAndAwait(string assertion) + public async Task AddsAsyncAndAwait(string assertion) { var before = string.Format(codeTemplate, $"[|{assertion}|];"); var after = string.Format(codeTemplate, $"await {assertion};").Replace("public void TestMethod", "public async Task TestMethod"); diff --git a/src/xunit.analyzers.tests/Fixes/X2000/BooleanAssertsShouldNotBeNegatedFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/BooleanAssertsShouldNotBeNegatedFixerTests.cs index 4a706d55..06073e90 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/BooleanAssertsShouldNotBeNegatedFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/BooleanAssertsShouldNotBeNegatedFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -19,7 +20,7 @@ public void TestMethod() {{ [Theory] [InlineData("False", "True")] [InlineData("True", "False")] - public async void ReplacesBooleanAssert( + public async Task ReplacesBooleanAssert( string assertion, string replacement) { diff --git a/src/xunit.analyzers.tests/Fixes/X2000/BooleanAssertsShouldNotBeUsedForSimpleEqualityCheckBooleanFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/BooleanAssertsShouldNotBeUsedForSimpleEqualityCheckBooleanFixerTests.cs index cd8850c9..a326bcca 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/BooleanAssertsShouldNotBeUsedForSimpleEqualityCheckBooleanFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/BooleanAssertsShouldNotBeUsedForSimpleEqualityCheckBooleanFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -41,7 +42,7 @@ public void TestMethod() {{ [Theory] [MemberData(nameof(AssertExpressionReplacement))] - public async void SimplifiesBooleanAssert( + public async Task SimplifiesBooleanAssert( string assertion, string expression, string replacement) @@ -54,7 +55,7 @@ public async void SimplifiesBooleanAssert( [Theory] [MemberData(nameof(AssertExpressionReplacement))] - public async void SimplifiesBooleanAssertWithMessage( + public async Task SimplifiesBooleanAssertWithMessage( string assertion, string expression, string replacement) diff --git a/src/xunit.analyzers.tests/Fixes/X2000/BooleanAssertsShouldNotBeUsedForSimpleEqualityCheckNonBooleanFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/BooleanAssertsShouldNotBeUsedForSimpleEqualityCheckNonBooleanFixerTests.cs index 38e327b9..44c51e3b 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/BooleanAssertsShouldNotBeUsedForSimpleEqualityCheckNonBooleanFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/BooleanAssertsShouldNotBeUsedForSimpleEqualityCheckNonBooleanFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Xunit; using Xunit.Analyzers; @@ -29,7 +30,7 @@ public void TestMethod() {{ [Theory] [MemberData(nameof(MethodOperatorValue))] - public async void BooleanAssertAgainstLiteralValue_ReplaceWithEquality( + public async Task BooleanAssertAgainstLiteralValue_ReplaceWithEquality( string method, string @operator, string value) @@ -65,7 +66,7 @@ await Verify.VerifyCodeFix( [Theory] [MemberData(nameof(MethodOperatorType))] - public async void BooleanAssertAgainstNull_ReplaceWithNull( + public async Task BooleanAssertAgainstNull_ReplaceWithNull( string method, string @operator, string type) diff --git a/src/xunit.analyzers.tests/Fixes/X2000/UseAssertFailInsteadOfBooleanAssertFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/UseAssertFailInsteadOfBooleanAssertFixerTests.cs index 8bb481de..ac7f6612 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/UseAssertFailInsteadOfBooleanAssertFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/UseAssertFailInsteadOfBooleanAssertFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -17,7 +18,7 @@ public void TestMethod() {{ [Theory] [InlineData(@"[|Assert.True(false, ""message"")|]")] [InlineData(@"[|Assert.False(true, ""message"")|]")] - public async void ReplacesBooleanAssert(string badAssert) + public async Task ReplacesBooleanAssert(string badAssert) { var before = string.Format(template, badAssert); var after = string.Format(template, @"Assert.Fail(""message"")"); diff --git a/src/xunit.analyzers.tests/Fixes/X2000/UseGenericOverloadFixTests.cs b/src/xunit.analyzers.tests/Fixes/X2000/UseGenericOverloadFixTests.cs index 0a11406c..ebeb600e 100644 --- a/src/xunit.analyzers.tests/Fixes/X2000/UseGenericOverloadFixTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X2000/UseGenericOverloadFixTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify_X2007 = CSharpVerifier; @@ -6,7 +7,7 @@ public class UseGenericOverloadFixTests { [Fact] - public async void X2007_SwitchesToGenericIsType() + public async Task X2007_SwitchesToGenericIsType() { var before = @" using Xunit; @@ -36,7 +37,7 @@ public void TestMethod() { } [Fact] - public async void X2015_SwitchesToGenericThrows() + public async Task X2015_SwitchesToGenericThrows() { var before = @" using System; diff --git a/src/xunit.analyzers.tests/Fixes/X3000/CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X3000/CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectFixerTests.cs index da892347..ed55c51f 100644 --- a/src/xunit.analyzers.tests/Fixes/X3000/CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X3000/CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Xunit; using Xunit.Analyzers; @@ -14,7 +15,7 @@ public class WithAbstractions : CrossAppDomainClassesMustBeLongLivedMarshalByRef [Theory] [MemberData(nameof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithAbstractions.Interfaces), MemberType = typeof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithAbstractions))] - public async void DoesNotAttemptToFix(string @interface) + public async Task DoesNotAttemptToFix(string @interface) { var source = string.Format(Template, "[|MyClass|]", @interface); @@ -48,7 +49,7 @@ public class {0}: {1} {{ }}"; [Theory] [MemberData(nameof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithExecution.Interfaces), MemberType = typeof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithExecution))] - public async void WithNoBaseClass_WithoutUsing_AddsBaseClass(string @interface) + public async Task WithNoBaseClass_WithoutUsing_AddsBaseClass(string @interface) { var before = string.Format(Template_WithoutUsing, "[|MyClass|]", @interface); var after = string.Format(Template_WithoutUsing, "MyClass", $"Xunit.LongLivedMarshalByRefObject, {@interface}"); @@ -62,7 +63,7 @@ await Verify_WithExecution.VerifyCodeFixV2( [Theory] [MemberData(nameof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithExecution.Interfaces), MemberType = typeof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithExecution))] - public async void WithNoBaseClass_WithUsing_AddsBaseClass(string @interface) + public async Task WithNoBaseClass_WithUsing_AddsBaseClass(string @interface) { var before = string.Format(Template_WithUsing, "[|MyClass|]", @interface); var after = string.Format(Template_WithUsing, "MyClass", $"LongLivedMarshalByRefObject, {@interface}"); @@ -76,7 +77,7 @@ await Verify_WithExecution.VerifyCodeFixV2( [Theory] [MemberData(nameof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithExecution.Interfaces), MemberType = typeof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithExecution))] - public async void WithBadBaseClass_WithoutUsing_ReplacesBaseClass(string @interface) + public async Task WithBadBaseClass_WithoutUsing_ReplacesBaseClass(string @interface) { var before = string.Format(Template_WithoutUsing, "[|MyClass|]", $"Foo, {@interface}"); var after = string.Format(Template_WithoutUsing, "MyClass", $"Xunit.LongLivedMarshalByRefObject, {@interface}"); @@ -90,7 +91,7 @@ await Verify_WithExecution.VerifyCodeFixV2( [Theory] [MemberData(nameof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithExecution.Interfaces), MemberType = typeof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithExecution))] - public async void WithBadBaseClass_WithUsing_ReplacesBaseClass(string @interface) + public async Task WithBadBaseClass_WithUsing_ReplacesBaseClass(string @interface) { var before = string.Format(Template_WithUsing, "[|MyClass|]", $"Foo, {@interface}"); var after = string.Format(Template_WithUsing, "MyClass", $"LongLivedMarshalByRefObject, {@interface}"); @@ -125,7 +126,7 @@ public class {0}: {1} {{ }}"; [Theory] [MemberData(nameof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithRunnerUtility.Interfaces), MemberType = typeof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithRunnerUtility))] - public async void WithNoBaseClass_WithoutUsing_AddsBaseClass(string @interface) + public async Task WithNoBaseClass_WithoutUsing_AddsBaseClass(string @interface) { var before = string.Format(Template_WithoutUsing, "[|MyClass|]", @interface); var after = string.Format(Template_WithoutUsing, "MyClass", $"Xunit.Sdk.LongLivedMarshalByRefObject, {@interface}"); @@ -139,7 +140,7 @@ await Verify_WithRunnerUtility.VerifyCodeFixV2RunnerUtility( [Theory] [MemberData(nameof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithRunnerUtility.Interfaces), MemberType = typeof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithRunnerUtility))] - public async void WithNoBaseClass_WithUsing_AddsBaseClass(string @interface) + public async Task WithNoBaseClass_WithUsing_AddsBaseClass(string @interface) { var before = string.Format(Template_WithUsing, "[|MyClass|]", @interface); var after = string.Format(Template_WithUsing, "MyClass", $"LongLivedMarshalByRefObject, {@interface}"); @@ -153,7 +154,7 @@ await Verify_WithRunnerUtility.VerifyCodeFixV2RunnerUtility( [Theory] [MemberData(nameof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithRunnerUtility.Interfaces), MemberType = typeof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithRunnerUtility))] - public async void WithBadBaseClass_WithoutUsing_ReplacesBaseClass(string @interface) + public async Task WithBadBaseClass_WithoutUsing_ReplacesBaseClass(string @interface) { var before = string.Format(Template_WithoutUsing, "[|MyClass|]", $"Foo, {@interface}"); var after = string.Format(Template_WithoutUsing, "MyClass", $"Xunit.Sdk.LongLivedMarshalByRefObject, {@interface}"); @@ -167,7 +168,7 @@ await Verify_WithRunnerUtility.VerifyCodeFixV2RunnerUtility( [Theory] [MemberData(nameof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithRunnerUtility.Interfaces), MemberType = typeof(CrossAppDomainClassesMustBeLongLivedMarshalByRefObjectTests.WithRunnerUtility))] - public async void WithBadBaseClass_WithUsing_ReplacesBaseClass(string @interface) + public async Task WithBadBaseClass_WithUsing_ReplacesBaseClass(string @interface) { var before = string.Format(Template_WithUsing, "[|MyClass|]", $"Foo, {@interface}"); var after = string.Format(Template_WithUsing, "MyClass", $"LongLivedMarshalByRefObject, {@interface}"); diff --git a/src/xunit.analyzers.tests/Fixes/X3000/SerializableClassMustHaveParameterlessConstructorFixerTests.cs b/src/xunit.analyzers.tests/Fixes/X3000/SerializableClassMustHaveParameterlessConstructorFixerTests.cs index 1c1f0a84..6503c084 100644 --- a/src/xunit.analyzers.tests/Fixes/X3000/SerializableClassMustHaveParameterlessConstructorFixerTests.cs +++ b/src/xunit.analyzers.tests/Fixes/X3000/SerializableClassMustHaveParameterlessConstructorFixerTests.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xunit; using Xunit.Analyzers.Fixes; using Verify = CSharpVerifier; @@ -5,7 +6,7 @@ public class SerializableClassMustHaveParameterlessConstructorFixerTests { [Fact] - public async void WithPublicParameteredConstructor_AddsNewConstructor() + public async Task WithPublicParameteredConstructor_AddsNewConstructor() { var before = @" public class [|MyTestCase|]: Xunit.Abstractions.IXunitSerializable { @@ -32,7 +33,7 @@ void Xunit.Abstractions.IXunitSerializable.Serialize(Xunit.Abstractions.IXunitSe } [Fact] - public async void WithNonPublicParameterlessConstructor_ChangesVisibility_WithoutUsing() + public async Task WithNonPublicParameterlessConstructor_ChangesVisibility_WithoutUsing() { var before = @" public class [|MyTestCase|]: Xunit.Abstractions.IXunitSerializable { @@ -55,7 +56,7 @@ void Xunit.Abstractions.IXunitSerializable.Serialize(Xunit.Abstractions.IXunitSe } [Fact] - public async void WithNonPublicParameterlessConstructor_ChangesVisibility_WithUsing() + public async Task WithNonPublicParameterlessConstructor_ChangesVisibility_WithUsing() { var before = @" using System; @@ -84,7 +85,7 @@ void IXunitSerializable.Serialize(IXunitSerializationInfo _) { } } [Fact] - public async void PreservesExistingObsoleteAttribute() + public async Task PreservesExistingObsoleteAttribute() { var before = @" using Xunit.Abstractions;