Skip to content

Commit 8c49772

Browse files
authored
Merge pull request #3985 from MDoerner/AdjustIoCInstaller
Introduces disabled attribute; experimental features extend to commands and menu items; enhances IoC configuration.
2 parents f43b2b1 + 130d6ed commit 8c49772

File tree

8 files changed

+117
-89
lines changed

8 files changed

+117
-89
lines changed

Rubberduck.Core/UI/Command/MenuItems/RefactorExtractMethodCommandMenuItem.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
using System.Drawing;
2+
using Rubberduck.Parsing.Common;
23
using Rubberduck.Parsing.VBA;
34
using Rubberduck.Properties;
45
using Rubberduck.UI.Command.MenuItems.ParentMenus;
56

67
namespace Rubberduck.UI.Command.MenuItems
78
{
9+
#if !DEBUG
10+
[Disabled]
11+
#endif
812
public class RefactorExtractMethodCommandMenuItem : CommandMenuItemBase
913
{
1014
public RefactorExtractMethodCommandMenuItem(CommandBase command)

Rubberduck.Core/UI/Command/MenuItems/RegexSearchReplaceCommandMenuItem.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
using Rubberduck.Parsing.Common;
12
using Rubberduck.UI.Command.MenuItems.ParentMenus;
23

34
namespace Rubberduck.UI.Command.MenuItems
45
{
6+
#if !DEBUG
7+
[Disabled]
8+
#endif
59
public class RegexSearchReplaceCommandMenuItem : CommandMenuItemBase
610
{
711
public RegexSearchReplaceCommandMenuItem(CommandBase command)

Rubberduck.Core/UI/Command/Refactorings/RefactorExtractMethodCommand.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
using Rubberduck.SmartIndenter;
55
using Rubberduck.VBEditor;
66
using System.Collections.Generic;
7+
using Rubberduck.Parsing.Common;
78
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
89

910
namespace Rubberduck.UI.Command.Refactorings
1011
{
12+
#if !DEBUG
13+
[Disabled]
14+
#endif
1115
[ComVisible(false)]
1216
public class RefactorExtractMethodCommand : RefactorCommandBase
1317
{

Rubberduck.Core/UI/Command/RegexSearchReplaceCommand.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
using System.Runtime.InteropServices;
22
using NLog;
33
using Rubberduck.Navigation.RegexSearchReplace;
4+
using Rubberduck.Parsing.Common;
45

56
namespace Rubberduck.UI.Command
67
{
8+
#if !DEBUG
9+
[Disabled]
10+
#endif
711
[ComVisible(false)]
812
public class RegexSearchReplaceCommand : CommandBase
913
{

Rubberduck.Main/Root/RubberduckIoCInstaller.cs

Lines changed: 73 additions & 85 deletions
Large diffs are not rendered by default.

Rubberduck.Main/Root/TypeExtensions.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
using Rubberduck.Parsing.Common;
22
using Rubberduck.Settings;
33
using System;
4-
using System.Collections.Generic;
54
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
85

96
namespace Rubberduck.Root
107
{
118
internal static class TypeExtensions
129
{
13-
internal static bool NotDisabledExperimental(this Type type, GeneralSettings initialSettings)
10+
internal static bool NotDisabledOrExperimental(this Type type, GeneralSettings initialSettings)
11+
{
12+
return type.NotDisabled() && type.NotExperimental(initialSettings);
13+
}
14+
15+
internal static bool NotExperimental(this Type type, GeneralSettings initialSettings)
1416
{
1517
var attribute = type.CustomAttributes.FirstOrDefault(f => f.AttributeType == typeof(ExperimentalAttribute));
1618
var ctorArg = attribute?.ConstructorArguments.Any() == true ? (string)attribute.ConstructorArguments.First().Value : string.Empty;
1719

1820
return attribute == null || initialSettings.EnableExperimentalFeatures.Any(a => a.Key == ctorArg && a.IsEnabled);
1921
}
2022

23+
internal static bool NotDisabled(this Type type)
24+
{
25+
return !Attribute.IsDefined(type, typeof(DisabledAttribute));
26+
}
27+
2128
internal static bool IsBasedOn(this Type type, Type allegedBase)
2229
{
2330
return allegedBase.IsAssignableFrom(type);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
3+
namespace Rubberduck.Parsing.Common
4+
{
5+
[AttributeUsage(AttributeTargets.Class)]
6+
public class DisabledAttribute : Attribute
7+
{
8+
public DisabledAttribute() : this(string.Empty)
9+
{
10+
}
11+
12+
public DisabledAttribute(string resource)
13+
{
14+
}
15+
}
16+
}

Rubberduck.Parsing/Rubberduck.Parsing.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
<Compile Include="Binding\Bindings\ParenthesizedDefaultBinding.cs" />
138138
<Compile Include="Binding\TypeBindingContext.cs" />
139139
<Compile Include="Binding\ExpressionClassification.cs" />
140+
<Compile Include="Common\DisabledAttribute.cs" />
140141
<Compile Include="Inspections\RequiredHostAttribute.cs" />
141142
<Compile Include="ProjectsProviderExtensions.cs" />
142143
<Compile Include="Common\ExperimentalAttribute.cs" />

0 commit comments

Comments
 (0)