Skip to content

Commit aecada3

Browse files
authored
Enable CA1822: Mark private members as static (PowerShell#13897)
1 parent bb78d4b commit aecada3

8 files changed

Lines changed: 11 additions & 10 deletions

File tree

.globalconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ dotnet_diagnostic.CA1820.severity = none
280280
dotnet_diagnostic.CA1821.severity = warning
281281

282282
# CA1822: Mark members as static
283-
dotnet_diagnostic.CA1822.severity = suggestion
283+
dotnet_diagnostic.CA1822.severity = warning
284+
dotnet_code_quality.ca1822.api_surface = private
284285

285286
# CA1823: Avoid unused private fields
286287
dotnet_diagnostic.CA1823.severity = none

src/Microsoft.PowerShell.MarkdownRender/ListBlockRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected override void Write(VT100Renderer renderer, ListBlock obj)
3333
renderer.WriteLine();
3434
}
3535

36-
private void RenderNumberedList(VT100Renderer renderer, ListItemBlock block, int index)
36+
private static void RenderNumberedList(VT100Renderer renderer, ListItemBlock block, int index)
3737
{
3838
// For a numbered list, we need to make sure the index is incremented.
3939
foreach (var line in block)

src/TypeCatalogGen/TypeCatalogGen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ namespace System.Management.Automation
431431
{{
432432
internal partial class PowerShellAssemblyLoadContext
433433
{{
434-
private Dictionary<string, string> InitializeTypeCatalog()
434+
private static Dictionary<string, string> InitializeTypeCatalog()
435435
{{
436436
return new Dictionary<string, string>({0}, StringComparer.OrdinalIgnoreCase) {{";
437437
const string SourceEnd = @"

test/tools/WebListener/Controllers/LinkController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public IActionResult Error()
109109
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
110110
}
111111

112-
private string GetLink(string baseUri, int maxLinks, int linkNumber, string whitespace, string type, string rel)
112+
private static string GetLink(string baseUri, int maxLinks, int linkNumber, string whitespace, string type, string rel)
113113
{
114114
return string.Format(Constants.LinkUriTemplate, baseUri, maxLinks, linkNumber, type, whitespace, rel);
115115
}

test/tools/WebListener/Controllers/ResponseController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public IActionResult Error()
9999
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
100100
}
101101

102-
private List<T> GetSingleOrArray<T>(JToken token)
102+
private static List<T> GetSingleOrArray<T>(JToken token)
103103
{
104104
if (token.HasValues)
105105
{

test/tools/WebListener/Controllers/ResumeController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public IActionResult Error()
9191
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
9292
}
9393

94-
private RangeItemHeaderValue GetRange(string rangeHeader)
94+
private static RangeItemHeaderValue GetRange(string rangeHeader)
9595
{
9696
return RangeHeaderValue.Parse(rangeHeader).Ranges.FirstOrDefault();
9797
}

test/xUnit/csharp/test_FileSystemProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected virtual void Dispose(bool disposing)
5353
}
5454
}
5555

56-
private ExecutionContext GetExecutionContext()
56+
private static ExecutionContext GetExecutionContext()
5757
{
5858
CultureInfo currentCulture = CultureInfo.CurrentCulture;
5959
PSHost hostInterface = new DefaultHost(currentCulture, currentCulture);
@@ -63,7 +63,7 @@ private ExecutionContext GetExecutionContext()
6363
return executionContext;
6464
}
6565

66-
private ProviderInfo GetProvider()
66+
private static ProviderInfo GetProvider()
6767
{
6868
ExecutionContext executionContext = GetExecutionContext();
6969
SessionStateInternal sessionState = new SessionStateInternal(executionContext);

test/xUnit/csharp/test_PSConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public void SetupConfigFile4()
366366
CreateEmptyFile(currentUserConfigFile);
367367
}
368368

369-
private void CreateEmptyFile(string fileName)
369+
private static void CreateEmptyFile(string fileName)
370370
{
371371
File.Create(fileName).Dispose();
372372
}
@@ -382,7 +382,7 @@ public void SetupConfigFile5()
382382
CreateBrokenConfigFile(currentUserConfigFile);
383383
}
384384

385-
private void CreateBrokenConfigFile(string fileName)
385+
private static void CreateBrokenConfigFile(string fileName)
386386
{
387387
File.WriteAllText(fileName, "[abbra");
388388
}

0 commit comments

Comments
 (0)