Skip to content

Commit 8e86f9b

Browse files
committed
Fix CA1822 (members that could be static but aren’t)
1 parent 27df69b commit 8e86f9b

28 files changed

+78
-78
lines changed

src/PowerShellEditorServices.Hosting/EditorServicesLoader.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public void Dispose()
226226
// This is not high priority, since the PSES process shouldn't be reused
227227
}
228228

229-
private void LoadEditorServices()
229+
private static void LoadEditorServices()
230230
{
231231
// This must be in its own method, since the actual load happens when the calling method is called
232232
// The call within this method is therefore a total no-op
@@ -317,7 +317,7 @@ private void LogHostInformation()
317317
LogOperatingSystemDetails();
318318
}
319319

320-
private string GetPSOutputEncoding()
320+
private static string GetPSOutputEncoding()
321321
{
322322
using (var pwsh = SMA.PowerShell.Create())
323323
{
@@ -346,7 +346,7 @@ private void LogOperatingSystemDetails()
346346
");
347347
}
348348

349-
private string GetOSArchitecture()
349+
private static string GetOSArchitecture()
350350
{
351351
#if CoreCLR
352352
if (Environment.OSVersion.Platform != PlatformID.Win32NT)

src/PowerShellEditorServices.VSCode/CustomViews/HtmlContentView.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public async Task SetContentAsync(HtmlContent htmlContent)
3939
new HtmlContent()
4040
{
4141
BodyContent = htmlContent.BodyContent,
42-
JavaScriptPaths = this.GetUriPaths(htmlContent.JavaScriptPaths),
43-
StyleSheetPaths = this.GetUriPaths(htmlContent.StyleSheetPaths)
42+
JavaScriptPaths = HtmlContentView.GetUriPaths(htmlContent.JavaScriptPaths),
43+
StyleSheetPaths = HtmlContentView.GetUriPaths(htmlContent.StyleSheetPaths)
4444
};
4545

4646
await languageServer.SendRequestAsync(
@@ -65,7 +65,7 @@ await languageServer.SendRequestAsync(
6565
).ConfigureAwait(false);
6666
}
6767

68-
private string[] GetUriPaths(string[] filePaths)
68+
private static string[] GetUriPaths(string[] filePaths)
6969
{
7070
return
7171
filePaths?

src/PowerShellEditorServices/Extensions/Api/EditorExtensionServiceProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public object GetService(Type serviceType)
156156
/// In .NET Framework, this returns null.
157157
/// </summary>
158158
/// <returns>The assembly load context used for loading PSES, or null in .NET Framework.</returns>
159-
public object GetPsesAssemblyLoadContext()
159+
public static object GetPsesAssemblyLoadContext()
160160
{
161161
if (!VersionUtils.IsNetCore)
162162
{
@@ -172,7 +172,7 @@ public object GetPsesAssemblyLoadContext()
172172
/// </summary>
173173
/// <param name="assemblyPath">The absolute path of the assembly to load.</param>
174174
/// <returns>The loaded assembly object.</returns>
175-
public Assembly LoadAssemblyInPsesLoadContext(string assemblyPath)
175+
public static Assembly LoadAssemblyInPsesLoadContext(string assemblyPath)
176176
{
177177
if (!VersionUtils.IsNetCore)
178178
{

src/PowerShellEditorServices/Extensions/Api/WorkspaceService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public IReadOnlyList<IEditorScriptFile> GetOpenedFiles()
147147
return files.AsReadOnly();
148148
}
149149

150-
private IEditorScriptFile GetEditorFileFromScriptFile(ScriptFile file)
150+
private static IEditorScriptFile GetEditorFileFromScriptFile(ScriptFile file)
151151
{
152152
return new EditorScriptFile(file);
153153
}

src/PowerShellEditorServices/Services/Analysis/PssaCmdletAnalysisEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ private PowerShellResult InvokePowerShell(PSCommand command)
362362
/// </summary>
363363
/// <param name="powershell">The PowerShell instance to execute.</param>
364364
/// <returns>The output of PowerShell execution.</returns>
365-
private Collection<PSObject> InvokePowerShellWithModulePathPreservation(System.Management.Automation.PowerShell powershell)
365+
private static Collection<PSObject> InvokePowerShellWithModulePathPreservation(System.Management.Automation.PowerShell powershell)
366366
{
367367
using (PSModulePathPreserver.Take())
368368
{

src/PowerShellEditorServices/Services/CodeLens/PesterCodeLensProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public PesterCodeLensProvider(ConfigurationService configurationService)
4242
/// <param name="pesterSymbol">The Pester symbol to get CodeLenses for.</param>
4343
/// <param name="scriptFile">The script file the Pester symbol comes from.</param>
4444
/// <returns>All CodeLenses for the given Pester symbol.</returns>
45-
private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile scriptFile)
45+
private static CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile scriptFile)
4646
{
4747
string word = pesterSymbol.Command == PesterCommandType.It ? "test" : "tests";
4848
var codeLensResults = new CodeLens[]

src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile)
8686
ScriptFile[] references = _workspaceService.ExpandScriptReferences(
8787
scriptFile);
8888

89-
SymbolReference foundSymbol = _symbolsService.FindFunctionDefinitionAtLocation(
89+
SymbolReference foundSymbol = SymbolsService.FindFunctionDefinitionAtLocation(
9090
scriptFile,
9191
codeLens.Range.Start.Line + 1,
9292
codeLens.Range.Start.Character + 1);

src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ private async Task FetchStackFramesAsync(string scriptNameOverride)
856856
}
857857
}
858858

859-
private string TrimScriptListingLine(PSObject scriptLineObj, ref int prefixLength)
859+
private static string TrimScriptListingLine(PSObject scriptLineObj, ref int prefixLength)
860860
{
861861
string scriptLine = scriptLineObj.ToString();
862862

@@ -908,7 +908,7 @@ await this.powerShellContext.ExecuteCommandAsync<PSObject>(
908908
string.Join(
909909
Environment.NewLine,
910910
scriptListingLines
911-
.Select(o => this.TrimScriptListingLine(o, ref linePrefixLength))
911+
.Select(o => DebugService.TrimScriptListingLine(o, ref linePrefixLength))
912912
.Where(s => s != null));
913913

914914
this.temporaryScriptListingPath =

src/PowerShellEditorServices/Services/PowerShellContext/Console/ChoicePromptHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public Task<int> PromptForChoiceAsync(
144144
throw new TaskCanceledException(task);
145145
}
146146

147-
return this.GetSingleResult(task.GetAwaiter().GetResult());
147+
return ChoicePromptHandler.GetSingleResult(task.GetAwaiter().GetResult());
148148
}));
149149
}
150150

@@ -335,7 +335,7 @@ protected override void OnPromptCancelled()
335335

336336
#region Private Methods
337337

338-
private int GetSingleResult(int[] choiceArray)
338+
private static int GetSingleResult(int[] choiceArray)
339339
{
340340
return
341341
choiceArray != null

src/PowerShellEditorServices/Services/PowerShellContext/Console/ConsoleReadLine.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public Task<string> ReadSimpleLineAsync(CancellationToken cancellationToken)
4242
return this.ReadLineAsync(false, cancellationToken);
4343
}
4444

45-
public async Task<SecureString> ReadSecureLineAsync(CancellationToken cancellationToken)
45+
public async static Task<SecureString> ReadSecureLineAsync(CancellationToken cancellationToken)
4646
{
4747
SecureString secureString = new SecureString();
4848

@@ -253,7 +253,7 @@ internal async Task<string> InvokeLegacyReadLineAsync(bool isCommandLine, Cancel
253253
if (completion != null)
254254
{
255255
currentCursorIndex =
256-
this.InsertInput(
256+
ConsoleReadLine.InsertInput(
257257
inputLine,
258258
promptStartCol,
259259
promptStartRow,
@@ -271,7 +271,7 @@ internal async Task<string> InvokeLegacyReadLineAsync(bool isCommandLine, Cancel
271271
if (currentCursorIndex > 0)
272272
{
273273
currentCursorIndex =
274-
this.MoveCursorToIndex(
274+
ConsoleReadLine.MoveCursorToIndex(
275275
promptStartCol,
276276
promptStartRow,
277277
consoleWidth,
@@ -283,7 +283,7 @@ internal async Task<string> InvokeLegacyReadLineAsync(bool isCommandLine, Cancel
283283
currentCompletion = null;
284284

285285
currentCursorIndex =
286-
this.MoveCursorToIndex(
286+
ConsoleReadLine.MoveCursorToIndex(
287287
promptStartCol,
288288
promptStartRow,
289289
consoleWidth,
@@ -296,7 +296,7 @@ internal async Task<string> InvokeLegacyReadLineAsync(bool isCommandLine, Cancel
296296
if (currentCursorIndex < inputLine.Length)
297297
{
298298
currentCursorIndex =
299-
this.MoveCursorToIndex(
299+
ConsoleReadLine.MoveCursorToIndex(
300300
promptStartCol,
301301
promptStartRow,
302302
consoleWidth,
@@ -308,7 +308,7 @@ internal async Task<string> InvokeLegacyReadLineAsync(bool isCommandLine, Cancel
308308
currentCompletion = null;
309309

310310
currentCursorIndex =
311-
this.MoveCursorToIndex(
311+
ConsoleReadLine.MoveCursorToIndex(
312312
promptStartCol,
313313
promptStartRow,
314314
consoleWidth,
@@ -342,7 +342,7 @@ internal async Task<string> InvokeLegacyReadLineAsync(bool isCommandLine, Cancel
342342
historyIndex--;
343343

344344
currentCursorIndex =
345-
this.InsertInput(
345+
ConsoleReadLine.InsertInput(
346346
inputLine,
347347
promptStartCol,
348348
promptStartRow,
@@ -367,7 +367,7 @@ internal async Task<string> InvokeLegacyReadLineAsync(bool isCommandLine, Cancel
367367
if (historyIndex < currentHistory.Count)
368368
{
369369
currentCursorIndex =
370-
this.InsertInput(
370+
ConsoleReadLine.InsertInput(
371371
inputLine,
372372
promptStartCol,
373373
promptStartRow,
@@ -379,7 +379,7 @@ internal async Task<string> InvokeLegacyReadLineAsync(bool isCommandLine, Cancel
379379
else if (historyIndex == currentHistory.Count)
380380
{
381381
currentCursorIndex =
382-
this.InsertInput(
382+
ConsoleReadLine.InsertInput(
383383
inputLine,
384384
promptStartCol,
385385
promptStartRow,
@@ -396,7 +396,7 @@ internal async Task<string> InvokeLegacyReadLineAsync(bool isCommandLine, Cancel
396396
historyIndex = currentHistory != null ? currentHistory.Count : -1;
397397

398398
currentCursorIndex =
399-
this.InsertInput(
399+
ConsoleReadLine.InsertInput(
400400
inputLine,
401401
promptStartCol,
402402
promptStartRow,
@@ -412,7 +412,7 @@ internal async Task<string> InvokeLegacyReadLineAsync(bool isCommandLine, Cancel
412412
if (currentCursorIndex > 0)
413413
{
414414
currentCursorIndex =
415-
this.InsertInput(
415+
ConsoleReadLine.InsertInput(
416416
inputLine,
417417
promptStartCol,
418418
promptStartRow,
@@ -430,7 +430,7 @@ internal async Task<string> InvokeLegacyReadLineAsync(bool isCommandLine, Cancel
430430
if (currentCursorIndex < inputLine.Length)
431431
{
432432
currentCursorIndex =
433-
this.InsertInput(
433+
ConsoleReadLine.InsertInput(
434434
inputLine,
435435
promptStartCol,
436436
promptStartRow,
@@ -471,7 +471,7 @@ internal async Task<string> InvokeLegacyReadLineAsync(bool isCommandLine, Cancel
471471
currentCompletion = null;
472472

473473
currentCursorIndex =
474-
this.InsertInput(
474+
ConsoleReadLine.InsertInput(
475475
inputLine,
476476
promptStartCol,
477477
promptStartRow,
@@ -490,7 +490,7 @@ internal async Task<string> InvokeLegacyReadLineAsync(bool isCommandLine, Cancel
490490
}
491491

492492
// TODO: Is this used?
493-
private int CalculateIndexFromCursor(
493+
private static int CalculateIndexFromCursor(
494494
int promptStartCol,
495495
int promptStartRow,
496496
int consoleWidth)
@@ -500,7 +500,7 @@ private int CalculateIndexFromCursor(
500500
ConsoleProxy.GetCursorLeft() - promptStartCol;
501501
}
502502

503-
private void CalculateCursorFromIndex(
503+
private static void CalculateCursorFromIndex(
504504
int promptStartCol,
505505
int promptStartRow,
506506
int consoleWidth,
@@ -513,7 +513,7 @@ private void CalculateCursorFromIndex(
513513
cursorCol = cursorCol % consoleWidth;
514514
}
515515

516-
private int InsertInput(
516+
private static int InsertInput(
517517
StringBuilder inputLine,
518518
int promptStartCol,
519519
int promptStartRow,
@@ -532,7 +532,7 @@ private int InsertInput(
532532
}
533533

534534
// Move the cursor to the new insertion point
535-
this.MoveCursorToIndex(
535+
ConsoleReadLine.MoveCursorToIndex(
536536
promptStartCol,
537537
promptStartRow,
538538
consoleWidth,
@@ -581,7 +581,7 @@ private int InsertInput(
581581
{
582582
// Move the cursor to the final position
583583
return
584-
this.MoveCursorToIndex(
584+
ConsoleReadLine.MoveCursorToIndex(
585585
promptStartCol,
586586
promptStartRow,
587587
consoleWidth,
@@ -593,13 +593,13 @@ private int InsertInput(
593593
}
594594
}
595595

596-
private int MoveCursorToIndex(
596+
private static int MoveCursorToIndex(
597597
int promptStartCol,
598598
int promptStartRow,
599599
int consoleWidth,
600600
int newCursorIndex)
601601
{
602-
this.CalculateCursorFromIndex(
602+
ConsoleReadLine.CalculateCursorFromIndex(
603603
promptStartCol,
604604
promptStartRow,
605605
consoleWidth,

src/PowerShellEditorServices/Services/PowerShellContext/Console/TerminalInputPromptHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected override async Task<string> ReadInputStringAsync(CancellationToken can
6666
/// <returns>A Task that can be awaited to get the user's response.</returns>
6767
protected override async Task<SecureString> ReadSecureStringAsync(CancellationToken cancellationToken)
6868
{
69-
SecureString secureString = await this.consoleReadLine.ReadSecureLineAsync(cancellationToken).ConfigureAwait(false);
69+
SecureString secureString = await ConsoleReadLine.ReadSecureLineAsync(cancellationToken).ConfigureAwait(false);
7070
this.hostOutput.WriteOutput(string.Empty);
7171

7272
return secureString;

src/PowerShellEditorServices/Services/PowerShellContext/Console/UnixConsoleOperations.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ private async Task<bool> ShortWaitForKeyAsync(CancellationToken cancellationToke
243243
return false;
244244
}
245245

246-
private bool SpinUntilKeyAvailable(int millisecondsTimeout, CancellationToken cancellationToken)
246+
private static bool SpinUntilKeyAvailable(int millisecondsTimeout, CancellationToken cancellationToken)
247247
{
248248
return SpinWait.SpinUntil(
249249
() =>
@@ -254,7 +254,7 @@ private bool SpinUntilKeyAvailable(int millisecondsTimeout, CancellationToken ca
254254
millisecondsTimeout);
255255
}
256256

257-
private Task<bool> SpinUntilKeyAvailableAsync(int millisecondsTimeout, CancellationToken cancellationToken)
257+
private static Task<bool> SpinUntilKeyAvailableAsync(int millisecondsTimeout, CancellationToken cancellationToken)
258258
{
259259
return Task<bool>.Factory.StartNew(
260260
() => SpinWait.SpinUntil(
@@ -267,7 +267,7 @@ private Task<bool> SpinUntilKeyAvailableAsync(int millisecondsTimeout, Cancellat
267267
millisecondsTimeout));
268268
}
269269

270-
private bool IsKeyAvailable(CancellationToken cancellationToken)
270+
private static bool IsKeyAvailable(CancellationToken cancellationToken)
271271
{
272272
s_stdInHandle.Wait(cancellationToken);
273273
try
@@ -280,7 +280,7 @@ private bool IsKeyAvailable(CancellationToken cancellationToken)
280280
}
281281
}
282282

283-
private async Task<bool> IsKeyAvailableAsync(CancellationToken cancellationToken)
283+
private async static Task<bool> IsKeyAvailableAsync(CancellationToken cancellationToken)
284284
{
285285
await s_stdInHandle.WaitAsync(cancellationToken).ConfigureAwait(false);
286286
try

src/PowerShellEditorServices/Services/PowerShellContext/Handlers/GetCommentHelpHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public async Task<CommentHelpRequestResult> Handle(CommentHelpRequestParams requ
4242

4343
int triggerLine = request.TriggerPosition.Line + 1;
4444

45-
FunctionDefinitionAst functionDefinitionAst = _symbolsService.GetFunctionDefinitionForHelpComment(
45+
FunctionDefinitionAst functionDefinitionAst = SymbolsService.GetFunctionDefinitionForHelpComment(
4646
scriptFile,
4747
triggerLine,
4848
out string helpLocation);

src/PowerShellEditorServices/Services/PowerShellContext/RemoteFileManagerService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ public async Task<string> FetchRemoteFileAsync(
319319

320320
if (fileContent != null)
321321
{
322-
this.StoreRemoteFile(localFilePath, fileContent, pathMappings);
322+
RemoteFileManagerService.StoreRemoteFile(localFilePath, fileContent, pathMappings);
323323
}
324324
else
325325
{
@@ -475,15 +475,15 @@ private string StoreRemoteFile(
475475
RemotePathMappings pathMappings = this.GetPathMappings(runspaceDetails);
476476
string localFilePath = pathMappings.GetMappedPath(remoteFilePath);
477477

478-
this.StoreRemoteFile(
478+
RemoteFileManagerService.StoreRemoteFile(
479479
localFilePath,
480480
fileContent,
481481
pathMappings);
482482

483483
return localFilePath;
484484
}
485485

486-
private void StoreRemoteFile(
486+
private static void StoreRemoteFile(
487487
string localFilePath,
488488
byte[] fileContent,
489489
RemotePathMappings pathMappings)

0 commit comments

Comments
 (0)