Skip to content

Commit a2445ac

Browse files
committed
CA1810: Initialize reference type static fields inline
1 parent f6acbd2 commit a2445ac

File tree

4 files changed

+9
-24
lines changed

4 files changed

+9
-24
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,6 @@ dotnet_diagnostic.CA1822.severity = warning
172172

173173
# CA2208: Instantiate argument exceptions correctly
174174
dotnet_diagnostic.CA2208.severity = warning
175+
176+
# CA1810: Initialize reference type static fields inline
177+
dotnet_diagnostic.CA1810.severity = warning

src/GitVersion.Core/Extensions/StringExtensions.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,8 @@ namespace GitVersion.Extensions
99
{
1010
public static class StringExtensions
1111
{
12-
private static readonly string[] Trues;
13-
private static readonly string[] Falses;
14-
15-
16-
static StringExtensions()
17-
{
18-
Trues = new[]
19-
{
20-
"1",
21-
"true"
22-
};
23-
24-
Falses = new[]
25-
{
26-
"0",
27-
"false"
28-
};
29-
}
12+
private static readonly string[] Trues = new[] { "1", "true" };
13+
private static readonly string[] Falses = new[] { "0", "false" };
3014

3115
public static bool IsTrue(this string value) => Trues.Contains(value, StringComparer.OrdinalIgnoreCase);
3216

src/GitVersion.Core/Logging/Disposable.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ namespace GitVersion.Logging
44
{
55
public static class Disposable
66
{
7-
static Disposable() => Empty = Create(() => { });
8-
97
public static IDisposable Create(Action disposer) => new AnonymousDisposable(disposer);
108

11-
public static readonly IDisposable Empty;
9+
public static readonly IDisposable Empty = Create(() => { });
1210

1311
private sealed class AnonymousDisposable : IDisposable
1412
{

src/GitVersion.MsBuild/Helpers/FileHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ public static class FileHelper
1515
{ ".vb", VisualBasicFileContainsVersionAttribute }
1616
};
1717

18-
public static string TempPath;
18+
public static string TempPath = MakeAndGetTempPath();
1919

20-
static FileHelper()
20+
private static string MakeAndGetTempPath()
2121
{
22-
TempPath = Path.Combine(Path.GetTempPath(), "GitVersionTask");
2322
Directory.CreateDirectory(TempPath);
23+
return Path.Combine(Path.GetTempPath(), "GitVersionTask");
2424
}
2525

2626
public static void DeleteTempFiles()

0 commit comments

Comments
 (0)