File tree Expand file tree Collapse file tree 6 files changed +123
-8
lines changed
src/CodingWithCalvin.BreakpointNotifier.Vsix Expand file tree Collapse file tree 6 files changed +123
-8
lines changed Original file line number Diff line number Diff line change 1- using System . Runtime . InteropServices ;
1+ using System ;
2+ using System . Runtime . InteropServices ;
23using System . Threading ;
34using Microsoft . VisualStudio . Shell ;
45using Task = System . Threading . Tasks . Task ;
@@ -7,14 +8,16 @@ namespace CodingWithCalvin.BreakpointNotifier.Vsix
78{
89 [ PackageRegistration ( UseManagedResourcesOnly = true , AllowsBackgroundLoading = true ) ]
910 [ InstalledProductRegistration ( Vsix . Name , Vsix . Description , Vsix . Version ) ]
11+ [ Guid ( PackageGuids . PackageGuidString ) ]
12+ [ ProvideMenuResource ( "Menus.ctmenu" , 1 ) ]
1013 public sealed class BreakpointNotifierPackage : AsyncPackage
1114 {
12- protected override Task OnAfterPackageLoadedAsync ( CancellationToken cancellationToken )
15+ protected override Task InitializeAsync ( CancellationToken cancellationToken , IProgress < ServiceProgressData > progress )
1316 {
14- DebuggerEvents . Initialize ( ) ;
17+
18+ InitializeCommand . Initialize ( this ) ;
1519
16- return Task . CompletedTask ;
20+ return base . InitializeAsync ( cancellationToken , progress ) ;
1721 }
18-
1922 }
2023}
Original file line number Diff line number Diff line change 4949 </PropertyGroup >
5050 <ItemGroup >
5151 <Compile Include =" BreakpointNotifierPackage.cs" />
52+ <Compile Include =" InitializeCommand.cs" />
53+ <Compile Include =" VSCommandTable.cs" >
54+ <AutoGen >True</AutoGen >
55+ <DesignTime >True</DesignTime >
56+ <DependentUpon >VSCommandTable.vsct</DependentUpon >
57+ </Compile >
5258 <Compile Include =" DebuggerEvents.cs" />
5359 <Compile Include =" Properties\AssemblyInfo.cs" />
5460 <Compile Include =" source.extension.cs" >
7076 <Reference Include =" System.Design" />
7177 <Reference Include =" System.Windows.Forms" />
7278 </ItemGroup >
79+ <ItemGroup >
80+ <VSCTCompile Include =" VSCommandTable.vsct" >
81+ <Generator >VsctGenerator</Generator >
82+ <LastGenOutput >VSCommandTable.cs</LastGenOutput >
83+ <ResourceName >Menus.ctmenu</ResourceName >
84+ </VSCTCompile >
85+ </ItemGroup >
7386 <ItemGroup >
7487 <PackageReference Include =" Microsoft.VisualStudio.SDK" >
75- <Version >17.5.33428.388 </Version >
88+ <Version >15.0.1 </Version >
7689 </PackageReference >
7790 <PackageReference Include =" Microsoft.VSSDK.BuildTools" >
7891 <Version >17.5.4072</Version >
Original file line number Diff line number Diff line change @@ -17,9 +17,9 @@ private DebuggerEvents()
1717 debugger . AdviseDebuggerEvents ( this , out _ ) ;
1818 }
1919
20- public static void Initialize ( )
20+ public static DebuggerEvents Initialize ( )
2121 {
22- _ = new DebuggerEvents ( ) ;
22+ return new DebuggerEvents ( ) ;
2323 }
2424
2525 public int OnModeChange ( DBGMODE dbgmodeNew )
Original file line number Diff line number Diff line change 1+ using Microsoft . VisualStudio . Shell ;
2+ using System . ComponentModel . Design ;
3+ using System ;
4+
5+ namespace CodingWithCalvin . BreakpointNotifier . Vsix
6+ {
7+ internal class InitializeCommand
8+ {
9+ private readonly Package _package ;
10+ private static DebuggerEvents _debuggerEvents ;
11+
12+ private InitializeCommand ( Package package )
13+ {
14+ _package = package ;
15+
16+ var commandService = ( OleMenuCommandService ) ServiceProvider . GetService ( typeof ( IMenuCommandService ) ) ;
17+
18+ if ( commandService == null )
19+ {
20+ return ;
21+ }
22+
23+ var menuCommandId = new CommandID ( PackageGuids . CommandSetGuid , PackageIds . InitializeCommandId ) ;
24+ var menuItem = new MenuCommand ( InitializeDebuggerEvents , menuCommandId ) ;
25+ commandService . AddCommand ( menuItem ) ;
26+ }
27+
28+ private IServiceProvider ServiceProvider => _package ;
29+
30+ public static void Initialize ( Package package )
31+ {
32+ _ = new InitializeCommand ( package ) ;
33+ }
34+
35+ private static void InitializeDebuggerEvents ( object sender , EventArgs e )
36+ {
37+ _debuggerEvents = DebuggerEvents . Initialize ( ) ;
38+ }
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ // ------------------------------------------------------------------------------
2+ // <auto-generated>
3+ // This file was generated by VSIX Synchronizer
4+ // </auto-generated>
5+ // ------------------------------------------------------------------------------
6+ namespace CodingWithCalvin . BreakpointNotifier . Vsix
7+ {
8+ using System ;
9+
10+ /// <summary>
11+ /// Helper class that exposes all GUIDs used across VS Package.
12+ /// </summary>
13+ internal sealed partial class PackageGuids
14+ {
15+ public const string PackageGuidString = "136f3004-4048-4dd9-bd6d-7ff910b2c900" ;
16+ public static Guid PackageGuid = new Guid ( PackageGuidString ) ;
17+
18+ public const string CommandSetGuidString = "a12047f1-37ef-4dc0-80c3-4e3d43c5b767" ;
19+ public static Guid CommandSetGuid = new Guid ( CommandSetGuidString ) ;
20+ }
21+ /// <summary>
22+ /// Helper class that encapsulates all CommandIDs uses across VS Package.
23+ /// </summary>
24+ internal sealed partial class PackageIds
25+ {
26+ public const int InitializeCommandId = 0x0100 ;
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <CommandTable xmlns =" http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns : xs =" http://www.w3.org/2001/XMLSchema" >
3+
4+ <Extern href =" stdidcmd.h" />
5+ <Extern href =" vsshlids.h" />
6+
7+ <Commands package =" PackageGuid" >
8+ <Buttons >
9+ <Button guid =" CommandSetGuid" id =" InitializeCommandId" type =" Button" >
10+ <Strings >
11+ <ButtonText >Initialize Debugger Events</ButtonText >
12+ </Strings >
13+ </Button >
14+ </Buttons >
15+ </Commands >
16+
17+ <CommandPlacements >
18+ <CommandPlacement guid =" CommandSetGuid" id =" InitializeCommandId" priority =" 0x0100" >
19+ <Parent guid =" guidSHLMainMenu" id =" IDG_VS_CTXT_PROJECT_EXPLORE" />
20+ </CommandPlacement >
21+ </CommandPlacements >
22+
23+ <Symbols >
24+ <GuidSymbol name =" PackageGuid" value =" {136f3004-4048-4dd9-bd6d-7ff910b2c900}" />
25+
26+ <GuidSymbol name =" CommandSetGuid" value =" {a12047f1-37ef-4dc0-80c3-4e3d43c5b767}" >
27+ <IDSymbol name =" InitializeCommandId" value =" 0x0100" />
28+ </GuidSymbol >
29+
30+ </Symbols >
31+ </CommandTable >
You can’t perform that action at this time.
0 commit comments