├── .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 |
17 |
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 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/ToolWindows/RunnerWindowControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using Community.VisualStudio.Toolkit;
6 | using Microsoft.VisualStudio;
7 | using Microsoft.VisualStudio.Shell;
8 | using Microsoft.VisualStudio.Shell.Interop;
9 | using Task = System.Threading.Tasks.Task;
10 |
11 | namespace TestExtension
12 | {
13 | public partial class RunnerWindowControl : UserControl, IToolWindowPaneAware
14 | {
15 | public RunnerWindowControl(Version vsVersion, RunnerWindowMessenger messenger)
16 | {
17 | InitializeComponent();
18 |
19 | lblHeadline.Content = $"Visual Studio v{vsVersion}";
20 |
21 | messenger.MessageReceived += OnMessageReceived;
22 | }
23 |
24 | private void OnMessageReceived(object sender, string e)
25 | {
26 | MessageList.Items.Add(e);
27 | }
28 |
29 | private void btnShowMessage_Click(object sender, RoutedEventArgs e)
30 | {
31 | ShowMessageAsync().FireAndForget();
32 | }
33 |
34 | private void btnHide_Click(object sender, RoutedEventArgs e)
35 | {
36 | HideAsync().FireAndForget();
37 | }
38 |
39 | private async Task ShowMessageAsync()
40 | {
41 | var rating = new RatingPrompt("SteveCadwallader.CodeMaidVS2022", Vsix.Name);
42 | await rating.PromptAsync();
43 |
44 | await VS.StatusBar.ShowMessageAsync("Test");
45 | string? text = await VS.StatusBar.GetMessageAsync();
46 | await VS.StatusBar.ShowMessageAsync(text + " OK");
47 |
48 | Exception ex = new Exception(nameof(TestExtension));
49 | await ex.LogAsync();
50 |
51 | VSConstants.MessageBoxResult button = await VS.MessageBox.ShowAsync("message", "title");
52 | Debug.WriteLine(button);
53 | }
54 |
55 | private async Task HideAsync()
56 | {
57 | await RunnerWindow.HideAsync();
58 | }
59 |
60 | public void SetPane(ToolWindowPane pane)
61 | {
62 | MessageList.Items.Add("Pane has been set.");
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/ToolWindows/RunnerWindowMessenger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace TestExtension
4 | {
5 | ///
6 | /// This service demonstrates a very simple way for a toolbar to communicate
7 | /// with a tool window. There are many ways that this can be done, and this
8 | /// service is by no means "best practice".
9 | ///
10 | /// In fact, there is nothing about this service that restricts its use
11 | /// to toolbars and tool windows - it's just raising events. Any sort of
12 | /// "message passing" can also be used to communicate with the tool window.
13 | ///
14 | public class RunnerWindowMessenger
15 | {
16 | public void Send(string message)
17 | {
18 | // The tooolbar button will call this method.
19 | // The tool window has added an event handler
20 | MessageReceived?.Invoke(this, message);
21 | }
22 |
23 | public event EventHandler MessageReceived;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/ToolWindows/ThemeWindow/CustomizedStylesDialog.xaml:
--------------------------------------------------------------------------------
1 |
20 |
21 |
22 |
23 |
27 |
28 |
29 |
30 |
31 |
34 |
37 |
38 |
42 |
45 |
46 |
47 |
48 |
49 |
55 |
56 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/ToolWindows/ThemeWindow/CustomizedStylesDialog.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.PlatformUI;
2 |
3 | namespace TestExtension
4 | {
5 | public partial class CustomizedStylesDialog : DialogWindow
6 | {
7 | public CustomizedStylesDialog()
8 | {
9 | InitializeComponent();
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/ToolWindows/ThemeWindow/ThemeWindow.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.Settings;
9 | using Microsoft.VisualStudio.Shell;
10 | using Microsoft.VisualStudio.Shell.Interop;
11 | using Microsoft.VisualStudio.Shell.Settings;
12 |
13 | namespace TestExtension
14 | {
15 | public class ThemeWindow : BaseToolWindow
16 | {
17 | public override string GetTitle(int toolWindowId) => "Theme Window";
18 |
19 | public override Type PaneType => typeof(Pane);
20 |
21 | public async override Task CreateAsync(int toolWindowId, CancellationToken cancellationToken)
22 | {
23 | Guid currentTheme = await GetCurrentThemeAsync(cancellationToken);
24 |
25 | return new ThemeWindowControl { DataContext = new ThemeWindowControlViewModel(currentTheme) };
26 | }
27 |
28 | private async Task GetCurrentThemeAsync(CancellationToken cancellationToken)
29 | {
30 | const string COLLECTION_NAME = @"ApplicationPrivateSettings\Microsoft\VisualStudio";
31 | const string PROPERTY_NAME = "ColorTheme";
32 |
33 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
34 |
35 | IVsSettingsManager manager = (IVsSettingsManager)await VS.Services.GetSettingsManagerAsync();
36 | SettingsStore store = new ShellSettingsManager(manager).GetReadOnlySettingsStore(SettingsScope.UserSettings);
37 |
38 | if (store.CollectionExists(COLLECTION_NAME))
39 | {
40 | if (store.PropertyExists(COLLECTION_NAME, PROPERTY_NAME))
41 | {
42 | // The value is made up of three parts, separated
43 | // by a star. The third part is the GUID of the theme.
44 | string[] parts = store.GetString(COLLECTION_NAME, PROPERTY_NAME).Split('*');
45 | if (parts.Length == 3)
46 | {
47 | if (Guid.TryParse(parts[2], out Guid value))
48 | {
49 | return value;
50 | }
51 | }
52 | }
53 | }
54 |
55 | return Guid.Empty;
56 | }
57 |
58 | [Guid("e3be6dd3-f017-4d6e-ae88-2b29319a77a2")]
59 | internal class Pane : ToolWindowPane
60 | {
61 | public Pane()
62 | {
63 | BitmapImageMoniker = KnownMonikers.ColorPalette;
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/ToolWindows/ThemeWindow/ThemeWindowControl.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 |
3 | namespace TestExtension
4 | {
5 | public partial class ThemeWindowControl : UserControl
6 | {
7 | public ThemeWindowControl()
8 | {
9 | InitializeComponent();
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/ToolWindows/ThemeWindow/ThemeWindowDemo.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel;
3 | using System.Runtime.CompilerServices;
4 | using System.Threading.Tasks;
5 | using System.Windows.Controls;
6 | using Microsoft.VisualStudio.Shell;
7 |
8 | namespace TestExtension
9 | {
10 | public partial class ThemeWindowDemo : UserControl, INotifyPropertyChanged
11 | {
12 | private double _progress;
13 |
14 | public ThemeWindowDemo()
15 | {
16 | InitializeComponent();
17 | UpdateProgressAsync().FireAndForget();
18 | }
19 |
20 | private async Task UpdateProgressAsync()
21 | {
22 | while (true)
23 | {
24 | await Task.Delay(250).ConfigureAwait(true);
25 | Progress = (Progress + 5) % 101;
26 | }
27 | }
28 |
29 | public IEnumerable ListItems { get; } = new string[] {
30 | "First",
31 | "Second",
32 | "Third",
33 | "Fourth",
34 | "Fifth",
35 | "Sixth"
36 | };
37 |
38 | public double Progress
39 | {
40 | get
41 | {
42 | return _progress;
43 | }
44 | set
45 | {
46 | _progress = value;
47 | RaisePropertyChanged();
48 | }
49 | }
50 |
51 | private void RaisePropertyChanged([CallerMemberName] string name = null)
52 | {
53 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
54 |
55 | }
56 |
57 | public event PropertyChangedEventHandler PropertyChanged;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/ToolWindows/ThemeWindow/ThemeWindowDialog.xaml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/ToolWindows/ThemeWindow/ThemeWindowDialog.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.PlatformUI;
2 |
3 | namespace TestExtension
4 | {
5 | public partial class ThemeWindowDialog : DialogWindow
6 | {
7 | public ThemeWindowDialog()
8 | {
9 | InitializeComponent();
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/ToolWindows/ThemeWindow/ThemeWindowDialogViewModel.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.PlatformUI;
2 |
3 | namespace TestExtension
4 | {
5 | public class ThemeWindowDialogViewModel : ObservableObject
6 | {
7 | private bool _useVsTheme = true;
8 |
9 | public bool UseVsTheme
10 | {
11 | get { return _useVsTheme; }
12 | set { SetProperty(ref _useVsTheme, value); }
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/ToolWindows/ThemeWindow/ThemedControl.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 |
4 | namespace TestExtension
5 | {
6 | public class ThemedControl : Control
7 | {
8 | public static readonly DependencyProperty LabelProperty = DependencyProperty.Register(
9 | "Label",
10 | typeof(string),
11 | typeof(ThemedControl),
12 | new FrameworkPropertyMetadata("")
13 | );
14 |
15 | public static readonly DependencyProperty EnabledProperty = DependencyProperty.Register(
16 | "Enabled",
17 | typeof(object),
18 | typeof(ThemedControl),
19 | new FrameworkPropertyMetadata(null)
20 | );
21 |
22 | public static readonly DependencyProperty DisabledProperty = DependencyProperty.Register(
23 | "Disabled",
24 | typeof(object),
25 | typeof(ThemedControl),
26 | new FrameworkPropertyMetadata(null)
27 | );
28 |
29 | static ThemedControl()
30 | {
31 | DefaultStyleKeyProperty.OverrideMetadata(typeof(ThemedControl), new FrameworkPropertyMetadata(typeof(ThemedControl)));
32 | }
33 |
34 | public string Label
35 | {
36 | get { return (string)GetValue(LabelProperty); }
37 | set { SetValue(LabelProperty, value); }
38 | }
39 |
40 | public object Enabled
41 | {
42 | get { return GetValue(EnabledProperty); }
43 | set { SetValue(EnabledProperty, value); }
44 | }
45 |
46 | public object Disabled
47 | {
48 | get { return GetValue(DisabledProperty); }
49 | set { SetValue(DisabledProperty, value); }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/ToolWindows/ThemeWindow/ThemedControl.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
35 |
36 |
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/VSCommandTable.cs:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------------
2 | //
3 | // This file was generated by VSIX Synchronizer
4 | //
5 | // ------------------------------------------------------------------------------
6 | namespace TestExtension
7 | {
8 | using System;
9 |
10 | ///
11 | /// Helper class that exposes all GUIDs used across VS Package.
12 | ///
13 | internal sealed partial class PackageGuids
14 | {
15 | public const string TestExtensionString = "05271709-8845-42fb-9d10-621cc8cffc5d";
16 | public static Guid TestExtension = new Guid(TestExtensionString);
17 | }
18 | ///
19 | /// Helper class that encapsulates all CommandIDs uses across VS Package.
20 | ///
21 | internal sealed partial class PackageIds
22 | {
23 | public const int TestExtensionMainMenu = 0x1000;
24 | public const int TestExtensionSolutionExplorerMenu = 0x1001;
25 | public const int TestExtensionEditProjectFileMenu = 0x1002;
26 | public const int SplitButtonMenu = 0x1003;
27 | public const int TestExtensionMainMenuGroup1 = 0x1100;
28 | public const int TestExtensionSolutionExplorerGroup = 0x1101;
29 | public const int TestExtensionEditProjectFileGroup = 0x1102;
30 | public const int RunnerWindowToolbarGroup = 0x1103;
31 | public const int SplitButtonGroup = 0x1104;
32 | public const int RunnerWindow = 0x0100;
33 | public const int ThemeWindow = 0x0101;
34 | public const int MultiInstanceWindow = 0x0102;
35 | public const int BuildActiveProjectAsync = 0x0103;
36 | public const int BuildSolutionAsync = 0x0104;
37 | public const int VsixManifestSolutionExplorerFilter = 0x0105;
38 | public const int ToggleVsixManifestFilter = 0x0106;
39 | public const int SelectCurrentProject = 0x0107;
40 | public const int EditSelectedItemLabel = 0x0108;
41 | public const int ExpandSelectedItems = 0x0109;
42 | public const int CollapseSelectedItems = 0x0110;
43 | public const int ListReferences = 0x0111;
44 | public const int LoadSelectedProject = 0x0112;
45 | public const int UnloadSelectedProject = 0x0113;
46 | public const int SendMessageToRunnerWindow = 0x0114;
47 | public const int FontsAndColorsWindow = 0x0115;
48 | public const int SplitButton = 0x0116;
49 | public const int SplitButtonChild1 = 0x0117;
50 | public const int SplitButtonChild2 = 0x0118;
51 | public const int EditProjectFile = 0x2001;
52 | public const int RunnerWindowToolbar = 0x0BB8;
53 | }
54 | }
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/source.extension.cs:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------------
2 | //
3 | // This file was generated by VSIX Synchronizer
4 | //
5 | // ------------------------------------------------------------------------------
6 | namespace TestExtension
7 | {
8 | internal sealed partial class Vsix
9 | {
10 | public const string Id = "VSSDK.TestExtension.5a9a059d-5738-41dc-9075-250890b4ef6f";
11 | public const string Name = "VSSDK.TestExtension";
12 | public const string Description = @"Empty VSIX Project.";
13 | public const string Language = "en-US";
14 | public const string Version = "1.0";
15 | public const string Author = "Mads Kristensen";
16 | public const string Tags = "";
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/demo/VSSDK.TestExtension/source.extension.vsixmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | VSSDK.TestExtension
6 | Empty VSIX Project.
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | ###############
2 | # folder #
3 | ###############
4 | /**/DROP/
5 | /**/TEMP/
6 | /**/packages/
7 | /**/bin/
8 | /**/obj/
9 | api/*
10 | !api/*.md
11 |
--------------------------------------------------------------------------------
/docs/api/index.md:
--------------------------------------------------------------------------------
1 | # This is the **HOMEPAGE**.
2 | Refer to [Markdown](http://daringfireball.net/projects/markdown/) for how to write markdown files.
3 | ## Quick Start Notes:
4 | 1. Add images to the *images* folder if the file is referencing an image.
5 |
--------------------------------------------------------------------------------
/docs/articles/details1.md:
--------------------------------------------------------------------------------
1 | Details1
2 | ------------
3 |
4 | This is a detailed description.
5 | 
--------------------------------------------------------------------------------
/docs/articles/details2.md:
--------------------------------------------------------------------------------
1 | Introduction
2 | ------------
3 |
4 | This is a introduction
--------------------------------------------------------------------------------
/docs/articles/details3.md:
--------------------------------------------------------------------------------
1 | Introduction
2 | ------------
3 |
4 | This is a introduction
--------------------------------------------------------------------------------
/docs/articles/intro.md:
--------------------------------------------------------------------------------
1 |
2 | # Add your introductions here!
3 |
--------------------------------------------------------------------------------
/docs/articles/toc.yml:
--------------------------------------------------------------------------------
1 |
2 | - name: Introduction
3 | href: intro.md
4 | - name: Details 1
5 | href: details1.md
6 | - name: Details 2
7 | href: details2.md
8 | - name: Details 3
9 | href: details3.md
--------------------------------------------------------------------------------
/docs/build_docs.cmd:
--------------------------------------------------------------------------------
1 | choco install docfx --confirm
2 |
3 | docfx
--------------------------------------------------------------------------------
/docs/docfx.json:
--------------------------------------------------------------------------------
1 | {
2 | "metadata": [
3 | {
4 | "src": [
5 | {
6 | "src": "../",
7 | "files": "src/Community.VisualStudio.Toolkit.16.0/Community.VisualStudio.Toolkit.16.0.csproj"
8 | }
9 | ],
10 | "dest": "api"
11 | }
12 | ],
13 | "build": {
14 | "content": [
15 | {
16 | "files": [
17 | "api/**.yml",
18 | "api/index.md",
19 | "api-vb/**.yml"
20 | ]
21 | },
22 | {
23 | "files": [
24 | "articles/**.md",
25 | "articles/**/toc.yml",
26 | "toc.yml",
27 | "*.md"
28 | ],
29 | "exclude": [
30 | "**/bin/**",
31 | "**/obj/**",
32 | "_site/**"
33 | ]
34 | }
35 | ],
36 | "resource": [
37 | {
38 | "files": [
39 | "images/**"
40 | ],
41 | "exclude": [
42 | "**/bin/**",
43 | "**/obj/**",
44 | "_site/**"
45 | ]
46 | }
47 | ],
48 | "dest": "v1",
49 | "template": [
50 | "default"
51 | ]
52 | }
53 | }
--------------------------------------------------------------------------------
/docs/images/details1_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VsixCommunity/Community.VisualStudio.Toolkit/2a4495f392c607164f5c9ecbb7dc2876f88e869f/docs/images/details1_image.png
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Please follow this link.
8 |
9 |
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | # This is the **HOMEPAGE**.
2 | Refer to [Markdown](http://daringfireball.net/projects/markdown/) for how to write markdown files.
3 | ## Quick Start Notes:
4 | 1. Add images to the *images* folder if the file is referencing an image.
5 |
--------------------------------------------------------------------------------
/docs/toc.yml:
--------------------------------------------------------------------------------
1 | - name: Articles
2 | href: articles/
3 | - name: Api Documentation
4 | href: api/
5 | homepage: api/index.md
6 |
--------------------------------------------------------------------------------
/docs/v1/articles/toc.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/docs/v1/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VsixCommunity/Community.VisualStudio.Toolkit/2a4495f392c607164f5c9ecbb7dc2876f88e869f/docs/v1/favicon.ico
--------------------------------------------------------------------------------
/docs/v1/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VsixCommunity/Community.VisualStudio.Toolkit/2a4495f392c607164f5c9ecbb7dc2876f88e869f/docs/v1/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/docs/v1/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VsixCommunity/Community.VisualStudio.Toolkit/2a4495f392c607164f5c9ecbb7dc2876f88e869f/docs/v1/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/docs/v1/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VsixCommunity/Community.VisualStudio.Toolkit/2a4495f392c607164f5c9ecbb7dc2876f88e869f/docs/v1/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/docs/v1/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VsixCommunity/Community.VisualStudio.Toolkit/2a4495f392c607164f5c9ecbb7dc2876f88e869f/docs/v1/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/docs/v1/images/details1_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VsixCommunity/Community.VisualStudio.Toolkit/2a4495f392c607164f5c9ecbb7dc2876f88e869f/docs/v1/images/details1_image.png
--------------------------------------------------------------------------------
/docs/v1/logo.svg:
--------------------------------------------------------------------------------
1 |
2 |
4 |
26 |
--------------------------------------------------------------------------------
/docs/v1/search-stopwords.json:
--------------------------------------------------------------------------------
1 | [
2 | "a",
3 | "able",
4 | "about",
5 | "across",
6 | "after",
7 | "all",
8 | "almost",
9 | "also",
10 | "am",
11 | "among",
12 | "an",
13 | "and",
14 | "any",
15 | "are",
16 | "as",
17 | "at",
18 | "be",
19 | "because",
20 | "been",
21 | "but",
22 | "by",
23 | "can",
24 | "cannot",
25 | "could",
26 | "dear",
27 | "did",
28 | "do",
29 | "does",
30 | "either",
31 | "else",
32 | "ever",
33 | "every",
34 | "for",
35 | "from",
36 | "get",
37 | "got",
38 | "had",
39 | "has",
40 | "have",
41 | "he",
42 | "her",
43 | "hers",
44 | "him",
45 | "his",
46 | "how",
47 | "however",
48 | "i",
49 | "if",
50 | "in",
51 | "into",
52 | "is",
53 | "it",
54 | "its",
55 | "just",
56 | "least",
57 | "let",
58 | "like",
59 | "likely",
60 | "may",
61 | "me",
62 | "might",
63 | "most",
64 | "must",
65 | "my",
66 | "neither",
67 | "no",
68 | "nor",
69 | "not",
70 | "of",
71 | "off",
72 | "often",
73 | "on",
74 | "only",
75 | "or",
76 | "other",
77 | "our",
78 | "own",
79 | "rather",
80 | "said",
81 | "say",
82 | "says",
83 | "she",
84 | "should",
85 | "since",
86 | "so",
87 | "some",
88 | "than",
89 | "that",
90 | "the",
91 | "their",
92 | "them",
93 | "then",
94 | "there",
95 | "these",
96 | "they",
97 | "this",
98 | "tis",
99 | "to",
100 | "too",
101 | "twas",
102 | "us",
103 | "wants",
104 | "was",
105 | "we",
106 | "were",
107 | "what",
108 | "when",
109 | "where",
110 | "which",
111 | "while",
112 | "who",
113 | "whom",
114 | "why",
115 | "will",
116 | "with",
117 | "would",
118 | "yet",
119 | "you",
120 | "your"
121 | ]
122 |
--------------------------------------------------------------------------------
/docs/v1/styles/main.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VsixCommunity/Community.VisualStudio.Toolkit/2a4495f392c607164f5c9ecbb7dc2876f88e869f/docs/v1/styles/main.css
--------------------------------------------------------------------------------
/docs/v1/styles/main.js:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.
2 |
--------------------------------------------------------------------------------
/docs/v1/styles/search-worker.js:
--------------------------------------------------------------------------------
1 | (function () {
2 | importScripts('lunr.min.js');
3 |
4 | var lunrIndex;
5 |
6 | var stopWords = null;
7 | var searchData = {};
8 |
9 | lunr.tokenizer.separator = /[\s\-\.\(\)]+/;
10 |
11 | var stopWordsRequest = new XMLHttpRequest();
12 | stopWordsRequest.open('GET', '../search-stopwords.json');
13 | stopWordsRequest.onload = function () {
14 | if (this.status != 200) {
15 | return;
16 | }
17 | stopWords = JSON.parse(this.responseText);
18 | buildIndex();
19 | }
20 | stopWordsRequest.send();
21 |
22 | var searchDataRequest = new XMLHttpRequest();
23 |
24 | searchDataRequest.open('GET', '../index.json');
25 | searchDataRequest.onload = function () {
26 | if (this.status != 200) {
27 | return;
28 | }
29 | searchData = JSON.parse(this.responseText);
30 |
31 | buildIndex();
32 |
33 | postMessage({ e: 'index-ready' });
34 | }
35 | searchDataRequest.send();
36 |
37 | onmessage = function (oEvent) {
38 | var q = oEvent.data.q;
39 | var hits = lunrIndex.search(q);
40 | var results = [];
41 | hits.forEach(function (hit) {
42 | var item = searchData[hit.ref];
43 | results.push({ 'href': item.href, 'title': item.title, 'keywords': item.keywords });
44 | });
45 | postMessage({ e: 'query-ready', q: q, d: results });
46 | }
47 |
48 | function buildIndex() {
49 | if (stopWords !== null && !isEmpty(searchData)) {
50 | lunrIndex = lunr(function () {
51 | this.pipeline.remove(lunr.stopWordFilter);
52 | this.ref('href');
53 | this.field('title', { boost: 50 });
54 | this.field('keywords', { boost: 20 });
55 |
56 | for (var prop in searchData) {
57 | if (searchData.hasOwnProperty(prop)) {
58 | this.add(searchData[prop]);
59 | }
60 | }
61 |
62 | var docfxStopWordFilter = lunr.generateStopWordFilter(stopWords);
63 | lunr.Pipeline.registerFunction(docfxStopWordFilter, 'docfxStopWordFilter');
64 | this.pipeline.add(docfxStopWordFilter);
65 | this.searchPipeline.add(docfxStopWordFilter);
66 | });
67 | }
68 | }
69 |
70 | function isEmpty(obj) {
71 | if(!obj) return true;
72 |
73 | for (var prop in obj) {
74 | if (obj.hasOwnProperty(prop))
75 | return false;
76 | }
77 |
78 | return true;
79 | }
80 | })();
81 |
--------------------------------------------------------------------------------
/docs/v1/toc.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | VSIX Community
8 | VSIX Community
9 | © Mads Kristensen. All rights reserved.
10 | https://github.com/VsixCommunity/Community.VisualStudio.Toolkit
11 | $(PackageProjectUrl)
12 | git
13 | true
14 | Icon.png
15 | false
16 | Apache-2.0
17 |
18 | true
19 | $(MSBuildThisFileDirectory)key.snk
20 |
21 | true
22 | snupkg
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/Directory.Build.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
12 | 1
13 | 0
14 | $(MajorVersion).$(MinorVersion)$(VersionSuffix)
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VsixCommunity/Community.VisualStudio.Toolkit/2a4495f392c607164f5c9ecbb7dc2876f88e869f/src/Icon.png
--------------------------------------------------------------------------------
/src/analyzers/Community.VisualStudio.Toolkit.Analyzers/AnalyzerBase.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Immutable;
2 | using Microsoft.CodeAnalysis;
3 | using Microsoft.CodeAnalysis.Diagnostics;
4 |
5 | namespace Community.VisualStudio.Toolkit.Analyzers
6 | {
7 | public abstract class AnalyzerBase : DiagnosticAnalyzer
8 | {
9 | protected static LocalizableString GetLocalizableString(string name)
10 | {
11 | return new LocalizableResourceString(name, Resources.ResourceManager, typeof(Resources));
12 | }
13 |
14 | protected static ImmutableDictionary CreateProperties(string key, string value)
15 | {
16 | ImmutableDictionary.Builder builder = ImmutableDictionary.CreateBuilder();
17 | builder.Add(key, value);
18 | return builder.ToImmutable();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/analyzers/Community.VisualStudio.Toolkit.Analyzers/Analyzers/CVST003UseCorrectTypeInProvideOptionDialogPageAttributeAnalyzer.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Immutable;
2 | using Microsoft.CodeAnalysis;
3 | using Microsoft.CodeAnalysis.Diagnostics;
4 |
5 | namespace Community.VisualStudio.Toolkit.Analyzers
6 | {
7 | [DiagnosticAnalyzer(LanguageNames.CSharp)]
8 | public class CVST003UseCorrectTypeInProvideOptionDialogPageAttributeAnalyzer : IncorrectProvidedTypeAnalyzerBase
9 | {
10 | internal const string DiagnosticId = Diagnostics.UseCorrectTypeInProvideOptionDialogPageAttribute;
11 |
12 | private static readonly DiagnosticDescriptor _rule = new(
13 | DiagnosticId,
14 | GetLocalizableString(nameof(Resources.CVST003_Title)),
15 | GetLocalizableString(nameof(Resources.IncorrectProvidedType_MessageFormat)),
16 | "Usage",
17 | DiagnosticSeverity.Error,
18 | isEnabledByDefault: true);
19 |
20 | public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(_rule);
21 |
22 | protected override string AttributeTypeName => KnownTypeNames.ProvideOptionDialogPageAttribute;
23 |
24 | protected override string ExpectedTypeName => KnownTypeNames.DialogPage;
25 |
26 | protected override DiagnosticDescriptor Descriptor => _rule;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/analyzers/Community.VisualStudio.Toolkit.Analyzers/Analyzers/CVST003UseCorrectTypeInProvideOptionDialogPageAttributeCodeFixProvider.cs:
--------------------------------------------------------------------------------
1 | using System.Composition;
2 | using Microsoft.CodeAnalysis;
3 | using Microsoft.CodeAnalysis.CodeFixes;
4 |
5 | namespace Community.VisualStudio.Toolkit.Analyzers
6 | {
7 | [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(CVST003UseCorrectTypeInProvideOptionDialogPageAttributeCodeFixProvider))]
8 | [Shared]
9 | public class CVST003UseCorrectTypeInProvideOptionDialogPageAttributeCodeFixProvider : IncorrectProvidedTypeCodeFixProviderBase
10 | {
11 | protected override string FixableDiagnosticId => CVST003UseCorrectTypeInProvideOptionDialogPageAttributeAnalyzer.DiagnosticId;
12 |
13 | protected override string ExpectedTypeName => KnownTypeNames.DialogPage;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/analyzers/Community.VisualStudio.Toolkit.Analyzers/Analyzers/CVST004UseCorrectTypeInProvideProfileAttributeAnalyzer.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Immutable;
2 | using Microsoft.CodeAnalysis;
3 | using Microsoft.CodeAnalysis.Diagnostics;
4 |
5 | namespace Community.VisualStudio.Toolkit.Analyzers
6 | {
7 | [DiagnosticAnalyzer(LanguageNames.CSharp)]
8 | public class CVST004UseCorrectTypeInProvideProfileAttributeAnalyzer : IncorrectProvidedTypeAnalyzerBase
9 | {
10 | internal const string DiagnosticId = Diagnostics.UseCorrectTypeInProvideProfileAttribute;
11 |
12 | private static readonly DiagnosticDescriptor _rule = new(
13 | DiagnosticId,
14 | GetLocalizableString(nameof(Resources.CVST004_Title)),
15 | GetLocalizableString(nameof(Resources.IncorrectProvidedType_MessageFormat)),
16 | "Usage",
17 | DiagnosticSeverity.Error,
18 | isEnabledByDefault: true);
19 |
20 | public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(_rule);
21 |
22 | protected override string AttributeTypeName => KnownTypeNames.ProvideProfileAttribute;
23 |
24 | protected override string ExpectedTypeName => KnownTypeNames.IProfileManager;
25 |
26 | protected override DiagnosticDescriptor Descriptor => _rule;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/analyzers/Community.VisualStudio.Toolkit.Analyzers/Analyzers/CVST004UseCorrectTypeInProvideProfileAttributeCodeFixProvider.cs:
--------------------------------------------------------------------------------
1 | using System.Composition;
2 | using Microsoft.CodeAnalysis;
3 | using Microsoft.CodeAnalysis.CodeFixes;
4 |
5 | namespace Community.VisualStudio.Toolkit.Analyzers
6 | {
7 | [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(CVST004UseCorrectTypeInProvideProfileAttributeCodeFixProvider))]
8 | [Shared]
9 | public class CVST004UseCorrectTypeInProvideProfileAttributeCodeFixProvider : IncorrectProvidedTypeCodeFixProviderBase
10 | {
11 | protected override string FixableDiagnosticId => CVST004UseCorrectTypeInProvideProfileAttributeAnalyzer.DiagnosticId;
12 |
13 | protected override string ExpectedTypeName => KnownTypeNames.IProfileManager;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/analyzers/Community.VisualStudio.Toolkit.Analyzers/Analyzers/CVST006SpecifyFontAndColorProviderGuidAnalyzer.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 | using Microsoft.CodeAnalysis.Diagnostics;
3 |
4 | namespace Community.VisualStudio.Toolkit.Analyzers
5 | {
6 | ///
7 | /// Detects font and color providers without an explicit GUID.
8 | ///
9 | [DiagnosticAnalyzer(LanguageNames.CSharp)]
10 | public class CVST006SpecifyFontAndColorProviderGuidAnalyzer : MissingGuidAttributeAnalyzerBase
11 | {
12 | internal const string DiagnosticId = Diagnostics.DefineExplicitGuidForFontAndColorProviders;
13 |
14 | private static readonly DiagnosticDescriptor _rule = new(
15 | DiagnosticId,
16 | GetLocalizableString(nameof(Resources.CVST006_Title)),
17 | GetLocalizableString(nameof(Resources.CVST006_MessageFormat)),
18 | "Usage",
19 | DiagnosticSeverity.Warning,
20 | isEnabledByDefault: true,
21 | description: GetLocalizableString(nameof(Resources.CVST006_Description)));
22 |
23 | protected override DiagnosticDescriptor Descriptor => _rule;
24 |
25 | protected override string BaseTypeName => KnownTypeNames.BaseFontAndColorProvider;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/analyzers/Community.VisualStudio.Toolkit.Analyzers/Analyzers/CVST006SpecifyFontAndColorProviderGuidCodeFixProvider.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Immutable;
2 | using System.Composition;
3 | using Community.VisualStudio.Toolkit.Analyzers.Analyzers;
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.CodeFixes;
6 |
7 | namespace Community.VisualStudio.Toolkit.Analyzers
8 | {
9 | [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(CVST006SpecifyFontAndColorProviderGuidCodeFixProvider))]
10 | [Shared]
11 | public class CVST006SpecifyFontAndColorProviderGuidCodeFixProvider : MissingGuidAttributeCodeFixProviderBase
12 | {
13 | public sealed override ImmutableArray FixableDiagnosticIds { get; } = ImmutableArray.Create(CVST006SpecifyFontAndColorProviderGuidAnalyzer.DiagnosticId);
14 |
15 | protected override string Title => Resources.CVST006_CodeFix;
16 |
17 | protected override string EquivalenceKey => nameof(Resources.CVST006_CodeFix);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/analyzers/Community.VisualStudio.Toolkit.Analyzers/Analyzers/CVST007SpecifyFontAndColorCategoryGuidAnalyzer.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CodeAnalysis;
2 | using Microsoft.CodeAnalysis.Diagnostics;
3 |
4 | namespace Community.VisualStudio.Toolkit.Analyzers
5 | {
6 | ///
7 | /// Detects font and color categories without an explicit GUID.
8 | ///
9 | [DiagnosticAnalyzer(LanguageNames.CSharp)]
10 | public class CVST007SpecifyFontAndColorCategoryGuidAnalyzer : MissingGuidAttributeAnalyzerBase
11 | {
12 | internal const string DiagnosticId = Diagnostics.DefineExplicitGuidForFontAndColorCategories;
13 |
14 | private static readonly DiagnosticDescriptor _rule = new(
15 | DiagnosticId,
16 | GetLocalizableString(nameof(Resources.CVST007_Title)),
17 | GetLocalizableString(nameof(Resources.CVST007_MessageFormat)),
18 | "Usage",
19 | DiagnosticSeverity.Warning,
20 | isEnabledByDefault: true,
21 | description: GetLocalizableString(nameof(Resources.CVST007_Description)));
22 |
23 | protected override DiagnosticDescriptor Descriptor => _rule;
24 |
25 | protected override string BaseTypeName => KnownTypeNames.BaseFontAndColorCategory;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/analyzers/Community.VisualStudio.Toolkit.Analyzers/Analyzers/CVST007SpecifyFontAndColorCategoryGuidCodeFixProvider.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Immutable;
2 | using System.Composition;
3 | using Community.VisualStudio.Toolkit.Analyzers.Analyzers;
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.CodeFixes;
6 |
7 | namespace Community.VisualStudio.Toolkit.Analyzers
8 | {
9 | [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(CVST007SpecifyFontAndColorCategoryGuidCodeFixProvider))]
10 | [Shared]
11 | public class CVST007SpecifyFontAndColorCategoryGuidCodeFixProvider : MissingGuidAttributeCodeFixProviderBase
12 | {
13 | public sealed override ImmutableArray FixableDiagnosticIds { get; } = ImmutableArray.Create(CVST007SpecifyFontAndColorCategoryGuidAnalyzer.DiagnosticId);
14 |
15 | protected override string Title => Resources.CVST007_CodeFix;
16 |
17 | protected override string EquivalenceKey => nameof(Resources.CVST007_CodeFix);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/analyzers/Community.VisualStudio.Toolkit.Analyzers/Analyzers/MissingGuidAttributeCodeFixProviderBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Threading;
4 | using System.Threading.Tasks;
5 | using Microsoft.CodeAnalysis;
6 | using Microsoft.CodeAnalysis.CodeActions;
7 | using Microsoft.CodeAnalysis.CodeFixes;
8 | using Microsoft.CodeAnalysis.CSharp.Syntax;
9 | using Microsoft.CodeAnalysis.Editing;
10 | using Microsoft.CodeAnalysis.Simplification;
11 | using Microsoft.CodeAnalysis.Text;
12 |
13 | namespace Community.VisualStudio.Toolkit.Analyzers.Analyzers
14 | {
15 | public abstract class MissingGuidAttributeCodeFixProviderBase : CodeFixProviderBase
16 | {
17 | protected abstract string Title { get; }
18 |
19 | protected abstract string EquivalenceKey { get; }
20 |
21 | public sealed override FixAllProvider GetFixAllProvider() => WellKnownFixAllProviders.BatchFixer;
22 |
23 | public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
24 | {
25 | SyntaxNode root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
26 |
27 | Diagnostic diagnostic = context.Diagnostics.First();
28 | TextSpan span = diagnostic.Location.SourceSpan;
29 | SyntaxNode node = root.FindToken(span.Start).Parent;
30 |
31 | if (node is ClassDeclarationSyntax declaration)
32 | {
33 | context.RegisterCodeFix(
34 | CodeAction.Create(
35 | Title,
36 | cancellation => AddGuidAttributeAsync(context.Document, declaration, cancellation),
37 | equivalenceKey: EquivalenceKey
38 | ),
39 | diagnostic
40 | );
41 | }
42 | }
43 |
44 | private async Task AddGuidAttributeAsync(Document document, ClassDeclarationSyntax declaration, CancellationToken cancellationToken)
45 | {
46 | SyntaxNode root = await document.GetSyntaxRootAsync(cancellationToken);
47 | SyntaxEditor editor = new(root, document.Project.Solution.Workspace);
48 | SyntaxGenerator generator = editor.Generator;
49 |
50 | editor.AddAttribute(
51 | declaration,
52 | generator.Attribute(
53 | "System.Runtime.InteropServices.GuidAttribute",
54 | generator.LiteralExpression(Guid.NewGuid().ToString())
55 | ).WithAdditionalAnnotations(Simplifier.Annotation)
56 | );
57 |
58 | return document.WithSyntaxRoot(editor.GetChangedRoot());
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/analyzers/Community.VisualStudio.Toolkit.Analyzers/Community.VisualStudio.Toolkit.Analyzers.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard1.3
5 | Community.VisualStudio.Toolkit.Analyzers
6 | 1
7 |
8 |
9 |
10 | Community.VisualStudio.Toolkit.Analyzers
11 | Code analyzers for the Community.VisualStudio.Toolkit package.
12 | VisualStudio, VSSDK, SDK, analyzers
13 | true
14 | true
15 | false
16 | false
17 | true
18 |
19 | $(TargetsForTfmSpecificContentInPackage);_AddAnalyzersToOutput
20 |
21 |
22 |
23 |
24 | all
25 | runtime; build; native; contentfiles; analyzers; buildtransitive
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/src/analyzers/Community.VisualStudio.Toolkit.Analyzers/Diagnostics.cs:
--------------------------------------------------------------------------------
1 | namespace Community.VisualStudio.Toolkit.Analyzers
2 | {
3 | public static class Diagnostics
4 | {
5 | public const string CastInteropTypes = "CVST001";
6 | public const string DialogPageShouldBeComVisible = "CVST002";
7 | public const string UseCorrectTypeInProvideOptionDialogPageAttribute = "CVST003";
8 | public const string UseCorrectTypeInProvideProfileAttribute = "CVST004";
9 | public const string InitializeCommands = "CVST005";
10 | public const string DefineExplicitGuidForFontAndColorProviders = "CVST006";
11 | public const string DefineExplicitGuidForFontAndColorCategories = "CVST007";
12 | public const string DefineProviderForFontAndColorCategories = "CVST008";
13 | public const string ProvideFontsAndColors = "CVST009";
14 | public const string RegisterFontsAndColors = "CVST010";
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/analyzers/Community.VisualStudio.Toolkit.Analyzers/KnownTypeNames.cs:
--------------------------------------------------------------------------------
1 | namespace Community.VisualStudio.Toolkit.Analyzers
2 | {
3 | internal static class KnownTypeNames
4 | {
5 | public const string AsyncPackage = "Microsoft.VisualStudio.Shell.AsyncPackage";
6 | public const string BaseCommand = "Community.VisualStudio.Toolkit.BaseCommand`1";
7 | public const string BaseFontAndColorCategory = "Community.VisualStudio.Toolkit.BaseFontAndColorCategory";
8 | public const string BaseFontAndColorProvider = "Community.VisualStudio.Toolkit.BaseFontAndColorProvider";
9 | public const string ComVisibleAttribute = "System.Runtime.InteropServices.ComVisibleAttribute";
10 | public const string DialogPage = "Microsoft.VisualStudio.Shell.DialogPage";
11 | public const string GuidAttribute = "System.Runtime.InteropServices.GuidAttribute";
12 | public const string IProfileManager = "Microsoft.VisualStudio.Shell.IProfileManager";
13 | public const string ProvideFontsAndColorsAttribute = "Community.VisualStudio.Toolkit.ProvideFontsAndColorsAttribute";
14 | public const string ProvideOptionDialogPageAttribute = "Microsoft.VisualStudio.Shell.ProvideOptionDialogPageAttribute";
15 | public const string ProvideProfileAttribute = "Microsoft.VisualStudio.Shell.ProvideProfileAttribute";
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VsixCommunity/Community.VisualStudio.Toolkit/2a4495f392c607164f5c9ecbb7dc2876f88e869f/src/key.snk
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.14.0/Community.VisualStudio.Toolkit.14.0.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net46
5 | 14
6 | Community.VisualStudio.Toolkit.$(MajorVersion)
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.15.0/Community.VisualStudio.Toolkit.15.0.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net46
5 | 15
6 | Community.VisualStudio.Toolkit.$(MajorVersion)
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.16.0/Community.VisualStudio.Toolkit.16.0.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net472
5 | 16
6 | Community.VisualStudio.Toolkit.$(MajorVersion)
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.17.0/Community.VisualStudio.Toolkit.17.0.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net48
5 | 17
6 | Community.VisualStudio.Toolkit.$(MajorVersion)
7 | NU1603
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/Attributes/ProvideBraceCompletionAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using Microsoft.VisualStudio.Shell;
4 |
5 | namespace Community.VisualStudio.Toolkit
6 | {
7 | ///
8 | /// Adds support for brace completion to the specified language.
9 | ///
10 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
11 | public class ProvideBraceCompletionAttribute : RegistrationAttribute
12 | {
13 | private readonly string _languageName;
14 |
15 | ///
16 | /// Creates a new instance.
17 | ///
18 | /// The language name to add brace completion to.
19 | public ProvideBraceCompletionAttribute(string languageName)
20 | {
21 | _languageName = languageName;
22 | }
23 |
24 | ///
25 | public override void Register(RegistrationContext context)
26 | {
27 | string keyName = string.Format(CultureInfo.InvariantCulture, "{0}\\{1}\\{2}", "Languages", "Language Services", _languageName);
28 | using (Key langKey = context.CreateKey(keyName))
29 | {
30 | langKey.SetValue("ShowBraceCompletion", 1);
31 | }
32 | }
33 |
34 | ///
35 | public override void Unregister(RegistrationContext context)
36 | {
37 | string keyName = string.Format(CultureInfo.InvariantCulture, "{0}\\{1}\\{2}", "Languages", "Language Services", _languageName);
38 | context.RemoveKey(keyName);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/Attributes/ProvideFileIconAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.Shell;
3 |
4 | namespace Community.VisualStudio.Toolkit
5 | {
6 | ///
7 | /// Associates an ImageMoniker icon to a file extension in Solution Explorer
8 | ///
9 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
10 | public class ProvideFileIconAttribute : RegistrationAttribute
11 | {
12 | ///
13 | /// Associates an icon with a file extension.
14 | ///
15 | /// Any file extension. Must start with a dot.
16 | /// Could be "KnownMonikers.Save" or "guid:id".
17 | public ProvideFileIconAttribute(string fileExtension, string monikerName)
18 | {
19 | FileExtension = fileExtension;
20 | MonikerName = monikerName;
21 | }
22 |
23 | ///
24 | /// The file extension that's the target of the icon.
25 | ///
26 | public string FileExtension { get; }
27 |
28 | ///
29 | /// The ImageMoniker identifier. It's either a KnownMonker or a guid:id pair.
30 | ///
31 | public string MonikerName { get; }
32 |
33 | ///
34 | public override void Register(RegistrationContext context)
35 | {
36 | using (Key langKey = context.CreateKey($@"ShellFileAssociations\{FileExtension}"))
37 | {
38 | langKey.SetValue("DefaultIconMoniker", MonikerName);
39 | }
40 | }
41 |
42 | ///
43 | public override void Unregister(RegistrationContext context)
44 | {
45 | context.RemoveKey($@"ShellFileAssociations\{FileExtension}");
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/Attributes/ProvideFontsAndColorsAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.Shell;
3 |
4 | namespace Community.VisualStudio.Toolkit
5 | {
6 | ///
7 | /// Registers font and color definitions in Visual Studio.
8 | ///
9 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
10 | public class ProvideFontsAndColorsAttribute : ProvideServiceAttributeBase
11 | {
12 | ///
13 | /// Initializes a new instance of the class.
14 | /// The will also be provided as a service.
15 | ///
16 | /// The type of the implementation to provide.
17 | public ProvideFontsAndColorsAttribute(Type providerType)
18 | : base(providerType, "Services")
19 | {
20 | ProviderType = providerType;
21 | }
22 |
23 | ///
24 | /// The implementation to provide.
25 | ///
26 | public Type ProviderType { get; }
27 |
28 | ///
29 | public override void Register(RegistrationContext context)
30 | {
31 | if (context is not null)
32 | {
33 | foreach (Type categoryType in BaseFontAndColorProvider.GetCategoryTypes(ProviderType))
34 | {
35 | using (Key key = context.CreateKey($"FontAndColors\\{categoryType.FullName}"))
36 | {
37 | key.SetValue("Category", categoryType.GUID.ToString("B"));
38 | key.SetValue("Package", ProviderType.GUID.ToString("B"));
39 | }
40 | }
41 | }
42 |
43 | base.Register(context);
44 | }
45 |
46 | ///
47 | public override void Unregister(RegistrationContext context)
48 | {
49 | if (context is not null)
50 | {
51 | foreach (Type categoryType in BaseFontAndColorProvider.GetCategoryTypes(ProviderType))
52 | {
53 | context.RemoveKey($"FontAndColors\\{categoryType.FullName}");
54 | }
55 | }
56 |
57 | base.Unregister(context);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/Attributes/ProvideGalleryFeedAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.Shell;
3 |
4 | namespace Community.VisualStudio.Toolkit
5 | {
6 | ///
7 | /// Registers a feed gallery to the extensions manager
8 | ///
9 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
10 | public class ProvideGalleryFeedAttribute : RegistrationAttribute
11 | {
12 | ///
13 | /// Registers a feed gallery
14 | ///
15 | /// A unique guid to use for registering the feed.
16 | /// The name of the feed as it shows up in the Extension Manager dialog.
17 | /// The absolute URL to the atom feed.
18 | public ProvideGalleryFeedAttribute(string guid, string name, string url)
19 | {
20 | Guid = guid;
21 | Name = name;
22 | Url = url;
23 | }
24 |
25 | ///
26 | /// A unique guid to use for registering the feed.
27 | ///
28 | public string Guid { get; }
29 |
30 | ///
31 | /// The name of the feed as it shows up in the Extension Manager dialog.
32 | ///
33 | public string Name { get; }
34 |
35 | ///
36 | /// The absolute URL to the atom feed.
37 | ///
38 | public string Url { get; }
39 |
40 | ///
41 | public override void Register(RegistrationContext context)
42 | {
43 | using (Key langKey = context.CreateKey($@"ExtensionManager\Repositories\{{{Guid}}}"))
44 | {
45 | langKey.SetValue("", Url);
46 | langKey.SetValue("Priority", 100);
47 | langKey.SetValue("Protocol", "Atom Feed");
48 | langKey.SetValue("DisplayName", Name);
49 | }
50 | }
51 |
52 | ///
53 | public override void Unregister(RegistrationContext context)
54 | {
55 | context.RemoveKey($@"ExtensionManager\Repositories\{Guid}");
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/CodeAnalysis/MemberNotNullAttribute.cs:
--------------------------------------------------------------------------------
1 | namespace System.Diagnostics.CodeAnalysis
2 | {
3 | ///
4 | /// This is a copy of the attribute of the same name from .NET 5+ to allow it to be used in .NET Framework.
5 | /// https://github.com/dotnet/runtime/blob/47071da67320985a10f4b70f50f894ab411f4994/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/NullableAttributes.cs#L137
6 | ///
7 | internal class MemberNotNullAttribute : Attribute
8 | {
9 | public MemberNotNullAttribute(string member) => Members = new[] { member };
10 | public MemberNotNullAttribute(params string[] members) => Members = members;
11 | public string[] Members { get; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/Commands/CommandAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Community.VisualStudio.Toolkit
4 | {
5 | ///
6 | /// Attribute for specifying command GUIDs and IDs.
7 | ///
8 | [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
9 | public class CommandAttribute : Attribute
10 | {
11 | ///
12 | /// Registers the command for handling the command ID and assumes the package GUID is used as command GUID.
13 | ///
14 | public CommandAttribute(int commandId)
15 | : this("00000000-0000-0000-0000-000000000000", commandId) { }
16 |
17 | ///
18 | /// Registers the command for handling the command with the specified GUID and ID.
19 | ///
20 | public CommandAttribute(string commandGuid, int commandId)
21 | {
22 | Guid = new Guid(commandGuid);
23 | Id = commandId;
24 | }
25 |
26 | ///
27 | /// The GUID of the command, often referred to as the Command Set Guid.
28 | ///
29 | public Guid Guid { get; set; }
30 |
31 | ///
32 | /// The ID of the command, often expressed in hex.
33 | ///
34 | public int Id { get; set; }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/Commands/DynamicItemMenuCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.Design;
3 | using Microsoft.VisualStudio.Shell;
4 |
5 | namespace Community.VisualStudio.Toolkit
6 | {
7 | internal class DynamicItemMenuCommand : OleMenuCommand
8 | {
9 | private readonly Func _isMatch;
10 |
11 | public DynamicItemMenuCommand(Func isMatch, EventHandler invoke, EventHandler beforeQueryStatus, CommandID id) : base(invoke, changeHandler: null, beforeQueryStatus, id)
12 | {
13 | _isMatch = isMatch;
14 | }
15 |
16 | public override bool DynamicItemMatch(int cmdId)
17 | {
18 | if (_isMatch(cmdId))
19 | {
20 | MatchedCommandId = cmdId;
21 | return true;
22 | }
23 |
24 | MatchedCommandId = 0;
25 | return false;
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/Community.VisualStudio.Toolkit.Shared.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 5ec463ac-24cb-443e-9ff9-91b7ecb1f822
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/Debugger/Debugger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Microsoft.VisualStudio.Shell;
4 | using Microsoft.VisualStudio.Shell.Interop;
5 |
6 | namespace Community.VisualStudio.Toolkit
7 | {
8 | ///
9 | /// Handles debugging.
10 | ///
11 | public class Debugger
12 | {
13 | ///
14 | /// The mode of the debugger.
15 | ///
16 | public enum DebugMode
17 | {
18 | /// The debugger is not attached.
19 | NotDebugging,
20 | /// The debugger is stopped at a breakpoint.
21 | AtBreakpoint,
22 | /// The debugger is attached and running.
23 | Running
24 | }
25 |
26 | ///
27 | /// Checks if the debugger is attached.
28 | ///
29 | public async Task IsDebuggingAsync()
30 | {
31 | DebugMode debugMode = await GetDebugModeAsync();
32 | return debugMode != DebugMode.NotDebugging;
33 | }
34 |
35 | ///
36 | /// Returns the current mode for the debugger.
37 | ///
38 | public async Task GetDebugModeAsync()
39 | {
40 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
41 |
42 | DBGMODE dbgMode = VsShellUtilities.GetDebugMode(ServiceProvider.GlobalProvider) & ~DBGMODE.DBGMODE_EncMask;
43 |
44 | return dbgMode switch
45 | {
46 | DBGMODE.DBGMODE_Design => DebugMode.NotDebugging,
47 | DBGMODE.DBGMODE_Break => DebugMode.AtBreakpoint,
48 | DBGMODE.DBGMODE_Run => DebugMode.Running,
49 | _ => throw new InvalidOperationException($"Unexpected {nameof(DebugMode)}")
50 | };
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/Debugger/DebuggerEvents.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio;
3 | using Microsoft.VisualStudio.Shell;
4 | using Microsoft.VisualStudio.Shell.Interop;
5 |
6 | namespace Community.VisualStudio.Toolkit
7 | {
8 | public partial class Events
9 | {
10 | private DebuggerEvents? _debuggerEvents;
11 |
12 | ///
13 | /// Events related to the debugger in Visual Studio.
14 | ///
15 | public DebuggerEvents DebuggerEvents => _debuggerEvents ??= new();
16 | }
17 |
18 | ///
19 | /// Events related to the debugger in Visual Studio.
20 | ///
21 | public class DebuggerEvents : IVsDebuggerEvents
22 | {
23 | internal DebuggerEvents()
24 | {
25 | ThreadHelper.ThrowIfNotOnUIThread();
26 | IVsDebugger svc = VS.GetRequiredService();
27 | svc.AdviseDebuggerEvents(this, out _);
28 | }
29 |
30 | ///
31 | /// Fires when entering break mode.
32 | ///
33 | public event Action? EnterBreakMode;
34 |
35 | ///
36 | /// Fired when the debugger enters run mode.
37 | ///
38 | public event Action? EnterRunMode;
39 |
40 | ///
41 | /// Fired when leaving run mode or debug mode, and when the debugger establishes design mode after debugging.
42 | ///
43 | public event Action? EnterDesignMode;
44 |
45 | ///
46 | /// Fires when entering Edit & Continue mode.
47 | ///
48 | public event Action? EnterEditAndContinueMode;
49 |
50 | int IVsDebuggerEvents.OnModeChange(DBGMODE dbgmodeNew)
51 | {
52 | switch (dbgmodeNew)
53 | {
54 | case DBGMODE.DBGMODE_Design:
55 | EnterDesignMode?.Invoke();
56 | break;
57 | case DBGMODE.DBGMODE_Break:
58 | EnterBreakMode?.Invoke();
59 | break;
60 | case DBGMODE.DBGMODE_Run:
61 | EnterRunMode?.Invoke();
62 | break;
63 | case DBGMODE.DBGMODE_Enc:
64 | EnterEditAndContinueMode?.Invoke();
65 | break;
66 | }
67 |
68 | return VSConstants.S_OK;
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/Documents/DocumentView.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.Shell;
2 | using Microsoft.VisualStudio.Shell.Interop;
3 | using Microsoft.VisualStudio.Text;
4 | using Microsoft.VisualStudio.Text.Editor;
5 | using Microsoft.VisualStudio.TextManager.Interop;
6 |
7 | namespace Community.VisualStudio.Toolkit
8 | {
9 | ///
10 | /// Represents an open text document view.
11 | ///
12 | public class DocumentView
13 | {
14 | internal DocumentView(WindowFrame? frame, IWpfTextView? view)
15 | {
16 | WindowFrame = frame;
17 | TextView = view;
18 | Document = TextBuffer?.GetTextDocument();
19 | FilePath = Document?.FilePath;
20 | }
21 |
22 | internal DocumentView(IVsWindowFrame nativeFrame)
23 | {
24 | ThreadHelper.ThrowIfNotOnUIThread();
25 | WindowFrame frame = new(nativeFrame);
26 | IWpfTextView? view = VsShellUtilities.GetTextView(nativeFrame)?.ToIWpfTextView();
27 |
28 | WindowFrame = frame;
29 | TextView = view;
30 | Document = TextBuffer?.GetTextDocument();
31 | nativeFrame.GetProperty((int)__VSFPROPID.VSFPROPID_pszMkDocument, out object pvar);
32 |
33 | if (pvar is string filePath)
34 | {
35 | FilePath = filePath;
36 | }
37 | }
38 |
39 | ///
40 | /// The window frame hosting the document.
41 | ///
42 | public WindowFrame? WindowFrame { get; }
43 |
44 | ///
45 | /// The text view loaded in the window frame.
46 | ///
47 | public IWpfTextView? TextView { get; }
48 |
49 | ///
50 | /// The text document loaded in the view.
51 | ///
52 | public ITextDocument? Document { get; }
53 |
54 | ///
55 | /// The text buffer loaded in the view.
56 | ///
57 | public ITextBuffer? TextBuffer => TextView?.TextBuffer;
58 |
59 | ///
60 | /// The absolute file path of the document.
61 | ///
62 | public string? FilePath { get; }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/ErrorList/SinkManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Microsoft.VisualStudio.Shell.TableManager;
5 |
6 | namespace Community.VisualStudio.Toolkit
7 | {
8 | ///
9 | /// ITableDataSink wrapper which manages and notifies of error snapshots
10 | ///
11 | internal class SinkManager : IDisposable
12 | {
13 | private bool _isDisposed;
14 |
15 | ///
16 | /// Underlying sink
17 | ///
18 | private readonly ITableDataSink _sink;
19 |
20 | ///
21 | /// Dispose action
22 | ///
23 | private readonly Action _onDispose;
24 |
25 | ///
26 | /// Snapshot collection
27 | ///
28 | private readonly List _snapshots = new();
29 |
30 | ///
31 | /// Constructor
32 | ///
33 | /// Sink to be wrapped
34 | /// Dispose action to be done on token disposal
35 | public SinkManager(ITableDataSink sink, Action onDispose)
36 | {
37 | _sink = sink;
38 | _onDispose = onDispose;
39 | }
40 |
41 | ///
42 | /// Notifies the underlying sink of the new errors
43 | ///
44 | ///
45 | public void UpdateSink(IEnumerable snapshots)
46 | {
47 | foreach (TableEntriesSnapshot snapshot in snapshots)
48 | {
49 | TableEntriesSnapshot existing = _snapshots.FirstOrDefault(s => s.FilePath == snapshot.FilePath);
50 |
51 | if (existing != null)
52 | {
53 | _snapshots.Remove(existing);
54 | _sink.ReplaceSnapshot(existing, snapshot);
55 | }
56 | else
57 | {
58 | _sink.AddSnapshot(snapshot);
59 | }
60 |
61 | _snapshots.Add(snapshot);
62 | }
63 | }
64 |
65 | ///
66 | /// Removes all registered errors
67 | ///
68 | public void Clear()
69 | {
70 | _sink.RemoveAllSnapshots();
71 | _snapshots.Clear();
72 | }
73 |
74 | protected virtual void Dispose(bool disposing)
75 | {
76 | if (!_isDisposed)
77 | {
78 | if (disposing)
79 | {
80 | _onDispose?.Invoke(this);
81 | }
82 |
83 | _isDisposed = true;
84 | }
85 | }
86 |
87 | public void Dispose()
88 | {
89 | Dispose(true);
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/ExtensionMethods/ITextBufferExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Community.VisualStudio.Toolkit;
4 | using Microsoft.VisualStudio.Shell;
5 | using Microsoft.VisualStudio.Shell.Interop;
6 | using Microsoft.VisualStudio.Text.Operations;
7 | using Microsoft.VisualStudio.TextManager.Interop;
8 |
9 | namespace Microsoft.VisualStudio.Text
10 | {
11 | ///
12 | /// Extension methods for the ITextBuffer interface.
13 | ///
14 | public static class ITextBufferExtensions
15 | {
16 | ///
17 | /// Opens an undo context with the specified name. Remember to call Complete() and Dispose() to commit the transaction.
18 | ///
19 | public static async Task OpenUndoContextAsync(this ITextBuffer buffer, string name)
20 | {
21 | ITextUndoHistoryRegistry? registry = await VS.GetMefServiceAsync();
22 | return registry.GetHistory(buffer).CreateTransaction(name);
23 | }
24 |
25 | ///
26 | /// Gets the text document.
27 | ///
28 | public static ITextDocument? GetTextDocument(this ITextBuffer buffer)
29 | {
30 | if (buffer.Properties.TryGetProperty(typeof(ITextDocument), out ITextDocument? document))
31 | {
32 | return document;
33 | }
34 |
35 | return null;
36 | }
37 |
38 | ///
39 | /// Gets the file name on disk associated with the buffer.
40 | ///
41 | public static string? GetFileName(this ITextBuffer buffer)
42 | {
43 | ThreadHelper.ThrowIfNotOnUIThread();
44 |
45 | if (!buffer.Properties.TryGetProperty(typeof(IVsTextBuffer), out IVsTextBuffer bufferAdapter))
46 | {
47 | return null;
48 | }
49 |
50 | string? ppzsFilename = null;
51 | int returnCode = -1;
52 |
53 | if (bufferAdapter is IPersistFileFormat persistFileFormat)
54 | {
55 | try
56 | {
57 | returnCode = persistFileFormat.GetCurFile(out ppzsFilename, out uint pnFormatIndex);
58 | }
59 | catch (NotImplementedException)
60 | {
61 | return null;
62 | }
63 | }
64 |
65 | if (returnCode != VSConstants.S_OK)
66 | {
67 | return null;
68 | }
69 |
70 | return ppzsFilename;
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/ExtensionMethods/ITextViewExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Community.VisualStudio.Toolkit;
3 | using Microsoft.VisualStudio.Shell;
4 | using Microsoft.VisualStudio.Text.Editor;
5 |
6 | namespace Microsoft.VisualStudio.Text
7 | {
8 | ///
9 | /// Extension methods for .
10 | ///
11 | public static class ITextViewExtensions
12 | {
13 | ///
14 | /// Creates an instance of an in the text view.
15 | ///
16 | public static async Task CreateInfoBarAsync(this ITextView textView, InfoBarModel model)
17 | {
18 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
19 |
20 | string? fileName = textView.TextBuffer.GetFileName();
21 |
22 | if (!string.IsNullOrEmpty(fileName))
23 | {
24 | return await VS.InfoBar.CreateAsync(fileName!, model);
25 | }
26 |
27 | return null;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/ExtensionMethods/IVsShareAssetsProjectExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Microsoft.VisualStudio.Shell.Interop
4 | {
5 | ///
6 | /// Extension methods for the interface.
7 | ///
8 | public static class IVsSharedAssetsProjectExtensions
9 | {
10 | ///
11 | /// Returns a collection of hierarchies that refernce the shared project
12 | ///
13 | ///
14 | ///
15 | public static IEnumerable GetReferencingHierarchies(this IVsSharedAssetsProject sharedAssetsProject)
16 | {
17 | ThreadHelper.ThrowIfNotOnUIThread();
18 |
19 | foreach (IVsHierarchy importingProject in sharedAssetsProject.EnumImportingProjects())
20 | {
21 | yield return importingProject;
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/ExtensionMethods/IVsTextViewExtensions.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VsixCommunity/Community.VisualStudio.Toolkit/2a4495f392c607164f5c9ecbb7dc2876f88e869f/src/toolkit/Community.VisualStudio.Toolkit.Shared/ExtensionMethods/IVsTextViewExtensions.cs
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/ExtensionMethods/ToolkitPackageExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using Microsoft.VisualStudio.Shell;
6 |
7 | namespace Community.VisualStudio.Toolkit
8 | {
9 | ///
10 | /// Extensions for an
11 | ///
12 | public static class ToolkitPackageExtensions
13 | {
14 | ///
15 | /// Automatically calls the
16 | /// method for every in the package or provided assemblies.
17 | ///
18 | /// The package that contains the tool windows to register.
19 | /// The additional assemblies to look for tool windows in.
20 | public static void RegisterToolWindows(this ToolkitPackage package, params Assembly[] assemblies)
21 | {
22 | List assembliesList = assemblies.ToList();
23 | Assembly packageAssembly = package.GetType().Assembly;
24 | if (!assembliesList.Contains(packageAssembly))
25 | assembliesList.Add(packageAssembly);
26 |
27 | Type baseToolWindowType = typeof(BaseToolWindow<>);
28 | IEnumerable toolWindowTypes = assembliesList.SelectMany(x => x.GetTypes())
29 | .Where(x =>
30 | !x.IsAbstract
31 | && x.IsAssignableToGenericType(baseToolWindowType));
32 |
33 | foreach (Type? toolWindowtype in toolWindowTypes)
34 | {
35 | MethodInfo initializeMethod = toolWindowtype.GetMethod(
36 | "Initialize",
37 | BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy);
38 |
39 | initializeMethod.Invoke(null, new object[] { package });
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/ExtensionMethods/TypeExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 |
3 | namespace System
4 | {
5 | ///
6 | /// Extensions for
7 | ///
8 | public static class TypeExtensions
9 | {
10 | ///
11 | /// Determines if a type is assignable (inherits) from the specified generic type.
12 | ///
13 | ///
14 | ///
15 | ///
16 | public static bool IsAssignableToGenericType(this Type type, Type genericType)
17 | {
18 | return type.FindGenericBaseType(genericType) != null;
19 | }
20 |
21 | ///
22 | /// Attempts to find the specified generic type in the inheritance hierarchy for the specified type.
23 | ///
24 | ///
25 | ///
26 | /// The generic type if present, otherwise null.
27 | public static Type? FindGenericBaseType(this Type type, Type genericType)
28 | {
29 | if (type == null || genericType == null)
30 | {
31 | return null;
32 | }
33 |
34 | if (type == genericType)
35 | {
36 | return type;
37 | }
38 |
39 | // See if any of the base types implement the type
40 | while (type != null && type != typeof(object))
41 | {
42 | Type? currentType = type.IsGenericType ? type.GetGenericTypeDefinition() : type;
43 | if (genericType == currentType)
44 | {
45 | return currentType;
46 | }
47 |
48 | // See if any of the interfaces implement the type
49 | Type? interfaceType = type.GetInterfaces()
50 | .FirstOrDefault(t => t.IsGenericType && t.GetGenericTypeDefinition() == genericType);
51 |
52 | if (interfaceType != null)
53 | {
54 | return interfaceType;
55 | }
56 |
57 | type = type.BaseType;
58 | }
59 | return null;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/ExtensionMethods/WindowExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Community.VisualStudio.Toolkit;
3 | using Microsoft.Internal.VisualStudio.PlatformUI;
4 | using Microsoft.VisualStudio;
5 | using Microsoft.VisualStudio.Shell;
6 | using Microsoft.VisualStudio.Shell.Interop;
7 |
8 | namespace System.Windows
9 | {
10 | /// Extension methods for the class.
11 | public static class WindowExtensions
12 | {
13 | /// Shows a window as a dialog.
14 | public static async Task ShowDialogAsync(this Window window, WindowStartupLocation windowStartupLocation = WindowStartupLocation.CenterOwner)
15 | {
16 | if (window == null)
17 | {
18 | throw new ArgumentNullException(nameof(window));
19 | }
20 |
21 | await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
22 |
23 | IVsUIShell vsUiShellService = await VS.Services.GetUIShellAsync();
24 |
25 | ErrorHandler.ThrowOnFailure(vsUiShellService.GetDialogOwnerHwnd(out IntPtr hwnd));
26 | ErrorHandler.ThrowOnFailure(vsUiShellService.EnableModeless(0));
27 |
28 | window.WindowStartupLocation = windowStartupLocation;
29 |
30 | try
31 | {
32 | WindowHelper.ShowModal(window, hwnd);
33 | return window.DialogResult;
34 | }
35 | finally
36 | {
37 | vsUiShellService.EnableModeless(1);
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/FontsAndColors/ColorOptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.Shell.Interop;
3 |
4 | namespace Community.VisualStudio.Toolkit
5 | {
6 | ///
7 | /// Defines what a user can change about a .
8 | ///
9 | /// Equivalent to .
10 | [Flags]
11 | public enum ColorOptions
12 | {
13 | ///
14 | /// No special behavior.
15 | ///
16 | None = 0,
17 | ///
18 | /// Enables the Background Color drop-down box that allows the user to change the background color.
19 | ///
20 | AllowBackgroundChange = __FCITEMFLAGS.FCIF_ALLOWBGCHANGE,
21 | ///
22 | /// Enables the Bold check box that allows the user to change the bold attribute.
23 | ///
24 | AllowBoldChange = __FCITEMFLAGS.FCIF_ALLOWBOLDCHANGE,
25 | ///
26 | /// Enables the Custom buttons that allows the user to create and select customized colors.
27 | ///
28 | AllowCustomColors = __FCITEMFLAGS.FCIF_ALLOWCUSTOMCOLORS,
29 | ///
30 | /// Enables the Foreground Color drop-down box that allows the user to change the foreground color.
31 | ///
32 | AllowForegroundChange = __FCITEMFLAGS.FCIF_ALLOWFGCHANGE,
33 | ///
34 | /// Specifies that the item is a marker type.
35 | ///
36 | IsMarker = __FCITEMFLAGS.FCIF_ISMARKER,
37 | ///
38 | /// Indicates that the Display Items is to be treated as "plain text." This means that the color used to display the item will track the environment wide font and color settings for plain text color.
39 | ///
40 | PlainText = __FCITEMFLAGS.FCIF_PLAINTEXT,
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/FontsAndColors/ConfiguredColorChangedEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Community.VisualStudio.Toolkit
4 | {
5 | ///
6 | /// Arguments for the event that is raised when a configured color changes.
7 | ///
8 | public class ConfiguredColorChangedEventArgs : EventArgs
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | /// The definition of the color that was changed.
14 | /// The color that was changed.
15 | public ConfiguredColorChangedEventArgs(ColorDefinition definition, ConfiguredColor color)
16 | {
17 | Definition = definition;
18 | Color = color;
19 | }
20 |
21 | ///
22 | /// The definition of the color that was changed.
23 | ///
24 | public ColorDefinition Definition { get; }
25 |
26 | ///
27 | /// The color that was changed.
28 | ///
29 | public ConfiguredColor Color { get; }
30 |
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/FontsAndColors/FontDefinition.cs:
--------------------------------------------------------------------------------
1 | namespace Community.VisualStudio.Toolkit
2 | {
3 | ///
4 | /// Defines information about a font for a category.
5 | ///
6 | public class FontDefinition
7 | {
8 | ///
9 | /// The "Automatic" font which corresponds to the current "icon" system font setting in Windows.
10 | ///
11 | public static readonly FontDefinition Automatic = new("Automatic", 0);
12 |
13 | ///
14 | /// Initializes a new instance of the class with the default character set.
15 | ///
16 | /// The name of the font family.
17 | /// The point size of the font.
18 | public FontDefinition(string familyName, ushort size) : this(familyName, size, 1 /* DEFAULT_CHARSET */) { }
19 |
20 | ///
21 | /// Initializes a new instance of the class with the specified character set.
22 | ///
23 | /// The name of the font family.
24 | /// The point size of the font.
25 | /// The character set.
26 | public FontDefinition(string familyName, ushort size, byte characterSet)
27 | {
28 | FamilyName = familyName;
29 | Size = size;
30 | CharacterSet = characterSet;
31 | }
32 |
33 | ///
34 | /// The name of the font family.
35 | ///
36 | public string FamilyName { get; }
37 |
38 | ///
39 | /// The point size of the font.
40 | ///
41 | public ushort Size { get; }
42 |
43 | ///
44 | /// The character set.
45 | ///
46 | public byte CharacterSet { get; }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/FontsAndColors/FontStyle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.Shell.Interop;
3 | using Microsoft.VisualStudio.TextManager.Interop;
4 |
5 | namespace Community.VisualStudio.Toolkit
6 | {
7 | ///
8 | /// Defines font styles.
9 | ///
10 | ///
11 | /// Equivalent to and .
12 | ///
13 | [Flags]
14 | public enum FontStyle
15 | {
16 | ///
17 | /// Plain text.
18 | ///
19 | None = 0,
20 | ///
21 | /// Bold text.
22 | ///
23 | Bold = FONTFLAGS.FF_BOLD,
24 | ///
25 | /// Strikethrough text.
26 | ///
27 | Strikethrough = FONTFLAGS.FF_STRIKETHROUGH,
28 | ///
29 | /// Specifies that the "bold" attribute of this Display Item will be the same as the "bold" attribute of the "plain text" item.
30 | ///
31 | TrackPlaintextBold = __FCFONTFLAGS.FCFF_TRACK_PLAINTEXT_BOLD
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/FontsAndColors/IFontAndColorChangeListener.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.Shell.Interop;
2 |
3 | namespace Community.VisualStudio.Toolkit
4 | {
5 | internal interface IFontAndColorChangeListener
6 | {
7 | void SetFont(ref LOGFONTW logfont, ref FontInfo info);
8 |
9 | void SetColor(ColorDefinition definition, uint background, uint foreground, FontStyle fontStyle);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/FontsAndColors/LineStyle.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TextManager.Interop;
2 |
3 | namespace Community.VisualStudio.Toolkit
4 | {
5 | ///
6 | /// Line style options.
7 | ///
8 | /// Same as and .
9 | public enum LineStyle
10 | {
11 | ///
12 | /// No line.
13 | ///
14 | None = LINESTYLE.LI_NONE,
15 | ///
16 | /// Solid line.
17 | ///
18 | Solid = LINESTYLE.LI_SOLID,
19 | ///
20 | /// Squiggly line.
21 | ///
22 | Squiggly = LINESTYLE.LI_SQUIGGLY,
23 | ///
24 | /// Hatched pattern.
25 | ///
26 | Hatch = LINESTYLE.LI_HATCH,
27 | ///
28 | /// Fifty percent gray dither (dotted when 1 pixel).
29 | ///
30 | Dotted = LINESTYLE.LI_DOTTED,
31 | ///
32 | /// Smart tag factoid.
33 | ///
34 | SmartTagFactoid = LINESTYLE2.LI_SMARTTAGFACT,
35 | ///
36 | /// Smart tag factoid side.
37 | ///
38 | SmartTagFactoidSide = LINESTYLE2.LI_SMARTTAGFACTSIDE,
39 | ///
40 | /// Smart tag ephemeral.
41 | ///
42 | SmartTagEphemeral = LINESTYLE2.LI_SMARTTAGEPHEM,
43 | ///
44 | /// Smart tag ephemeral side.
45 | ///
46 | SmartTagEphemeralSide = LINESTYLE2.LI_SMARTTAGEPHEMSIDE
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/Helpers/ContentTypes.cs:
--------------------------------------------------------------------------------
1 | namespace Community.VisualStudio.Toolkit
2 | {
3 | /// A list of content types for known languages.
4 | public class ContentTypes
5 | {
6 | /// Applies to all languages.
7 | public const string Any = "any";
8 | /// The base content type of all text documents including 'code'.
9 | public const string Text = "text";
10 | /// The base content type of all coding text documents and languages.
11 | public const string Code = "code";
12 |
13 |
14 | #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
15 | public const string CSharp = "CSharp";
16 | public const string VisualBasic = "Basic";
17 | public const string FSharp = "F#";
18 | public const string CPlusPlus = "C/C++";
19 | public const string Css = "CSS";
20 | public const string Less = "LESS";
21 | public const string Scss = "SCSS";
22 | public const string HTML = "HTMLX";
23 | public const string WebForms = "HTML";
24 | public const string Json = "JSON";
25 | public const string Xaml = "XAML";
26 | public const string Xml = "XML";
27 | public const string Repl = "REPL";
28 | public const string Output = "Output";
29 | #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/Helpers/Disposable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Community.VisualStudio.Toolkit
4 | {
5 | internal sealed class Disposable : IDisposable
6 | {
7 | private readonly Action _action;
8 | private bool _disposed;
9 |
10 | public Disposable(Action action)
11 | {
12 | _action = action;
13 | }
14 |
15 | public void Dispose()
16 | {
17 | if (!_disposed)
18 | {
19 | _disposed = true;
20 | _action();
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/Helpers/SingleFileGeneratorTypes.cs:
--------------------------------------------------------------------------------
1 | namespace Community.VisualStudio.Toolkit
2 | {
3 | ///
4 | /// SingleFileGenerators rely on Language GUIDs rather than ProjectType GUIDs.
5 | /// This class contains known types for easier registration of SingleFileGenerators.
6 | ///
7 | ///
8 | ///
9 | /// Example class Attribute Usage:
10 | /// [Guid("Guid-For-Your-IVsSingleFileGenerator")]
11 | /// [ComVisible(true)]
12 | /// [ProvideObject(typeof(YourCustomToolClass))]
13 | /// [CodeGeneratorRegistration(typeof(YourCustomToolClass), "NameOfCustomTool", SingleFileGeneratorTypes.CSHARP)]
14 | ///
15 | public static class SingleFileGeneratorTypes
16 | {
17 | /// SingleFileGenerator Registration for C#
18 | public const string CSHARP = "{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}";
19 |
20 | /// SingleFileGenerator Registration for J#
21 | public const string JSHARP = "{E6FDF8B0-F3D1-11D4-8576-0002A516ECE8}";
22 |
23 | /// SingleFileGenerator Registration for VB
24 | public const string VisualBasic = "{164B10B9-B200-11D0-8C61-00A0C91E29D5}";
25 | }
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/MEF/InternalTaggerBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Microsoft.VisualStudio.Text;
5 | using Microsoft.VisualStudio.Text.Tagging;
6 |
7 | namespace Community.VisualStudio.Toolkit
8 | {
9 | ///
10 | /// A base class for creating token taggers for your custom language implementation.
11 | ///
12 | ///
13 | internal abstract class InternalTaggerBase : ITagger, IDisposable where TTag : ITag
14 | {
15 | private bool _isDisposed;
16 |
17 | ///
18 | /// Creates a new instance of the base class.
19 | ///
20 | ///
21 | public InternalTaggerBase(ITagAggregator? tags)
22 | {
23 | Tags = tags ?? throw new ArgumentNullException(nameof(tags));
24 | Tags.TagsChanged += TokenTagsChanged;
25 | }
26 |
27 | ///
28 | /// The collection of Token Tags.
29 | ///
30 | public ITagAggregator Tags { get; }
31 |
32 | private void TokenTagsChanged(object sender, TagsChangedEventArgs e)
33 | {
34 | ITextBuffer buffer = e.Span.BufferGraph.TopBuffer;
35 | SnapshotSpan span = new(buffer.CurrentSnapshot, 0, buffer.CurrentSnapshot.Length);
36 |
37 | TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(span));
38 | }
39 |
40 | ///
41 | public IEnumerable>? GetTags(NormalizedSnapshotSpanCollection spans)
42 | {
43 | if (spans[0].IsEmpty)
44 | {
45 | return null;
46 | }
47 |
48 | bool isFullParse = spans.First().Start == 0 && spans.Last().End == spans[0].Snapshot.Length;
49 | return GetTags(spans, isFullParse);
50 | }
51 |
52 | ///
53 | /// Override to provide custom tags
54 | ///
55 | public abstract IEnumerable> GetTags(NormalizedSnapshotSpanCollection spans, bool isFullParse);
56 |
57 | ///
58 | /// Disposes the instance
59 | ///
60 | public virtual void Dispose(bool disposing)
61 | {
62 | if (!_isDisposed)
63 | {
64 | if (disposing && Tags != null)
65 | {
66 | Tags.TagsChanged -= TokenTagsChanged;
67 | }
68 |
69 | _isDisposed = true;
70 | }
71 | }
72 |
73 | ///
74 | public void Dispose()
75 | {
76 | Dispose(true);
77 | GC.SuppressFinalize(this);
78 | }
79 |
80 | ///
81 | public event EventHandler? TagsChanged;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/toolkit/Community.VisualStudio.Toolkit.Shared/MEF/TokenClassificationTaggerBase.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel.Composition;
3 | using Microsoft.VisualStudio.Text;
4 | using Microsoft.VisualStudio.Text.Classification;
5 | using Microsoft.VisualStudio.Text.Tagging;
6 |
7 | namespace Community.VisualStudio.Toolkit
8 | {
9 | ///
10 | /// A base class to provide classification (syntax highlighting) based on a Token Tagger.
11 | ///
12 | public abstract class TokenClassificationTaggerBase : ITaggerProvider
13 | {
14 | [Import] internal IClassificationTypeRegistryService? _classificationRegistry = null;
15 | [Import] internal IBufferTagAggregatorFactoryService? _bufferTagAggregator = null;
16 |
17 | ///
18 | /// A map of a token value and which classification name it corresponds with.
19 | ///
20 | public abstract Dictionary