Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Raven.CodeAnalysis.Test/ConfigureAwaitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,41 @@ async Task M()
});
}

[TestMethod]
public void TestMethod6_VariableArgument()
{
const string input = @"
class C
{
private Task SthAsync() { return null; }
private bool _continueOnCapturedContext;

async Task M()
{
await SthAsync().ConfigureAwait(_continueOnCapturedContext);
}
}";

VerifyCSharpDiagnostic(input);
}

[TestMethod]
public void TestMethod7_NoArgument()
{
const string input = @"
class C
{
private Task SthAsync() { return null; }

async Task M()
{
await SthAsync().ConfigureAwait();
}
}";

VerifyCSharpDiagnostic(input);
}

Comment on lines +136 to +153
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two blank lines between the new test and the protected override below — drop one to match the single-blank-line spacing used elsewhere in the file.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

protected override DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
{
return new ConfigureAwaitAnalyzer();
Expand Down
2 changes: 1 addition & 1 deletion Raven.CodeAnalysis.nuspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
<metadata minClientVersion="2.12">
<version>1.0.13</version>
<version>1.0.14</version>
<id>Raven.CodeAnalysis</id>
<description>Raven.CodeAnalysis</description>
<authors>RavenDB</authors>
Expand Down
5 changes: 3 additions & 2 deletions Raven.CodeAnalysis/ConfigureAwait/ConfigureAwaitAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Raven.CodeAnalysis.ConfigureAwait
{
[DiagnosticAnalyzer(LanguageNames.CSharp)]
internal class ConfigureAwaitAnalyzer : DiagnosticAnalyzer

Check warning on line 11 in Raven.CodeAnalysis/ConfigureAwait/ConfigureAwaitAnalyzer.cs

View workflow job for this annotation

GitHub Actions / build

'Raven.CodeAnalysis.ConfigureAwait.ConfigureAwaitAnalyzer': A project containing analyzers or source generators should specify the property '<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>'
{
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics =>
ImmutableArray.Create(DiagnosticDescriptors.ConfigureAwait);
Expand All @@ -26,8 +26,9 @@

if (awaitedExpression?.Name.Identifier.Text == "ConfigureAwait")
{
var configureAwaitIsFalse = invocationExpressionSyntax.ArgumentList.Arguments.Single().Expression.IsKind(SyntaxKind.FalseLiteralExpression);
if (configureAwaitIsFalse)
// argument list may be empty during typing — FirstOrDefault avoids a throw from Single()
var argument = invocationExpressionSyntax.ArgumentList.Arguments.FirstOrDefault()?.Expression;
if (argument == null || !argument.IsKind(SyntaxKind.TrueLiteralExpression))
return;
Comment on lines 27 to 32
}

Expand Down
Loading