Skip to content

Commit fcb2df0

Browse files
committed
Add async analyzers and error on missing ConfigureAwait
1 parent 6c9b6d0 commit fcb2df0

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

BencodeNET/BencodeNET.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFrameworks>netstandard1.3;netstandard2.0;netcoreapp2.1</TargetFrameworks>
55
<LangVersion>7.3</LangVersion>
66
<GenerateDocumentationFile>True</GenerateDocumentationFile>
7+
<CodeAnalysisRuleSet>BencodeNET.ruleset</CodeAnalysisRuleSet>
78
</PropertyGroup>
89

910
<!-- Needed for code coverage -->
@@ -36,6 +37,7 @@
3637

3738
<ItemGroup>
3839
<PackageReference Include="System.IO.Pipelines" Version="4.5.3" />
40+
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.3.52" PrivateAssets="All" />
3941
</ItemGroup>
4042

4143
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">

BencodeNET/BencodeNET.ruleset

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RuleSet Name="Microsoft Managed Recommended Rules" Description="These rules focus on the most critical problems in your code, including potential security holes, application crashes, and other important logic and design errors. It is recommended to include this rule set in any custom rule set you create for your projects." ToolsVersion="10.0">
3+
<Localization ResourceAssembly="Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.dll" ResourceBaseName="Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.Localized">
4+
<Name Resource="MinimumRecommendedRules_Name" />
5+
<Description Resource="MinimumRecommendedRules_Description" />
6+
</Localization>
7+
<Rules AnalyzerId="Microsoft.VisualStudio.Threading.Analyzers" RuleNamespace="Microsoft.VisualStudio.Threading.Analyzers">
8+
<Rule Id="VSTHRD111" Action="Error" />
9+
</Rules>
10+
</RuleSet>

BencodeNET/Torrents/TorrentParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Text;
@@ -90,7 +90,7 @@ public override Torrent Parse(BencodeReader reader)
9090
/// <returns>The parsed <see cref="Torrent"/>.</returns>
9191
public override async ValueTask<Torrent> ParseAsync(PipeBencodeReader pipeReader, CancellationToken cancellationToken = default)
9292
{
93-
var data = await BencodeParser.ParseAsync<BDictionary>(pipeReader, cancellationToken);
93+
var data = await BencodeParser.ParseAsync<BDictionary>(pipeReader, cancellationToken).ConfigureAwait(false);
9494
return CreateTorrent(data);
9595
}
9696

0 commit comments

Comments
 (0)