├── .editorconfig ├── .gitattributes ├── .github └── FUNDING.yml ├── .gitignore ├── Community.VisualStudio.Toolkit.sln ├── Directory.Build.props ├── LICENSE ├── README.md ├── appveyor.yml ├── demo └── VSSDK.TestExtension │ ├── Commands │ ├── BuildActiveProjectAsyncCommand.cs │ ├── BuildSolutionAsyncCommand.cs │ ├── CollapseSelectedItemsCommand.cs │ ├── EditProjectFileCommand.cs │ ├── EditSelectedItemLabelCommand.cs │ ├── ExpandSelectedItemsCommand.cs │ ├── FontsAndColorsWindowCommand.cs │ ├── ListReferencesCommand.cs │ ├── LoadSelectedProject.cs │ ├── MultiInstanceWindowCommand.cs │ ├── RunnerWindowCommand.cs │ ├── SelectCurrentProjectCommand.cs │ ├── SendMessageToRunnerWindowCommand.cs │ ├── SplitButtonCommand.cs │ ├── ThemeWindowCommand.cs │ ├── ToggleVsixManifestFilterCommand.cs │ └── UnloadSelectedProject.cs │ ├── MEF │ ├── HighlightWord.cs │ └── TextviewCreationListener.cs │ ├── Options │ ├── General.cs │ ├── RuntimeEnumProxy.cs │ └── RuntimeEnumTypeConverter.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── Resources │ ├── Theme.Blue.vssettings │ ├── Theme.BlueHighContrast.vssettings │ ├── Theme.Dark.vssettings │ └── Theme.Light.vssettings │ ├── SolutionExplorer │ └── VsixManifestFilterProvider.cs │ ├── TestExtensionPackage.cs │ ├── Themes │ └── Generic.xaml │ ├── ToolWindows │ ├── FontsAndColors │ │ ├── DemoFontAndColorCategory.cs │ │ ├── DemoFontAndColorProvider.cs │ │ ├── FontsAndColorsWindow.cs │ │ ├── FontsAndColorsWindowControl.xaml │ │ ├── FontsAndColorsWindowControl.xaml.cs │ │ └── FontsAndColorsWindowViewModel.cs │ ├── MultiInstanceWindow.cs │ ├── MultiInstanceWindowControl.xaml │ ├── MultiInstanceWindowControl.xaml.cs │ ├── RunnerWindow.cs │ ├── RunnerWindowControl.xaml │ ├── RunnerWindowControl.xaml.cs │ ├── RunnerWindowMessenger.cs │ └── ThemeWindow │ │ ├── CustomizedStylesDialog.xaml │ │ ├── CustomizedStylesDialog.xaml.cs │ │ ├── ThemeWindow.cs │ │ ├── ThemeWindowControl.xaml │ │ ├── ThemeWindowControl.xaml.cs │ │ ├── ThemeWindowControlViewModel.cs │ │ ├── ThemeWindowDemo.xaml │ │ ├── ThemeWindowDemo.xaml.cs │ │ ├── ThemeWindowDialog.xaml │ │ ├── ThemeWindowDialog.xaml.cs │ │ ├── ThemeWindowDialogViewModel.cs │ │ ├── ThemedControl.cs │ │ └── ThemedControl.xaml │ ├── VSCommandTable.cs │ ├── VSCommandTable.vsct │ ├── VSSDK.TestExtension.csproj │ ├── source.extension.cs │ └── source.extension.vsixmanifest ├── docs ├── .gitignore ├── api │ └── index.md ├── articles │ ├── details1.md │ ├── details2.md │ ├── details3.md │ ├── intro.md │ └── toc.yml ├── build_docs.cmd ├── docfx.json ├── images │ └── details1_image.png ├── index.html ├── index.md ├── toc.yml └── v1 │ ├── api │ ├── Community.VisualStudio.Toolkit.BaseCommand-1.html │ ├── Community.VisualStudio.Toolkit.BaseOptionModel-1.html │ ├── Community.VisualStudio.Toolkit.BaseOptionPage-1.html │ ├── Community.VisualStudio.Toolkit.BaseToolWindow-1.html │ ├── Community.VisualStudio.Toolkit.CommandAttribute.html │ ├── Community.VisualStudio.Toolkit.Commanding.html │ ├── Community.VisualStudio.Toolkit.Debugger.html │ ├── Community.VisualStudio.Toolkit.Editor.ContentTypes.html │ ├── Community.VisualStudio.Toolkit.Editor.html │ ├── Community.VisualStudio.Toolkit.Events.html │ ├── Community.VisualStudio.Toolkit.Notifications.html │ ├── Community.VisualStudio.Toolkit.Shell.html │ ├── Community.VisualStudio.Toolkit.Solution.html │ ├── Community.VisualStudio.Toolkit.StatusAnimation.html │ ├── Community.VisualStudio.Toolkit.Themes.html │ ├── Community.VisualStudio.Toolkit.ToolkitPackage.html │ ├── Community.VisualStudio.Toolkit.ToolkitResourceKeys.html │ ├── Community.VisualStudio.Toolkit.VS.html │ ├── Community.VisualStudio.Toolkit.VsTheme.html │ ├── Community.VisualStudio.Toolkit.WindowGuids.html │ ├── Community.VisualStudio.Toolkit.Windows.html │ ├── Community.VisualStudio.Toolkit.html │ ├── EnvDTE.ProjectExtensions.html │ ├── EnvDTE.ProjectItemExtensions.html │ ├── EnvDTE.ProjectTypes.html │ ├── EnvDTE.html │ ├── Microsoft.VisualStudio.Imaging.Interop.ImageMonikerExtensions.html │ ├── Microsoft.VisualStudio.Imaging.Interop.html │ ├── Microsoft.VisualStudio.Shell.Interop.IVsSolutionExtensions.html │ ├── Microsoft.VisualStudio.Shell.Interop.html │ ├── Microsoft.VisualStudio.Shell.TaskExtensions.html │ ├── Microsoft.VisualStudio.Shell.html │ ├── Microsoft.VisualStudio.Text.TextBufferExtensions.html │ ├── Microsoft.VisualStudio.Text.html │ ├── System.ExceptionExtensions.html │ ├── System.html │ ├── index.html │ └── toc.html │ ├── articles │ ├── details1.html │ ├── details2.html │ ├── details3.html │ ├── intro.html │ └── toc.html │ ├── favicon.ico │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 │ ├── images │ └── details1_image.png │ ├── index.html │ ├── logo.svg │ ├── manifest.json │ ├── search-stopwords.json │ ├── styles │ ├── docfx.css │ ├── docfx.js │ ├── docfx.vendor.css │ ├── docfx.vendor.js │ ├── lunr.js │ ├── lunr.min.js │ ├── main.css │ ├── main.js │ └── search-worker.js │ ├── toc.html │ └── xrefmap.yml ├── src ├── Directory.Build.props ├── Directory.Build.targets ├── Icon.png ├── analyzers │ └── Community.VisualStudio.Toolkit.Analyzers │ │ ├── AnalyzerBase.cs │ │ ├── Analyzers │ │ ├── CVST001CastInteropServicesAnalyzer.cs │ │ ├── CVST001CastInteropServicesCodeFixProvider.cs │ │ ├── CVST002DialogPageShouldBeComVisibleAnalyzer.cs │ │ ├── CVST002DialogPageShouldBeComVisibleCodeFixProvider.cs │ │ ├── CVST003UseCorrectTypeInProvideOptionDialogPageAttributeAnalyzer.cs │ │ ├── CVST003UseCorrectTypeInProvideOptionDialogPageAttributeCodeFixProvider.cs │ │ ├── CVST004UseCorrectTypeInProvideProfileAttributeAnalyzer.cs │ │ ├── CVST004UseCorrectTypeInProvideProfileAttributeCodeFixProvider.cs │ │ ├── CVST005InitializeCommandsAnalyzer.cs │ │ ├── CVST005InitializeCommandsCodeFixProvider.cs │ │ ├── CVST006SpecifyFontAndColorProviderGuidAnalyzer.cs │ │ ├── CVST006SpecifyFontAndColorProviderGuidCodeFixProvider.cs │ │ ├── CVST007SpecifyFontAndColorCategoryGuidAnalyzer.cs │ │ ├── CVST007SpecifyFontAndColorCategoryGuidCodeFixProvider.cs │ │ ├── CVST008FontAndColorCategoryShouldHaveProviderAnalyzer.cs │ │ ├── CVST009ProvideFontsAndColorsAnalyzer.cs │ │ ├── CVST010RegisterFontsAndColorsAnalyzer.cs │ │ ├── CVST010RegisterFontsAndColorsCodeFixProvider.cs │ │ ├── IncorrectProvidedTypeAnalyzerBase.cs │ │ ├── IncorrectProvidedTypeCodeFixProviderBase.cs │ │ ├── MissingGuidAttributeAnalyzerBase.cs │ │ └── MissingGuidAttributeCodeFixProviderBase.cs │ │ ├── CodeFixProviderBase.cs │ │ ├── Community.VisualStudio.Toolkit.Analyzers.csproj │ │ ├── Diagnostics.cs │ │ ├── Extensions.cs │ │ ├── KnownTypeNames.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ └── tools │ │ ├── install.ps1 │ │ └── uninstall.ps1 ├── key.snk └── toolkit │ ├── Community.VisualStudio.Toolkit.14.0 │ └── Community.VisualStudio.Toolkit.14.0.csproj │ ├── Community.VisualStudio.Toolkit.15.0 │ └── Community.VisualStudio.Toolkit.15.0.csproj │ ├── Community.VisualStudio.Toolkit.16.0 │ └── Community.VisualStudio.Toolkit.16.0.csproj │ ├── Community.VisualStudio.Toolkit.17.0 │ └── Community.VisualStudio.Toolkit.17.0.csproj │ ├── Community.VisualStudio.Toolkit.Shared │ ├── Attributes │ │ ├── ProvideBraceCompletionAttribute.cs │ │ ├── ProvideFileIconAttribute.cs │ │ ├── ProvideFontsAndColorsAttribute.cs │ │ └── ProvideGalleryFeedAttribute.cs │ ├── Build │ │ ├── Build.cs │ │ └── BuildEvents.cs │ ├── CodeAnalysis │ │ └── MemberNotNullAttribute.cs │ ├── Commands │ │ ├── BaseCommand.cs │ │ ├── BaseDynamicCommand.cs │ │ ├── CommandAttribute.cs │ │ ├── Commands.cs │ │ ├── DynamicItemMenuCommand.cs │ │ └── KnownCommands.cs │ ├── Community.VisualStudio.Toolkit.Shared.shproj │ ├── Debugger │ │ ├── Debugger.cs │ │ └── DebuggerEvents.cs │ ├── Documents │ │ ├── DocumentEvents.cs │ │ ├── DocumentView.cs │ │ └── Documents.cs │ ├── ErrorList │ │ ├── ErrorListItem.cs │ │ ├── SinkManager.cs │ │ ├── TableDataSource.cs │ │ └── TableEntriesSnapshot.cs │ ├── ExtensionMethods │ │ ├── AsyncPackageExtensions.cs │ │ ├── CommandExtensions.cs │ │ ├── ExceptionExtensions.cs │ │ ├── ITextBufferExtensions.cs │ │ ├── ITextViewExtensions.cs │ │ ├── IVsHierarchyExtensions.cs │ │ ├── IVsShareAssetsProjectExtensions.cs │ │ ├── IVsSolutionExtensions.cs │ │ ├── IVsTextViewExtensions.cs │ │ ├── ImageMonikerExtensions.cs │ │ ├── TaskExtensions.cs │ │ ├── ToolkitPackageExtensions.cs │ │ ├── TypeExtensions.cs │ │ └── WindowExtensions.cs │ ├── FontsAndColors │ │ ├── BaseFontAndColorCategory.cs │ │ ├── BaseFontAndColorCategory`1.cs │ │ ├── BaseFontAndColorProvider.cs │ │ ├── ColorDefinition.cs │ │ ├── ColorOptions.cs │ │ ├── ConfiguredColor.cs │ │ ├── ConfiguredColorChangedEventArgs.cs │ │ ├── ConfiguredFont.cs │ │ ├── ConfiguredFontAndColorSet.cs │ │ ├── FontDefinition.cs │ │ ├── FontStyle.cs │ │ ├── FontsAndColors.cs │ │ ├── IFontAndColorChangeListener.cs │ │ ├── LineStyle.cs │ │ ├── MarkerVisualStyle.cs │ │ └── VisualStudioColor.cs │ ├── Helpers │ │ ├── ContentTypes.cs │ │ ├── Disposable.cs │ │ ├── OutputWindowPane.cs │ │ ├── OutputWindowTextWriterVS14.cs │ │ ├── ProjectTypes.cs │ │ ├── SingleFileGeneratorTypes.cs │ │ └── ToolkitThreadHelper.cs │ ├── LanguageService │ │ └── LanguageBase.cs │ ├── MEF │ │ ├── BraceCompletionBase.cs │ │ ├── BraceMatchingBase.cs │ │ ├── CompletionCommitManagerBase.cs │ │ ├── InternalTaggerBase.cs │ │ ├── SameWordHighlighterBase.cs │ │ ├── TokenClassificationTaggerBase.cs │ │ ├── TokenErrorTaggerBase.cs │ │ ├── TokenOutliningTaggerBase.cs │ │ ├── TokenQuickInfoBase.cs │ │ ├── TokenTag.cs │ │ ├── TokenTaggerBase.cs │ │ └── WpfTextViewCreationListener.cs │ ├── Notifications │ │ ├── IRatingConfig.cs │ │ ├── InfoBar.cs │ │ ├── MessageBox.cs │ │ ├── RatingPrompt.cs │ │ └── StatusBar.cs │ ├── Options │ │ ├── BaseOptionModel.cs │ │ ├── BaseOptionPage.cs │ │ ├── IOptionModelPropertyWrapper.cs │ │ ├── NativeSettingsType.cs │ │ ├── OptionModelPropertyWrapper.cs │ │ ├── OverrideCollectionNameAttribute.cs │ │ ├── OverrideDataTypeAttribute.cs │ │ ├── OverridePropertyNameAttribute.cs │ │ ├── SettingDataType.cs │ │ └── Settings.cs │ ├── Projects │ │ └── ProjectItemsEvents.cs │ ├── References │ │ ├── AssemblyReference.cs │ │ ├── ProjectReference.cs │ │ ├── Reference.cs │ │ └── ReferenceCollection.cs │ ├── Selection │ │ ├── Selection.cs │ │ └── SelectionEvents.cs │ ├── Services.cs │ ├── Shell │ │ ├── Shell.cs │ │ └── ShellEvents.cs │ ├── Solution │ │ ├── PhysicalFile.cs │ │ ├── PhysicalFolder.cs │ │ ├── Project.cs │ │ ├── ProjectStateFilter.cs │ │ ├── Solution.cs │ │ ├── SolutionEvents.cs │ │ ├── SolutionFolder.cs │ │ ├── SolutionItem.cs │ │ ├── SolutionItemType.cs │ │ ├── Solutions.cs │ │ └── VirtualFolder.cs │ ├── Themes │ │ ├── InternalResourceKeys.cs │ │ ├── ThemeResources.xaml │ │ ├── Themes.cs │ │ └── ToolkitResourceKeys.cs │ ├── ToolkitPackage.cs │ ├── VS.cs │ ├── VSSDK.Helpers.Shared.projitems │ └── Windows │ │ ├── BaseToolWindow.cs │ │ ├── IToolWindowPaneAware.cs │ │ ├── IToolWindowProvider.cs │ │ ├── SolutionExplorerWindow.cs │ │ ├── ToolkitToolWindowPane.cs │ │ ├── WindowEvents.cs │ │ ├── WindowFrame.cs │ │ ├── WindowGuids.cs │ │ └── Windows.cs │ ├── Directory.Build.props │ ├── Directory.Build.targets │ └── nuget │ └── build │ ├── AssemblyInfo.cs │ ├── Community.VisualStudio.Toolkit.props │ ├── Community.VisualStudio.Toolkit.targets │ └── imports │ ├── Constants.14.props │ ├── Constants.15.props │ ├── Constants.16.props │ ├── Constants.17.props │ ├── ExtensibilityEssentialsCheck.targets │ ├── MSBuildCapabilities.props │ ├── NewtonsoftJsonVersionCheck.targets │ └── PublishToMarketplace.targets ├── test ├── Directory.Build.props ├── analyzers │ └── Community.VisualStudio.Toolkit.Analyzers.UnitTests │ │ ├── Analyzers │ │ ├── CVST001CastInteropServicesAnalyzerTests.cs │ │ ├── CVST002DialogPageShouldBeComVisibleAnalyzerTests.cs │ │ ├── CVST003UseCorrectTypeInProvideOptionDialogPageAttributeAnalyzerTests.cs │ │ ├── CVST004UseCorrectTypeInProvideProfileAttributeAnalyzerTests.cs │ │ ├── CVST005InitializeCommandsAnalyzerTests.cs │ │ ├── CVST006SpecifyFontAndColorProviderGuidAnalyzerTests.cs │ │ ├── CVST007SpecifyFontAndColorCategoryGuidAnalyzerTests.cs │ │ ├── CVST008FontAndColorCategoryShouldHaveProviderAnalyzerTests.cs │ │ ├── CVST009ProvideFontsAndColorsAnalyzerTests.cs │ │ └── CVST010RegisterFontsAndColorsAnalyzerTests.cs │ │ ├── Community.VisualStudio.Toolkit.Analyzers.UnitTests.csproj │ │ └── Helpers │ │ ├── AnalyzerAndCodeFixTestBase.cs │ │ ├── AnalyzerTestBase.cs │ │ ├── TestBase.cs │ │ └── VerifierHelper.cs └── toolkit │ └── Community.VisualStudio.Toolkit.UnitTests │ ├── App.config │ ├── Community.VisualStudio.Toolkit.UnitTests.csproj │ ├── MSBuild │ ├── CompilationResult.cs │ ├── CompileOptions.cs │ ├── ProjectFixture.cs │ ├── PublishToMarketplaceTests.cs │ └── TempDirectory.cs │ └── OptionModelPropertyWrapperTests.cs └── tools ├── GenerateKnownCommands.ps1 └── MockVsixPublisher ├── MockVsixPublisher.csproj └── Program.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: madskristensen 4 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 6 | enable 7 | embedded 8 | false 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2017 LigerShark 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VsixCommunity/Community.VisualStudio.Toolkit/2a4495f392c607164f5c9ecbb7dc2876f88e869f/appveyor.yml -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/BuildActiveProjectAsyncCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Community.VisualStudio.Toolkit; 3 | using Microsoft.VisualStudio.Shell; 4 | using Task = System.Threading.Tasks.Task; 5 | 6 | namespace TestExtension.Commands 7 | { 8 | [Command(PackageIds.BuildActiveProjectAsync)] 9 | internal sealed class BuildActiveProjectAsyncCommand : BaseCommand 10 | { 11 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 12 | { 13 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 14 | 15 | SolutionItem activeItem = await VS.Solutions.GetActiveItemAsync(); 16 | if (activeItem != null) 17 | { 18 | Project activeProject; 19 | if (activeItem.Type == SolutionItemType.Project) 20 | { 21 | activeProject = (Project)activeItem; 22 | } 23 | else 24 | { 25 | activeProject = activeItem.FindParent(SolutionItemType.Project) as Project; 26 | } 27 | 28 | if (activeProject != null) 29 | { 30 | try 31 | { 32 | bool buildResult = await VS.Build.BuildProjectAsync(activeProject); 33 | if (buildResult) 34 | { 35 | await VS.MessageBox.ShowAsync("Build Result", $"The '{activeProject.Name}' project was built successfully!"); 36 | } 37 | else 38 | { 39 | await VS.MessageBox.ShowErrorAsync("Build Result", $"The '{activeProject.Name}' project did not build successfully :("); 40 | } 41 | 42 | } 43 | catch (OperationCanceledException) 44 | { 45 | await VS.MessageBox.ShowAsync("Build Result", $"The build of '{activeProject.Name}' was cancelled."); 46 | } 47 | } 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/BuildSolutionAsyncCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Community.VisualStudio.Toolkit; 3 | using Microsoft.VisualStudio.Shell; 4 | using Task = System.Threading.Tasks.Task; 5 | 6 | namespace TestExtension.Commands 7 | { 8 | [Command(PackageIds.BuildSolutionAsync)] 9 | internal sealed class BuildSolutionAsyncCommand : BaseCommand 10 | { 11 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 12 | { 13 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 14 | 15 | try 16 | { 17 | bool buildResult = await VS.Build.BuildSolutionAsync(); 18 | if (buildResult) 19 | { 20 | await VS.MessageBox.ShowAsync("Build Result", $"The solution was built successfully!"); 21 | } 22 | else 23 | { 24 | await VS.MessageBox.ShowErrorAsync("Build Result", $"The solution did not build successfully :("); 25 | } 26 | } 27 | catch (OperationCanceledException) 28 | { 29 | await VS.MessageBox.ShowAsync("Build Result", "The solution build was cancelled."); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/CollapseSelectedItemsCommand.cs: -------------------------------------------------------------------------------- 1 | using Community.VisualStudio.Toolkit; 2 | using Microsoft.VisualStudio.Shell; 3 | using Task = System.Threading.Tasks.Task; 4 | 5 | namespace TestExtension 6 | { 7 | [Command(PackageIds.CollapseSelectedItems)] 8 | internal sealed class CollapseSelectedItemsCommand : BaseCommand 9 | { 10 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 11 | { 12 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 13 | 14 | SolutionExplorerWindow solutionExplorer = await VS.Windows.GetSolutionExplorerWindowAsync(); 15 | if (solutionExplorer != null) 16 | { 17 | solutionExplorer.Collapse(await solutionExplorer.GetSelectionAsync()); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/EditProjectFileCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics.CodeAnalysis; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Threading.Tasks; 7 | using Community.VisualStudio.Toolkit; 8 | using Microsoft.VisualStudio; 9 | using Microsoft.VisualStudio.Shell; 10 | using Microsoft.VisualStudio.Shell.Interop; 11 | 12 | namespace TestExtension.Commands 13 | { 14 | [Command(PackageIds.EditProjectFile)] 15 | internal sealed class EditProjectFileCommand : BaseDynamicCommand 16 | { 17 | [SuppressMessage("Usage", "VSTHRD102:Implement internal logic asynchronously", Justification = "Must be synchronous.")] 18 | protected override IReadOnlyList GetItems() 19 | { 20 | return ThreadHelper.JoinableTaskFactory.Run(async () => 21 | { 22 | return (await VS.Solutions.GetAllProjectsAsync()).OrderBy(x => x.Name).ToList(); 23 | }); 24 | } 25 | 26 | protected override void BeforeQueryStatus(OleMenuCommand menuItem, EventArgs e, Project project) 27 | { 28 | menuItem.Text = project.Name; 29 | } 30 | 31 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e, Project project) 32 | { 33 | try 34 | { 35 | await VS.Documents.OpenAsync(project.FullPath); 36 | } 37 | catch (COMException ex) when (ex.ErrorCode == -2147467259) 38 | { 39 | // The project needs to be unloaded before it 40 | // can be opened. Get the GUID of the project. 41 | project.GetItemInfo(out IVsHierarchy hierarchy, out _, out _); 42 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 43 | IVsSolution solution = await VS.Services.GetSolutionAsync(); 44 | ErrorHandler.ThrowOnFailure(solution.GetGuidOfProject(hierarchy, out Guid guid)); 45 | 46 | // Unload the project. 47 | ((IVsSolution4)solution).UnloadProject(guid, (uint)_VSProjectUnloadStatus.UNLOADSTATUS_UnloadedByUser); 48 | 49 | // Now try to open the project file again. 50 | await VS.Documents.OpenAsync(project.FullPath); 51 | } 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/EditSelectedItemLabelCommand.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Community.VisualStudio.Toolkit; 3 | using Microsoft.VisualStudio.Shell; 4 | using Task = System.Threading.Tasks.Task; 5 | 6 | namespace TestExtension 7 | { 8 | [Command(PackageIds.EditSelectedItemLabel)] 9 | internal sealed class EditSelectedItemLabelCommand : BaseCommand 10 | { 11 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 12 | { 13 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 14 | 15 | SolutionExplorerWindow solutionExplorer = await VS.Windows.GetSolutionExplorerWindowAsync(); 16 | if (solutionExplorer != null) 17 | { 18 | SolutionItem item = (await solutionExplorer.GetSelectionAsync()).FirstOrDefault(); 19 | if (item != null) 20 | { 21 | solutionExplorer.EditLabel(item); 22 | } 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/ExpandSelectedItemsCommand.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Windows.Input; 3 | using Community.VisualStudio.Toolkit; 4 | using Microsoft.VisualStudio.Shell; 5 | using Task = System.Threading.Tasks.Task; 6 | 7 | namespace TestExtension 8 | { 9 | [Command(PackageIds.ExpandSelectedItems)] 10 | internal sealed class ExpandSelectedItemsCommand : BaseCommand 11 | { 12 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 13 | { 14 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 15 | 16 | SolutionExplorerWindow solutionExplorer = await VS.Windows.GetSolutionExplorerWindowAsync(); 17 | if (solutionExplorer != null) 18 | { 19 | IEnumerable items = await solutionExplorer.GetSelectionAsync(); 20 | SolutionItemExpansionMode mode = SolutionItemExpansionMode.None; 21 | 22 | ModifierKeys modifiers = Keyboard.Modifiers; 23 | if (modifiers == ModifierKeys.None) 24 | { 25 | mode = SolutionItemExpansionMode.Single; 26 | } 27 | else 28 | { 29 | if ((modifiers & ModifierKeys.Control) == ModifierKeys.Control) 30 | { 31 | mode |= SolutionItemExpansionMode.Recursive; 32 | } 33 | 34 | if ((modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) 35 | { 36 | // To expand to the selected items, theose items and their ancestors 37 | // all need to be collapsed, so collapse them first, then pause for a 38 | // moment so that you can see that we start from a collapsed state. 39 | foreach (SolutionItem item in items) 40 | { 41 | CollapseRecursively(solutionExplorer, item); 42 | } 43 | await Task.Delay(2000); 44 | mode |= SolutionItemExpansionMode.Ancestors; 45 | } 46 | } 47 | 48 | solutionExplorer.Expand(items, mode); 49 | } 50 | } 51 | 52 | private void CollapseRecursively(SolutionExplorerWindow solutionExplorer, SolutionItem item) 53 | { 54 | while (item != null) 55 | { 56 | solutionExplorer.Collapse(item); 57 | item = item.Parent; 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/FontsAndColorsWindowCommand.cs: -------------------------------------------------------------------------------- 1 | using Community.VisualStudio.Toolkit; 2 | using Microsoft.VisualStudio.Shell; 3 | using Task = System.Threading.Tasks.Task; 4 | 5 | namespace TestExtension 6 | { 7 | [Command(PackageIds.FontsAndColorsWindow)] 8 | internal sealed class FontsAndColorsWindowCommand : BaseCommand 9 | { 10 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) => 11 | await FontsAndColorsWindow.ShowAsync(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/ListReferencesCommand.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Community.VisualStudio.Toolkit; 3 | using Microsoft.VisualStudio.Shell; 4 | using Task = System.Threading.Tasks.Task; 5 | 6 | namespace TestExtension.Commands 7 | { 8 | [Command(PackageIds.ListReferences)] 9 | internal sealed class ListReferencesCommand : BaseCommand 10 | { 11 | OutputWindowPane _pane; 12 | 13 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 14 | { 15 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 16 | 17 | if (_pane is null) 18 | { 19 | _pane = await VS.Windows.CreateOutputWindowPaneAsync("References"); 20 | } 21 | 22 | await _pane.ActivateAsync(); 23 | 24 | foreach (Project project in await VS.Solutions.GetAllProjectsAsync()) 25 | { 26 | await _pane.WriteLineAsync(project.Name); 27 | foreach (Reference reference in project.References.OrderBy(x => x.Name)) 28 | { 29 | if (reference is AssemblyReference assemblyRef) 30 | { 31 | await _pane.WriteLineAsync($" * {reference.Name} (Assembly: {assemblyRef.FullPath})"); 32 | } 33 | else if (reference is ProjectReference projectRef) 34 | { 35 | await _pane.WriteLineAsync($" * {reference.Name} (Project: {(await projectRef.GetProjectAsync())?.Name ?? "?"})"); 36 | } 37 | else 38 | { 39 | await _pane.WriteLineAsync($" * {reference.Name} (Unknown)"); 40 | } 41 | } 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/LoadSelectedProject.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Community.VisualStudio.Toolkit; 3 | using Microsoft.VisualStudio.Shell; 4 | 5 | namespace TestExtension.Commands 6 | { 7 | [Command(PackageIds.LoadSelectedProject)] 8 | internal sealed class LoadSelectedProjectCommand : BaseCommand 9 | { 10 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 11 | { 12 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 13 | 14 | Project project = await VS.Solutions.GetActiveProjectAsync(); 15 | if (project != null) 16 | { 17 | await project.LoadAsync(); 18 | 19 | // Show a message to demonstrate that the Project object can still be used. 20 | await VS.MessageBox.ShowAsync($"Project '{project.Name}' has been loaded."); 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/MultiInstanceWindowCommand.cs: -------------------------------------------------------------------------------- 1 | using Community.VisualStudio.Toolkit; 2 | using Microsoft.VisualStudio.Shell; 3 | using Task = System.Threading.Tasks.Task; 4 | 5 | namespace TestExtension 6 | { 7 | [Command(PackageIds.MultiInstanceWindow)] 8 | internal sealed class MultiInstanceWindowCommand : BaseCommand 9 | { 10 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 11 | { 12 | // Create the window with the first free ID. 13 | for (int i = 0; i < 10; i++) 14 | { 15 | ToolWindowPane window = await MultiInstanceWindow.ShowAsync(id: i, create: false); 16 | 17 | if (window == null) 18 | { 19 | await MultiInstanceWindow.ShowAsync(id: i, create: true); 20 | break; 21 | } 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/RunnerWindowCommand.cs: -------------------------------------------------------------------------------- 1 | using Community.VisualStudio.Toolkit; 2 | using Microsoft.VisualStudio.Shell; 3 | using Task = System.Threading.Tasks.Task; 4 | 5 | namespace TestExtension 6 | { 7 | [Command(PackageIds.RunnerWindow)] 8 | internal sealed class RunnerWindowCommand : BaseCommand 9 | { 10 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) => 11 | await RunnerWindow.ShowAsync(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/SelectCurrentProjectCommand.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Community.VisualStudio.Toolkit; 3 | using Microsoft.VisualStudio.Shell; 4 | using Task = System.Threading.Tasks.Task; 5 | 6 | namespace TestExtension 7 | { 8 | [Command(PackageIds.SelectCurrentProject)] 9 | internal sealed class SelectCurrentProjectCommand : BaseCommand 10 | { 11 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 12 | { 13 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 14 | 15 | SolutionExplorerWindow solutionExplorer = await VS.Windows.GetSolutionExplorerWindowAsync(); 16 | if (solutionExplorer != null) 17 | { 18 | List projects = new List(); 19 | foreach (SolutionItem item in await solutionExplorer.GetSelectionAsync()) 20 | { 21 | SolutionItem project = item.FindParent(SolutionItemType.Project); 22 | if (project != null) 23 | { 24 | projects.Add(project); 25 | } 26 | } 27 | 28 | if (projects.Count > 0) 29 | { 30 | solutionExplorer.SetSelection(projects); 31 | } 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/SendMessageToRunnerWindowCommand.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Community.VisualStudio.Toolkit; 3 | using Microsoft.VisualStudio.Shell; 4 | 5 | namespace TestExtension 6 | { 7 | [Command(PackageIds.SendMessageToRunnerWindow)] 8 | internal sealed class SendMessageToRunnerWindowCommand : BaseCommand 9 | { 10 | private int _counter; 11 | 12 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 13 | { 14 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 15 | 16 | RunnerWindowMessenger messenger = await Package.GetServiceAsync(); 17 | _counter += 1; 18 | messenger.Send($"Message #{_counter}"); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/SplitButtonCommand.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Community.VisualStudio.Toolkit; 3 | using Microsoft.VisualStudio.Shell; 4 | using Microsoft.VisualStudio.Shell.Interop; 5 | 6 | namespace TestExtension.Commands 7 | { 8 | [Command(PackageIds.SplitButton)] 9 | internal sealed class SplitButtonMenuCommand : BaseCommand 10 | { 11 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 12 | { 13 | await VS.MessageBox.ShowAsync("The main split button was pressed.", buttons: OLEMSGBUTTON.OLEMSGBUTTON_OK); 14 | } 15 | } 16 | 17 | [Command(PackageIds.SplitButtonChild1)] 18 | internal sealed class SplitButton1Command : BaseCommand 19 | { 20 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 21 | { 22 | await VS.MessageBox.ShowAsync("The first split button child was pressed.", buttons: OLEMSGBUTTON.OLEMSGBUTTON_OK); 23 | } 24 | } 25 | 26 | [Command(PackageIds.SplitButtonChild2)] 27 | internal sealed class SplitButton2Command : BaseCommand 28 | { 29 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 30 | { 31 | await VS.MessageBox.ShowAsync("The second split button child was pressed.", buttons: OLEMSGBUTTON.OLEMSGBUTTON_OK); 32 | 33 | // Toggle the checked state to demonstrate having a check mark on the button. 34 | Command.Checked = !Command.Checked; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/ThemeWindowCommand.cs: -------------------------------------------------------------------------------- 1 | using Community.VisualStudio.Toolkit; 2 | using Microsoft.VisualStudio.Shell; 3 | using Task = System.Threading.Tasks.Task; 4 | 5 | namespace TestExtension 6 | { 7 | [Command(PackageIds.ThemeWindow)] 8 | internal sealed class ThemeWindowCommand : BaseCommand 9 | { 10 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 11 | { 12 | await ThemeWindow.ShowAsync(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/ToggleVsixManifestFilterCommand.cs: -------------------------------------------------------------------------------- 1 | using Community.VisualStudio.Toolkit; 2 | using Microsoft.VisualStudio.Shell; 3 | using Task = System.Threading.Tasks.Task; 4 | 5 | namespace TestExtension 6 | { 7 | [Command(PackageIds.ToggleVsixManifestFilter)] 8 | internal sealed class ToggleVsixManifestFilterCommand : BaseCommand 9 | { 10 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 11 | { 12 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 13 | 14 | SolutionExplorerWindow solutionExplorer = await VS.Windows.GetSolutionExplorerWindowAsync(); 15 | if (solutionExplorer != null) 16 | { 17 | if (solutionExplorer.IsFilterEnabled()) 18 | { 19 | solutionExplorer.DisableFilter(); 20 | } 21 | else 22 | { 23 | solutionExplorer.EnableFilter(); 24 | } 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Commands/UnloadSelectedProject.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Community.VisualStudio.Toolkit; 3 | using Microsoft.VisualStudio.Shell; 4 | 5 | namespace TestExtension.Commands 6 | { 7 | [Command(PackageIds.UnloadSelectedProject)] 8 | internal sealed class UnloadSelectedProjectCommand : BaseCommand 9 | { 10 | protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) 11 | { 12 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); 13 | 14 | Project project = await VS.Solutions.GetActiveProjectAsync(); 15 | if (project != null) 16 | { 17 | await project.UnloadAsync(); 18 | 19 | // Show a message to demonstrate that the Project object can still be used. 20 | await VS.MessageBox.ShowAsync($"Project '{project.Name}' has been unloaded."); 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/MEF/HighlightWord.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.Text.Operations; 2 | using Microsoft.VisualStudio.Text.Tagging; 3 | using Microsoft.VisualStudio.Utilities; 4 | using Community.VisualStudio.Toolkit; 5 | using System.ComponentModel.Composition; 6 | using Microsoft.VisualStudio.Text.Editor; 7 | using Microsoft.VisualStudio.Text.Classification; 8 | using System.Windows.Media; 9 | namespace TestExtension.MEF 10 | { 11 | 12 | [Export(typeof(EditorFormatDefinition))] 13 | [Name("MarkerFormatDefinition/HighlightWordFormatDefinition")] 14 | [UserVisible(true)] 15 | internal class HighlightWordFormatDefinition : MarkerFormatDefinition 16 | { 17 | public HighlightWordFormatDefinition() 18 | { 19 | this.BackgroundColor = Colors.LightBlue; 20 | this.ForegroundColor = Colors.DarkBlue; 21 | this.DisplayName = "Highlight Word"; 22 | this.ZOrder = 5; 23 | } 24 | } 25 | 26 | /// 27 | /// This class demonstrates a HighlightWord tagger for text files 28 | /// and it only highlights whole words starting with a Letter 29 | /// 30 | [Export(typeof(IViewTaggerProvider))] 31 | [ContentType("Text")] 32 | [TagType(typeof(TextMarkerTag))] 33 | [TextViewRole(PredefinedTextViewRoles.PrimaryDocument)] 34 | internal class HighlightWordTaggerProvider : SameWordHighlighterBase 35 | { 36 | public override FindOptions FindOptions => FindOptions.WholeWord; 37 | public override bool ShouldHighlight(string text) 38 | { 39 | if (text?.Length > 0) 40 | return char.IsLetter(text[0]); 41 | return false; 42 | } 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/MEF/TextviewCreationListener.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.Composition; 2 | using Community.VisualStudio.Toolkit; 3 | using Microsoft.VisualStudio.Shell; 4 | using Microsoft.VisualStudio.Text; 5 | using Microsoft.VisualStudio.Text.Editor; 6 | using Microsoft.VisualStudio.Utilities; 7 | using Task = System.Threading.Tasks.Task; 8 | 9 | namespace TestExtension.MEF 10 | { 11 | [Export(typeof(IWpfTextViewCreationListener))] 12 | [ContentType("text")] 13 | [TextViewRole(PredefinedTextViewRoles.PrimaryDocument)] 14 | internal class TextViewCreationListener : WpfTextViewCreationListener 15 | { 16 | protected override Task CreatedAsync(DocumentView docView) 17 | { 18 | // Do your async work here 19 | return Task.CompletedTask; 20 | } 21 | 22 | protected override void FileActionOccurred(TextDocumentFileActionEventArgs e) 23 | { 24 | VS.StatusBar.ShowMessageAsync($"File Action: {e.FileActionType}").FireAndForget(); 25 | } 26 | 27 | protected override void DirtyStateChanged() 28 | { 29 | VS.StatusBar.ShowMessageAsync($"Dirty state changed").FireAndForget(); 30 | } 31 | 32 | protected override void EncodingChanged(EncodingChangedEventArgs e) 33 | { 34 | VS.StatusBar.ShowMessageAsync($"Encoding chaged from {e.OldEncoding} to: {e.OldEncoding}").FireAndForget(); 35 | } 36 | 37 | protected override void Closed(IWpfTextView textView) 38 | { 39 | VS.StatusBar.ShowMessageAsync("Document closed").FireAndForget(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Options/RuntimeEnumProxy.cs: -------------------------------------------------------------------------------- 1 | namespace TestExtension 2 | { 3 | public class RuntimeEnumProxy 4 | { 5 | public RuntimeEnumProxy(string value) 6 | { 7 | Value = value; 8 | } 9 | 10 | public string Value { get; } 11 | 12 | public override string ToString() 13 | { 14 | return Value; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | 3 | using System.Windows; 4 | using Microsoft.VisualStudio.Shell; 5 | 6 | [assembly: ProvideCodeBase(AssemblyName = "Community.VisualStudio.Toolkit")] 7 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] 8 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Resources/Theme.Blue.vssettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 2 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Resources/Theme.BlueHighContrast.vssettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 2 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Resources/Theme.Dark.vssettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 2 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/SolutionExplorer/VsixManifestFilterProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.Composition; 3 | using System.Text.RegularExpressions; 4 | using System.Threading.Tasks; 5 | using Microsoft.Internal.VisualStudio.PlatformUI; 6 | using Microsoft.VisualStudio.Shell; 7 | 8 | namespace TestExtension 9 | { 10 | [SolutionTreeFilterProvider(PackageGuids.TestExtensionString, PackageIds.VsixManifestSolutionExplorerFilter)] 11 | public class VsixManifestFilterProvider : HierarchyTreeFilterProvider 12 | { 13 | private readonly IVsHierarchyItemCollectionProvider _hierarchyCollectionProvider; 14 | 15 | [ImportingConstructor] 16 | public VsixManifestFilterProvider(IVsHierarchyItemCollectionProvider hierarchyCollectionProvider) 17 | { 18 | _hierarchyCollectionProvider = hierarchyCollectionProvider; 19 | } 20 | 21 | protected override HierarchyTreeFilter CreateFilter() 22 | { 23 | return new Filter(_hierarchyCollectionProvider); 24 | } 25 | 26 | private sealed class Filter : HierarchyTreeFilter 27 | { 28 | private static readonly Regex _pattern = new Regex(@"\.vsixmanifest$", RegexOptions.IgnoreCase); 29 | 30 | private readonly IVsHierarchyItemCollectionProvider _hierarchyCollectionProvider; 31 | 32 | public Filter(IVsHierarchyItemCollectionProvider hierarchyCollectionProvider) 33 | { 34 | _hierarchyCollectionProvider = hierarchyCollectionProvider; 35 | } 36 | 37 | protected override async Task GetIncludedItemsAsync(IEnumerable rootItems) 38 | { 39 | IVsHierarchyItem root = HierarchyUtilities.FindCommonAncestor(rootItems); 40 | IReadOnlyObservableSet sourceItems; 41 | 42 | sourceItems = await _hierarchyCollectionProvider.GetDescendantsAsync(root.HierarchyIdentity.NestedHierarchy, CancellationToken); 43 | 44 | return await _hierarchyCollectionProvider.GetFilteredHierarchyItemsAsync(sourceItems, MeetsFilter, CancellationToken); 45 | } 46 | 47 | private static bool MeetsFilter(IVsHierarchyItem item) 48 | { 49 | return (item != null) && _pattern.IsMatch(item.Text); 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/ToolWindows/FontsAndColors/DemoFontAndColorCategory.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | using Community.VisualStudio.Toolkit; 3 | using Microsoft.VisualStudio.Shell.Interop; 4 | using Microsoft.VisualStudio.TextManager.Interop; 5 | 6 | namespace TestExtension 7 | { 8 | [Guid("bfbcd352-3b43-4034-b951-7ca841a16c81")] 9 | public class DemoFontAndColorCategory : BaseFontAndColorCategory 10 | { 11 | public DemoFontAndColorCategory() : base(new FontDefinition("Consolas", 12)) { } 12 | 13 | public override string Name => "Fonts and Colors Demo"; 14 | 15 | public ColorDefinition TopLeft { get; } = new( 16 | "Top Left", 17 | defaultBackground: VisualStudioColor.Indexed(COLORINDEX.CI_RED), 18 | defaultForeground: VisualStudioColor.Indexed(COLORINDEX.CI_WHITE), 19 | options: ColorDefinition.DefaultOptions | ColorOptions.AllowBoldChange 20 | ); 21 | 22 | public ColorDefinition TopRight { get; } = new( 23 | "Top Right", 24 | defaultBackground: VisualStudioColor.Automatic(), 25 | defaultForeground: VisualStudioColor.Automatic(), 26 | automaticBackground: VisualStudioColor.VsColor(__VSSYSCOLOREX.VSCOLOR_ENVIRONMENT_BACKGROUND), 27 | automaticForeground: VisualStudioColor.VsColor(__VSSYSCOLOREX.VSCOLOR_PANEL_TEXT), 28 | options: ColorDefinition.DefaultOptions | ColorOptions.AllowBoldChange 29 | ); 30 | 31 | public ColorDefinition BottomLeft { get; } = new( 32 | "Bottom Left", 33 | defaultBackground: VisualStudioColor.SysColor(13), 34 | defaultForeground: VisualStudioColor.SysColor(14), 35 | options: ColorOptions.AllowBackgroundChange | ColorOptions.AllowForegroundChange 36 | ); 37 | 38 | public ColorDefinition BottomRight { get; } = new( 39 | "Bottom Right", 40 | defaultBackground: VisualStudioColor.Indexed(COLORINDEX.CI_DARKGREEN), 41 | defaultForeground: VisualStudioColor.Indexed(COLORINDEX.CI_WHITE) 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/ToolWindows/FontsAndColors/DemoFontAndColorProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using Community.VisualStudio.Toolkit; 4 | 5 | namespace TestExtension 6 | { 7 | [Guid("d2bc5f5f-6c24-4f6c-b6ef-aea775be5fa4")] 8 | public class DemoFontAndColorProvider : BaseFontAndColorProvider { } 9 | } 10 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/ToolWindows/FontsAndColors/FontsAndColorsWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using System.Windows; 6 | using Community.VisualStudio.Toolkit; 7 | using Microsoft.VisualStudio.Imaging; 8 | 9 | namespace TestExtension 10 | { 11 | public class FontsAndColorsWindow : BaseToolWindow 12 | { 13 | public override string GetTitle(int toolWindowId) => "Fonts and Colors Window"; 14 | 15 | public override Type PaneType => typeof(Pane); 16 | 17 | public override async Task CreateAsync(int toolWindowId, CancellationToken cancellationToken) 18 | { 19 | return new FontsAndColorsWindowControl 20 | { 21 | DataContext = new FontsAndColorsWindowViewModel( 22 | await VS.FontsAndColors.GetConfiguredFontAndColorsAsync(), 23 | Package.JoinableTaskFactory 24 | ) 25 | }; 26 | } 27 | 28 | [Guid("b7141d35-7b95-4ad0-a37d-58220c1aa5e3")] 29 | internal class Pane : ToolkitToolWindowPane 30 | { 31 | public Pane() 32 | { 33 | BitmapImageMoniker = KnownMonikers.ColorDialog; 34 | } 35 | 36 | protected override void Dispose(bool disposing) 37 | { 38 | ((Content as FontsAndColorsWindowControl).DataContext as IDisposable)?.Dispose(); 39 | base.Dispose(disposing); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/ToolWindows/FontsAndColors/FontsAndColorsWindowControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | using System.Windows.Documents; 3 | using Community.VisualStudio.Toolkit; 4 | 5 | namespace TestExtension 6 | { 7 | public partial class FontsAndColorsWindowControl : UserControl 8 | { 9 | public FontsAndColorsWindowControl() 10 | { 11 | InitializeComponent(); 12 | } 13 | 14 | private void ApplyColor(Border border, ConfiguredColor color) 15 | { 16 | // Bind the border's properties to the configured 17 | // color properties. This could also be done in XAML. 18 | border.DataContext = color; 19 | border.SetBinding(BackgroundProperty, nameof(ConfiguredColor.BackgroundBrush)); 20 | border.SetBinding(TextElement.ForegroundProperty, nameof(ConfiguredColor.ForegroundBrush)); 21 | border.SetBinding(TextElement.FontWeightProperty, nameof(ConfiguredColor.FontWeight)); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/ToolWindows/MultiInstanceWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using System.Windows; 6 | using Community.VisualStudio.Toolkit; 7 | using Microsoft.VisualStudio.Imaging; 8 | using Microsoft.VisualStudio.Shell; 9 | using Task = System.Threading.Tasks.Task; 10 | 11 | namespace TestExtension 12 | { 13 | public class MultiInstanceWindow : BaseToolWindow 14 | { 15 | public override string GetTitle(int toolWindowId) => $"Multi Instance Window #{toolWindowId}"; 16 | 17 | public override Type PaneType => typeof(Pane); 18 | 19 | public override Task CreateAsync(int toolWindowId, CancellationToken cancellationToken) 20 | { 21 | return Task.FromResult(new MultiInstanceWindowControl(toolWindowId)); 22 | } 23 | 24 | [Guid("13dccc25-9d1d-417d-8525-40c4c14ff0a2")] 25 | internal class Pane : ToolWindowPane 26 | { 27 | public Pane() 28 | { 29 | BitmapImageMoniker = KnownMonikers.MultiView; 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/ToolWindows/MultiInstanceWindowControl.xaml: -------------------------------------------------------------------------------- 1 |  12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/ToolWindows/MultiInstanceWindowControl.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace TestExtension 4 | { 5 | public partial class MultiInstanceWindowControl : UserControl 6 | { 7 | public MultiInstanceWindowControl(int toolWindowId) 8 | { 9 | InitializeComponent(); 10 | lblWindowId.Content = toolWindowId; 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/ToolWindows/RunnerWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Design; 3 | using System.Diagnostics; 4 | using System.Runtime.InteropServices; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using Community.VisualStudio.Toolkit; 9 | using Microsoft.VisualStudio.Imaging; 10 | using Microsoft.VisualStudio.Shell; 11 | 12 | namespace TestExtension 13 | { 14 | public class RunnerWindow : BaseToolWindow 15 | { 16 | public override string GetTitle(int toolWindowId) => "Runner Window"; 17 | 18 | public override Type PaneType => typeof(Pane); 19 | 20 | public override async Task CreateAsync(int toolWindowId, CancellationToken cancellationToken) 21 | { 22 | Version version = await VS.Shell.GetVsVersionAsync(); 23 | RunnerWindowMessenger messenger = await Package.GetServiceAsync(); 24 | return new RunnerWindowControl(version, messenger); 25 | } 26 | 27 | [Guid("d3b3ebd9-87d1-41cd-bf84-268d88953417")] 28 | internal class Pane : ToolkitToolWindowPane 29 | { 30 | public Pane() 31 | { 32 | BitmapImageMoniker = KnownMonikers.StatusInformation; 33 | ToolBar = new CommandID(PackageGuids.TestExtension, PackageIds.RunnerWindowToolbar); 34 | WindowFrameAvailable += (_, _) => Debug.WriteLine("RunnerWindow frame is now available"); 35 | } 36 | 37 | public override void OnToolWindowCreated() 38 | { 39 | base.OnToolWindowCreated(); 40 | GetWindowFrame().OnShow += (_, args) => Debug.WriteLine($"RunnerWindow state changed: {args.Reason}"); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /demo/VSSDK.TestExtension/ToolWindows/RunnerWindowControl.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |