From 067eb41d0e98be04a31ba5c727ed704c685bea64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Sat, 7 Apr 2018 20:24:21 +0500 Subject: [PATCH 01/16] move file to Settings --- .../{Highlightings => Settings}/AsyncConverterGroupSettings.cs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename AsyncConverter/{Highlightings => Settings}/AsyncConverterGroupSettings.cs (100%) diff --git a/AsyncConverter/Highlightings/AsyncConverterGroupSettings.cs b/AsyncConverter/Settings/AsyncConverterGroupSettings.cs similarity index 100% rename from AsyncConverter/Highlightings/AsyncConverterGroupSettings.cs rename to AsyncConverter/Settings/AsyncConverterGroupSettings.cs From e5853e779a09dc930c4ee918b6552d0dfa041c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Sat, 7 Apr 2018 20:29:05 +0500 Subject: [PATCH 02/16] first test --- .../ConfigureAwait/WithAttributeOnClass.cs | 21 +++++++++++++++++ .../WithAttributeOnClass.cs.gold | 23 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs.gold diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs new file mode 100644 index 0000000..59df8bd --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using NUnit.Framework; + public class Class + { + [Test] + public async Task Test() + { + await Task.Delay(1000); + } + } +} + +namespace NUnit.Framework +{ + public class TestAttribute : Attribute + { } +} diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs.gold new file mode 100644 index 0000000..c8e7747 --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs.gold @@ -0,0 +1,23 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using NUnit.Framework; + public class Class + { + [Test] + public async Task Test() + { + await Task.Delay(1000); + } + } +} + +namespace NUnit.Framework +{ + public class TestAttribute : Attribute + { } +} + +--------------------------------------------------------- \ No newline at end of file From f2ebd913e410f67f9579293d1a12cb10d6a38daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Sat, 7 Apr 2018 20:29:18 +0500 Subject: [PATCH 03/16] tmp --- AsyncConverter/Analyzers/ConfigureAwaitAnalyzer.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/AsyncConverter/Analyzers/ConfigureAwaitAnalyzer.cs b/AsyncConverter/Analyzers/ConfigureAwaitAnalyzer.cs index 5a7db5a..590a98b 100644 --- a/AsyncConverter/Analyzers/ConfigureAwaitAnalyzer.cs +++ b/AsyncConverter/Analyzers/ConfigureAwaitAnalyzer.cs @@ -15,6 +15,8 @@ public class ConfigureAwaitAnalyzer : ElementProblemAnalyzer { protected override void Run(IAwaitExpression element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer) { + var needConfAwaitCheckers = element.GetSolution().GetComponent(); + var attributeFunctionChecker = element.GetSolution().GetComponent(); var attributeTypeChecker = element.GetSolution().GetComponent(); @@ -32,4 +34,13 @@ protected override void Run(IAwaitExpression element, ElementProblemAnalyzerData consumer.AddHighlighting(new ConfigureAwaitHighlighting(element)); } } + + public interface IConfigureAwaitChecker + { + bool NeedAdding(); + } + + class ConfigureAwaitChecker : IConfigureAwaitChecker + { + } } \ No newline at end of file From 593ae284ebbe4103346e27e31b5cbc77042050cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Sun, 20 May 2018 16:05:41 +0500 Subject: [PATCH 04/16] fix expected gold file --- .../Highlightings/ConfigureAwait/WithAttributeOnClass.cs.gold | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs.gold index c8e7747..3a77abf 100644 --- a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs.gold +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs.gold @@ -20,4 +20,4 @@ namespace NUnit.Framework { } } ---------------------------------------------------------- \ No newline at end of file +--------------------------------------------------------- From 42e19e07819846aeff6eecc8298b04b0a86fab6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Sun, 20 May 2018 16:06:02 +0500 Subject: [PATCH 05/16] fix rider namespace --- AsyncConverter/AsyncConverter.Rider.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/AsyncConverter/AsyncConverter.Rider.csproj b/AsyncConverter/AsyncConverter.Rider.csproj index 709401b..92e7e22 100644 --- a/AsyncConverter/AsyncConverter.Rider.csproj +++ b/AsyncConverter/AsyncConverter.Rider.csproj @@ -12,6 +12,7 @@ Plugin for resharper, for converting code to async. async https://github.com/BigBabay/AsyncConverter + AsyncConverter bin\Rider\Debug From b7d0247ef6d6982a06ec66aaa4eb2801546b02d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Sun, 20 May 2018 16:07:23 +0500 Subject: [PATCH 06/16] decompose ConfigureAwaitCheckers --- .../Analyzers/ConfigureAwaitAnalyzer.cs | 27 ++----------------- .../Checker/AttributeFunctionChecker.cs | 2 +- .../ConfigureAwaitChecker.cs | 24 +++++++++++++++++ .../AttributeFunctionChecker.cs | 22 +++++++++++++++ .../CustomCheckers/AttributeTypeChecker.cs | 18 +++++++++++++ .../CustomCheckers/BaseChecker.cs | 18 +++++++++++++ .../IConfigureAwaitCustomChecker.cs | 9 +++++++ .../IConfigureAwaitChecker.cs | 9 +++++++ 8 files changed, 103 insertions(+), 26 deletions(-) create mode 100644 AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/ConfigureAwaitChecker.cs create mode 100644 AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeFunctionChecker.cs create mode 100644 AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeTypeChecker.cs create mode 100644 AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/BaseChecker.cs create mode 100644 AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/IConfigureAwaitCustomChecker.cs create mode 100644 AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/IConfigureAwaitChecker.cs diff --git a/AsyncConverter/Analyzers/ConfigureAwaitAnalyzer.cs b/AsyncConverter/Analyzers/ConfigureAwaitAnalyzer.cs index 590a98b..60a3d9b 100644 --- a/AsyncConverter/Analyzers/ConfigureAwaitAnalyzer.cs +++ b/AsyncConverter/Analyzers/ConfigureAwaitAnalyzer.cs @@ -1,10 +1,7 @@ -using AsyncConverter.AsyncHelpers.Checker; -using AsyncConverter.Checkers; +using AsyncConverter.AsyncHelpers.ConfigureAwaitCheckers; using AsyncConverter.Highlightings; using JetBrains.ProjectModel; -using JetBrains.ReSharper.Feature.Services.CSharp.PostfixTemplates; using JetBrains.ReSharper.Feature.Services.Daemon; -using JetBrains.ReSharper.Psi; using JetBrains.ReSharper.Psi.CSharp.Tree; using JetBrains.ReSharper.Psi.Tree; @@ -17,30 +14,10 @@ protected override void Run(IAwaitExpression element, ElementProblemAnalyzerData { var needConfAwaitCheckers = element.GetSolution().GetComponent(); - var attributeFunctionChecker = element.GetSolution().GetComponent(); - var attributeTypeChecker = element.GetSolution().GetComponent(); - - var declaredType = element.Task?.GetExpressionType() as IDeclaredType; - - if (declaredType.IsConfigurableAwaitable() || declaredType.IsGenericConfigurableAwaitable()) - return; - - if (attributeFunctionChecker.IsUnder(element)) - return; - - if (attributeTypeChecker.IsUnder(element)) + if(!needConfAwaitCheckers.NeedAdding(element)) return; consumer.AddHighlighting(new ConfigureAwaitHighlighting(element)); } } - - public interface IConfigureAwaitChecker - { - bool NeedAdding(); - } - - class ConfigureAwaitChecker : IConfigureAwaitChecker - { - } } \ No newline at end of file diff --git a/AsyncConverter/AsyncHelpers/Checker/AttributeFunctionChecker.cs b/AsyncConverter/AsyncHelpers/Checker/AttributeFunctionChecker.cs index 3857023..a201115 100644 --- a/AsyncConverter/AsyncHelpers/Checker/AttributeFunctionChecker.cs +++ b/AsyncConverter/AsyncHelpers/Checker/AttributeFunctionChecker.cs @@ -1,10 +1,10 @@ using System.Linq; using AsyncConverter.Helpers; using AsyncConverter.Settings; -using JetBrains.ReSharper.Psi.Tree; using JetBrains.Application.Settings; using JetBrains.ProjectModel; using JetBrains.ReSharper.Psi.CSharp.Tree; +using JetBrains.ReSharper.Psi.Tree; using JetBrains.Util; namespace AsyncConverter.AsyncHelpers.Checker diff --git a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/ConfigureAwaitChecker.cs b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/ConfigureAwaitChecker.cs new file mode 100644 index 0000000..f37300f --- /dev/null +++ b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/ConfigureAwaitChecker.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using System.Linq; +using AsyncConverter.AsyncHelpers.ConfigureAwaitCheckers.CustomCheckers; +using JetBrains.ProjectModel; +using JetBrains.ReSharper.Psi.CSharp.Tree; + +namespace AsyncConverter.AsyncHelpers.ConfigureAwaitCheckers +{ + [SolutionComponent] + internal class ConfigureAwaitChecker : IConfigureAwaitChecker + { + private readonly IConfigureAwaitCustomChecker[] awaitCustomCheckers; + + public ConfigureAwaitChecker(IEnumerable awaitCustomCheckers) + { + this.awaitCustomCheckers = awaitCustomCheckers.ToArray(); + } + + public bool NeedAdding(IAwaitExpression element) + { + return awaitCustomCheckers.All(x => x.NeedAdding(element)); + } + } +} \ No newline at end of file diff --git a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeFunctionChecker.cs b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeFunctionChecker.cs new file mode 100644 index 0000000..6dbe612 --- /dev/null +++ b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeFunctionChecker.cs @@ -0,0 +1,22 @@ +using AsyncConverter.AsyncHelpers.Checker; +using JetBrains.ProjectModel; +using JetBrains.ReSharper.Psi.CSharp.Tree; + +namespace AsyncConverter.AsyncHelpers.ConfigureAwaitCheckers.CustomCheckers +{ + [SolutionComponent] + internal class AttributeFunctionChecker: IConfigureAwaitCustomChecker + { + private readonly IAttributeFunctionChecker attributeFunctionChecker; + + public AttributeFunctionChecker(IAttributeFunctionChecker attributeFunctionChecker) + { + this.attributeFunctionChecker = attributeFunctionChecker; + } + + public bool NeedAdding(IAwaitExpression element) + { + return !attributeFunctionChecker.IsUnder(element); + } + } +} \ No newline at end of file diff --git a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeTypeChecker.cs b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeTypeChecker.cs new file mode 100644 index 0000000..df20a45 --- /dev/null +++ b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeTypeChecker.cs @@ -0,0 +1,18 @@ +using AsyncConverter.Checkers; +using JetBrains.ProjectModel; +using JetBrains.ReSharper.Psi.CSharp.Tree; +using JetBrains.ReSharper.Psi.Tree; + +namespace AsyncConverter.AsyncHelpers.ConfigureAwaitCheckers.CustomCheckers +{ + [SolutionComponent] + class AttributeTypeChecker : IConfigureAwaitCustomChecker + { + public bool NeedAdding(IAwaitExpression element) + { + var attributeTypeChecker = element.GetSolution().GetComponent(); + + return !attributeTypeChecker.IsUnder(element); + } + } +} \ No newline at end of file diff --git a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/BaseChecker.cs b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/BaseChecker.cs new file mode 100644 index 0000000..4ebdf06 --- /dev/null +++ b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/BaseChecker.cs @@ -0,0 +1,18 @@ +using JetBrains.ProjectModel; +using JetBrains.ReSharper.Feature.Services.CSharp.PostfixTemplates; +using JetBrains.ReSharper.Psi; +using JetBrains.ReSharper.Psi.CSharp.Tree; + +namespace AsyncConverter.AsyncHelpers.ConfigureAwaitCheckers.CustomCheckers +{ + [SolutionComponent] + internal class BaseChecker : IConfigureAwaitCustomChecker + { + public bool NeedAdding(IAwaitExpression element) + { + var declaredType = element.Task?.GetExpressionType() as IDeclaredType; + + return !declaredType.IsConfigurableAwaitable() && !declaredType.IsGenericConfigurableAwaitable(); + } + } +} \ No newline at end of file diff --git a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/IConfigureAwaitCustomChecker.cs b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/IConfigureAwaitCustomChecker.cs new file mode 100644 index 0000000..fa0bdd6 --- /dev/null +++ b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/IConfigureAwaitCustomChecker.cs @@ -0,0 +1,9 @@ +using JetBrains.ReSharper.Psi.CSharp.Tree; + +namespace AsyncConverter.AsyncHelpers.ConfigureAwaitCheckers.CustomCheckers +{ + public interface IConfigureAwaitCustomChecker + { + bool NeedAdding(IAwaitExpression element); + } +} \ No newline at end of file diff --git a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/IConfigureAwaitChecker.cs b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/IConfigureAwaitChecker.cs new file mode 100644 index 0000000..bb9c346 --- /dev/null +++ b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/IConfigureAwaitChecker.cs @@ -0,0 +1,9 @@ +using JetBrains.ReSharper.Psi.CSharp.Tree; + +namespace AsyncConverter.AsyncHelpers.ConfigureAwaitCheckers +{ + public interface IConfigureAwaitChecker + { + bool NeedAdding(IAwaitExpression element); + } +} \ No newline at end of file From dc4ef454d4c78aafbce7af1aca963324c1744fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Sun, 20 May 2018 16:08:29 +0500 Subject: [PATCH 07/16] Fix Namespace for settings --- .../AsyncHelpers/RenameCheckers/ControllerRenameChecker.cs | 4 ++-- .../Highlightings/AsyncAwaitMayBeElidedHighlighting.cs | 1 + AsyncConverter/Highlightings/AsyncMethodNamingHighlighting.cs | 1 + .../Highlightings/CanBeUseAsyncMethodHighlighting.cs | 1 + AsyncConverter/Highlightings/ConfigureAwaitHighlighting.cs | 1 + AsyncConverter/Highlightings/NullReturnAsTaskHighlighting.cs | 1 + AsyncConverter/Settings/AsyncConverterGroupSettings.cs | 4 ++-- 7 files changed, 9 insertions(+), 4 deletions(-) diff --git a/AsyncConverter/AsyncHelpers/RenameCheckers/ControllerRenameChecker.cs b/AsyncConverter/AsyncHelpers/RenameCheckers/ControllerRenameChecker.cs index de76ac7..ba2b713 100644 --- a/AsyncConverter/AsyncHelpers/RenameCheckers/ControllerRenameChecker.cs +++ b/AsyncConverter/AsyncHelpers/RenameCheckers/ControllerRenameChecker.cs @@ -1,5 +1,5 @@ -using System.Linq; -using System.Collections.Generic; +using System.Collections.Generic; +using System.Linq; using JetBrains.Metadata.Reader.Impl; using JetBrains.ProjectModel; using JetBrains.ReSharper.Psi; diff --git a/AsyncConverter/Highlightings/AsyncAwaitMayBeElidedHighlighting.cs b/AsyncConverter/Highlightings/AsyncAwaitMayBeElidedHighlighting.cs index 9ee01f1..08d01e3 100644 --- a/AsyncConverter/Highlightings/AsyncAwaitMayBeElidedHighlighting.cs +++ b/AsyncConverter/Highlightings/AsyncAwaitMayBeElidedHighlighting.cs @@ -1,4 +1,5 @@ using AsyncConverter.Highlightings; +using AsyncConverter.Settings; using JetBrains.DocumentModel; using JetBrains.ReSharper.Feature.Services.Daemon; using JetBrains.ReSharper.Psi.CSharp; diff --git a/AsyncConverter/Highlightings/AsyncMethodNamingHighlighting.cs b/AsyncConverter/Highlightings/AsyncMethodNamingHighlighting.cs index bc56682..7dce6df 100644 --- a/AsyncConverter/Highlightings/AsyncMethodNamingHighlighting.cs +++ b/AsyncConverter/Highlightings/AsyncMethodNamingHighlighting.cs @@ -1,4 +1,5 @@ using AsyncConverter.Highlightings; +using AsyncConverter.Settings; using JetBrains.DocumentModel; using JetBrains.ReSharper.Feature.Services.Daemon; using JetBrains.ReSharper.Psi.CSharp; diff --git a/AsyncConverter/Highlightings/CanBeUseAsyncMethodHighlighting.cs b/AsyncConverter/Highlightings/CanBeUseAsyncMethodHighlighting.cs index 53c26bf..03b94a4 100644 --- a/AsyncConverter/Highlightings/CanBeUseAsyncMethodHighlighting.cs +++ b/AsyncConverter/Highlightings/CanBeUseAsyncMethodHighlighting.cs @@ -1,4 +1,5 @@ using AsyncConverter.Highlightings; +using AsyncConverter.Settings; using JetBrains.DocumentModel; using JetBrains.ReSharper.Feature.Services.Daemon; using JetBrains.ReSharper.Psi.CSharp; diff --git a/AsyncConverter/Highlightings/ConfigureAwaitHighlighting.cs b/AsyncConverter/Highlightings/ConfigureAwaitHighlighting.cs index 858e810..760506c 100644 --- a/AsyncConverter/Highlightings/ConfigureAwaitHighlighting.cs +++ b/AsyncConverter/Highlightings/ConfigureAwaitHighlighting.cs @@ -1,4 +1,5 @@ using AsyncConverter.Highlightings; +using AsyncConverter.Settings; using JetBrains.DocumentModel; using JetBrains.ReSharper.Feature.Services.Daemon; using JetBrains.ReSharper.Psi.CSharp; diff --git a/AsyncConverter/Highlightings/NullReturnAsTaskHighlighting.cs b/AsyncConverter/Highlightings/NullReturnAsTaskHighlighting.cs index 5a97b63..bb7dd63 100644 --- a/AsyncConverter/Highlightings/NullReturnAsTaskHighlighting.cs +++ b/AsyncConverter/Highlightings/NullReturnAsTaskHighlighting.cs @@ -1,4 +1,5 @@ using AsyncConverter.Highlightings; +using AsyncConverter.Settings; using JetBrains.DocumentModel; using JetBrains.ReSharper.Feature.Services.Daemon; using JetBrains.ReSharper.Psi; diff --git a/AsyncConverter/Settings/AsyncConverterGroupSettings.cs b/AsyncConverter/Settings/AsyncConverterGroupSettings.cs index 85b4043..12afce1 100644 --- a/AsyncConverter/Settings/AsyncConverterGroupSettings.cs +++ b/AsyncConverter/Settings/AsyncConverterGroupSettings.cs @@ -1,9 +1,9 @@ -using AsyncConverter.Highlightings; +using AsyncConverter.Settings; using JetBrains.ReSharper.Feature.Services.Daemon; [assembly: RegisterConfigurableHighlightingsGroup(AsyncConverterGroupSettings.Id, AsyncConverterGroupSettings.Name)] -namespace AsyncConverter.Highlightings +namespace AsyncConverter.Settings { public static class AsyncConverterGroupSettings { From 4c2c62898f90e4121c750e03d58aa2336d3e0a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Mon, 18 Jun 2018 18:53:34 +0500 Subject: [PATCH 08/16] add settings to ExcludeTestMethodsFromConfigureAwait --- AsyncConverter/Settings/AsyncConverterSettingsAccessor.cs | 4 ++++ AsyncConverter/Settings/General/GeneralSettings.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/AsyncConverter/Settings/AsyncConverterSettingsAccessor.cs b/AsyncConverter/Settings/AsyncConverterSettingsAccessor.cs index 149fb87..3a0710e 100644 --- a/AsyncConverter/Settings/AsyncConverterSettingsAccessor.cs +++ b/AsyncConverter/Settings/AsyncConverterSettingsAccessor.cs @@ -17,6 +17,10 @@ public static readonly Expression> public static readonly Expression> ExcludeTestMethodsFromEliding = x => x.ExcludeTestMethodsFromEliding; + [NotNull] + public static readonly Expression> + ExcludeTestMethodsFromConfigureAwait = x => x.ExcludeTestMethodsFromConfigureAwait; + [NotNull] public static readonly Expression>> ConfigureAwaitIgnoreAttributeTypes = diff --git a/AsyncConverter/Settings/General/GeneralSettings.cs b/AsyncConverter/Settings/General/GeneralSettings.cs index 238d9d7..ed7093a 100644 --- a/AsyncConverter/Settings/General/GeneralSettings.cs +++ b/AsyncConverter/Settings/General/GeneralSettings.cs @@ -10,5 +10,9 @@ public class GeneralSettings [SettingsEntry(true, "Do not suggest add 'Async' suffix to test method.")] public bool ExcludeTestMethodsFromRanaming { get; set; } + + [SettingsEntry(true, "Do not suggest add 'ConfigureAwait' into test method.")] + public bool ExcludeTestMethodsFromConfigureAwait { get; set; } + } } \ No newline at end of file From 198f1e538692a7bb419255556aa36574fc41d564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Tue, 19 Jun 2018 17:52:31 +0500 Subject: [PATCH 09/16] update package --- AsyncConverter.Tests/AsyncConverter.Rider.Tests.csproj | 2 +- AsyncConverter.Tests/AsyncConverter.Tests.csproj | 2 +- AsyncConverter/AsyncConverter.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AsyncConverter.Tests/AsyncConverter.Rider.Tests.csproj b/AsyncConverter.Tests/AsyncConverter.Rider.Tests.csproj index d80b902..c8f2950 100644 --- a/AsyncConverter.Tests/AsyncConverter.Rider.Tests.csproj +++ b/AsyncConverter.Tests/AsyncConverter.Rider.Tests.csproj @@ -30,6 +30,6 @@ - + \ No newline at end of file diff --git a/AsyncConverter.Tests/AsyncConverter.Tests.csproj b/AsyncConverter.Tests/AsyncConverter.Tests.csproj index e7b4d0f..e79316f 100644 --- a/AsyncConverter.Tests/AsyncConverter.Tests.csproj +++ b/AsyncConverter.Tests/AsyncConverter.Tests.csproj @@ -26,7 +26,7 @@ - + diff --git a/AsyncConverter/AsyncConverter.csproj b/AsyncConverter/AsyncConverter.csproj index d253850..4e97a8e 100644 --- a/AsyncConverter/AsyncConverter.csproj +++ b/AsyncConverter/AsyncConverter.csproj @@ -25,7 +25,7 @@ - + \ No newline at end of file From 073ef27b649262758f24970e228de5a201369c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Mon, 25 Jun 2018 11:43:17 +0500 Subject: [PATCH 10/16] Move tests to separate folder --- .../ConfigureAwaitOnTestTests.cs | 11 +++++++++ .../ConfigureAwait/ConfigureAwaitTests.cs | 7 ++++++ .../ConfigureAwaitWithAttributeTests.cs | 4 ++-- .../Highlightings/ConfigureAwaitTests.cs | 7 ------ .../ConfigureAwait/Common/MsTestAttr.cs | 21 +++++++++++++++++ .../ConfigureAwait/Common/MsTestAttr.cs.gold | 22 ++++++++++++++++++ .../{ => Common}/WithAttributeOnClass.cs | 0 .../{ => Common}/WithAttributeOnClass.cs.gold | 0 .../ConfigureAwait/{ => Common}/WithFalse.cs | 0 .../{ => Common}/WithFalse.cs.gold | 0 .../ConfigureAwait/{ => Common}/WithTrue.cs | 0 .../{ => Common}/WithTrue.cs.gold | 0 .../ConfigureAwait/{ => Common}/Without.cs | 0 .../{ => Common}/Without.cs.gold | 0 .../ConfigureAwait/OnTest/MsTestAttr.cs | 21 +++++++++++++++++ .../ConfigureAwait/OnTest/MsTestAttr.cs.gold | 23 +++++++++++++++++++ .../ConfigureAwait/OnTest/NUnitTestAttr.cs | 21 +++++++++++++++++ .../OnTest/NUnitTestAttr.cs.gold | 23 +++++++++++++++++++ .../OnTest/NUnitTestCaseAttr.cs | 21 +++++++++++++++++ .../OnTest/NUnitTestCaseAttr.cs.gold | 23 +++++++++++++++++++ .../ConfigureAwait/OnTest/XunitFactAttr.cs | 21 +++++++++++++++++ .../OnTest/XunitFactAttr.cs.gold | 23 +++++++++++++++++++ .../ConfigureAwait/OnTest/XunitTheoryAttr.cs | 21 +++++++++++++++++ .../OnTest/XunitTheoryAttr.cs.gold | 23 +++++++++++++++++++ .../WithAttribute}/WithAttributeOnClass.cs | 0 .../WithAttributeOnClass.cs.gold | 0 .../WithAttribute}/WithAttributeOnMethod.cs | 0 .../WithAttributeOnMethod.cs.gold | 0 .../WithAttribute}/WithoutAttribute.cs | 0 .../WithAttribute}/WithoutAttribute.cs.gold | 0 30 files changed, 283 insertions(+), 9 deletions(-) create mode 100644 AsyncConverter.Tests/Highlightings/ConfigureAwait/ConfigureAwaitOnTestTests.cs create mode 100644 AsyncConverter.Tests/Highlightings/ConfigureAwait/ConfigureAwaitTests.cs rename AsyncConverter.Tests/Highlightings/{ => ConfigureAwait}/ConfigureAwaitWithAttributeTests.cs (79%) delete mode 100644 AsyncConverter.Tests/Highlightings/ConfigureAwaitTests.cs create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/MsTestAttr.cs create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/MsTestAttr.cs.gold rename AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/{ => Common}/WithAttributeOnClass.cs (100%) rename AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/{ => Common}/WithAttributeOnClass.cs.gold (100%) rename AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/{ => Common}/WithFalse.cs (100%) rename AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/{ => Common}/WithFalse.cs.gold (100%) rename AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/{ => Common}/WithTrue.cs (100%) rename AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/{ => Common}/WithTrue.cs.gold (100%) rename AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/{ => Common}/Without.cs (100%) rename AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/{ => Common}/Without.cs.gold (100%) create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/MsTestAttr.cs create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/MsTestAttr.cs.gold create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestAttr.cs create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestAttr.cs.gold create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestCaseAttr.cs create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestCaseAttr.cs.gold create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitFactAttr.cs create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitFactAttr.cs.gold create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitTheoryAttr.cs create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitTheoryAttr.cs.gold rename AsyncConverter.Tests/Test/Data/Highlightings/{ConfigureAwaitWithAttribute => ConfigureAwait/WithAttribute}/WithAttributeOnClass.cs (100%) rename AsyncConverter.Tests/Test/Data/Highlightings/{ConfigureAwaitWithAttribute => ConfigureAwait/WithAttribute}/WithAttributeOnClass.cs.gold (100%) rename AsyncConverter.Tests/Test/Data/Highlightings/{ConfigureAwaitWithAttribute => ConfigureAwait/WithAttribute}/WithAttributeOnMethod.cs (100%) rename AsyncConverter.Tests/Test/Data/Highlightings/{ConfigureAwaitWithAttribute => ConfigureAwait/WithAttribute}/WithAttributeOnMethod.cs.gold (100%) rename AsyncConverter.Tests/Test/Data/Highlightings/{ConfigureAwaitWithAttribute => ConfigureAwait/WithAttribute}/WithoutAttribute.cs (100%) rename AsyncConverter.Tests/Test/Data/Highlightings/{ConfigureAwaitWithAttribute => ConfigureAwait/WithAttribute}/WithoutAttribute.cs.gold (100%) diff --git a/AsyncConverter.Tests/Highlightings/ConfigureAwait/ConfigureAwaitOnTestTests.cs b/AsyncConverter.Tests/Highlightings/ConfigureAwait/ConfigureAwaitOnTestTests.cs new file mode 100644 index 0000000..bc724dd --- /dev/null +++ b/AsyncConverter.Tests/Highlightings/ConfigureAwait/ConfigureAwaitOnTestTests.cs @@ -0,0 +1,11 @@ +using AsyncConverter.Settings.General; +using JetBrains.ReSharper.TestFramework; + +namespace AsyncConverter.Tests.Highlightings +{ + [TestSetting(typeof(GeneralSettings), nameof(GeneralSettings.ExcludeTestMethodsFromConfigureAwait), false)] + public class ConfigureAwaitOnTestTests : HighlightingsTestsBase + { + protected override string Folder => "ConfigureAwait/OnTest"; + } +} \ No newline at end of file diff --git a/AsyncConverter.Tests/Highlightings/ConfigureAwait/ConfigureAwaitTests.cs b/AsyncConverter.Tests/Highlightings/ConfigureAwait/ConfigureAwaitTests.cs new file mode 100644 index 0000000..b061a48 --- /dev/null +++ b/AsyncConverter.Tests/Highlightings/ConfigureAwait/ConfigureAwaitTests.cs @@ -0,0 +1,7 @@ +namespace AsyncConverter.Tests.Highlightings +{ + public class ConfigureAwaitTests : HighlightingsTestsBase + { + protected override string Folder => "ConfigureAwait/Common"; + } +} \ No newline at end of file diff --git a/AsyncConverter.Tests/Highlightings/ConfigureAwaitWithAttributeTests.cs b/AsyncConverter.Tests/Highlightings/ConfigureAwait/ConfigureAwaitWithAttributeTests.cs similarity index 79% rename from AsyncConverter.Tests/Highlightings/ConfigureAwaitWithAttributeTests.cs rename to AsyncConverter.Tests/Highlightings/ConfigureAwait/ConfigureAwaitWithAttributeTests.cs index fa48e4a..9d50f4a 100644 --- a/AsyncConverter.Tests/Highlightings/ConfigureAwaitWithAttributeTests.cs +++ b/AsyncConverter.Tests/Highlightings/ConfigureAwait/ConfigureAwaitWithAttributeTests.cs @@ -1,4 +1,4 @@ -using AsyncConverter.Settings.ConfigureAwaitOptions; +using AsyncConverter.Settings.ConfigureAwaitOptions; using JetBrains.Application.Settings; namespace AsyncConverter.Tests.Highlightings @@ -9,6 +9,6 @@ protected override void MutateSettings(IContextBoundSettingsStore settingsStore) { settingsStore.SetIndexedValue((AsyncConverterConfigureAwaitSettings s) => s.ConfigureAwaitIgnoreAttributeTypes, "MyCustomAttribute", "AsyncConverter.Tests.Test.Data.Highlightings.ConfigureAwaitWithAttribute.MyCustomAttribute"); } - protected override string Folder => "ConfigureAwaitWithAttribute"; + protected override string Folder => "ConfigureAwait/WithAttribute"; } } \ No newline at end of file diff --git a/AsyncConverter.Tests/Highlightings/ConfigureAwaitTests.cs b/AsyncConverter.Tests/Highlightings/ConfigureAwaitTests.cs deleted file mode 100644 index 445c0d9..0000000 --- a/AsyncConverter.Tests/Highlightings/ConfigureAwaitTests.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace AsyncConverter.Tests.Highlightings -{ - public class ConfigureAwaitTests : HighlightingsTestsBase - { - protected override string Folder => "ConfigureAwait"; - } -} \ No newline at end of file diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/MsTestAttr.cs b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/MsTestAttr.cs new file mode 100644 index 0000000..f8a7bbe --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/MsTestAttr.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using Microsoft.VisualStudio.TestTools.UnitTesting; + public class Class + { + [TestMethod] + public async Task Test() + { + await Task.Delay(1000); + } + } +} + +namespace Microsoft.VisualStudio.TestTools.UnitTesting +{ + public class TestMethodAttribute : Attribute + { } +} \ No newline at end of file diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/MsTestAttr.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/MsTestAttr.cs.gold new file mode 100644 index 0000000..2171058 --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/MsTestAttr.cs.gold @@ -0,0 +1,22 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using Microsoft.VisualStudio.TestTools.UnitTesting; + public class Class + { + [TestMethod] + public async Task Test() + { + await Task.Delay(1000); + } + } +} + +namespace Microsoft.VisualStudio.TestTools.UnitTesting +{ + public class TestMethodAttribute : Attribute + { } +} +--------------------------------------------------------- diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/WithAttributeOnClass.cs similarity index 100% rename from AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs rename to AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/WithAttributeOnClass.cs diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/WithAttributeOnClass.cs.gold similarity index 100% rename from AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttributeOnClass.cs.gold rename to AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/WithAttributeOnClass.cs.gold diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithFalse.cs b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/WithFalse.cs similarity index 100% rename from AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithFalse.cs rename to AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/WithFalse.cs diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithFalse.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/WithFalse.cs.gold similarity index 100% rename from AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithFalse.cs.gold rename to AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/WithFalse.cs.gold diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithTrue.cs b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/WithTrue.cs similarity index 100% rename from AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithTrue.cs rename to AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/WithTrue.cs diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithTrue.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/WithTrue.cs.gold similarity index 100% rename from AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithTrue.cs.gold rename to AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/WithTrue.cs.gold diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Without.cs b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/Without.cs similarity index 100% rename from AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Without.cs rename to AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/Without.cs diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Without.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/Without.cs.gold similarity index 100% rename from AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Without.cs.gold rename to AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/Common/Without.cs.gold diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/MsTestAttr.cs b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/MsTestAttr.cs new file mode 100644 index 0000000..f8a7bbe --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/MsTestAttr.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using Microsoft.VisualStudio.TestTools.UnitTesting; + public class Class + { + [TestMethod] + public async Task Test() + { + await Task.Delay(1000); + } + } +} + +namespace Microsoft.VisualStudio.TestTools.UnitTesting +{ + public class TestMethodAttribute : Attribute + { } +} \ No newline at end of file diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/MsTestAttr.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/MsTestAttr.cs.gold new file mode 100644 index 0000000..cc498ba --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/MsTestAttr.cs.gold @@ -0,0 +1,23 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using Microsoft.VisualStudio.TestTools.UnitTesting; + public class Class + { + [TestMethod] + public async Task Test() + { + |await Task.Delay(1000)|(0); + } + } +} + +namespace Microsoft.VisualStudio.TestTools.UnitTesting +{ + public class TestMethodAttribute : Attribute + { } +} +--------------------------------------------------------- +(0): ReSharper Warning: (T) 'If await not configured it may cause deadlock, if this code will be call synchronously' (E) 'Await not configured' diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestAttr.cs b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestAttr.cs new file mode 100644 index 0000000..8e0b648 --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestAttr.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using NUnit.Framework; + public class Class + { + [Test] + public async Task Test() + { + await Task.Delay(1000); + } + } +} + +namespace NUnit.Framework +{ + public class TestAttribute : Attribute + { } +} \ No newline at end of file diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestAttr.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestAttr.cs.gold new file mode 100644 index 0000000..c8018dd --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestAttr.cs.gold @@ -0,0 +1,23 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using NUnit.Framework; + public class Class + { + [Test] + public async Task Test() + { + |await Task.Delay(1000)|(0); + } + } +} + +namespace NUnit.Framework +{ + public class TestAttribute : Attribute + { } +} +--------------------------------------------------------- +(0): ReSharper Warning: (T) 'If await not configured it may cause deadlock, if this code will be call synchronously' (E) 'Await not configured' diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestCaseAttr.cs b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestCaseAttr.cs new file mode 100644 index 0000000..9ed6e2c --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestCaseAttr.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using NUnit.Framework; + public class Class + { + [TestCase] + public async Task Test() + { + await Task.Delay(1000); + } + } +} + +namespace NUnit.Framework +{ + public class TestCaseAttribute : Attribute + { } +} \ No newline at end of file diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestCaseAttr.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestCaseAttr.cs.gold new file mode 100644 index 0000000..aaafe95 --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/NUnitTestCaseAttr.cs.gold @@ -0,0 +1,23 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using NUnit.Framework; + public class Class + { + [TestCase] + public async Task Test() + { + |await Task.Delay(1000)|(0); + } + } +} + +namespace NUnit.Framework +{ + public class TestCaseAttribute : Attribute + { } +} +--------------------------------------------------------- +(0): ReSharper Warning: (T) 'If await not configured it may cause deadlock, if this code will be call synchronously' (E) 'Await not configured' diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitFactAttr.cs b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitFactAttr.cs new file mode 100644 index 0000000..5b96cf6 --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitFactAttr.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using Xunit; + public class Class + { + [Fact] + public async Task Test() + { + await Task.Delay(1000); + } + } +} + +namespace Xunit +{ + public class FactAttribute : Attribute + { } +} \ No newline at end of file diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitFactAttr.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitFactAttr.cs.gold new file mode 100644 index 0000000..4213673 --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitFactAttr.cs.gold @@ -0,0 +1,23 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using Xunit; + public class Class + { + [Fact] + public async Task Test() + { + |await Task.Delay(1000)|(0); + } + } +} + +namespace Xunit +{ + public class FactAttribute : Attribute + { } +} +--------------------------------------------------------- +(0): ReSharper Warning: (T) 'If await not configured it may cause deadlock, if this code will be call synchronously' (E) 'Await not configured' diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitTheoryAttr.cs b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitTheoryAttr.cs new file mode 100644 index 0000000..1963956 --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitTheoryAttr.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using Xunit; + public class Class + { + [Theory] + public async Task Test() + { + await Task.Delay(1000); + } + } +} + +namespace Xunit +{ + public class TheoryAttribute : Attribute + { } +} \ No newline at end of file diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitTheoryAttr.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitTheoryAttr.cs.gold new file mode 100644 index 0000000..5be9601 --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/OnTest/XunitTheoryAttr.cs.gold @@ -0,0 +1,23 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using Xunit; + public class Class + { + [Theory] + public async Task Test() + { + |await Task.Delay(1000)|(0); + } + } +} + +namespace Xunit +{ + public class TheoryAttribute : Attribute + { } +} +--------------------------------------------------------- +(0): ReSharper Warning: (T) 'If await not configured it may cause deadlock, if this code will be call synchronously' (E) 'Await not configured' diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwaitWithAttribute/WithAttributeOnClass.cs b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttribute/WithAttributeOnClass.cs similarity index 100% rename from AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwaitWithAttribute/WithAttributeOnClass.cs rename to AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttribute/WithAttributeOnClass.cs diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwaitWithAttribute/WithAttributeOnClass.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttribute/WithAttributeOnClass.cs.gold similarity index 100% rename from AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwaitWithAttribute/WithAttributeOnClass.cs.gold rename to AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttribute/WithAttributeOnClass.cs.gold diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwaitWithAttribute/WithAttributeOnMethod.cs b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttribute/WithAttributeOnMethod.cs similarity index 100% rename from AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwaitWithAttribute/WithAttributeOnMethod.cs rename to AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttribute/WithAttributeOnMethod.cs diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwaitWithAttribute/WithAttributeOnMethod.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttribute/WithAttributeOnMethod.cs.gold similarity index 100% rename from AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwaitWithAttribute/WithAttributeOnMethod.cs.gold rename to AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttribute/WithAttributeOnMethod.cs.gold diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwaitWithAttribute/WithoutAttribute.cs b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttribute/WithoutAttribute.cs similarity index 100% rename from AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwaitWithAttribute/WithoutAttribute.cs rename to AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttribute/WithoutAttribute.cs diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwaitWithAttribute/WithoutAttribute.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttribute/WithoutAttribute.cs.gold similarity index 100% rename from AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwaitWithAttribute/WithoutAttribute.cs.gold rename to AsyncConverter.Tests/Test/Data/Highlightings/ConfigureAwait/WithAttribute/WithoutAttribute.cs.gold From a1474ed70ef20142065f029f0d85aa864758c717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Mon, 25 Jun 2018 11:43:48 +0500 Subject: [PATCH 11/16] clean up --- AsyncConverter/AsyncHelpers/AwaitEliders/MethodAwaitElider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AsyncConverter/AsyncHelpers/AwaitEliders/MethodAwaitElider.cs b/AsyncConverter/AsyncHelpers/AwaitEliders/MethodAwaitElider.cs index 4a18f95..11ceac2 100644 --- a/AsyncConverter/AsyncHelpers/AwaitEliders/MethodAwaitElider.cs +++ b/AsyncConverter/AsyncHelpers/AwaitEliders/MethodAwaitElider.cs @@ -9,7 +9,7 @@ internal class MethodAwaitElider : ICustomAwaitElider { public bool CanElide(ICSharpDeclaration declarationOrClosure) => declarationOrClosure is IMethodDeclaration; - public void Elide(ICSharpDeclaration declarationOrClosure, ICSharpExpression awaitExpression) + public void Elide(ICSharpDeclaration declarationOrClosure, ICSharpExpression awaitExpression) { var factory = CSharpElementFactory.GetInstance(awaitExpression); From ae7feec6ab5b517e391e778bf485cb07005a8077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Mon, 25 Jun 2018 11:44:32 +0500 Subject: [PATCH 12/16] rename NeedAdding to CanBeAdded --- .../ConfigureAwaitCheckers/ConfigureAwaitChecker.cs | 2 +- .../CustomCheckers/AttributeFunctionChecker.cs | 2 +- .../CustomCheckers/AttributeTypeChecker.cs | 11 ++++++----- .../CustomCheckers/BaseChecker.cs | 2 +- .../CustomCheckers/IConfigureAwaitCustomChecker.cs | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/ConfigureAwaitChecker.cs b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/ConfigureAwaitChecker.cs index f37300f..3cbfc16 100644 --- a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/ConfigureAwaitChecker.cs +++ b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/ConfigureAwaitChecker.cs @@ -18,7 +18,7 @@ public ConfigureAwaitChecker(IEnumerable awaitCust public bool NeedAdding(IAwaitExpression element) { - return awaitCustomCheckers.All(x => x.NeedAdding(element)); + return awaitCustomCheckers.All(x => x.CanBeAdded(element)); } } } \ No newline at end of file diff --git a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeFunctionChecker.cs b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeFunctionChecker.cs index 6dbe612..4741fe3 100644 --- a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeFunctionChecker.cs +++ b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeFunctionChecker.cs @@ -14,7 +14,7 @@ public AttributeFunctionChecker(IAttributeFunctionChecker attributeFunctionCheck this.attributeFunctionChecker = attributeFunctionChecker; } - public bool NeedAdding(IAwaitExpression element) + public bool CanBeAdded(IAwaitExpression element) { return !attributeFunctionChecker.IsUnder(element); } diff --git a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeTypeChecker.cs b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeTypeChecker.cs index df20a45..ccc4233 100644 --- a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeTypeChecker.cs +++ b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/AttributeTypeChecker.cs @@ -1,18 +1,19 @@ using AsyncConverter.Checkers; using JetBrains.ProjectModel; using JetBrains.ReSharper.Psi.CSharp.Tree; -using JetBrains.ReSharper.Psi.Tree; namespace AsyncConverter.AsyncHelpers.ConfigureAwaitCheckers.CustomCheckers { [SolutionComponent] class AttributeTypeChecker : IConfigureAwaitCustomChecker { - public bool NeedAdding(IAwaitExpression element) - { - var attributeTypeChecker = element.GetSolution().GetComponent(); + private readonly IAttributeTypeChecker attributeTypeChecker; - return !attributeTypeChecker.IsUnder(element); + public AttributeTypeChecker(IAttributeTypeChecker attributeTypeChecker) + { + this.attributeTypeChecker = attributeTypeChecker; } + + public bool CanBeAdded(IAwaitExpression element) => !attributeTypeChecker.IsUnder(element); } } \ No newline at end of file diff --git a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/BaseChecker.cs b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/BaseChecker.cs index 4ebdf06..b2d1139 100644 --- a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/BaseChecker.cs +++ b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/BaseChecker.cs @@ -8,7 +8,7 @@ namespace AsyncConverter.AsyncHelpers.ConfigureAwaitCheckers.CustomCheckers [SolutionComponent] internal class BaseChecker : IConfigureAwaitCustomChecker { - public bool NeedAdding(IAwaitExpression element) + public bool CanBeAdded(IAwaitExpression element) { var declaredType = element.Task?.GetExpressionType() as IDeclaredType; diff --git a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/IConfigureAwaitCustomChecker.cs b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/IConfigureAwaitCustomChecker.cs index fa0bdd6..f5d5b6d 100644 --- a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/IConfigureAwaitCustomChecker.cs +++ b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/IConfigureAwaitCustomChecker.cs @@ -4,6 +4,6 @@ namespace AsyncConverter.AsyncHelpers.ConfigureAwaitCheckers.CustomCheckers { public interface IConfigureAwaitCustomChecker { - bool NeedAdding(IAwaitExpression element); + bool CanBeAdded(IAwaitExpression element); } } \ No newline at end of file From b6f655ef13a6a8a012c1acde8e9694f6bfdd73ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Mon, 25 Jun 2018 11:44:47 +0500 Subject: [PATCH 13/16] add OnTestChecker --- .../CustomCheckers/OnTestChecker.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/OnTestChecker.cs diff --git a/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/OnTestChecker.cs b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/OnTestChecker.cs new file mode 100644 index 0000000..b06b2b3 --- /dev/null +++ b/AsyncConverter/AsyncHelpers/ConfigureAwaitCheckers/CustomCheckers/OnTestChecker.cs @@ -0,0 +1,30 @@ +using AsyncConverter.Checkers; +using AsyncConverter.Settings; +using JetBrains.Application.Settings; +using JetBrains.ProjectModel; +using JetBrains.ReSharper.Psi.CSharp.Tree; +using JetBrains.ReSharper.Psi.Tree; + +namespace AsyncConverter.AsyncHelpers.ConfigureAwaitCheckers.CustomCheckers +{ + [SolutionComponent] + internal class OnTestChecker : IConfigureAwaitCustomChecker + { + private readonly IUnderTestChecker underTestChecker; + + public OnTestChecker(IUnderTestChecker underTestChecker) + { + this.underTestChecker = underTestChecker; + } + + public bool CanBeAdded(IAwaitExpression element) + { + var excludeTestMethods = element.GetSettingsStore().GetValue(AsyncConverterSettingsAccessor.ExcludeTestMethodsFromConfigureAwait); + var methodDeclaration = + element.GetContainingTypeMemberDeclarationIgnoringClosures() as IMethodDeclaration; + if (methodDeclaration == null) + return true; + return !excludeTestMethods || !underTestChecker.IsUnder(methodDeclaration); + } + } +} \ No newline at end of file From 8d9eeff5f552f24cf63fade9bf3027c78a1fea2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Tue, 26 Jun 2018 22:47:50 +0500 Subject: [PATCH 14/16] version --- AsyncConverter/AsyncConverter.Rider.csproj | 2 +- AsyncConverter/AsyncConverter.csproj | 2 +- Rider/AsyncConverter.Rider/META-INF/plugin.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AsyncConverter/AsyncConverter.Rider.csproj b/AsyncConverter/AsyncConverter.Rider.csproj index 92e7e22..b01764a 100644 --- a/AsyncConverter/AsyncConverter.Rider.csproj +++ b/AsyncConverter/AsyncConverter.Rider.csproj @@ -3,7 +3,7 @@ net461 true AsyncConverter.Rider - 1.1.8.10 + 1.1.8.11 i.mamay diff --git a/AsyncConverter/AsyncConverter.csproj b/AsyncConverter/AsyncConverter.csproj index 4e97a8e..aef06d9 100644 --- a/AsyncConverter/AsyncConverter.csproj +++ b/AsyncConverter/AsyncConverter.csproj @@ -3,7 +3,7 @@ net461 true AsyncConverter.AsyncConverter - 1.1.8.10 + 1.1.8.11 i.mamay diff --git a/Rider/AsyncConverter.Rider/META-INF/plugin.xml b/Rider/AsyncConverter.Rider/META-INF/plugin.xml index 95c0110..598dd08 100644 --- a/Rider/AsyncConverter.Rider/META-INF/plugin.xml +++ b/Rider/AsyncConverter.Rider/META-INF/plugin.xml @@ -1,8 +1,8 @@ - + AsyncConverter.AsyncConverter AsyncConverter Plugin for converting code to async. - 1.1.8.10 + 1.1.8.11 i.mamay From c974ecde4ca576040d858e7c3fd19f4eedd88d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Tue, 10 Jul 2018 22:12:38 +0500 Subject: [PATCH 15/16] add test on TestCaseSourceAttribute --- .../Naming/NUnitTestCaseSource.cs | 36 +++++++++++++++++ .../Naming/NUnitTestCaseSource.cs.gold | 38 ++++++++++++++++++ .../NUnitTestCaseSource.cs | 36 +++++++++++++++++ .../NUnitTestCaseSource.cs.gold | 39 +++++++++++++++++++ 4 files changed, 149 insertions(+) create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/Naming/NUnitTestCaseSource.cs create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/Naming/NUnitTestCaseSource.cs.gold create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/NamingWithExcludeTestMethods/NUnitTestCaseSource.cs create mode 100644 AsyncConverter.Tests/Test/Data/Highlightings/NamingWithExcludeTestMethods/NUnitTestCaseSource.cs.gold diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/Naming/NUnitTestCaseSource.cs b/AsyncConverter.Tests/Test/Data/Highlightings/Naming/NUnitTestCaseSource.cs new file mode 100644 index 0000000..8cb55c7 --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/Naming/NUnitTestCaseSource.cs @@ -0,0 +1,36 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using NUnit.Framework; + public class Class + { + [TestCaseSource(nameof(FileNames))] + public async Task Test() + { + await Task.Delay(1000).ConfigureAwait(false); + await Task.Delay(1000).ConfigureAwait(false); + } + + protected TestCaseData[] FileNames() + { + return new TestCaseData[0]; + } + } +} + +namespace NUnit.Framework +{ + public class TestCaseSourceAttribute : Attribute + { + public TestCaseSourceAttribute(string sourceName) + { + + } + } + + public class TestCaseData + { + } +} \ No newline at end of file diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/Naming/NUnitTestCaseSource.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/Naming/NUnitTestCaseSource.cs.gold new file mode 100644 index 0000000..69baba1 --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/Naming/NUnitTestCaseSource.cs.gold @@ -0,0 +1,38 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using NUnit.Framework; + public class Class + { + [TestCaseSource(nameof(FileNames))] + public async Task Test() + { + await Task.Delay(1000).ConfigureAwait(false); + await Task.Delay(1000).ConfigureAwait(false); + } + + protected TestCaseData[] FileNames() + { + return new TestCaseData[0]; + } + } +} + +namespace NUnit.Framework +{ + public class TestCaseSourceAttribute : Attribute + { + public TestCaseSourceAttribute(string |sourceName|(0)) + { + + } + } + + public class TestCaseData + { + } +} +--------------------------------------------------------- +(0): ReSharper Dead Code: Parameter 'sourceName' is never used diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/NamingWithExcludeTestMethods/NUnitTestCaseSource.cs b/AsyncConverter.Tests/Test/Data/Highlightings/NamingWithExcludeTestMethods/NUnitTestCaseSource.cs new file mode 100644 index 0000000..8cb55c7 --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/NamingWithExcludeTestMethods/NUnitTestCaseSource.cs @@ -0,0 +1,36 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using NUnit.Framework; + public class Class + { + [TestCaseSource(nameof(FileNames))] + public async Task Test() + { + await Task.Delay(1000).ConfigureAwait(false); + await Task.Delay(1000).ConfigureAwait(false); + } + + protected TestCaseData[] FileNames() + { + return new TestCaseData[0]; + } + } +} + +namespace NUnit.Framework +{ + public class TestCaseSourceAttribute : Attribute + { + public TestCaseSourceAttribute(string sourceName) + { + + } + } + + public class TestCaseData + { + } +} \ No newline at end of file diff --git a/AsyncConverter.Tests/Test/Data/Highlightings/NamingWithExcludeTestMethods/NUnitTestCaseSource.cs.gold b/AsyncConverter.Tests/Test/Data/Highlightings/NamingWithExcludeTestMethods/NUnitTestCaseSource.cs.gold new file mode 100644 index 0000000..0838bc6 --- /dev/null +++ b/AsyncConverter.Tests/Test/Data/Highlightings/NamingWithExcludeTestMethods/NUnitTestCaseSource.cs.gold @@ -0,0 +1,39 @@ +using System; +using System.Threading.Tasks; + +namespace AsyncConverter.Tests.Test.Data.FixReturnValueToTaskTests +{ + using NUnit.Framework; + public class Class + { + [TestCaseSource(nameof(FileNames))] + public async Task |Test|(0)() + { + await Task.Delay(1000).ConfigureAwait(false); + await Task.Delay(1000).ConfigureAwait(false); + } + + protected TestCaseData[] FileNames() + { + return new TestCaseData[0]; + } + } +} + +namespace NUnit.Framework +{ + public class TestCaseSourceAttribute : Attribute + { + public TestCaseSourceAttribute(string |sourceName|(1)) + { + + } + } + + public class TestCaseData + { + } +} +--------------------------------------------------------- +(0): ReSharper Warning: (T) '' (E) 'Async method must ends on "Async"' +(1): ReSharper Dead Code: Parameter 'sourceName' is never used From e16c3d9b129c794c2c08ac17aa75abc3bb8b8433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BC=D0=B0=D0=B9=20=D0=98=D0=B3=D0=BE=D1=80?= =?UTF-8?q?=D1=8C?= Date: Tue, 10 Jul 2018 22:13:03 +0500 Subject: [PATCH 16/16] add support TestCaseSourceAttribute --- AsyncConverter/Checkers/UnderTestChecker.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AsyncConverter/Checkers/UnderTestChecker.cs b/AsyncConverter/Checkers/UnderTestChecker.cs index 81aa4d8..d93a07d 100644 --- a/AsyncConverter/Checkers/UnderTestChecker.cs +++ b/AsyncConverter/Checkers/UnderTestChecker.cs @@ -16,7 +16,8 @@ public class UnderTestChecker : IUnderTestChecker new ClrTypeName("Xunit.FactAttribute"), new ClrTypeName("Xunit.TheoryAttribute"), new ClrTypeName("NUnit.Framework.TestAttribute"), - new ClrTypeName("NUnit.Framework.TestCaseAttribute") + new ClrTypeName("NUnit.Framework.TestCaseAttribute"), + new ClrTypeName("NUnit.Framework.TestCaseSourceAttribute"), }; public bool IsUnder(IMethodDeclaration method) => method.AttributeSectionList != null && method.ContainsAttribute(testAttributesClass);