forked from Unity-Technologies/com.unity.netcode.gameobjects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
66 lines (60 loc) · 2.77 KB
/
Program.cs
File metadata and controls
66 lines (60 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System;
using System.IO;
using System.Diagnostics;
internal static class Program
{
/// <summary>
/// C# coding standards tool for Netcode that relies on `.editorconfig` ruleset and `dotnet format` tool
/// </summary>
/// <param name="check">Check for standards issues (will not change files)</param>
/// <param name="fix">Try to fix standards issues (could change files)</param>
/// <param name="project">Target project folder</param>
/// <param name="pattern">Search pattern string</param>
/// <param name="verbosity">Logs verbosity level</param>
private static int Main(
bool check = false, bool fix = false,
string project = "testproject",
string pattern = "*.sln",
string verbosity = "normal")
{
if (check && fix)
{
Console.WriteLine($"FAILED: Please use --{nameof(check)} or --{nameof(fix)} individually, not both at the same time");
return 1;
}
if (!check && !fix)
{
Console.WriteLine($"FAILED: Please use at least one of --{nameof(check)} or --{nameof(fix)} workflows");
return 2;
}
foreach (var file in Directory.GetFiles(project, pattern))
{
var procInfo = new ProcessStartInfo("dotnet");
procInfo.Arguments = check
? $"format {file} whitespace --no-restore --verify-no-changes --verbosity {verbosity}"
: $"format {file} whitespace --no-restore --verbosity {verbosity}";
Console.WriteLine($"######## START -> {(check ? "check" : "fix")} whitespace issues");
var whitespace = Process.Start(procInfo);
whitespace.WaitForExit();
if (whitespace.ExitCode != 0)
{
Console.WriteLine("######## FAILED -> found whitespace issues (see details above)");
return whitespace.ExitCode;
}
Console.WriteLine("######## SUCCEEDED -> no whitespace issues");
procInfo.Arguments = check
? $"format {file} style --severity error --no-restore --verify-no-changes --verbosity {verbosity}"
: $"format {file} style --severity error --no-restore --verbosity {verbosity}";
Console.WriteLine($"######## START -> {(check ? "check" : "fix")} style/naming issues");
var style = Process.Start(procInfo);
style.WaitForExit();
if (style.ExitCode != 0)
{
Console.WriteLine("######## FAILED -> found style/naming issues (see details above)");
return style.ExitCode;
}
Console.WriteLine("######## SUCCEEDED -> no style/naming issues");
}
return 0;
}
}