Skip to content

Commit 07df16a

Browse files
committed
Fix numerous .NET warnings
1 parent 68f6f8c commit 07df16a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+131
-136
lines changed

src/PowerShellEditorServices.Hosting/EditorServicesLoader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public Task LoadAndRunEditorServicesAsync()
213213
_editorServicesRunner = new EditorServicesRunner(_logger, _hostConfig, _sessionFileWriter, _loggersToUnsubscribe);
214214

215215
// The trigger method for Editor Services
216-
return Task.Run(_editorServicesRunner.RunUntilShutdown);
216+
return Task.Run(_editorServicesRunner.RunUntilShutdownAsync);
217217
}
218218

219219
public void Dispose()
@@ -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.Hosting/Internal/EditorServicesRunner.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ public EditorServicesRunner(
5454
/// TODO: Use "Async" suffix in names of methods that return an awaitable type.
5555
/// </remarks>
5656
/// <returns>A task that ends when Editor Services shuts down.</returns>
57-
public Task RunUntilShutdown()
57+
public Task RunUntilShutdownAsync()
5858
{
5959
// Start Editor Services (see function below)
60-
Task runAndAwaitShutdown = CreateEditorServicesAndRunUntilShutdown();
60+
Task runAndAwaitShutdown = CreateEditorServicesAndRunUntilShutdownAsync();
6161

6262
// Now write the session file
6363
_logger.Log(PsesLogLevel.Diagnostic, "Writing session file");
@@ -113,17 +113,17 @@ public void Dispose()
113113
/// </description>
114114
/// </item>
115115
/// <item>
116-
/// <term><see cref="RunUntilShutdown"></term>
116+
/// <term><see cref="RunUntilShutdownAsync"></term>
117117
/// <description>Task which opens a logfile then returns this task.</description>
118118
/// </item>
119119
/// <item>
120-
/// <term><see cref="CreateEditorServicesAndRunUntilShutdown"></term>
120+
/// <term><see cref="CreateEditorServicesAndRunUntilShutdownAsync"></term>
121121
/// <description>This task!</description>
122122
/// </item>
123123
/// </list>
124124
/// </remarks>
125125
/// <returns>A task that ends when Editor Services shuts down.</returns>
126-
private async Task CreateEditorServicesAndRunUntilShutdown()
126+
private async Task CreateEditorServicesAndRunUntilShutdownAsync()
127127
{
128128
try
129129
{
@@ -177,15 +177,15 @@ private async Task CreateEditorServicesAndRunUntilShutdown()
177177
if (creatingDebugServer)
178178
{
179179
// We don't need to wait for this to start, since we instead wait for it to complete later
180-
debugServerStart = StartDebugServer(debugServerCreation);
180+
debugServerStart = StartDebugServerAsync(debugServerCreation);
181181
}
182182

183183
await languageServerStart.ConfigureAwait(false);
184184
if (debugServerStart != null)
185185
{
186186
await debugServerStart.ConfigureAwait(false);
187187
}
188-
await languageServer.WaitForShutdown().ConfigureAwait(false);
188+
await languageServer.WaitForShutdownAsync().ConfigureAwait(false);
189189
}
190190
finally
191191
{
@@ -201,10 +201,10 @@ private async Task RunTempDebugSessionAsync(HostStartupInfo hostDetails)
201201
_logger.Log(PsesLogLevel.Verbose, "Debug server created");
202202
await debugServer.StartAsync().ConfigureAwait(false);
203203
_logger.Log(PsesLogLevel.Verbose, "Debug server started");
204-
await debugServer.WaitForShutdown().ConfigureAwait(false);
204+
await debugServer.WaitForShutdownAsync().ConfigureAwait(false);
205205
}
206206

207-
private async Task StartDebugServer(Task<PsesDebugServer> debugServerCreation)
207+
private async Task StartDebugServerAsync(Task<PsesDebugServer> debugServerCreation)
208208
{
209209
PsesDebugServer debugServer = await debugServerCreation.ConfigureAwait(false);
210210

@@ -226,7 +226,7 @@ private Task RestartDebugServerAsync(PsesDebugServer debugServer, bool usePSRead
226226
{
227227
_logger.Log(PsesLogLevel.Diagnostic, "Restarting debug server");
228228
Task<PsesDebugServer> debugServerCreation = RecreateDebugServerAsync(debugServer, usePSReadLine);
229-
return StartDebugServer(debugServerCreation);
229+
return StartDebugServerAsync(debugServerCreation);
230230
}
231231

232232
private async Task<PsesLanguageServer> CreateLanguageServerAsync(HostStartupInfo hostDetails)

src/PowerShellEditorServices.VSCode/Cmdlets/VSCodeHtmlContentViewCommands.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected override void BeginProcessing()
6262
if (_showInColumn != null) {
6363
try
6464
{
65-
view.Show(_showInColumn.Value).GetAwaiter().GetResult();
65+
view.ShowAsync(_showInColumn.Value).GetAwaiter().GetResult();
6666
}
6767
catch (Exception e)
6868
{
@@ -143,7 +143,7 @@ protected override void BeginProcessing()
143143
{
144144
try
145145
{
146-
HtmlContentView.Close().GetAwaiter().GetResult();
146+
HtmlContentView.CloseAsync().GetAwaiter().GetResult();
147147
}
148148
catch (Exception e)
149149
{
@@ -178,7 +178,7 @@ protected override void BeginProcessing()
178178
{
179179
try
180180
{
181-
HtmlContentView.Show(ViewColumn).GetAwaiter().GetResult();
181+
HtmlContentView.ShowAsync(ViewColumn).GetAwaiter().GetResult();
182182
}
183183
catch (Exception e)
184184
{

src/PowerShellEditorServices.VSCode/CustomViews/CustomViewBase.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ await languageServer.SendRequestAsync(
3838
Title = this.Title,
3939
ViewType = this.ViewType,
4040
}
41-
);
41+
).ConfigureAwait(false);
4242
}
4343

44-
public async Task Show(ViewColumn viewColumn)
44+
public async Task ShowAsync(ViewColumn viewColumn)
4545
{
4646
await languageServer.SendRequestAsync(
4747
ShowCustomViewRequest.Method,
@@ -50,18 +50,18 @@ await languageServer.SendRequestAsync(
5050
Id = this.Id,
5151
ViewColumn = viewColumn
5252
}
53-
);
53+
).ConfigureAwait(false);
5454
}
5555

56-
public async Task Close()
56+
public async Task CloseAsync()
5757
{
5858
await languageServer.SendRequestAsync(
5959
CloseCustomViewRequest.Method,
6060
new CloseCustomViewRequest
6161
{
6262
Id = this.Id,
6363
}
64-
);
64+
).ConfigureAwait(false);
6565
}
6666
}
6767
}

src/PowerShellEditorServices.VSCode/CustomViews/HtmlContentView.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ await languageServer.SendRequestAsync(
3030
Id = this.Id,
3131
HtmlContent = new HtmlContent { BodyContent = htmlBodyContent }
3232
}
33-
);
33+
).ConfigureAwait(false);
3434
}
3535

3636
public async Task SetContentAsync(HtmlContent htmlContent)
@@ -50,7 +50,7 @@ await languageServer.SendRequestAsync(
5050
Id = this.Id,
5151
HtmlContent = validatedContent
5252
}
53-
);
53+
).ConfigureAwait(false);
5454
}
5555

5656
public async Task AppendContentAsync(string appendedHtmlBodyContent)
@@ -62,7 +62,7 @@ await languageServer.SendRequestAsync(
6262
Id = this.Id,
6363
AppendedHtmlBodyContent = appendedHtmlBodyContent
6464
}
65-
);
65+
).ConfigureAwait(false);
6666
}
6767

6868
private string[] GetUriPaths(string[] filePaths)

src/PowerShellEditorServices.VSCode/CustomViews/HtmlContentViewsFeature.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public async Task<IHtmlContentView> CreateHtmlContentViewAsync(string viewTitle)
2121
viewTitle,
2222
languageServer);
2323

24-
await htmlView.CreateAsync();
24+
await htmlView.CreateAsync().ConfigureAwait(false);
2525
this.AddView(htmlView);
2626

2727
return htmlView;

src/PowerShellEditorServices.VSCode/CustomViews/ICustomView.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ public interface ICustomView
2727
/// </summary>
2828
/// <param name="viewColumn">The column in which the view will be shown.</param>
2929
/// <returns>A Task which can be awaited for completion.</returns>
30-
Task Show(ViewColumn viewColumn);
30+
Task ShowAsync(ViewColumn viewColumn);
3131

3232
/// <summary>
3333
/// Closes the view in the editor.
3434
/// </summary>
3535
/// <returns>A Task which can be awaited for completion.</returns>
36-
Task Close();
36+
Task CloseAsync();
3737
}
3838
}

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/EditorUIService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public async Task<string> PromptInputAsync(string message)
116116
new ShowInputPromptRequest
117117
{
118118
Name = message,
119-
}).Returning<ShowInputPromptResponse>(CancellationToken.None);
119+
}).Returning<ShowInputPromptResponse>(CancellationToken.None).ConfigureAwait(false);
120120

121121
if (response.PromptCancelled)
122122
{
@@ -142,7 +142,7 @@ public async Task<IReadOnlyList<string>> PromptMultipleSelectionAsync(string mes
142142
Message = message,
143143
Choices = choiceDetails,
144144
DefaultChoices = defaultChoiceIndexes?.ToArray(),
145-
}).Returning<ShowChoicePromptResponse>(CancellationToken.None);
145+
}).Returning<ShowChoicePromptResponse>(CancellationToken.None).ConfigureAwait(false);
146146

147147
if (response.PromptCancelled)
148148
{
@@ -168,7 +168,7 @@ public async Task<string> PromptSelectionAsync(string message, IReadOnlyList<Pro
168168
Message = message,
169169
Choices = choiceDetails,
170170
DefaultChoices = defaultChoiceIndex > -1 ? new[] { defaultChoiceIndex } : null,
171-
}).Returning<ShowChoicePromptResponse>(CancellationToken.None);
171+
}).Returning<ShowChoicePromptResponse>(CancellationToken.None).ConfigureAwait(false);
172172

173173
if (response.PromptCancelled)
174174
{

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/Server/PsesDebugServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public void Dispose()
144144
_serverStopped.SetResult(true);
145145
}
146146

147-
public async Task WaitForShutdown()
147+
public async Task WaitForShutdownAsync()
148148
{
149149
await _serverStopped.Task.ConfigureAwait(false);
150150
}

src/PowerShellEditorServices/Server/PsesLanguageServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public async Task StartAsync()
140140
/// Get a task that completes when the server is shut down.
141141
/// </summary>
142142
/// <returns>A task that completes when the server is shut down.</returns>
143-
public async Task WaitForShutdown()
143+
public async Task WaitForShutdownAsync()
144144
{
145145
Log.Logger.Debug("Shutting down OmniSharp Language Server");
146146
await _serverStart.Task.ConfigureAwait(false);

src/PowerShellEditorServices/Services/Analysis/AnalysisService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public Task<string> FormatAsync(string scriptFileContents, Hashtable formatSetti
197197
/// <param name="helpLocation">A string referring to which location comment help should be placed around the function.</param>
198198
/// <param name="forBlockComment">If true, block comment help will be supplied.</param>
199199
/// <returns></returns>
200-
public async Task<string> GetCommentHelpText(string functionText, string helpLocation, bool forBlockComment)
200+
public async Task<string> GetCommentHelpTextAsync(string functionText, string helpLocation, bool forBlockComment)
201201
{
202202
if (AnalysisEngine == null)
203203
{

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/BreakpointService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ await _powerShellContextService.ExecuteCommandAsync<Breakpoint>(
146146
return configuredBreakpoints;
147147
}
148148

149-
public async Task<IEnumerable<CommandBreakpointDetails>> SetCommandBreakpoints(IEnumerable<CommandBreakpointDetails> breakpoints)
149+
public async Task<IEnumerable<CommandBreakpointDetails>> SetCommandBreakpointsAsync(IEnumerable<CommandBreakpointDetails> breakpoints)
150150
{
151151
if (BreakpointApiUtils.SupportsBreakpointApis)
152152
{

src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ internal class DebugService
4343
private StackFrameDetails[] stackFrameDetails;
4444
private readonly PropertyInfo invocationTypeScriptPositionProperty;
4545

46-
private static int breakpointHitCounter;
47-
4846
private readonly SemaphoreSlim debugInfoHandle = AsyncUtils.CreateSimpleLockingSemaphore();
4947
#endregion
5048

@@ -107,7 +105,7 @@ public DebugService(
107105
this.logger = factory.CreateLogger<DebugService>();
108106
this.powerShellContext = powerShellContext;
109107
_breakpointService = breakpointService;
110-
this.powerShellContext.DebuggerStop += this.OnDebuggerStopAsync;
108+
this.powerShellContext.DebuggerStop += this.OnDebuggerStop;
111109
this.powerShellContext.DebuggerResumed += this.OnDebuggerResumed;
112110

113111
this.powerShellContext.BreakpointUpdated += this.OnBreakpointUpdated;
@@ -190,7 +188,7 @@ public async Task<BreakpointDetails[]> SetLineBreakpointsAsync(
190188
return await dscBreakpoints.SetLineBreakpointsAsync(
191189
this.powerShellContext,
192190
escapedScriptPath,
193-
breakpoints);
191+
breakpoints).ConfigureAwait(false);
194192
}
195193

196194
/// <summary>
@@ -208,12 +206,14 @@ public async Task<CommandBreakpointDetails[]> SetCommandBreakpointsAsync(
208206
if (clearExisting)
209207
{
210208
// Flatten dictionary values into one list and remove them all.
211-
await _breakpointService.RemoveBreakpointsAsync((await _breakpointService.GetBreakpointsAsync()).Where( i => i is CommandBreakpoint)).ConfigureAwait(false);
209+
await _breakpointService.RemoveBreakpointsAsync(
210+
(await _breakpointService.GetBreakpointsAsync().ConfigureAwait(false))
211+
.Where( i => i is CommandBreakpoint)).ConfigureAwait(false);
212212
}
213213

214214
if (breakpoints.Length > 0)
215215
{
216-
resultBreakpointDetails = (await _breakpointService.SetCommandBreakpoints(breakpoints).ConfigureAwait(false)).ToArray();
216+
resultBreakpointDetails = (await _breakpointService.SetCommandBreakpointsAsync(breakpoints).ConfigureAwait(false)).ToArray();
217217
}
218218

219219
return resultBreakpointDetails ?? new CommandBreakpointDetails[0];
@@ -882,7 +882,7 @@ private string TrimScriptListingLine(PSObject scriptLineObj, ref int prefixLengt
882882
/// </summary>
883883
public event EventHandler<DebuggerStoppedEventArgs> DebuggerStopped;
884884

885-
internal async void OnDebuggerStopAsync(object sender, DebuggerStopEventArgs e)
885+
internal async void OnDebuggerStop(object sender, DebuggerStopEventArgs e)
886886
{
887887
bool noScriptName = false;
888888
string localScriptPath = e.InvocationInfo.ScriptName;

0 commit comments

Comments
 (0)