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
}

0 commit comments

Comments
 (0)