Skip to content

Commit 004627f

Browse files
committed
Enable VSTHRD109 (Switch instead of assert in async methods) and fix violations
1 parent e1f8eb2 commit 004627f

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

GitCommands/RevisionReader.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private async Task ExecuteAsync(
6363
string pathFilter,
6464
[CanBeNull] Func<GitRevision, bool> revisionPredicate)
6565
{
66-
ThreadHelper.ThrowIfNotOnUIThread();
66+
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
6767

6868
var token = _cancellationTokenSequence.Next();
6969

GitExtensions.ruleset

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
</Rules>
88
<Rules AnalyzerId="Microsoft.VisualStudio.Threading.Analyzers" RuleNamespace="Microsoft.VisualStudio.Threading.Analyzers">
99
<Rule Id="VSTHRD010" Action="None" />
10-
<Rule Id="VSTHRD109" Action="None" />
1110
<Rule Id="VSTHRD110" Action="None" />
1211
</Rules>
1312
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">

GitUI/BranchTreePanel/RepoObjectsTree.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void SetBranchFilterer(FilterBranchHelper filterBranchHelper)
5757

5858
public async Task ReloadAsync()
5959
{
60-
ThreadHelper.ThrowIfNotOnUIThread();
60+
await this.SwitchToMainThreadAsync();
6161

6262
var token = CancelBackgroundTasks();
6363
Enabled = false;

0 commit comments

Comments
 (0)