66using System . Diagnostics ;
77using System . Globalization ;
88using System . IO ;
9- using System . Linq ;
109using System . Runtime . InteropServices ;
1110using System . Windows . Forms ;
1211using Microsoft . NodejsTools . Commands ;
1312using Microsoft . NodejsTools . Debugger . DebugEngine ;
1413using Microsoft . NodejsTools . Debugger . Remote ;
1514using Microsoft . NodejsTools . Jade ;
16- using Microsoft . NodejsTools . Logging ;
1715using Microsoft . NodejsTools . Options ;
1816using Microsoft . NodejsTools . Project ;
1917using Microsoft . NodejsTools . ProjectWizard ;
@@ -66,13 +64,13 @@ namespace Microsoft.NodejsTools
6664 internal sealed partial class NodejsPackage : CommonPackage
6765 {
6866 internal const string NodeExpressionEvaluatorGuid = "{F16F2A71-1C45-4BAB-BECE-09D28CFDE3E6}" ;
69- private IContentType _contentType ;
67+ private IContentType contentType ;
7068 internal static NodejsPackage Instance ;
7169 internal HashSet < ITextBuffer > ChangedBuffers = new HashSet < ITextBuffer > ( ) ;
72- private NodejsToolsLogger _logger ;
70+
7371 // Hold references for the subscribed events. Otherwise the callbacks will be garbage collected
7472 // after the initialization
75- private List < EnvDTE . CommandEvents > _subscribedCommandEvents = new List < EnvDTE . CommandEvents > ( ) ;
73+ private readonly List < EnvDTE . CommandEvents > subscribedCommandEvents = new List < EnvDTE . CommandEvents > ( ) ;
7674
7775 /// <summary>
7876 /// Default constructor of the package.
@@ -125,21 +123,18 @@ protected override void Initialize()
125123 new SendFeedbackCommand ( ) ,
126124 new ShowDocumentationCommand ( )
127125 } ;
126+
128127 try
129128 {
130129 commands . Add ( new AzureExplorerAttachDebuggerCommand ( ) ) ;
131130 }
132131 catch ( NotSupportedException )
133132 {
134133 }
135- RegisterCommands ( commands , Guids . NodejsCmdSet ) ;
136134
135+ RegisterCommands ( commands , Guids . NodejsCmdSet ) ;
137136 MakeDebuggerContextAvailable ( ) ;
138137
139- InitializeLogging ( ) ;
140-
141- InitializeTelemetry ( ) ;
142-
143138 // The variable is inherited by child processes backing Test Explorer, and is used in
144139 // the NTVS test discoverer and test executor to connect back to VS.
145140 Environment . SetEnvironmentVariable ( NodejsConstants . NodeToolsProcessIdEnvironmentVariable , Process . GetCurrentProcess ( ) . Id . ToString ( ) ) ;
@@ -174,25 +169,11 @@ private void SubscribeToVsCommandEvents(
174169 {
175170 targetEvent . AfterExecute += afterExecute ;
176171 }
177- this . _subscribedCommandEvents . Add ( targetEvent ) ;
178- }
179-
180- private void InitializeLogging ( )
181- {
182- this . _logger = new NodejsToolsLogger ( this . ComponentModel . GetExtensions < INodejsToolsLogger > ( ) . ToArray ( ) ) ;
183- }
184-
185- private void InitializeTelemetry ( )
186- {
187- // Fetch the session synchronously on the UI thread; if this doesn't happen before we try using this on
188- // the background thread then the VS process will deadlock.
189- TelemetryHelper . Initialize ( ) ;
172+ this . subscribedCommandEvents . Add ( targetEvent ) ;
190173 }
191174
192175 public new IComponentModel ComponentModel => this . GetComponentModel ( ) ;
193176
194- internal NodejsToolsLogger Logger => this . _logger ;
195-
196177 /// <summary>
197178 /// Makes the debugger context available - this enables our debugger when we're installed into
198179 /// a SKU which doesn't support every installed debugger.
@@ -201,8 +182,8 @@ private void MakeDebuggerContextAvailable()
201182 {
202183 var monitorSelection = ( IVsMonitorSelection ) GetService ( typeof ( SVsShellMonitorSelection ) ) ;
203184 var debugEngineGuid = AD7Engine . DebugEngineGuid ;
204- uint contextCookie ;
205- if ( ErrorHandler . Succeeded ( monitorSelection . GetCmdUIContextCookie ( ref debugEngineGuid , out contextCookie ) ) )
185+
186+ if ( ErrorHandler . Succeeded ( monitorSelection . GetCmdUIContextCookie ( ref debugEngineGuid , out var contextCookie ) ) )
206187 {
207188 ErrorHandler . ThrowOnFailure ( monitorSelection . SetCmdUIContext ( contextCookie , 1 ) ) ;
208189 }
@@ -262,11 +243,11 @@ private IContentType ReplContentType
262243 {
263244 get
264245 {
265- if ( this . _contentType == null )
246+ if ( this . contentType == null )
266247 {
267- this . _contentType = this . ComponentModel . GetService < IContentTypeRegistryService > ( ) . GetContentType ( NodejsConstants . TypeScript ) ;
248+ this . contentType = this . ComponentModel . GetService < IContentTypeRegistryService > ( ) . GetContentType ( NodejsConstants . TypeScript ) ;
268249 }
269- return this . _contentType ;
250+ return this . contentType ;
270251 }
271252 }
272253
@@ -358,15 +339,5 @@ public string BrowseForDirectory(IntPtr owner, string initialDirectory = null)
358339 }
359340 }
360341 }
361-
362- internal static void NavigateTo ( string filename , int line , int col )
363- {
364- VsUtilities . NavigateTo ( Instance , filename , Guid . Empty , line , col ) ;
365- }
366-
367- internal static void NavigateTo ( string filename , int pos )
368- {
369- VsUtilities . NavigateTo ( Instance , filename , Guid . Empty , pos ) ;
370- }
371342 }
372343}
0 commit comments