Add Async suffix to async methods
Analyzers will also help catch and enforce this going forward.
This commit is contained in:
Родитель
4b648e2e86
Коммит
cef4778712
|
@ -71,5 +71,7 @@
|
||||||
<Rules AnalyzerId="AsyncUsageAnalyzers" RuleNamespace="AsyncUsageAnalyzers">
|
<Rules AnalyzerId="AsyncUsageAnalyzers" RuleNamespace="AsyncUsageAnalyzers">
|
||||||
<Rule Id="UseConfigureAwait" Action="Error" />
|
<Rule Id="UseConfigureAwait" Action="Error" />
|
||||||
<Rule Id="AvoidAsyncVoid" Action="Error" />
|
<Rule Id="AvoidAsyncVoid" Action="Error" />
|
||||||
|
<Rule Id="UseAsyncSuffix" Action="Error" />
|
||||||
|
<Rule Id="AvoidAsyncSuffix" Action="Error" />
|
||||||
</Rules>
|
</Rules>
|
||||||
</RuleSet>
|
</RuleSet>
|
|
@ -70,7 +70,7 @@ namespace StreamJsonRpc
|
||||||
};
|
};
|
||||||
|
|
||||||
this.splitJoinStream = new SplitJoinStream(options);
|
this.splitJoinStream = new SplitJoinStream(options);
|
||||||
this.readLinesTask = Task.Run(this.ReadAndHandleRequests, this.disposeCts.Token);
|
this.readLinesTask = Task.Run(this.ReadAndHandleRequestsAsync, this.disposeCts.Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
private event EventHandler<JsonRpcDisconnectedEventArgs> onDisconnected;
|
private event EventHandler<JsonRpcDisconnectedEventArgs> onDisconnected;
|
||||||
|
@ -325,7 +325,7 @@ namespace StreamJsonRpc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<JsonRpcMessage> DispatchIncomingRequest(JsonRpcMessage request)
|
private async Task<JsonRpcMessage> DispatchIncomingRequestAsync(JsonRpcMessage request)
|
||||||
{
|
{
|
||||||
if (this.callbackTarget == null)
|
if (this.callbackTarget == null)
|
||||||
{
|
{
|
||||||
|
@ -414,7 +414,7 @@ namespace StreamJsonRpc
|
||||||
return JsonRpcMessage.CreateError(id, JsonRpcErrorCode.InvocationError, message, data);
|
return JsonRpcMessage.CreateError(id, JsonRpcErrorCode.InvocationError, message, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ReadAndHandleRequests()
|
private async Task ReadAndHandleRequestsAsync()
|
||||||
{
|
{
|
||||||
JsonRpcDisconnectedEventArgs disconnectedEventArgs = null;
|
JsonRpcDisconnectedEventArgs disconnectedEventArgs = null;
|
||||||
|
|
||||||
|
@ -457,7 +457,7 @@ namespace StreamJsonRpc
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.HandleRpc(json);
|
this.HandleRpcAsync(json);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
@ -487,7 +487,7 @@ namespace StreamJsonRpc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task HandleRpc(string json)
|
private async Task HandleRpcAsync(string json)
|
||||||
{
|
{
|
||||||
JsonRpcMessage rpc;
|
JsonRpcMessage rpc;
|
||||||
try
|
try
|
||||||
|
@ -508,7 +508,7 @@ namespace StreamJsonRpc
|
||||||
|
|
||||||
if (rpc.IsRequest)
|
if (rpc.IsRequest)
|
||||||
{
|
{
|
||||||
JsonRpcMessage result = await this.DispatchIncomingRequest(rpc).ConfigureAwait(false);
|
JsonRpcMessage result = await this.DispatchIncomingRequestAsync(rpc).ConfigureAwait(false);
|
||||||
|
|
||||||
if (!rpc.IsNotification)
|
if (!rpc.IsNotification)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<CodeAnalysisRuleSet>StreamJsonRpc.Tests.ruleset</CodeAnalysisRuleSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<CodeAnalysisRuleSet>StreamJsonRpc.Tests.ruleset</CodeAnalysisRuleSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- A reference to the entire .NET Framework is automatically included -->
|
<!-- A reference to the entire .NET Framework is automatically included -->
|
||||||
|
@ -48,6 +50,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="project.json" />
|
<None Include="project.json" />
|
||||||
|
<None Include="StreamJsonRpc.Tests.ruleset" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<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">
|
||||||
|
<Localization ResourceAssembly="Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.dll" ResourceBaseName="Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.Localized">
|
||||||
|
<Name Resource="MinimumRecommendedRules_Name" />
|
||||||
|
<Description Resource="MinimumRecommendedRules_Description" />
|
||||||
|
</Localization>
|
||||||
|
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
|
||||||
|
<Rule Id="CA1001" Action="Warning" />
|
||||||
|
<Rule Id="CA1009" Action="Warning" />
|
||||||
|
<Rule Id="CA1016" Action="Warning" />
|
||||||
|
<Rule Id="CA1033" Action="Warning" />
|
||||||
|
<Rule Id="CA1049" Action="Warning" />
|
||||||
|
<Rule Id="CA1060" Action="Warning" />
|
||||||
|
<Rule Id="CA1061" Action="Warning" />
|
||||||
|
<Rule Id="CA1063" Action="Warning" />
|
||||||
|
<Rule Id="CA1065" Action="Warning" />
|
||||||
|
<Rule Id="CA1301" Action="Warning" />
|
||||||
|
<Rule Id="CA1400" Action="Warning" />
|
||||||
|
<Rule Id="CA1401" Action="Warning" />
|
||||||
|
<Rule Id="CA1403" Action="Warning" />
|
||||||
|
<Rule Id="CA1404" Action="Warning" />
|
||||||
|
<Rule Id="CA1405" Action="Warning" />
|
||||||
|
<Rule Id="CA1410" Action="Warning" />
|
||||||
|
<Rule Id="CA1415" Action="Warning" />
|
||||||
|
<Rule Id="CA1821" Action="Warning" />
|
||||||
|
<Rule Id="CA1900" Action="Warning" />
|
||||||
|
<Rule Id="CA1901" Action="Warning" />
|
||||||
|
<Rule Id="CA2002" Action="Warning" />
|
||||||
|
<Rule Id="CA2100" Action="Warning" />
|
||||||
|
<Rule Id="CA2101" Action="Warning" />
|
||||||
|
<Rule Id="CA2108" Action="Warning" />
|
||||||
|
<Rule Id="CA2111" Action="Warning" />
|
||||||
|
<Rule Id="CA2112" Action="Warning" />
|
||||||
|
<Rule Id="CA2114" Action="Warning" />
|
||||||
|
<Rule Id="CA2116" Action="Warning" />
|
||||||
|
<Rule Id="CA2117" Action="Warning" />
|
||||||
|
<Rule Id="CA2122" Action="Warning" />
|
||||||
|
<Rule Id="CA2123" Action="Warning" />
|
||||||
|
<Rule Id="CA2124" Action="Warning" />
|
||||||
|
<Rule Id="CA2126" Action="Warning" />
|
||||||
|
<Rule Id="CA2131" Action="Warning" />
|
||||||
|
<Rule Id="CA2132" Action="Warning" />
|
||||||
|
<Rule Id="CA2133" Action="Warning" />
|
||||||
|
<Rule Id="CA2134" Action="Warning" />
|
||||||
|
<Rule Id="CA2137" Action="Warning" />
|
||||||
|
<Rule Id="CA2138" Action="Warning" />
|
||||||
|
<Rule Id="CA2140" Action="Warning" />
|
||||||
|
<Rule Id="CA2141" Action="Warning" />
|
||||||
|
<Rule Id="CA2146" Action="Warning" />
|
||||||
|
<Rule Id="CA2147" Action="Warning" />
|
||||||
|
<Rule Id="CA2149" Action="Warning" />
|
||||||
|
<Rule Id="CA2200" Action="Warning" />
|
||||||
|
<Rule Id="CA2202" Action="Warning" />
|
||||||
|
<Rule Id="CA2207" Action="Warning" />
|
||||||
|
<Rule Id="CA2212" Action="Warning" />
|
||||||
|
<Rule Id="CA2213" Action="Warning" />
|
||||||
|
<Rule Id="CA2214" Action="Warning" />
|
||||||
|
<Rule Id="CA2216" Action="Warning" />
|
||||||
|
<Rule Id="CA2220" Action="Warning" />
|
||||||
|
<Rule Id="CA2229" Action="Warning" />
|
||||||
|
<Rule Id="CA2231" Action="Warning" />
|
||||||
|
<Rule Id="CA2232" Action="Warning" />
|
||||||
|
<Rule Id="CA2235" Action="Warning" />
|
||||||
|
<Rule Id="CA2236" Action="Warning" />
|
||||||
|
<Rule Id="CA2237" Action="Warning" />
|
||||||
|
<Rule Id="CA2238" Action="Warning" />
|
||||||
|
<Rule Id="CA2240" Action="Warning" />
|
||||||
|
<Rule Id="CA2241" Action="Warning" />
|
||||||
|
<Rule Id="CA2242" Action="Warning" />
|
||||||
|
</Rules>
|
||||||
|
<Rules AnalyzerId="AsyncUsageAnalyzers" RuleNamespace="AsyncUsageAnalyzers">
|
||||||
|
<Rule Id="UseAsyncSuffix" Action="Hidden" />
|
||||||
|
</Rules>
|
||||||
|
</RuleSet>
|
|
@ -71,5 +71,7 @@
|
||||||
<Rules AnalyzerId="AsyncUsageAnalyzers" RuleNamespace="AsyncUsageAnalyzers">
|
<Rules AnalyzerId="AsyncUsageAnalyzers" RuleNamespace="AsyncUsageAnalyzers">
|
||||||
<Rule Id="UseConfigureAwait" Action="Error" />
|
<Rule Id="UseConfigureAwait" Action="Error" />
|
||||||
<Rule Id="AvoidAsyncVoid" Action="Error" />
|
<Rule Id="AvoidAsyncVoid" Action="Error" />
|
||||||
|
<Rule Id="AvoidAsyncSuffix" Action="Error" />
|
||||||
|
<Rule Id="UseAsyncSuffix" Action="Error" />
|
||||||
</Rules>
|
</Rules>
|
||||||
</RuleSet>
|
</RuleSet>
|
Загрузка…
Ссылка в новой задаче