Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 3b11ae4

Browse files
authored
Merge pull request #2132 from github/fixes/vssdk-warnings
Fix VSSDK analyzer warnings.
2 parents 30d7a9f + 29e0f98 commit 3b11ae4

19 files changed

+92
-11
lines changed

src/GitHub.InlineReviews/Commands/InlineCommentNavigationCommand.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
using GitHub.Models;
1010
using GitHub.Services;
1111
using GitHub.Services.Vssdk.Commands;
12+
using Microsoft;
1213
using Microsoft.VisualStudio;
1314
using Microsoft.VisualStudio.ComponentModelHost;
1415
using Microsoft.VisualStudio.Editor;
16+
using Microsoft.VisualStudio.Shell;
1517
using Microsoft.VisualStudio.Shell.Interop;
1618
using Microsoft.VisualStudio.Text;
1719
using Microsoft.VisualStudio.Text.Differencing;
@@ -99,6 +101,8 @@ protected int GetCursorPoint(ITextView textView, int lineNumber)
99101
/// </remarks>
100102
protected IEnumerable<ITextView> GetCurrentTextViews()
101103
{
104+
ThreadHelper.ThrowIfNotOnUIThread();
105+
102106
var result = new List<ITextView>();
103107

104108
try
@@ -164,6 +168,8 @@ protected IEnumerable<ITextView> GetCurrentTextViews()
164168
}
165169

166170
var model = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
171+
Assumes.Present(model);
172+
167173
var adapterFactory = model.GetService<IVsEditorAdaptersFactoryService>();
168174
var wpfTextView = adapterFactory.GetWpfTextView(textView);
169175
result.Add(wpfTextView);

src/GitHub.InlineReviews/Commands/ToggleInlineCommentMarginCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.VisualStudio.TextManager.Interop;
1010
using Microsoft.VisualStudio;
1111
using Microsoft.VisualStudio.Editor;
12+
using GitHub.Extensions;
1213

1314
namespace GitHub.InlineReviews.Commands
1415
{
@@ -42,7 +43,7 @@ public ToggleInlineCommentMarginCommand(
4243

4344
public override Task Execute()
4445
{
45-
usageTracker.Value.IncrementCounter(x => x.ExecuteToggleInlineCommentMarginCommand);
46+
usageTracker.Value.IncrementCounter(x => x.ExecuteToggleInlineCommentMarginCommand).Forget();
4647

4748
IVsTextView activeView = null;
4849
if (textManager.Value.GetActiveView(1, null, out activeView) == VSConstants.S_OK)

src/GitHub.InlineReviews/GitHub.InlineReviews.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<Compile Include="Commands\InlineCommentNavigationCommand.cs" />
6060
<Compile Include="Commands\PreviousInlineCommentCommand.cs" />
6161
<Compile Include="Commands\NextInlineCommentCommand.cs" />
62+
<Compile Include="GlobalSuppressions.cs" />
6263
<Compile Include="Margins\InlineCommentTextViewOptions.cs" />
6364
<Compile Include="Margins\PullRequestFileMargin.cs" />
6465
<Compile Include="Margins\PullRequestFileMarginProvider.cs" />
@@ -289,10 +290,10 @@
289290
<Version>0.2.1</Version>
290291
</PackageReference>
291292
<PackageReference Include="Microsoft.VisualStudio.SDK.Analyzers">
292-
<Version>15.8.33</Version>
293+
<Version>15.8.36</Version>
293294
</PackageReference>
294295
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers">
295-
<Version>15.8.122</Version>
296+
<Version>15.8.192</Version>
296297
</PackageReference>
297298
<PackageReference Include="Microsoft.VSSDK.BuildTools">
298299
<Version>15.8.3252</Version>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+

2+
// This file is used by Code Analysis to maintain SuppressMessage
3+
// attributes that are applied to this project.
4+
// Project-level suppressions either have no target or are given
5+
// a specific target and scoped to a namespace, type, member, etc.
6+
7+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods")]
8+

src/GitHub.InlineReviews/InlineReviewsPackage.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.VisualStudio.Threading;
1313
using Serilog;
1414
using Task = System.Threading.Tasks.Task;
15+
using Microsoft;
1516

1617
namespace GitHub.InlineReviews
1718
{
@@ -27,8 +28,9 @@ protected override async Task InitializeAsync(
2728
CancellationToken cancellationToken,
2829
IProgress<ServiceProgressData> progress)
2930
{
30-
var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService)));
3131
var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel)));
32+
Assumes.Present(componentModel);
33+
3234
var exports = componentModel.DefaultExportProvider;
3335

3436
// Avoid delays when there is ongoing UI activity.
@@ -45,6 +47,8 @@ async Task InitializeMenus()
4547
}
4648

4749
var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel)));
50+
Assumes.Present(componentModel);
51+
4852
var exports = componentModel.DefaultExportProvider;
4953
var commands = new IVsCommandBase[]
5054
{
@@ -55,6 +59,8 @@ async Task InitializeMenus()
5559

5660
await JoinableTaskFactory.SwitchToMainThreadAsync();
5761
var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService)));
62+
Assumes.Present(componentModel);
63+
5864
menuService.AddCommands(commands);
5965
}
6066
}

src/GitHub.InlineReviews/Services/PullRequestSessionService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ int GetUpdatedLineNumber(IInlineCommentThreadModel thread, IEnumerable<DiffChunk
770770

771771
Task<IRepository> GetRepository(LocalRepositoryModel repository)
772772
{
773-
return Task.Factory.StartNew(() => gitService.GetRepository(repository.LocalPath));
773+
return Task.Run(() => gitService.GetRepository(repository.LocalPath));
774774
}
775775

776776
async Task<LastCommitAdapter> GetPullRequestLastCommitAdapter(HostAddress address, string owner, string name, int number)

src/GitHub.InlineReviews/ViewModels/InlineCommentPeekViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ public async Task Initialize()
160160
}
161161

162162
fileSubscription?.Dispose();
163-
fileSubscription = file.LinesChanged.ObserveOn(RxApp.MainThreadScheduler).Subscribe(LinesChanged);
163+
fileSubscription = file.LinesChanged.ObserveOn(RxApp.MainThreadScheduler).Subscribe(x => LinesChanged(x).Forget());
164164
}
165165

166-
async void LinesChanged(IReadOnlyList<Tuple<int, DiffSide>> lines)
166+
async Task LinesChanged(IReadOnlyList<Tuple<int, DiffSide>> lines)
167167
{
168168
try
169169
{

src/GitHub.StartPage/GitHub.StartPage.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<Compile Include="..\common\SolutionInfo.cs">
5656
<Link>Properties\SolutionInfo.cs</Link>
5757
</Compile>
58+
<Compile Include="GlobalSuppressions.cs" />
5859
<Compile Include="Properties\AssemblyInfo.cs" />
5960
<Compile Include="StartPagePackage.cs" />
6061
</ItemGroup>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+

2+
// This file is used by Code Analysis to maintain SuppressMessage
3+
// attributes that are applied to this project.
4+
// Project-level suppressions either have no target or are given
5+
// a specific target and scoped to a namespace, type, member, etc.
6+
7+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods")]
8+

src/GitHub.StartPage/StartPagePackage.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ public class GitHubContainerProvider : ICodeContainerProvider
4040
public async Task<CodeContainer> AcquireCodeContainerAsync(IProgress<ServiceProgressData> downloadProgress, CancellationToken cancellationToken)
4141
{
4242

43-
return await RunAcquisition(downloadProgress, cancellationToken, null);
43+
return await RunAcquisition(downloadProgress, null, cancellationToken);
4444
}
4545

4646
public async Task<CodeContainer> AcquireCodeContainerAsync(RemoteCodeContainer onlineCodeContainer, IProgress<ServiceProgressData> downloadProgress, CancellationToken cancellationToken)
4747
{
4848
var repository = new RepositoryModel(onlineCodeContainer.Name, UriString.ToUriString(onlineCodeContainer.DisplayUrl));
49-
return await RunAcquisition(downloadProgress, cancellationToken, repository);
49+
return await RunAcquisition(downloadProgress, repository, cancellationToken);
5050
}
5151

5252
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "cancellationToken")]
53-
async Task<CodeContainer> RunAcquisition(IProgress<ServiceProgressData> downloadProgress, CancellationToken cancellationToken, RepositoryModel repository)
53+
async Task<CodeContainer> RunAcquisition(IProgress<ServiceProgressData> downloadProgress, RepositoryModel repository, CancellationToken cancellationToken)
5454
{
5555
CloneDialogResult request = null;
5656

0 commit comments

Comments
 (0)