@@ -61,23 +61,163 @@ private ProcessArgumentBuilder GetArguments(
6161 {
6262 var builder = new ProcessArgumentBuilder ( ) ;
6363
64- builder . Append ( "Cover" ) ;
64+ // Command name - always lowercase 'cover' for both formats
65+ builder . Append ( "cover" ) ;
6566
6667 // Set configuration file if exists.
6768 GetConfigurationFileArgument ( settings ) . CopyTo ( builder ) ;
6869
69- // Get Target executable arguments
70- GetTargetArguments ( context , action ) . CopyTo ( builder ) ;
70+ if ( settings . UseLegacySyntax )
71+ {
72+ // Use legacy format
73+ GetTargetArguments ( context , action ) . CopyTo ( builder ) ;
74+ // Set the output file - legacy format
75+ outputPath = outputPath . MakeAbsolute ( _environment ) ;
76+ builder . AppendSwitch ( "/Output" , "=" , outputPath . FullPath . Quote ( ) ) ;
77+ // Get Coverage arguments - legacy format
78+ GetCoverageArguments ( settings ) . CopyTo ( builder ) ;
79+ // Get base arguments - legacy format
80+ GetArguments ( settings ) . CopyTo ( builder ) ;
81+ }
82+ else
83+ {
84+ // Use new format
85+ GetCoverTargetArguments ( context , action ) . CopyTo ( builder ) ;
86+ // Set the output file - new format
87+ outputPath = outputPath . MakeAbsolute ( _environment ) ;
88+ builder . AppendSwitch ( "--snapshot-output" , outputPath . FullPath . Quote ( ) ) ;
89+ // Get Coverage arguments - new format
90+ GetCoverCoverageArguments ( settings ) . CopyTo ( builder ) ;
91+ // New report options (only available in new format)
92+ if ( settings . JsonReportOutput != null )
93+ {
94+ builder . AppendSwitch ( "--json-report-output" , settings . JsonReportOutput . MakeAbsolute ( _environment ) . FullPath . Quote ( ) ) ;
95+ }
7196
72- // Set the output file.
73- outputPath = outputPath . MakeAbsolute ( _environment ) ;
74- builder . AppendSwitch ( "/Output" , "=" , outputPath . FullPath . Quote ( ) ) ;
97+ if ( settings . JsonReportCoveringTestsScope . HasValue )
98+ {
99+ builder . AppendSwitch ( "--json-report-covering-tests-scope" , settings . JsonReportCoveringTestsScope . Value . ToString ( ) . ToLowerInvariant ( ) . Quote ( ) ) ;
100+ }
75101
76- // Get Coverage arguments
77- GetCoverageArguments ( settings ) . CopyTo ( builder ) ;
102+ if ( settings . XmlReportOutput != null )
103+ {
104+ builder . AppendSwitch ( "--xml-report-output" , settings . XmlReportOutput . MakeAbsolute ( _environment ) . FullPath . Quote ( ) ) ;
105+ }
78106
79- // Get base arguments
80- GetArguments ( settings ) . CopyTo ( builder ) ;
107+ if ( settings . XmlReportCoveringTestsScope . HasValue )
108+ {
109+ builder . AppendSwitch ( "--xml-report-covering-tests-scope" , settings . XmlReportCoveringTestsScope . Value . ToString ( ) . ToLowerInvariant ( ) . Quote ( ) ) ;
110+ }
111+
112+ if ( settings . TemporaryDirectory != null )
113+ {
114+ builder . AppendSwitch ( "--temporary-directory" , settings . TemporaryDirectory . MakeAbsolute ( _environment ) . FullPath . Quote ( ) ) ;
115+ }
116+
117+ if ( settings . UseApi )
118+ {
119+ builder . Append ( "--use-api" ) ;
120+ }
121+
122+ if ( settings . NoNGen )
123+ {
124+ builder . Append ( "--no-ngen" ) ;
125+ }
126+
127+ // Get base arguments - new format
128+ GetCoverArguments ( settings ) . CopyTo ( builder ) ;
129+ }
130+
131+ return builder ;
132+ }
133+
134+ /// <summary>
135+ /// Get arguments from coverage settings for Cover command (using new format).
136+ /// </summary>
137+ /// <param name="settings">The settings.</param>
138+ /// <returns>The process arguments.</returns>
139+ private ProcessArgumentBuilder GetCoverCoverageArguments ( DotCoverCoverageSettings settings )
140+ {
141+ var builder = new ProcessArgumentBuilder ( ) ;
142+
143+ // TargetWorkingDir - using new format for Cover command
144+ if ( settings . TargetWorkingDir != null )
145+ {
146+ builder . AppendSwitch ( "--target-working-directory" , settings . TargetWorkingDir . MakeAbsolute ( _environment ) . FullPath . Quote ( ) ) ;
147+ }
148+
149+ // New filtering options (only available in new format)
150+ if ( settings . ExcludeAssemblies . Count > 0 )
151+ {
152+ var excludeAssemblies = string . Join ( ',' , settings . ExcludeAssemblies ) ;
153+ builder . AppendSwitch ( "--exclude-assemblies" , excludeAssemblies . Quote ( ) ) ;
154+ }
155+
156+ if ( settings . ExcludeAttributes . Count > 0 )
157+ {
158+ var excludeAttributes = string . Join ( ',' , settings . ExcludeAttributes ) ;
159+ builder . AppendSwitch ( "--exclude-attributes" , excludeAttributes . Quote ( ) ) ;
160+ }
161+
162+ if ( settings . ExcludeProcesses . Count > 0 )
163+ {
164+ var excludeProcesses = string . Join ( ',' , settings . ExcludeProcesses ) ;
165+ builder . AppendSwitch ( "--exclude-processes" , excludeProcesses . Quote ( ) ) ;
166+ }
167+
168+ // Legacy filtering options (maintain backward compatibility with old format)
169+ // Scope
170+ if ( settings . Scope . Count > 0 )
171+ {
172+ var scope = string . Join ( ';' , settings . Scope ) ;
173+ builder . AppendSwitch ( "/Scope" , "=" , scope . Quote ( ) ) ;
174+ }
175+
176+ // Filters
177+ if ( settings . Filters . Count > 0 )
178+ {
179+ var filters = string . Join ( ';' , settings . Filters ) ;
180+ builder . AppendSwitch ( "/Filters" , "=" , filters . Quote ( ) ) ;
181+ }
182+
183+ // AttributeFilters
184+ if ( settings . AttributeFilters . Count > 0 )
185+ {
186+ var attributeFilters = string . Join ( ';' , settings . AttributeFilters ) ;
187+ builder . AppendSwitch ( "/AttributeFilters" , "=" , attributeFilters . Quote ( ) ) ;
188+ }
189+
190+ // ProcessFilters
191+ if ( settings . ProcessFilters . Count > 0 )
192+ {
193+ var processFilters = string . Join ( ';' , settings . ProcessFilters ) ;
194+ builder . AppendSwitch ( "/ProcessFilters" , "=" , processFilters . Quote ( ) ) ;
195+ }
196+
197+ // DisableDefaultFilters
198+ if ( settings . DisableDefaultFilters )
199+ {
200+ builder . Append ( "/DisableDefaultFilters" ) ;
201+ }
202+
203+ return builder ;
204+ }
205+
206+ /// <summary>
207+ /// Get arguments from global settings for Cover command (using new format).
208+ /// </summary>
209+ /// <param name="settings">The settings.</param>
210+ /// <returns>The process arguments.</returns>
211+ private ProcessArgumentBuilder GetCoverArguments ( DotCoverSettings settings )
212+ {
213+ var builder = new ProcessArgumentBuilder ( ) ;
214+
215+ // LogFile - using new format for Cover command
216+ if ( settings . LogFile != null )
217+ {
218+ var logFilePath = settings . LogFile . MakeAbsolute ( _environment ) ;
219+ builder . AppendSwitch ( "--log-file" , logFilePath . FullPath . Quote ( ) ) ;
220+ }
81221
82222 return builder ;
83223 }
0 commit comments