Skip to content

Commit ffb9fe0

Browse files
committed
Experimental Attribute
1 parent 76d570d commit ffb9fe0

File tree

11 files changed

+57
-26
lines changed

11 files changed

+57
-26
lines changed

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ public Visibility ExportAllVisibility
574574

575575
public bool IsSourceControlEnabled
576576
{
577-
get { return _generalSettings.SourceControlEnabled; }
577+
get { return _generalSettings.EnableExperimentalFeatures; }
578578
}
579579

580580
public Visibility TreeViewVisibility

RetailCoder.VBE/Root/RubberduckIoCInstaller.cs

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
using Component = Castle.MicroKernel.Registration.Component;
4646
using Rubberduck.UI.CodeMetrics;
4747
using Rubberduck.Navigation.CodeMetrics;
48+
using Rubberduck.Parsing.Common;
4849

4950
namespace Rubberduck.Root
5051
{
@@ -155,7 +156,10 @@ private void RegisterConfiguration(IWindsorContainer container, Assembly[] assem
155156
{
156157
foreach (var assembly in assembliesToRegister)
157158
{
158-
container.Register(Classes.FromAssembly(assembly)
159+
var assemblyClasses = assembly.GetTypes()
160+
.Where(w => _initialSettings.EnableExperimentalFeatures || Attribute.IsDefined(w, typeof(ExperimentalAttribute)));
161+
162+
container.Register(Classes.From(assemblyClasses)
159163
.InSameNamespaceAs<Configuration>()
160164
.WithService.AllInterfaces()
161165
.LifestyleSingleton());
@@ -181,11 +185,14 @@ private void RegisterConfiguration(IWindsorContainer container, Assembly[] assem
181185
.LifestyleTransient());
182186
}
183187

184-
private static void ApplyDefaultInterfaceConvention(IWindsorContainer container, Assembly[] assembliesToRegister)
188+
private void ApplyDefaultInterfaceConvention(IWindsorContainer container, Assembly[] assembliesToRegister)
185189
{
186190
foreach (var assembly in assembliesToRegister)
187191
{
188-
container.Register(Classes.FromAssembly(assembly)
192+
var assemblyClasses = assembly.GetTypes()
193+
.Where(w => _initialSettings.EnableExperimentalFeatures || Attribute.IsDefined(w, typeof(ExperimentalAttribute)));
194+
195+
container.Register(Classes.From(assemblyClasses)
189196
.Where(type => type.Namespace != null
190197
&& !type.Namespace.StartsWith("Rubberduck.VBEditor.SafeComWrappers")
191198
&& !type.Name.Equals("SelectionChangeService")
@@ -198,11 +205,14 @@ private static void ApplyDefaultInterfaceConvention(IWindsorContainer container,
198205
}
199206
}
200207

201-
private static void RegisterFactories(IWindsorContainer container, Assembly[] assembliesToRegister)
208+
private void RegisterFactories(IWindsorContainer container, Assembly[] assembliesToRegister)
202209
{
203210
foreach (var assembly in assembliesToRegister)
204211
{
205-
container.Register(Types.FromAssembly(assembly)
212+
var assemblyClasses = assembly.GetTypes()
213+
.Where(w => _initialSettings.EnableExperimentalFeatures || Attribute.IsDefined(w, typeof(ExperimentalAttribute)));
214+
215+
container.Register(Classes.From(assemblyClasses)
206216
.Where(type => type.IsInterface && type.Name.EndsWith("Factory"))
207217
.Configure(c => c.AsFactory())
208218
.LifestyleSingleton());
@@ -219,34 +229,43 @@ private static void RegisterSpecialFactories(IWindsorContainer container)
219229
.LifestyleSingleton());
220230
}
221231

222-
private static void RegisterQuickFixes(IWindsorContainer container, Assembly[] assembliesToRegister)
232+
private void RegisterQuickFixes(IWindsorContainer container, Assembly[] assembliesToRegister)
223233
{
224234
foreach (var assembly in assembliesToRegister)
225235
{
226-
container.Register(Classes.FromAssembly(assembly)
236+
var assemblyClasses = assembly.GetTypes()
237+
.Where(w => _initialSettings.EnableExperimentalFeatures || Attribute.IsDefined(w, typeof(ExperimentalAttribute)));
238+
239+
container.Register(Classes.From(assemblyClasses)
227240
.BasedOn<IQuickFix>()
228241
.WithService.Base()
229242
.WithService.Self()
230243
.LifestyleSingleton());
231244
}
232245
}
233246

234-
private static void RegisterInspections(IWindsorContainer container, Assembly[] assembliesToRegister)
247+
private void RegisterInspections(IWindsorContainer container, Assembly[] assembliesToRegister)
235248
{
236249
foreach (var assembly in assembliesToRegister)
237250
{
238-
container.Register(Classes.FromAssembly(assembly)
251+
var assemblyClasses = assembly.GetTypes()
252+
.Where(w => _initialSettings.EnableExperimentalFeatures || Attribute.IsDefined(w, typeof(ExperimentalAttribute)));
253+
254+
container.Register(Classes.From(assemblyClasses)
239255
.BasedOn<IInspection>()
240256
.WithService.Base()
241257
.LifestyleTransient());
242258
}
243259
}
244260

245-
private static void RegisterParseTreeInspections(IWindsorContainer container, Assembly[] assembliesToRegister)
261+
private void RegisterParseTreeInspections(IWindsorContainer container, Assembly[] assembliesToRegister)
246262
{
247263
foreach (var assembly in assembliesToRegister)
248264
{
249-
container.Register(Classes.FromAssembly(assembly)
265+
var assemblyClasses = assembly.GetTypes()
266+
.Where(w => _initialSettings.EnableExperimentalFeatures || Attribute.IsDefined(w, typeof(ExperimentalAttribute)));
267+
268+
container.Register(Classes.From(assemblyClasses)
250269
.BasedOn<IParseTreeInspection>()
251270
.WithService.Base()
252271
.WithService.Select(new[]{typeof(IInspection)})
@@ -493,7 +512,7 @@ private Type[] ToolsMenuItems()
493512
typeof(ExportAllCommandMenuItem)
494513
};
495514

496-
if (_initialSettings.SourceControlEnabled)
515+
if (_initialSettings.EnableExperimentalFeatures)
497516
{
498517
items.Add(typeof(SourceControlCommandMenuItem));
499518
}
@@ -560,7 +579,7 @@ private void RegisterCommands(IWindsorContainer container)
560579

561580
private void RegisterCommandsWithPresenters(IWindsorContainer container)
562581
{
563-
if (_initialSettings.SourceControlEnabled)
582+
if (_initialSettings.EnableExperimentalFeatures)
564583
{
565584
container.Register(Component.For<CommandBase>()
566585
.ImplementedBy<SourceControlCommand>()

RetailCoder.VBE/Settings/GeneralSettings.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public interface IGeneralSettings
1414
bool AutoSaveEnabled { get; set; }
1515
int AutoSavePeriod { get; set; }
1616
int MinimumLogLevel { get; set; }
17-
bool SourceControlEnabled { get; set; }
17+
bool EnableExperimentalFeatures { get; set; }
1818
}
1919

2020
[XmlType(AnonymousType = true)]
@@ -48,7 +48,7 @@ public int MinimumLogLevel
4848
}
4949
}
5050

51-
public bool SourceControlEnabled { get; set; }
51+
public bool EnableExperimentalFeatures { get; set; }
5252

5353
public GeneralSettings()
5454
{
@@ -59,7 +59,7 @@ public GeneralSettings()
5959
AutoSaveEnabled = false;
6060
AutoSavePeriod = 10;
6161
MinimumLogLevel = LogLevel.Off.Ordinal;
62-
SourceControlEnabled = false;
62+
EnableExperimentalFeatures = false;
6363
}
6464

6565
public bool Equals(GeneralSettings other)
@@ -72,7 +72,7 @@ public bool Equals(GeneralSettings other)
7272
AutoSaveEnabled == other.AutoSaveEnabled &&
7373
AutoSavePeriod == other.AutoSavePeriod &&
7474
MinimumLogLevel == other.MinimumLogLevel &&
75-
SourceControlEnabled == other.SourceControlEnabled;
75+
EnableExperimentalFeatures == other.EnableExperimentalFeatures;
7676
}
7777
}
7878
}

RetailCoder.VBE/UI/Settings/GeneralSettingsViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private Rubberduck.Settings.GeneralSettings GetCurrentGeneralSettings()
196196
AutoSaveEnabled = AutoSaveEnabled,
197197
AutoSavePeriod = AutoSavePeriod,
198198
MinimumLogLevel = SelectedLogLevel.Ordinal,
199-
SourceControlEnabled = SourceControlEnabled
199+
EnableExperimentalFeatures = SourceControlEnabled
200200
};
201201
}
202202

@@ -210,7 +210,7 @@ private void TransferSettingsToView(IGeneralSettings general, IHotkeySettings ho
210210
AutoSaveEnabled = general.AutoSaveEnabled;
211211
AutoSavePeriod = general.AutoSavePeriod;
212212
SelectedLogLevel = LogLevels.First(l => l.Ordinal == general.MinimumLogLevel);
213-
SourceControlEnabled = general.SourceControlEnabled;
213+
SourceControlEnabled = general.EnableExperimentalFeatures;
214214
}
215215

216216
private void ImportSettings()

Rubberduck.Inspections/Concrete/ConstantNotUsedInspection.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
using Rubberduck.Inspections.Abstract;
66
using Rubberduck.Inspections.Results;
77
using Rubberduck.Parsing;
8+
using Rubberduck.Parsing.Common;
89
using Rubberduck.Parsing.Inspections.Abstract;
910
using Rubberduck.Parsing.Inspections.Resources;
1011
using Rubberduck.Parsing.Symbols;
1112
using Rubberduck.Parsing.VBA;
1213

1314
namespace Rubberduck.Inspections.Concrete
1415
{
16+
[Experimental]
1517
public sealed class ConstantNotUsedInspection : InspectionBase
1618
{
1719
public ConstantNotUsedInspection(RubberduckParserState state)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System;
2+
3+
namespace Rubberduck.Parsing.Common
4+
{
5+
[AttributeUsage(AttributeTargets.Class)]
6+
public class ExperimentalAttribute : Attribute
7+
{
8+
}
9+
}

Rubberduck.Parsing/Rubberduck.Parsing.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
<Compile Include="Binding\ParenthesizedDefaultBinding.cs" />
125125
<Compile Include="Binding\TypeBindingContext.cs" />
126126
<Compile Include="Binding\ExpressionClassification.cs" />
127+
<Compile Include="Common\ExperimentalAttribute.cs" />
127128
<Compile Include="ComReflection\ComAlias.cs" />
128129
<Compile Include="ComReflection\ComBase.cs" />
129130
<Compile Include="ComReflection\ComCoClass.cs" />

RubberduckTests/CodeExplorer/CodeExplorerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,7 @@ private Configuration GetDefaultUnitTestConfig()
21232123

21242124
var generalSettings = new GeneralSettings
21252125
{
2126-
SourceControlEnabled = true
2126+
EnableExperimentalFeatures = true
21272127
};
21282128

21292129
var userSettings = new UserSettings(generalSettings, null, null, null, unitTestSettings, null, null);

RubberduckTests/IoCContainer/IoCRegistrationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void RegistrationOfRubberduckIoCContainerWithSC_NoException()
1717
var vbeBuilder = new MockVbeBuilder();
1818
var ide = vbeBuilder.Build().Object;
1919
var addin = new Mock<IAddIn>().Object;
20-
var initialSettings = new GeneralSettings {SourceControlEnabled = true};
20+
var initialSettings = new GeneralSettings {EnableExperimentalFeatures = true};
2121

2222
using (var container =
2323
new WindsorContainer().Install(new RubberduckIoCInstaller(ide, addin, initialSettings)))
@@ -33,7 +33,7 @@ public void RegistrationOfRubberduckIoCContainerWithoutSC_NoException()
3333
var vbeBuilder = new MockVbeBuilder();
3434
var ide = vbeBuilder.Build().Object;
3535
var addin = new Mock<IAddIn>().Object;
36-
var initialSettings = new GeneralSettings {SourceControlEnabled = false};
36+
var initialSettings = new GeneralSettings {EnableExperimentalFeatures = false};
3737

3838
using (var container =
3939
new WindsorContainer().Install(new RubberduckIoCInstaller(ide, addin, initialSettings)))

RubberduckTests/IoCContainer/IoCResolvingTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void ResolveInspections_NoException()
2020
var vbeBuilder = new MockVbeBuilder();
2121
var ide = vbeBuilder.Build().Object;
2222
var addin = new Mock<IAddIn>().Object;
23-
var initialSettings = new GeneralSettings {SourceControlEnabled = true};
23+
var initialSettings = new GeneralSettings {EnableExperimentalFeatures = true};
2424

2525
IWindsorContainer container = null;
2626
try
@@ -50,7 +50,7 @@ public void ResolveRubberduckParserState_NoException()
5050
var vbeBuilder = new MockVbeBuilder();
5151
var ide = vbeBuilder.Build().Object;
5252
var addin = new Mock<IAddIn>().Object;
53-
var initialSettings = new GeneralSettings { SourceControlEnabled = true };
53+
var initialSettings = new GeneralSettings { EnableExperimentalFeatures = true };
5454

5555
IWindsorContainer container = null;
5656
try

0 commit comments

Comments
 (0)