Skip to content

Commit d582474

Browse files
author
Kapil Borle
committed
Move configurable property attribute to own file
1 parent 59ccace commit d582474

File tree

3 files changed

+31
-26
lines changed

3 files changed

+31
-26
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
3+
namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic
4+
{
5+
/// <summary>
6+
/// The attribute class to designate if a property is configurable or not.
7+
/// </summary>
8+
[AttributeUsage(AttributeTargets.Property)]
9+
public class ConfigurableRulePropertyAttribute : Attribute
10+
{
11+
/// <summary>
12+
/// Default value of the property that the attribute decorates.
13+
/// </summary>
14+
public object DefaultValue { get; private set; }
15+
16+
/// <summary>
17+
/// Initialize the attribute with the decorated property's default value.
18+
/// </summary>
19+
/// <param name="defaultValue"></param>
20+
public ConfigurableRulePropertyAttribute(object defaultValue)
21+
{
22+
if (defaultValue == null)
23+
{
24+
throw new ArgumentNullException(nameof(defaultValue), Strings.ConfigurableScriptRuleNRE);
25+
}
26+
27+
DefaultValue = defaultValue;
28+
}
29+
}
30+
}

Engine/Generic/ConfigurableScriptRule.cs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -143,30 +143,4 @@ private Object GetDefaultValue(PropertyInfo property)
143143
return ((ConfigurableRulePropertyAttribute)attr).DefaultValue;
144144
}
145145
}
146-
147-
/// <summary>
148-
/// The attribute class to designate if a property is configurable or not.
149-
/// </summary>
150-
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
151-
public class ConfigurableRulePropertyAttribute : Attribute
152-
{
153-
/// <summary>
154-
/// Default value of the property that the attribute decorates.
155-
/// </summary>
156-
public object DefaultValue { get; private set; }
157-
158-
/// <summary>
159-
/// Initialize the attribute with the decorated property's default value.
160-
/// </summary>
161-
/// <param name="defaultValue"></param>
162-
public ConfigurableRulePropertyAttribute(object defaultValue)
163-
{
164-
if (defaultValue == null)
165-
{
166-
throw new ArgumentNullException(nameof(defaultValue), Strings.ConfigurableScriptRuleNRE);
167-
}
168-
169-
DefaultValue = defaultValue;
170-
}
171-
}
172146
}

Engine/ScriptAnalyzerEngine.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<Compile Include="Commands\InvokeScriptAnalyzerCommand.cs" />
7171
<Compile Include="Generic\AvoidCmdletGeneric.cs" />
7272
<Compile Include="Generic\AvoidParameterGeneric.cs" />
73+
<Compile Include="Generic\ConfigurableRuleProperty.cs" />
7374
<Compile Include="Generic\ConfigurableScriptRule.cs" />
7475
<Compile Include="Generic\ModuleDependencyHandler.cs" />
7576
<Compile Include="Generic\CorrectionExtent.cs" />

0 commit comments

Comments
 (0)