@@ -81,6 +81,9 @@ private static string GetAggregateProjectTypeGuids(this IVsProject project)
8181 /// </summary>
8282 public static bool IsTestProject ( this IVsProject project , Guid projectGuid )
8383 {
84+ // Overload IsTestProject method to check if we should use this test adapter
85+ // at all. This is much less error prone than adding this check to all locations
86+ // where this method is called.
8487 if ( ! IsTestAdapaterEnabled ( ) )
8588 {
8689 return false ;
@@ -94,19 +97,25 @@ public static bool IsTestProject(this IVsProject project, Guid projectGuid)
9497 return ( projectTypeGuids . IndexOf ( projectGuid . ToString ( ) , StringComparison . OrdinalIgnoreCase ) >= 0 ) ;
9598 }
9699
100+ private static bool checkedRegistryForTestAdapterEnabled = false ;
101+ private static bool registryValueForTestAdapterEnabled = true ;
102+
97103 public static bool IsTestAdapaterEnabled ( )
98104 {
99- using ( var nodeKey = VSRegistry . RegistryRoot ( __VsLocalRegistryType . RegType_UserSettings , true ) . CreateSubKey ( NodejsConstants . BaseRegistryKey ) )
105+ if ( ! checkedRegistryForTestAdapterEnabled )
100106 {
107+ using ( var nodeKey = VSRegistry . RegistryRoot ( __VsLocalRegistryType . RegType_UserSettings , true ) . CreateSubKey ( NodejsConstants . BaseRegistryKey ) )
101108 using ( var optionsKey = nodeKey . CreateSubKey ( "Options" ) )
109+ using ( var categoryKey = optionsKey . CreateSubKey ( "testing" ) )
102110 {
103- using ( var categoryKey = optionsKey . CreateSubKey ( "testing" ) )
104- {
105- // If the value is set to something we disable this testadapter
106- return string . IsNullOrEmpty ( categoryKey . GetValue ( "testadapter" ) as string ) ;
107- }
111+ // If the value is set to something we disable this testadapter
112+ registryValueForTestAdapterEnabled = string . IsNullOrEmpty ( categoryKey . GetValue ( "testadapter" ) as string ) ;
108113 }
114+
115+ checkedRegistryForTestAdapterEnabled = true ;
109116 }
117+
118+ return registryValueForTestAdapterEnabled ;
110119 }
111120
112121 /// <summary>
0 commit comments