Skip to content

Commit

Permalink
VS2022 project
Browse files Browse the repository at this point in the history
- Drop pre-2019
- Bump to v4.0
- Aim to publish v2022 (preview)
- Move VSCT to Shared folder
  • Loading branch information
flcdrg committed Jan 7, 2022
1 parent 5cb8356 commit 78ceca6
Show file tree
Hide file tree
Showing 37 changed files with 2,512 additions and 314 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '33 5 * * 0'
workflow_dispatch:
# push:
# branches: [ master ]
# pull_request:
# # The branches below must be a subset of the branches above
# branches: [ master ]
# schedule:
# - cron: '33 5 * * 0'

env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages

jobs:
analyze:
name: Analyze
runs-on: windows-latest
runs-on: windows-2022
permissions:
actions: read
contents: read
Expand Down Expand Up @@ -61,7 +62,7 @@ jobs:
- name: Build
id: build
run: |
msbuild /p:configuration=Release /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal /v:m
msbuild /p:configuration=Release /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal /v:m /p:UseSharedCompilation=false
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
57 changes: 42 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,19 @@ env:
jobs:
# This workflow contains a single job called "build"
build:
strategy:
matrix:
include:
- solution: VS2019.slnf
os: windows-2019
artifact: vs2019
- solution: VS2022.slnf
os: windows-2022
artifact: vs2022

# The type of runner that the job will run on
runs-on: windows-latest
runs-on: ${{ matrix.os }}

outputs:
GitAssemblyInformationalVersion: ${{ steps.gitversion.outputs.GitAssemblyInformationalVersion }}
GitBuildVersion: ${{ steps.gitversion.outputs.GitBuildVersion }}
Expand All @@ -36,16 +47,16 @@ jobs:
restore-keys: |
${{ runner.os }}-nuget-
- name: setup-msbuild
uses: microsoft/setup-msbuild@v1

- name: nuget restore
run: nuget restore -Verbosity quiet

- name: setup-msbuild
uses: microsoft/setup-msbuild@v1

- name: Build
id: build
run: |
msbuild /p:configuration=Release /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal /v:m
msbuild /p:configuration=Release /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal /v:m ${{ matrix.solution }}
- name: gitversion
id: gitversion
Expand All @@ -60,9 +71,9 @@ jobs:
uses: actions/upload-artifact@v2
with:
# Artifact name
name: 'vsix'
name: ${{ matrix.artifact }}
# A file, directory or wildcard pattern that describes what to upload
path: 'vs2019/**/*.vsix'
path: '**/Release/*.vsix'

# - name: Dump steps context
# env:
Expand Down Expand Up @@ -98,20 +109,17 @@ jobs:

- uses: actions/download-artifact@v2
with:
name: vsix
path: vsix

- name: Display structure of downloaded files
run: ls -R

- name: Display environment
run: 'printenv | sort'

- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"

- name: Remove existing release asset
- name: Remove existing release asset 2019
uses: flcdrg/remove-release-asset-action@v1
with:
# The release id to remove asset from
Expand All @@ -121,13 +129,32 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset
id: upload-release-asset
- name: Remove existing release asset 2022
uses: flcdrg/remove-release-asset-action@v1
with:
# The release id to remove asset from
release_id: ${{ steps.create_release.outputs.id }}
# The name of the asset you want to remove
asset_name: Gardiner.VsShowMissing.2022.vsix
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset 2019
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./bin/Release/Gardiner.VsShowMissing.VS2019.vsix
asset_path: ./vsix/VS2019/bin/Release/Gardiner.VsShowMissing.VS2019.vsix
asset_name: Gardiner.VsShowMissing.VS2019.vsix
asset_content_type: application/octet-stream

- name: Upload Release Asset 2022
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: .vsix/VS2022/bin/Release/Gardiner.VsShowMissing.VS2022.vsix
asset_name: Gardiner.VsShowMissing.VS2022.vsix
asset_content_type: application/octet-stream
17 changes: 8 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,21 @@ jobs:
runs-on: windows-latest

steps:
# - name: Dump GitHub context
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: echo "$GITHUB_CONTEXT"
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

- uses: actions/checkout@v2

- name: Download Assets
uses: i3h/download-release-asset@v1.2.0
uses: i3h/download-release-asset@v1.3.2
with:
owner: ${{ github.event.repository.owner.login }}
repo: ${{ github.event.repository.name }}
tag: ${{ github.event.release.tag_name }}
file: Gardiner.VsShowMissing.VS2019.vsix
file: /Gardiner\.VsShowMissing\.VS\d+.vsix/
token: ${{ secrets.GITHUB_TOKEN }}

# - run: dir -recurse

- name: Script
run: |
Expand All @@ -37,6 +35,7 @@ jobs:
Write-Host $Path
$VsixPublisher = Join-Path -Path $Path -ChildPath "VSSDK\VisualStudioIntegration\Tools\Bin\VsixPublisher.exe" -Resolve
& $VsixPublisher publish -payload ".\Gardiner.VsShowMissing.VS2019.vsix" -publishManifest ".\build\extension-manifest.json" -personalAccessToken $env:PersonalAccessToken -ignoreWarnings "VSIXValidatorWarning01,VSIXValidatorWarning02,VSIXValidatorWarning08"
& $VsixPublisher publish -payload ".\Gardiner.VsShowMissing.VS2022.vsix" -publishManifest ".\build\extension-manifest-2022.json" -personalAccessToken $env:PersonalAccessToken -ignoreWarnings "VSIXValidatorWarning01,VSIXValidatorWarning02,VSIXValidatorWarning08"
env:
PersonalAccessToken: ${{ secrets.PersonalAccessToken }}
7 changes: 7 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Development notes

## Architecture

IVsSolutionEvents is implemented so we can hook into the OnAfterCloseSolution event to clear the errorListProvider.

DTE.Events are hooked into for OnBuildProjConfigBegin, OnBuildProjConfigDone, OnBuildBegin, OnBuildDone events.
8 changes: 4 additions & 4 deletions Gardiner.VsShowMissing.Shared/DeleteFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ErrorListProvider errorListProvider
{
commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));

var menuCommandID = new CommandID(PackageGuids.guidGardiner_ErrorListCmdSet, PackageIds.cmdidDeleteFileOnDisk);
var menuCommandID = new CommandID(PackageGuids.VS2022, PackageIds.cmdidDeleteFileOnDisk);
var menuItem = new OleMenuCommand(Execute, menuCommandID);
menuItem.BeforeQueryStatus += MenuItemOnBeforeQueryStatus;
commandService.AddCommand(menuItem);
Expand All @@ -47,7 +47,7 @@ public static void Initialize(IServiceProvider provider, ErrorListProvider error
Instance = new DeleteFileCommand(commandService, dte, errorListProvider);
}

#if VS2019
#if VS2019 || VS2022
/// <summary>
/// Initializes the singleton instance of the command.
/// </summary>
Expand All @@ -57,7 +57,7 @@ public static async System.Threading.Tasks.Task InitializeAsync(AsyncPackage pac
{
// Switch to the main thread - the call to AddCommand in DeleteFileCommand's constructor requires
// the UI thread.
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);
await package.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);

OleMenuCommandService commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;
var dte = (DTE)await package.GetServiceAsync(typeof(DTE));
Expand Down Expand Up @@ -105,7 +105,7 @@ private void Execute(object sender, EventArgs e)

if (failedFiles.Count > 0)
{
MessageBox.Show("Unable to delete these files:\n\n" + string.Join("\n", failedFiles), "Warning",
System.Windows.Forms.MessageBox.Show("Unable to delete these files:\n\n" + string.Join("\n", failedFiles), "Warning",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
Expand Down
20 changes: 18 additions & 2 deletions Gardiner.VsShowMissing.Shared/ErrorListCommand.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;

using Community.VisualStudio.Toolkit;

using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;

#if VS2019
using TaskListItem = Microsoft.VisualStudio.Shell.Task;
#else
using TaskListItem = Microsoft.VisualStudio.Shell.TaskListItem;
#endif
namespace Gardiner.VsShowMissing
{
abstract class ErrorListCommand
Expand All @@ -29,6 +37,13 @@ protected void ForEachTask(Action<object> action)

myErrorList.EnumSelectedItems(out var itemEnumerator);

if (itemEnumerator == null)
{
// Probably too early or list is empty?
Debug.WriteLine("too early");
return;
}

uint[] fetched = { 0 };
IVsTaskItem[] items = { null };
#pragma warning disable S1264
Expand All @@ -53,16 +68,17 @@ protected List<MissingErrorTask> MissingErrorTasks(string code)
return tasks;
}

protected void RemoveTask(Microsoft.VisualStudio.Shell.Task task)
protected void RemoveTask(TaskListItem task)
{
_errorListProvider.Tasks.Remove(task);
}

protected void MenuItemOnBeforeQueryStatus(object sender, EventArgs e)
{
Debug.WriteLine("MenuItemOnBeforeQueryStatus");
var menuItem = (OleMenuCommand)sender;

Debug.WriteLine($"MenuItemOnBeforeQueryStatus {menuItem.Text}");

ThreadHelper.ThrowIfNotOnUIThread();
menuItem.Visible = CalculateVisible();
}
Expand Down
6 changes: 3 additions & 3 deletions Gardiner.VsShowMissing.Shared/ExcludeFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private ExcludeFileCommand(
{
commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));

var menuCommandID = new CommandID(PackageGuids.guidGardiner_ErrorListCmdSet, PackageIds.cmdidExcludeFileFromProject);
var menuCommandID = new CommandID(PackageGuids.VS2022, PackageIds.cmdidExcludeFileFromProject);
var menuItem = new OleMenuCommand(Execute, menuCommandID);
menuItem.BeforeQueryStatus += MenuItemOnBeforeQueryStatus;
commandService.AddCommand(menuItem);
Expand Down Expand Up @@ -86,10 +86,10 @@ public static void Initialize(IServiceProvider serviceProvider, ErrorListProvide
Instance = new ExcludeFileCommand(commandService, dte, errorListProvider);
}

#if VS2019
#if VS2019 || VS2022
internal static async System.Threading.Tasks.Task InitializeAsync(AsyncPackage package, ErrorListProvider errorListProvider)
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);
await package.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);

var commandService = (OleMenuCommandService) await package.GetServiceAsync(typeof(IMenuCommandService));
var dte = (DTE) await package.GetServiceAsync(typeof(DTE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,16 @@
<Compile Include="$(MSBuildThisFileDirectory)RunWhen.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TaskProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UIHierarchyExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UserControl1.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)UserControl1.Designer.cs">
<DependentUpon>UserControl1.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)UserControl1.resx">
<DependentUpon>UserControl1.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions Gardiner.VsShowMissing.Shared/IncludeFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private IncludeFileCommand(
throw new ArgumentNullException(nameof(commandService));
}

var menuCommandID = new CommandID(PackageGuids.guidGardiner_ErrorListCmdSet, PackageIds.cmdidIncludeFileInProject);
var menuCommandID = new CommandID(PackageGuids.VS2022, PackageIds.cmdidIncludeFileInProject);
var menuItem = new OleMenuCommand(Execute, menuCommandID);
menuItem.BeforeQueryStatus += MenuItemOnBeforeQueryStatus;
commandService.AddCommand(menuItem);
Expand Down Expand Up @@ -65,10 +65,10 @@ public static void Initialize(IServiceProvider serviceProvider, ErrorListProvide
Instance = new IncludeFileCommand(commandService, dte, errorListProvider);
}

#if VS2019
#if VS2019 || VS2022
internal static async System.Threading.Tasks.Task InitializeAsync(AsyncPackage package, ErrorListProvider errorListProvider)
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);
await package.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);

var commandService = (OleMenuCommandService)await package.GetServiceAsync(typeof(IMenuCommandService));
var dte = (DTE)await package.GetServiceAsync(typeof(DTE));
Expand Down
7 changes: 3 additions & 4 deletions Gardiner.VsShowMissing.Shared/Options/BaseOptionModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,10 @@ protected virtual object DeserializeValue(string value, Type type)
private static async Task<ShellSettingsManager> GetSettingsManagerAsync()
#pragma warning restore 1998
{
#if VS2019
#pragma warning disable VSTHRD010
// False-positive in Threading Analyzers. Bug tracked here https://github.com/Microsoft/vs-threading/issues/230
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

#if VS2019 || VS2022
var svc = await AsyncServiceProvider.GlobalProvider.GetServiceAsync(typeof(SVsSettingsManager)) as IVsSettingsManager;
#pragma warning restore VSTHRD010

Assumes.Present(svc);
return new ShellSettingsManager(svc);
Expand Down
4 changes: 3 additions & 1 deletion Gardiner.VsShowMissing.Shared/ProjectExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using EnvDTE;
using EnvDTE80;
using JetBrains.Annotations;
using Microsoft.VisualStudio.Shell;

using Project = EnvDTE.Project;

namespace Gardiner.VsShowMissing
{
public static class ProjectExtensions
Expand Down
2 changes: 2 additions & 0 deletions Gardiner.VsShowMissing.Shared/UIHierarchyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Collections;
using EnvDTE;
using Microsoft.VisualStudio.Shell;
using Project = EnvDTE.Project;
using Solution = EnvDTE.Solution;

namespace Gardiner.VsShowMissing
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 78ceca6

Please sign in to comment.