44
44
using Rubberduck . VBEditor . SafeComWrappers . Office . Core . Abstract ;
45
45
using Component = Castle . MicroKernel . Registration . Component ;
46
46
using Rubberduck . UI . CodeMetrics ;
47
- using Rubberduck . Navigation . CodeMetrics ;
48
47
using Rubberduck . Parsing . Common ;
49
48
50
49
namespace Rubberduck . Root
@@ -157,7 +156,14 @@ private void RegisterConfiguration(IWindsorContainer container, Assembly[] assem
157
156
foreach ( var assembly in assembliesToRegister )
158
157
{
159
158
var assemblyTypes = assembly . DefinedTypes
160
- . Where ( w => _initialSettings . EnableExperimentalFeatures || ! Attribute . IsDefined ( w , typeof ( ExperimentalAttribute ) ) ) ;
159
+ . Where ( w =>
160
+ {
161
+ var attribute = w . CustomAttributes . FirstOrDefault ( f => f . AttributeType == typeof ( ExperimentalAttribute ) ) ;
162
+ var ctorArg = attribute ? . ConstructorArguments . Any ( ) == true ? ( string ) attribute . ConstructorArguments . First ( ) . Value : string . Empty ;
163
+
164
+ return attribute == null ||
165
+ _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == ctorArg && a . IsEnabled ) ;
166
+ } ) ;
161
167
162
168
container . Register ( Classes . From ( assemblyTypes )
163
169
. InSameNamespaceAs < Configuration > ( )
@@ -190,7 +196,14 @@ private void ApplyDefaultInterfaceConvention(IWindsorContainer container, Assemb
190
196
foreach ( var assembly in assembliesToRegister )
191
197
{
192
198
var assemblyTypes = assembly . DefinedTypes
193
- . Where ( w => _initialSettings . EnableExperimentalFeatures || ! Attribute . IsDefined ( w , typeof ( ExperimentalAttribute ) ) ) ;
199
+ . Where ( w =>
200
+ {
201
+ var attribute = w . CustomAttributes . FirstOrDefault ( f => f . AttributeType == typeof ( ExperimentalAttribute ) ) ;
202
+ var ctorArg = attribute ? . ConstructorArguments . Any ( ) == true ? ( string ) attribute . ConstructorArguments . First ( ) . Value : string . Empty ;
203
+
204
+ return attribute == null ||
205
+ _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == ctorArg && a . IsEnabled ) ;
206
+ } ) ;
194
207
195
208
assemblyTypes . Any ( t => t . Name == nameof ( IMessageBox ) ) ;
196
209
@@ -212,7 +225,14 @@ private void RegisterFactories(IWindsorContainer container, Assembly[] assemblie
212
225
foreach ( var assembly in assembliesToRegister )
213
226
{
214
227
var assemblyTypes = assembly . DefinedTypes
215
- . Where ( w => _initialSettings . EnableExperimentalFeatures || ! Attribute . IsDefined ( w , typeof ( ExperimentalAttribute ) ) ) ;
228
+ . Where ( w =>
229
+ {
230
+ var attribute = w . CustomAttributes . FirstOrDefault ( f => f . AttributeType == typeof ( ExperimentalAttribute ) ) ;
231
+ var ctorArg = attribute ? . ConstructorArguments . Any ( ) == true ? ( string ) attribute . ConstructorArguments . First ( ) . Value : string . Empty ;
232
+
233
+ return attribute == null ||
234
+ _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == ctorArg && a . IsEnabled ) ;
235
+ } ) ;
216
236
217
237
container . Register ( Types . From ( assemblyTypes )
218
238
. Where ( type => type . IsInterface && type . Name . EndsWith ( "Factory" ) )
@@ -236,7 +256,14 @@ private void RegisterQuickFixes(IWindsorContainer container, Assembly[] assembli
236
256
foreach ( var assembly in assembliesToRegister )
237
257
{
238
258
var assemblyTypes = assembly . DefinedTypes
239
- . Where ( w => _initialSettings . EnableExperimentalFeatures || ! Attribute . IsDefined ( w , typeof ( ExperimentalAttribute ) ) ) ;
259
+ . Where ( w =>
260
+ {
261
+ var attribute = w . CustomAttributes . FirstOrDefault ( f => f . AttributeType == typeof ( ExperimentalAttribute ) ) ;
262
+ var ctorArg = attribute ? . ConstructorArguments . Any ( ) == true ? ( string ) attribute . ConstructorArguments . First ( ) . Value : string . Empty ;
263
+
264
+ return attribute == null ||
265
+ _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == ctorArg && a . IsEnabled ) ;
266
+ } ) ;
240
267
241
268
container . Register ( Classes . From ( assemblyTypes )
242
269
. BasedOn < IQuickFix > ( )
@@ -251,7 +278,14 @@ private void RegisterInspections(IWindsorContainer container, Assembly[] assembl
251
278
foreach ( var assembly in assembliesToRegister )
252
279
{
253
280
var assemblyTypes = assembly . DefinedTypes
254
- . Where ( w => _initialSettings . EnableExperimentalFeatures || ! Attribute . IsDefined ( w , typeof ( ExperimentalAttribute ) ) ) ;
281
+ . Where ( w =>
282
+ {
283
+ var attribute = w . CustomAttributes . FirstOrDefault ( f => f . AttributeType == typeof ( ExperimentalAttribute ) ) ;
284
+ var ctorArg = attribute ? . ConstructorArguments . Any ( ) == true ? ( string ) attribute . ConstructorArguments . First ( ) . Value : string . Empty ;
285
+
286
+ return attribute == null ||
287
+ _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == ctorArg && a . IsEnabled && a . IsEnabled ) ;
288
+ } ) ;
255
289
256
290
container . Register ( Classes . From ( assemblyTypes )
257
291
. BasedOn < IInspection > ( )
@@ -265,8 +299,15 @@ private void RegisterParseTreeInspections(IWindsorContainer container, Assembly[
265
299
foreach ( var assembly in assembliesToRegister )
266
300
{
267
301
var assemblyTypes = assembly . DefinedTypes
268
- . Where ( w => _initialSettings . EnableExperimentalFeatures || ! Attribute . IsDefined ( w , typeof ( ExperimentalAttribute ) ) ) ;
269
-
302
+ . Where ( w =>
303
+ {
304
+ var attribute = w . CustomAttributes . FirstOrDefault ( f => f . AttributeType == typeof ( ExperimentalAttribute ) ) ;
305
+ var ctorArg = attribute ? . ConstructorArguments . Any ( ) == true ? ( string ) attribute . ConstructorArguments . First ( ) . Value : string . Empty ;
306
+
307
+ return attribute == null ||
308
+ _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == ctorArg && a . IsEnabled ) ;
309
+ } ) ;
310
+
270
311
container . Register ( Classes . From ( assemblyTypes )
271
312
. BasedOn < IParseTreeInspection > ( )
272
313
. WithService . Base ( )
@@ -514,7 +555,7 @@ private Type[] ToolsMenuItems()
514
555
typeof ( ExportAllCommandMenuItem )
515
556
} ;
516
557
517
- if ( _initialSettings . EnableExperimentalFeatures )
558
+ if ( _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == nameof ( RubberduckUI . GeneralSettings_EnableSourceControl ) && a . IsEnabled ) )
518
559
{
519
560
items . Add ( typeof ( SourceControlCommandMenuItem ) ) ;
520
561
}
@@ -581,7 +622,7 @@ private void RegisterCommands(IWindsorContainer container)
581
622
582
623
private void RegisterCommandsWithPresenters ( IWindsorContainer container )
583
624
{
584
- if ( _initialSettings . EnableExperimentalFeatures )
625
+ if ( _initialSettings . EnableExperimentalFeatures . Any ( a => a . Key == nameof ( RubberduckUI . GeneralSettings_EnableSourceControl ) && a . IsEnabled ) )
585
626
{
586
627
container . Register ( Component . For < CommandBase > ( )
587
628
. ImplementedBy < SourceControlCommand > ( )
@@ -811,7 +852,7 @@ private void RegisterCustomDeclarationLoadersToParser(IWindsorContainer containe
811
852
. LifestyleSingleton ( ) ) ;
812
853
}
813
854
814
- private IEnumerable < Assembly > AssembliesToRegister ( )
855
+ public static IEnumerable < Assembly > AssembliesToRegister ( )
815
856
{
816
857
var assemblies = new [ ]
817
858
{
@@ -824,7 +865,7 @@ private IEnumerable<Assembly> AssembliesToRegister()
824
865
return assemblies ;
825
866
}
826
867
827
- private IEnumerable < Assembly > FindPlugins ( )
868
+ private static IEnumerable < Assembly > FindPlugins ( )
828
869
{
829
870
var assemblies = new List < Assembly > ( ) ;
830
871
var basePath = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ;
0 commit comments