1010// THE SOFTWARE.
1111//
1212
13+ using System ;
1314using System . Management . Automation . Language ;
1415
1516namespace Microsoft . Windows . PowerShell . ScriptAnalyzer . Generic
@@ -24,7 +25,7 @@ public class DiagnosticRecord
2425 private IScriptExtent extent ;
2526 private string ruleName ;
2627 private DiagnosticSeverity severity ;
27- private string scriptName ;
28+ private string scriptPath ;
2829 private string ruleSuppressionId ;
2930
3031 /// <summary>
@@ -33,7 +34,7 @@ public class DiagnosticRecord
3334 public string Message
3435 {
3536 get { return message ; }
36- set { message = value ; }
37+ protected set { message = string . IsNullOrEmpty ( value ) ? string . Empty : value ; }
3738 }
3839
3940 /// <summary>
@@ -42,7 +43,7 @@ public string Message
4243 public IScriptExtent Extent
4344 {
4445 get { return extent ; }
45- set { extent = value ; }
46+ protected set { extent = value ; }
4647 }
4748
4849 /// <summary>
@@ -51,7 +52,7 @@ public IScriptExtent Extent
5152 public string RuleName
5253 {
5354 get { return ruleName ; }
54- set { ruleName = value ; }
55+ protected set { ruleName = string . IsNullOrEmpty ( value ) ? string . Empty : value ; }
5556 }
5657
5758 /// <summary>
@@ -68,18 +69,16 @@ public DiagnosticSeverity Severity
6869 /// </summary>
6970 public string ScriptName
7071 {
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 ; }
8382 }
8483
8584 /// <summary>
@@ -106,16 +105,28 @@ public DiagnosticRecord()
106105 /// <param name="extent">The place in the script this diagnostic refers to</param>
107106 /// <param name="ruleName">The name of the rule that created this diagnostic</param>
108107 /// <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 )
111110 {
112- Message = string . IsNullOrEmpty ( message ) ? string . Empty : message ;
113- RuleName = string . IsNullOrEmpty ( ruleName ) ? string . Empty : ruleName ;
111+ Message = message ;
112+ RuleName = ruleName ;
114113 Extent = extent ;
115114 Severity = severity ;
116- ScriptName = string . IsNullOrEmpty ( scriptName ) ? string . Empty : scriptName ;
115+ ScriptPath = scriptPath ;
117116 ruleSuppressionId = ruleId ;
118117 }
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+ }
119130 }
120131
121132
0 commit comments