Skip to content

Commit a55745f

Browse files
committed
clean code
1 parent aa40ac6 commit a55745f

File tree

6 files changed

+17
-9
lines changed

6 files changed

+17
-9
lines changed

CmlLib/Core/Auth/MLogin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public bool Signout(string id, string pw)
313313
}
314314
}
315315

316-
public static class HttpWebResponseExt
316+
internal static class HttpWebResponseExt
317317
{
318318
public static HttpWebResponse GetResponseNoException(this HttpWebRequest req)
319319
{

CmlLib/Utils/Changelogs.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static async Task<Changelogs> GetChangelogs()
2828
}
2929

3030
var obj = JObject.Parse(response);
31-
var versions = new Dictionary<string, string?>();
31+
var versionDict = new Dictionary<string, string?>();
3232
var array = obj["entries"] as JArray;
3333
if (array != null)
3434
{
@@ -39,11 +39,11 @@ public static async Task<Changelogs> GetChangelogs()
3939
continue;
4040

4141
var body = item["body"]?.ToString();
42-
versions[version] = body;
42+
versionDict[version] = body;
4343
}
4444
}
4545

46-
return new Changelogs(versions);
46+
return new Changelogs(versionDict);
4747
}
4848

4949
private Changelogs(Dictionary<string, string?> versions)

CmlLib/Utils/IOUtil.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,15 @@ public static async Task CopyFileAsync(string sourceFile, string destinationFile
206206
var destinationStream = AsyncWriteStream(destinationFile, false);
207207

208208
await sourceStream.CopyToAsync(destinationStream).ConfigureAwait(false);
209-
await destinationStream.FlushAsync();
209+
await destinationStream.FlushAsync().ConfigureAwait(false);
210210

211211
await disposeStreamAsync(sourceStream).ConfigureAwait(false);
212212
await disposeStreamAsync(destinationStream).ConfigureAwait(false);
213213
}
214214

215215
private static Task disposeStreamAsync(Stream stream)
216216
{
217+
// .NET Framework does not support DisposeAsync
217218
#if NETFRAMEWORK
218219
stream.Dispose();
219220
return Task.CompletedTask;

CmlLib/Utils/NativeMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace CmlLib.Utils
66
{
7-
static class NativeMethods
7+
internal static class NativeMethods
88
{
99
[DllImport("libc", SetLastError = true)]
1010
private static extern int chmod(string pathname, int mode);

CmlLib/Utils/SevenZipWrapper.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ public static void DecompressFileLZMA(string inFile, string outFile)
1313

1414
// Read the decoder properties
1515
byte[] properties = new byte[5];
16-
input.Read(properties, 0, 5);
16+
var readCount = input.Read(properties, 0, 5);
1717

18+
if (readCount < 5)
19+
return;
20+
1821
// Read in the decompress file size.
1922
byte[] fileLengthBytes = new byte[8];
20-
input.Read(fileLengthBytes, 0, 8);
23+
readCount = input.Read(fileLengthBytes, 0, 8);
24+
25+
if (readCount < 8)
26+
return;
27+
2128
long fileLength = BitConverter.ToInt64(fileLengthBytes, 0);
2229

2330
coder.SetDecoderProperties(properties);

CmlLib/Utils/WebDownload.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace CmlLib.Utils
99
{
10-
public class WebDownload
10+
internal class WebDownload
1111
{
1212
public static bool IgnoreProxy { get; set; } = true;
1313

0 commit comments

Comments
 (0)