@@ -29,7 +29,9 @@ public DiagnosticTestData(
29
29
string ? diagnosticMessage = null ,
30
30
IFormatProvider ? formatProvider = null ,
31
31
string ? equivalenceKey = null ,
32
- bool alwaysVerifyAdditionalLocations = false )
32
+ bool alwaysVerifyAdditionalLocations = false ,
33
+ string ? directoryPath = null ,
34
+ string ? fileName = null )
33
35
{
34
36
Descriptor = descriptor ?? throw new ArgumentNullException ( nameof ( descriptor ) ) ;
35
37
Source = source ?? throw new ArgumentNullException ( nameof ( source ) ) ;
@@ -41,6 +43,12 @@ public DiagnosticTestData(
41
43
EquivalenceKey = equivalenceKey ;
42
44
AlwaysVerifyAdditionalLocations = alwaysVerifyAdditionalLocations ;
43
45
46
+ FileSystemVerifier . VerifyDirectoryPath ( directoryPath ) ;
47
+ DirectoryPath = directoryPath ;
48
+
49
+ FileSystemVerifier . VerifyFileName ( fileName ) ;
50
+ FileName = fileName ;
51
+
44
52
if ( Spans . Length > 1
45
53
&& ! AdditionalSpans . IsEmpty )
46
54
{
@@ -60,7 +68,9 @@ public DiagnosticTestData(
60
68
string ? diagnosticMessage = null ,
61
69
IFormatProvider ? formatProvider = null ,
62
70
string ? equivalenceKey = null ,
63
- bool alwaysVerifyAdditionalLocations = false )
71
+ bool alwaysVerifyAdditionalLocations = false ,
72
+ string ? directoryPath = null ,
73
+ string ? fileName = null )
64
74
{
65
75
Source = source ?? throw new ArgumentNullException ( nameof ( source ) ) ;
66
76
Spans = spans ? . ToImmutableArray ( ) ?? ImmutableArray < TextSpan > . Empty ;
@@ -70,6 +80,13 @@ public DiagnosticTestData(
70
80
FormatProvider = formatProvider ;
71
81
EquivalenceKey = equivalenceKey ;
72
82
AlwaysVerifyAdditionalLocations = alwaysVerifyAdditionalLocations ;
83
+
84
+ FileSystemVerifier . VerifyDirectoryPath ( directoryPath ) ;
85
+ DirectoryPath = directoryPath ;
86
+
87
+ FileSystemVerifier . VerifyFileName ( fileName ) ;
88
+ FileName = fileName ;
89
+
73
90
Descriptor = null ! ;
74
91
75
92
if ( Spans . Length > 1
@@ -89,7 +106,9 @@ internal DiagnosticTestData(DiagnosticTestData other)
89
106
diagnosticMessage : other . DiagnosticMessage ,
90
107
formatProvider : other . FormatProvider ,
91
108
equivalenceKey : other . EquivalenceKey ,
92
- alwaysVerifyAdditionalLocations : other . AlwaysVerifyAdditionalLocations )
109
+ alwaysVerifyAdditionalLocations : other . AlwaysVerifyAdditionalLocations ,
110
+ directoryPath : other . DirectoryPath ,
111
+ fileName : other . FileName )
93
112
{
94
113
}
95
114
#pragma warning restore CS0618 // Type or member is obsolete
@@ -143,6 +162,16 @@ internal DiagnosticTestData(DiagnosticTestData other)
143
162
/// </summary>
144
163
public bool AlwaysVerifyAdditionalLocations { get ; }
145
164
165
+ /// <summary>
166
+ /// Gets the relative directory path.
167
+ /// </summary>
168
+ public string ? DirectoryPath { get ; }
169
+
170
+ /// <summary>
171
+ /// Gets the file name.
172
+ /// </summary>
173
+ public string ? FileName { get ; }
174
+
146
175
internal ImmutableArray < Diagnostic > GetDiagnostics ( DiagnosticDescriptor descriptor , SyntaxTree tree )
147
176
{
148
177
if ( Spans . IsEmpty )
0 commit comments