10
10
// THE SOFTWARE.
11
11
//
12
12
13
+ using System ;
13
14
using System . Management . Automation . Language ;
14
15
15
16
namespace Microsoft . Windows . PowerShell . ScriptAnalyzer . Generic
@@ -24,7 +25,7 @@ public class DiagnosticRecord
24
25
private IScriptExtent extent ;
25
26
private string ruleName ;
26
27
private DiagnosticSeverity severity ;
27
- private string scriptName ;
28
+ private string scriptPath ;
28
29
private string ruleSuppressionId ;
29
30
30
31
/// <summary>
@@ -33,7 +34,7 @@ public class DiagnosticRecord
33
34
public string Message
34
35
{
35
36
get { return message ; }
36
- set { message = value ; }
37
+ protected set { message = string . IsNullOrEmpty ( value ) ? string . Empty : value ; }
37
38
}
38
39
39
40
/// <summary>
@@ -42,7 +43,7 @@ public string Message
42
43
public IScriptExtent Extent
43
44
{
44
45
get { return extent ; }
45
- set { extent = value ; }
46
+ protected set { extent = value ; }
46
47
}
47
48
48
49
/// <summary>
@@ -51,7 +52,7 @@ public IScriptExtent Extent
51
52
public string RuleName
52
53
{
53
54
get { return ruleName ; }
54
- set { ruleName = value ; }
55
+ protected set { ruleName = string . IsNullOrEmpty ( value ) ? string . Empty : value ; }
55
56
}
56
57
57
58
/// <summary>
@@ -68,18 +69,16 @@ public DiagnosticSeverity Severity
68
69
/// </summary>
69
70
public string ScriptName
70
71
{
71
- get { return scriptName ; }
72
- //Trim down to the leaf element of the filePath and pass it to Diagnostic Record
73
- set {
74
- if ( ! string . IsNullOrWhiteSpace ( value ) )
75
- {
76
- scriptName = System . IO . Path . GetFileName ( value ) ;
77
- }
78
- else
79
- {
80
- scriptName = string . Empty ;
81
- }
82
- }
72
+ get { return string . IsNullOrEmpty ( scriptPath ) ? string . Empty : System . IO . Path . GetFileName ( scriptPath ) ; }
73
+ }
74
+
75
+ /// <summary>
76
+ /// Returns the path of the script.
77
+ /// </summary>
78
+ public string ScriptPath
79
+ {
80
+ get { return scriptPath ; }
81
+ protected set { scriptPath = string . IsNullOrEmpty ( value ) ? string . Empty : value ; }
83
82
}
84
83
85
84
/// <summary>
@@ -106,16 +105,28 @@ public DiagnosticRecord()
106
105
/// <param name="extent">The place in the script this diagnostic refers to</param>
107
106
/// <param name="ruleName">The name of the rule that created this diagnostic</param>
108
107
/// <param name="severity">The severity of this diagnostic</param>
109
- /// <param name="scriptName">The name of the script file being analyzed</param>
110
- public DiagnosticRecord ( string message , IScriptExtent extent , string ruleName , DiagnosticSeverity severity , string scriptName , string ruleId = null )
108
+ /// <param name="scriptName">The path of the script file being analyzed</param>
109
+ public DiagnosticRecord ( string message , IScriptExtent extent , string ruleName , DiagnosticSeverity severity , string scriptPath , string ruleId = null )
111
110
{
112
- Message = string . IsNullOrEmpty ( message ) ? string . Empty : message ;
113
- RuleName = string . IsNullOrEmpty ( ruleName ) ? string . Empty : ruleName ;
111
+ Message = message ;
112
+ RuleName = ruleName ;
114
113
Extent = extent ;
115
114
Severity = severity ;
116
- ScriptName = string . IsNullOrEmpty ( scriptName ) ? string . Empty : scriptName ;
115
+ ScriptPath = scriptPath ;
117
116
ruleSuppressionId = ruleId ;
118
117
}
118
+
119
+ /// <summary>
120
+ /// Copy Constructor
121
+ /// </summary>
122
+ /// <param name="record"></param>
123
+ public DiagnosticRecord ( DiagnosticRecord diagnosticRecord )
124
+ {
125
+ if ( diagnosticRecord == null )
126
+ {
127
+ throw new ArgumentNullException ( "diagnosticRecord" ) ;
128
+ }
129
+ }
119
130
}
120
131
121
132
0 commit comments