-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCodingRulesHelper.cs
37 lines (31 loc) · 1.08 KB
/
CodingRulesHelper.cs
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
namespace Atc.Rest.ApiGenerator.CLI;
public static class CodingRulesHelper
{
public static bool ShouldScaffoldCodingRules(
string rootPath,
bool disableCodingRules)
{
ArgumentNullException.ThrowIfNull(rootPath);
return !disableCodingRules &&
!HasBuildPropsWithCodingRulesEnabled(rootPath);
}
public static bool IsUsingCodingRules(
string rootPath,
bool disableCodingRules)
{
ArgumentNullException.ThrowIfNull(rootPath);
return !disableCodingRules ||
HasBuildPropsWithCodingRulesEnabled(rootPath);
}
private static bool HasBuildPropsWithCodingRulesEnabled(
string rootPath)
{
var rootDirectoryBuildProps = new FileInfo(Path.Combine(rootPath, AtcCodingRulesUpdater.FileNameDirectoryBuildProps));
if (!rootDirectoryBuildProps.Exists)
{
return false;
}
var fileContent = FileHelper.ReadAllText(rootDirectoryBuildProps);
return fileContent.Contains("<Nullable>enable</Nullable>", StringComparison.Ordinal);
}
}