3
3
4
4
using System ;
5
5
using System . Collections . Generic ;
6
+ using System . Collections . Immutable ;
6
7
using System . IO ;
7
8
using System . Linq ;
8
9
using System . Threading ;
@@ -32,13 +33,15 @@ private static int Main(string[] args)
32
33
return - 1 ;
33
34
}
34
35
35
- List < string > ruleTypes = new List < string > ( ) ;
36
- List < string > filenames = new List < string > ( ) ;
36
+ var ruleTypes = new List < string > ( ) ;
37
+ var filenames = new List < string > ( ) ;
38
+ var disableCopyright = false ;
39
+ var comparer = StringComparer . OrdinalIgnoreCase ;
37
40
38
41
for ( int i = 1 ; i < args . Length ; i ++ )
39
42
{
40
43
string arg = args [ i ] ;
41
- if ( arg . Equals ( "/file" , StringComparison . InvariantCultureIgnoreCase ) )
44
+ if ( comparer . Equals ( arg , "/file" ) )
42
45
{
43
46
if ( i + 1 < args . Length )
44
47
{
@@ -47,28 +50,35 @@ private static int Main(string[] args)
47
50
i ++ ;
48
51
}
49
52
}
53
+ else if ( comparer . Equals ( arg , "/nocopyright" ) )
54
+ {
55
+ disableCopyright = true ;
56
+ }
50
57
else
51
58
{
52
59
ruleTypes . Add ( arg ) ;
53
60
}
54
61
}
55
62
56
-
57
63
var cts = new CancellationTokenSource ( ) ;
58
64
var ct = cts . Token ;
59
65
60
66
Console . CancelKeyPress += delegate { cts . Cancel ( ) ; } ;
61
67
62
- RunAsync ( projectOrSolutionPath , ruleTypes , filenames , ct ) . Wait ( ct ) ;
68
+ RunAsync ( projectOrSolutionPath , ruleTypes , filenames , disableCopyright , ct ) . Wait ( ct ) ;
63
69
Console . WriteLine ( "Completed formatting." ) ;
64
70
return 0 ;
65
71
}
66
72
67
- private static async Task RunAsync ( string projectOrSolutionPath , IEnumerable < string > ruleTypes , IEnumerable < string > filenames , CancellationToken cancellationToken )
73
+ private static async Task RunAsync ( string projectOrSolutionPath , IEnumerable < string > ruleTypes , IEnumerable < string > filenames , bool disableCopright , CancellationToken cancellationToken )
68
74
{
69
75
var workspace = MSBuildWorkspace . Create ( ) ;
70
76
var engine = FormattingEngine . Create ( ruleTypes , filenames ) ;
71
77
engine . Verbose = true ;
78
+ if ( disableCopright )
79
+ {
80
+ engine . CopyrightHeader = ImmutableArray < string > . Empty ;
81
+ }
72
82
73
83
string extension = Path . GetExtension ( projectOrSolutionPath ) ;
74
84
if ( StringComparer . OrdinalIgnoreCase . Equals ( extension , ".sln" ) )
0 commit comments