Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StyleCop upgrade and many warning was resolved or disabled #261

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Some another warnings eliminated.
  • Loading branch information
soroshsabz committed Jul 10, 2022
commit 5897c51b6cdffd36b53a3be29cd99fedf1ac2f78
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.ServiceHub.Framework" Version="3.1.4097" />
<PackageReference Include="Microsoft.VisualStudio.Internal.MicroBuild.NonShipping" Version="2.0.66" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Microsoft.VisualStudio.TemplateWizardInterface" Version="17.2.32505.113" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Nerdbank.GitVersioning" Version="1.6.30" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@

<ItemGroup>
<PackageReference Include="EnvDTE" Version="17.2.32505.113" />
<PackageReference Include="Microsoft.ServiceHub.Framework" Version="3.1.4097" />

<PackageReference Include="Microsoft.VisualStudio.Internal.MicroBuild.VisualStudio" Version="2.0.66" />

<PackageReference Include="Microsoft.VisualStudio.TemplateWizardInterface" Version="17.2.32505.113" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.2.2186">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public BackgroundInstallationHandler(IPackageHandler successor)
public bool IsUpdate { get; set; } = false;

/// <inheritdoc/>
public override async TPL.Task Execute(Project project)
public override async TPL.Task ExecuteAsync(Project project)
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
string projName = project.UniqueName;
Expand All @@ -62,7 +62,7 @@ public override async TPL.Task Execute(Project project)
string outputMessage = Resources.Resources.NugetInstall_FinishedOutput;
try
{
await this.Successor.Execute(project);
await this.Successor.ExecuteAsync(project);
}
catch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ protected BasePackageHandler(IPackageHandler successor)
protected IPackageHandler Successor { get; }

/// <inheritdoc/>
public abstract TPL.Task Execute(Project project);
public abstract TPL.Task ExecuteAsync(Project project);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Microsoft.VisualStudio.SlowCheetah.VS
{
using EnvDTE;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using TPL = System.Threading.Tasks;

Expand All @@ -22,8 +23,9 @@ public DialogInstallationHandler(IPackageHandler successor)
}

/// <inheritdoc/>
public override async TPL.Task Execute(Project project)
public override async TPL.Task ExecuteAsync(Project project)
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
if (await this.HasUserAcceptedWarningMessageAsync(Resources.Resources.NugetUpdate_Title, Resources.Resources.NugetUpdate_Text))
{
// Creates dialog informing the user to wait for the installation to finish
Expand All @@ -37,7 +39,7 @@ public override async TPL.Task Execute(Project project)

try
{
await this.Successor.Execute(project);
await this.Successor.ExecuteAsync(project);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public EmptyHandler(AsyncPackage package)
public AsyncPackage Package { get; }

/// <inheritdoc/>
public TPL.Task Execute(Project project)
public TPL.Task ExecuteAsync(Project project)
{
// Do nothing
return TPL.Task.CompletedTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ internal interface IPackageHandler
/// </summary>
/// <param name="project">The project to peform actions on</param>
/// <returns>A task that executes the function</returns>
TPL.Task Execute(Project project);
TPL.Task ExecuteAsync(Project project);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public NuGetUninstaller(IPackageHandler successor)
}

/// <inheritdoc/>
public override async TPL.Task Execute(Project project)
public override async TPL.Task ExecuteAsync(Project project)
{
var componentModel = (IComponentModel)await this.Package.GetServiceAsync(typeof(SComponentModel));
Assumes.Present(componentModel);
IVsPackageUninstaller packageUninstaller = componentModel.GetService<IVsPackageUninstaller>();
packageUninstaller.UninstallPackage(project, SlowCheetahNuGetManager.OldPackageName, true);

await this.Successor.Execute(project);
await this.Successor.ExecuteAsync(project);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Microsoft.VisualStudio.SlowCheetah.VS
{
using EnvDTE;
using Microsoft;
using Microsoft.VisualStudio.ComponentModelHost;
using NuGet.VisualStudio;
using TPL = System.Threading.Tasks;
Expand All @@ -23,9 +24,10 @@ public NugetInstaller(IPackageHandler successor)
}

/// <inheritdoc/>
public override async TPL.Task Execute(Project project)
public override async TPL.Task ExecuteAsync(Project project)
{
var componentModel = (IComponentModel)await this.Package.GetServiceAsync(typeof(SComponentModel));
Assumes.Present(componentModel);
IVsPackageInstaller packageInstaller = componentModel.GetService<IVsPackageInstaller>();
packageInstaller.InstallPackage(
null,
Expand All @@ -34,7 +36,7 @@ public override async TPL.Task Execute(Project project)
version: (string)null, // install latest stable version
ignoreDependencies: false);

await this.Successor.Execute(project);
await this.Successor.ExecuteAsync(project);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public TargetsUninstaller(IPackageHandler successor)
}

/// <inheritdoc/>
public override async TPL.Task Execute(Project project)
public override async TPL.Task ExecuteAsync(Project project)
{
// We handle any NuGet package logic before editing the project file
await this.Successor.Execute(project);
await this.Successor.ExecuteAsync(project);
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

project.Save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Microsoft.VisualStudio.SlowCheetah.VS
using System;
using System.Threading.Tasks;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;

/// <summary>
Expand All @@ -30,6 +31,7 @@ public UserInstallationHandler(IPackageHandler successor)
/// <returns>True if the user has accepted the warning message</returns>
protected async Task<bool> HasUserAcceptedWarningMessageAsync(string title, string message)
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
var shell = (IVsUIShell)await this.Package.GetServiceAsync(typeof(SVsUIShell));

if (shell != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public async TPL.Task CheckSlowCheetahInstallationAsync(IVsHierarchy hierarchy)
};
}

await plan.Execute(currentProject);
await plan.ExecuteAsync(currentProject);
}

private static IVsPackageInstallerServices GetInstallerServices(IServiceProvider package)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ protected override void OnChange(object sender, EventArgs e)
protected override void OnBeforeQueryStatus(object sender, EventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();

// get the menu that fired the event
if (sender is OleMenuCommand menuCommand)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.VisualStudio.SlowCheetah.VS
using System.Globalization;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using SlowCheetah;
using Microsoft.VisualStudio.SlowCheetah;

/// <summary>
/// Logger for XDT transformation on Preview Transform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static class ProjectUtilities
/// <returns>The Visual Studio DTE object</returns>
public static DTE GetDTE()
{
ThreadHelper.ThrowIfNotOnUIThread();
return (DTE)Package.GetGlobalService(typeof(DTE));
}

Expand Down Expand Up @@ -119,6 +120,7 @@ public static bool IsSingleProjectItemSelection(out IVsHierarchy hierarchy, out
/// <returns>List of configuration names for that project</returns>
public static IEnumerable<string> GetProjectConfigurations(Project project)
{
ThreadHelper.ThrowIfNotOnUIThread();
List<string> configurations = new List<string>();

if (project != null && project.ConfigurationManager != null && project.ConfigurationManager.ConfigurationRowNames != null)
Expand Down Expand Up @@ -185,6 +187,7 @@ public static IEnumerable<string> GetSupportedItemExtensions(IVsSettingsManager
/// <returns>True if a subtype GUID matches the Web App Guid in Resources</returns>
public static bool IsProjectWebApp(IVsProject project)
{
ThreadHelper.ThrowIfNotOnUIThread();
if (project is IVsAggregatableProject aggregatableProject)
{
aggregatableProject.GetAggregateProjectTypeGuids(out string projectTypeGuidStrings);
Expand Down
1 change: 1 addition & 0 deletions src/SlowCheetah.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.Slow
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{16014DDD-6525-48EF-9D6A-E1067594E1E8}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
stylecop.json = stylecop.json
..\version.json = ..\version.json
EndProjectSection
Expand Down