Skip to content

Commit a29f5f4

Browse files
Corrects CA2000 and IDE0008 (#1463)
Corrects CA2000 issue but also correct's IDE0008. This seems to be traced back to .editorconfig csharp_style_var_for_built_in_types = false:error csharp_style_var_when_type_is_apparent = false:none This was unexpected but solution compiles now.
1 parent a91803c commit a29f5f4

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

lib/PuppeteerSharp.ruleset

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<RuleSet Name="Rules for PlaywrightSharp" Description="Rules for PlaywrightSharp" ToolsVersion="10.0">
1+
<RuleSet Name="Rules for PlaywrightSharp" Description="Rules for PlaywrightSharp" ToolsVersion="10.0">
22
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
33
<Rule Id="SA1633" Action="None" />
44
<Rule Id="SA1200" Action="None" />
@@ -76,7 +76,7 @@
7676
<Rule Id="CA1724" Action="None" /> <!-- Error CA1724: The type name Extensions conflicts in whole or in part with the namespace name 'Microsoft.Extensions'. Change either name to eliminate the conflict. (CA1724) -->
7777
<Rule Id="CA1806" Action="None" /> <!-- Error CA1806: DownloadAsync calls Chmod but does not use the HRESULT or error code that the method returns. This could lead to unexpected behavior in error conditions or low-resource situations. Use the result in a conditional statement, assign the result to a variable, or pass it as an argument to another method. (CA1806)-->
7878
<Rule Id="CA1816" Action="None" /> <!-- Error CA1816: Change Connection.Dispose() to call GC.SuppressFinalize(object). This will prevent derived types that introduce a finalizer from needing to re-implement 'IDisposable' to call it. (CA1816) -->
79-
<Rule Id="CA2000" Action="None" /> <!-- Error CA2000: Call System.IDisposable.Dispose on object created by 'new Process()' before all references to it are out of scope. (CA2000) -->
79+
<Rule Id="CA2000" Action="Error" /> <!-- Error CA2000: Call System.IDisposable.Dispose on object created by 'new Process()' before all references to it are out of scope. (CA2000) -->
8080
<Rule Id="CA2008" Action="None" /> <!-- Error ca2008: Pass TaskScheduler-->
8181
<Rule Id="CA2200" Action="None" /> <!-- Error CA2200: Re-throwing caught exception changes stack information. (CA2200) -->
8282
<Rule Id="CA2213" Action="None" /> <!-- Error CA2213: 'WebSocketTransport' contains field '_readerCancellationSource' that is of IDisposable type 'CancellationTokenSource', but it is never disposed. Change the Dispose method on 'WebSocketTransport' to call Close or Dispose on this field. (CA2213) -->
@@ -87,4 +87,4 @@
8787
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
8888
<Rule Id="CA1303" Action="None" />
8989
</Rules>
90-
</RuleSet>
90+
</RuleSet>

lib/PuppeteerSharp/BrowserFetcher.cs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics;
44
using System.IO;
@@ -107,13 +107,15 @@ public async Task<bool> CanDownloadAsync(int revision)
107107
{
108108
try
109109
{
110-
var url = GetDownloadURL(Platform, DownloadHost, revision);
110+
string url = GetDownloadURL(Platform, DownloadHost, revision);
111111

112112
var client = WebRequest.Create(url);
113113
client.Proxy = _webClient.Proxy;
114114
client.Method = "HEAD";
115-
var response = await client.GetResponseAsync().ConfigureAwait(false) as HttpWebResponse;
116-
return response.StatusCode == HttpStatusCode.OK;
115+
using (var response = await client.GetResponseAsync().ConfigureAwait(false) as HttpWebResponse)
116+
{
117+
return response.StatusCode == HttpStatusCode.OK;
118+
}
117119
}
118120
catch (WebException)
119121
{
@@ -177,9 +179,9 @@ public RevisionInfo RevisionInfo(int revision)
177179
/// <param name="revision">Revision.</param>
178180
public async Task<RevisionInfo> DownloadAsync(int revision)
179181
{
180-
var url = GetDownloadURL(Platform, DownloadHost, revision);
181-
var zipPath = Path.Combine(DownloadsFolder, $"download-{Platform.ToString()}-{revision}.zip");
182-
var folderPath = GetFolderPath(revision);
182+
string url = GetDownloadURL(Platform, DownloadHost, revision);
183+
string zipPath = Path.Combine(DownloadsFolder, $"download-{Platform.ToString()}-{revision}.zip");
184+
string folderPath = GetFolderPath(revision);
183185

184186
if (new DirectoryInfo(folderPath).Exists)
185187
{
@@ -289,17 +291,18 @@ private string GetFolderPath(int revision)
289291

290292
private void NativeExtractToDirectory(string zipPath, string folderPath)
291293
{
292-
var process = new Process();
293-
294-
process.StartInfo.FileName = "unzip";
295-
process.StartInfo.Arguments = $"\"{zipPath}\" -d \"{folderPath}\"";
296-
process.Start();
297-
process.WaitForExit();
294+
using (var process = new Process())
295+
{
296+
process.StartInfo.FileName = "unzip";
297+
process.StartInfo.Arguments = $"\"{zipPath}\" -d \"{folderPath}\"";
298+
process.Start();
299+
process.WaitForExit();
300+
}
298301
}
299302

300303
private int GetRevisionFromPath(string folderName)
301304
{
302-
var splits = folderName.Split('-');
305+
string[] splits = folderName.Split('-');
303306
if (splits.Length != 2)
304307
{
305308
return 0;
@@ -315,7 +318,7 @@ private int GetRevisionFromPath(string folderName)
315318
return 0;
316319
}
317320

318-
int.TryParse(splits[1], out var revision);
321+
int.TryParse(splits[1], out int revision);
319322
return revision;
320323
}
321324

0 commit comments

Comments
 (0)