Skip to content

Commit

Permalink
Update Threading.Analyzers and fix VSTHRD200 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sw-joelmut committed Jul 29, 2024
1 parent 276bb33 commit 2fd2929
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
</ItemGroup>
<ItemGroup>
<Analyzer Include="packages\Microsoft.VisualStudio.SDK.Analyzers.15.8.33\analyzers\cs\Microsoft.VisualStudio.SDK.Analyzers.dll" />
<Analyzer Include="packages\Microsoft.VisualStudio.Threading.Analyzers.15.8.122\analyzers\cs\Microsoft.VisualStudio.Threading.Analyzers.dll" />
<Analyzer Include="packages\Microsoft.VisualStudio.Threading.Analyzers.17.10.48\analyzers\cs\Microsoft.VisualStudio.Threading.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
Expand All @@ -128,12 +128,12 @@
powershell Compress-Archive -Path '$(SolutionDir)UncompressedProjectTemplates\*' -DestinationPath $(ProjectDir)ProjectTemplates\Bot` Framework.zip -Force
</PreBuildEvent>
</PropertyGroup>
<Import Project="packages\Microsoft.VisualStudio.Threading.Analyzers.15.8.122\build\Microsoft.VisualStudio.Threading.Analyzers.targets" Condition="Exists('packages\Microsoft.VisualStudio.Threading.Analyzers.15.8.122\build\Microsoft.VisualStudio.Threading.Analyzers.targets')" />
<Import Project="packages\Microsoft.VisualStudio.Threading.Analyzers.17.10.48\build\Microsoft.VisualStudio.Threading.Analyzers.targets" Condition="Exists('packages\Microsoft.VisualStudio.Threading.Analyzers.17.10.48\build\Microsoft.VisualStudio.Threading.Analyzers.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Microsoft.VisualStudio.Threading.Analyzers.15.8.122\build\Microsoft.VisualStudio.Threading.Analyzers.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.VisualStudio.Threading.Analyzers.15.8.122\build\Microsoft.VisualStudio.Threading.Analyzers.targets'))" />
<Error Condition="!Exists('packages\Microsoft.VisualStudio.Threading.Analyzers.17.10.48\build\Microsoft.VisualStudio.Threading.Analyzers.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.VisualStudio.Threading.Analyzers.17.10.48\build\Microsoft.VisualStudio.Threading.Analyzers.targets'))" />
<Error Condition="!Exists('packages\Microsoft.VisualStudio.SDK.Analyzers.15.8.33\build\Microsoft.VisualStudio.SDK.Analyzers.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.VisualStudio.SDK.Analyzers.15.8.33\build\Microsoft.VisualStudio.SDK.Analyzers.targets'))" />
<Error Condition="!Exists('packages\Microsoft.VSSDK.BuildTools.17.0.5232\build\Microsoft.VSSDK.BuildTools.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.VSSDK.BuildTools.17.0.5232\build\Microsoft.VSSDK.BuildTools.props'))" />
<Error Condition="!Exists('packages\Microsoft.VSSDK.BuildTools.17.0.5232\build\Microsoft.VSSDK.BuildTools.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.VSSDK.BuildTools.17.0.5232\build\Microsoft.VSSDK.BuildTools.targets'))" />
Expand Down
2 changes: 1 addition & 1 deletion generators/vsix-vs-win/BotBuilderVSIX-V4/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.VisualStudio.SDK.Analyzers" version="15.8.33" targetFramework="net46" />
<package id="Microsoft.VisualStudio.Threading.Analyzers" version="15.8.122" targetFramework="net46" />
<package id="Microsoft.VisualStudio.Threading.Analyzers" version="17.10.48" targetFramework="net46" />
<package id="Microsoft.VSSDK.BuildTools" version="17.0.5232" targetFramework="net46" developmentDependency="true" />
</packages>
2 changes: 1 addition & 1 deletion libraries/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.8.55">
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public async Task ExecuteAsync(ResourceExplorer resourceExplorer, [CallerMemberN
userToken.Setup(adapter);
}

async Task Inspect(DialogContextInspector inspector)
async Task InspectAsync(DialogContextInspector inspector)
{
var di = new DialogInspector(Dialog, resourceExplorer);
var activity = new Activity();
Expand Down Expand Up @@ -235,7 +235,7 @@ await adapter.ProcessActivityAsync(

foreach (var testAction in Script)
{
await testAction.ExecuteAsync(adapter, callback, Inspect).ConfigureAwait(false);
await testAction.ExecuteAsync(adapter, callback, InspectAsync).ConfigureAwait(false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ private void ResourceProvider_Changed(object sender, IEnumerable<Resource> resou
cancelReloadToken.Cancel();
cancelReloadToken = new CancellationTokenSource();

Task.Delay(1000, cancelReloadToken.Token)
_ = Task.Delay(1000, cancelReloadToken.Token)
.ContinueWith(
t =>
{
Expand Down
32 changes: 16 additions & 16 deletions libraries/Microsoft.Bot.Builder/TurnContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,24 +351,24 @@ public ITurnContext OnDeleteActivity(DeleteActivityHandler handler)
// If there are no callbacks registered, bypass the overhead of invoking them and send directly to the adapter
if (_onSendActivities.Count == 0)
{
return SendActivitiesThroughAdapter();
return SendActivitiesThroughAdapterAsync();
}

// Send through the full callback pipeline
return SendActivitiesThroughCallbackPipeline();
return SendActivitiesThroughCallbackPipelineAsync();

Task<ResourceResponse[]> SendActivitiesThroughCallbackPipeline(int nextCallbackIndex = 0)
Task<ResourceResponse[]> SendActivitiesThroughCallbackPipelineAsync(int nextCallbackIndex = 0)
{
// If we've executed the last callback, we now send straight to the adapter
if (nextCallbackIndex == _onSendActivities.Count)
{
return SendActivitiesThroughAdapter();
return SendActivitiesThroughAdapterAsync();
}

return _onSendActivities[nextCallbackIndex].Invoke(this, bufferedActivities, () => SendActivitiesThroughCallbackPipeline(nextCallbackIndex + 1));
return _onSendActivities[nextCallbackIndex].Invoke(this, bufferedActivities, () => SendActivitiesThroughCallbackPipelineAsync(nextCallbackIndex + 1));
}

async Task<ResourceResponse[]> SendActivitiesThroughAdapter()
async Task<ResourceResponse[]> SendActivitiesThroughAdapterAsync()
{
if (Activity.DeliveryMode == DeliveryModes.ExpectReplies)
{
Expand Down Expand Up @@ -453,12 +453,12 @@ public async Task<ResourceResponse> UpdateActivityAsync(IActivity activity, Canc
var conversationReference = Activity.GetConversationReference();
var a = activity.ApplyConversationReference(conversationReference);

async Task<ResourceResponse> ActuallyUpdateStuff()
async Task<ResourceResponse> ActuallyUpdateStuffAsync()
{
return await Adapter.UpdateActivityAsync(this, a, cancellationToken).ConfigureAwait(false);
}

return await UpdateActivityInternalAsync(a, _onUpdateActivity, ActuallyUpdateStuff, cancellationToken).ConfigureAwait(false);
return await UpdateActivityInternalAsync(a, _onUpdateActivity, ActuallyUpdateStuffAsync, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -484,12 +484,12 @@ async Task<ResourceResponse> ActuallyUpdateStuff()
var cr = Activity.GetConversationReference();
cr.ActivityId = activityId;

async Task ActuallyDeleteStuff()
async Task ActuallyDeleteStuffAsync()
{
await Adapter.DeleteActivityAsync(this, cr, cancellationToken).ConfigureAwait(false);
}

await DeleteActivityInternalAsync(cr, _onDeleteActivity, ActuallyDeleteStuff, cancellationToken).ConfigureAwait(false);
await DeleteActivityInternalAsync(cr, _onDeleteActivity, ActuallyDeleteStuffAsync, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -514,12 +514,12 @@ async Task ActuallyDeleteStuff()
throw new ArgumentNullException(nameof(conversationReference));
}

async Task ActuallyDeleteStuff()
async Task ActuallyDeleteStuffAsync()
{
await Adapter.DeleteActivityAsync(this, conversationReference, cancellationToken).ConfigureAwait(false);
}

await DeleteActivityInternalAsync(conversationReference, _onDeleteActivity, ActuallyDeleteStuff, cancellationToken).ConfigureAwait(false);
await DeleteActivityInternalAsync(conversationReference, _onDeleteActivity, ActuallyDeleteStuffAsync, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand Down Expand Up @@ -574,7 +574,7 @@ private async Task<ResourceResponse> UpdateActivityInternalAsync(
}

// Default to "No more Middleware after this".
async Task<ResourceResponse> Next()
async Task<ResourceResponse> NextAsync()
{
// Remove the first item from the list of middleware to call,
// so that the next call just has the remaining items to worry about.
Expand All @@ -586,7 +586,7 @@ async Task<ResourceResponse> Next()

// Grab the current middleware, which is the 1st element in the array, and execute it
UpdateActivityHandler toCall = updateHandlers.First();
return await toCall(this, activity, Next).ConfigureAwait(false);
return await toCall(this, activity, NextAsync).ConfigureAwait(false);
}

private async Task DeleteActivityInternalAsync(
Expand Down Expand Up @@ -614,7 +614,7 @@ private async Task DeleteActivityInternalAsync(
}

// Default to "No more Middleware after this".
async Task Next()
async Task NextAsync()
{
// Remove the first item from the list of middleware to call,
// so that the next call just has the remaining items to worry about.
Expand All @@ -624,7 +624,7 @@ async Task Next()

// Grab the current middleware, which is the 1st element in the array, and execute it.
DeleteActivityHandler toCall = deleteHandlers.First();
await toCall(this, cr, Next).ConfigureAwait(false);
await toCall(this, cr, NextAsync).ConfigureAwait(false);
}
}
}

0 comments on commit 2fd2929

Please sign in to comment.