diff --git a/examples/AvaloniaCrossPlat/App.axaml.cs b/examples/AvaloniaCrossPlat/App.axaml.cs index 5bd6a57b..42dcc01d 100644 --- a/examples/AvaloniaCrossPlat/App.axaml.cs +++ b/examples/AvaloniaCrossPlat/App.axaml.cs @@ -13,8 +13,7 @@ public partial class App : Application public override void OnFrameworkInitializationCompleted() { - if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) - { + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { desktop.MainWindow = new MainWindow(); } diff --git a/examples/AvaloniaCrossPlat/MainWindow.axaml.cs b/examples/AvaloniaCrossPlat/MainWindow.axaml.cs index 13c4918a..e30d9d63 100644 --- a/examples/AvaloniaCrossPlat/MainWindow.axaml.cs +++ b/examples/AvaloniaCrossPlat/MainWindow.axaml.cs @@ -1,8 +1,6 @@ using System; -using System.IO; using System.Text; using System.Threading.Tasks; -using System.Xml.Linq; using Avalonia.Controls; using Avalonia.Threading; using Microsoft.Extensions.Logging; diff --git a/examples/AvaloniaCrossPlat/Program.cs b/examples/AvaloniaCrossPlat/Program.cs index 61c66dad..f256321c 100644 --- a/examples/AvaloniaCrossPlat/Program.cs +++ b/examples/AvaloniaCrossPlat/Program.cs @@ -1,5 +1,5 @@ -using Avalonia; -using System; +using System; +using Avalonia; using Velopack; namespace AvaloniaCrossPlat; diff --git a/src/Velopack.Deployment/S3Repository.cs b/src/Velopack.Deployment/S3Repository.cs index adb73841..8db15e15 100644 --- a/src/Velopack.Deployment/S3Repository.cs +++ b/src/Velopack.Deployment/S3Repository.cs @@ -1,6 +1,5 @@ using System.Net; using System.Text; -using System.Text.RegularExpressions; using Amazon; using Amazon.S3; using Amazon.S3.Model; diff --git a/src/Velopack.Deployment/_Repository.cs b/src/Velopack.Deployment/_Repository.cs index 98ad6738..ab8d6f12 100644 --- a/src/Velopack.Deployment/_Repository.cs +++ b/src/Velopack.Deployment/_Repository.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using Velopack.Sources; -using Velopack.Packaging; namespace Velopack.Deployment; diff --git a/src/Velopack.Packaging.OSX/Commands/OsxBundleCommandRunner.cs b/src/Velopack.Packaging.OSX/Commands/OsxBundleCommandRunner.cs index e16ae11a..67ee0801 100644 --- a/src/Velopack.Packaging.OSX/Commands/OsxBundleCommandRunner.cs +++ b/src/Velopack.Packaging.OSX/Commands/OsxBundleCommandRunner.cs @@ -1,5 +1,4 @@ -using System.Text; -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; using Microsoft.Extensions.Logging; using NuGet.Versioning; diff --git a/src/Velopack.Packaging.OSX/Commands/OsxPackCommandRunner.cs b/src/Velopack.Packaging.OSX/Commands/OsxPackCommandRunner.cs index 5c720f5f..81bbc8d7 100644 --- a/src/Velopack.Packaging.OSX/Commands/OsxPackCommandRunner.cs +++ b/src/Velopack.Packaging.OSX/Commands/OsxPackCommandRunner.cs @@ -1,6 +1,4 @@ -using System.Text; -using System.Text.RegularExpressions; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using NuGet.Versioning; namespace Velopack.Packaging.OSX.Commands; diff --git a/src/Velopack.Packaging.Windows/AuthenticodeTools.cs b/src/Velopack.Packaging.Windows/AuthenticodeTools.cs index 0c924ecd..9f73245e 100644 --- a/src/Velopack.Packaging.Windows/AuthenticodeTools.cs +++ b/src/Velopack.Packaging.Windows/AuthenticodeTools.cs @@ -1,5 +1,4 @@ -using System; -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using System.Runtime.Versioning; diff --git a/src/Velopack.Packaging.Windows/Commands/WindowsPackCommandRunner.cs b/src/Velopack.Packaging.Windows/Commands/WindowsPackCommandRunner.cs index 34d8c106..ad6c8b32 100644 --- a/src/Velopack.Packaging.Windows/Commands/WindowsPackCommandRunner.cs +++ b/src/Velopack.Packaging.Windows/Commands/WindowsPackCommandRunner.cs @@ -1,7 +1,4 @@ -using System.Drawing; -using System.Text; -using Microsoft.Extensions.Logging; -using Velopack.NuGet; +using Microsoft.Extensions.Logging; namespace Velopack.Packaging.Windows.Commands; diff --git a/src/Velopack.Packaging.Windows/Commands/WindowsReleasifyCommandRunner.cs b/src/Velopack.Packaging.Windows/Commands/WindowsReleasifyCommandRunner.cs index a16a8f5c..c7c59c97 100644 --- a/src/Velopack.Packaging.Windows/Commands/WindowsReleasifyCommandRunner.cs +++ b/src/Velopack.Packaging.Windows/Commands/WindowsReleasifyCommandRunner.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using System.Text; using Microsoft.Extensions.Logging; using NuGet.Versioning; using Velopack.NuGet; diff --git a/src/Velopack.Packaging.Windows/HelperExe.cs b/src/Velopack.Packaging.Windows/HelperExe.cs index 3e2e1cdf..2ad53aeb 100644 --- a/src/Velopack.Packaging.Windows/HelperExe.cs +++ b/src/Velopack.Packaging.Windows/HelperExe.cs @@ -1,7 +1,6 @@ using System.ComponentModel; using System.Runtime.InteropServices; using System.Runtime.Versioning; -using System.Text; using System.Text.RegularExpressions; using Microsoft.Extensions.Logging; diff --git a/src/Velopack.Packaging/Commands/DeltaGenOptions.cs b/src/Velopack.Packaging/Commands/DeltaGenOptions.cs index be5f8b3f..2daa3ba3 100644 --- a/src/Velopack.Packaging/Commands/DeltaGenOptions.cs +++ b/src/Velopack.Packaging/Commands/DeltaGenOptions.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Velopack.Packaging.Commands +namespace Velopack.Packaging.Commands { public class DeltaGenOptions { diff --git a/src/Velopack.Packaging/Commands/DeltaPatchCommandRunner.cs b/src/Velopack.Packaging/Commands/DeltaPatchCommandRunner.cs index 809a573b..5ff29389 100644 --- a/src/Velopack.Packaging/Commands/DeltaPatchCommandRunner.cs +++ b/src/Velopack.Packaging/Commands/DeltaPatchCommandRunner.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; using Velopack.Compression; namespace Velopack.Packaging.Commands diff --git a/src/Velopack.Packaging/Commands/DeltaPatchOptions.cs b/src/Velopack.Packaging/Commands/DeltaPatchOptions.cs index bc58264d..df604cb3 100644 --- a/src/Velopack.Packaging/Commands/DeltaPatchOptions.cs +++ b/src/Velopack.Packaging/Commands/DeltaPatchOptions.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Velopack.Packaging.Commands +namespace Velopack.Packaging.Commands { public class DeltaPatchOptions { diff --git a/src/Velopack.Packaging/DeltaPackageBuilder.cs b/src/Velopack.Packaging/DeltaPackageBuilder.cs index d1ee5c9f..f3e9ed84 100644 --- a/src/Velopack.Packaging/DeltaPackageBuilder.cs +++ b/src/Velopack.Packaging/DeltaPackageBuilder.cs @@ -1,7 +1,7 @@ -using System.Text; -using Velopack.Compression; +using System.IO.MemoryMappedFiles; +using System.Text; using Microsoft.Extensions.Logging; -using System.IO.MemoryMappedFiles; +using Velopack.Compression; namespace Velopack.Packaging; @@ -31,7 +31,7 @@ public class DeltaPackageBuilder legacyBsdiff = true; } } - + if (basePackage.Version >= newPackage.Version) { var message = String.Format( "Cannot create a delta package based on version {0} as it is a later or equal to the base version {1}", diff --git a/src/Velopack.Packaging/HelperFile.cs b/src/Velopack.Packaging/HelperFile.cs index 676ddb27..ea70c5f3 100644 --- a/src/Velopack.Packaging/HelperFile.cs +++ b/src/Velopack.Packaging/HelperFile.cs @@ -1,10 +1,6 @@ using System.ComponentModel; using System.Diagnostics; using System.Reflection; -using System.Runtime.InteropServices; -using System.Runtime.Versioning; -using System.Text; -using System.Text.RegularExpressions; using Microsoft.Extensions.Logging; namespace Velopack.Packaging; diff --git a/src/Velopack.Packaging/ICommand.cs b/src/Velopack.Packaging/ICommand.cs index dfcebe83..be776d70 100644 --- a/src/Velopack.Packaging/ICommand.cs +++ b/src/Velopack.Packaging/ICommand.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; namespace Velopack.Packaging { diff --git a/src/Velopack.Packaging/MarkdownSharp.cs b/src/Velopack.Packaging/MarkdownSharp.cs index 0c3fd69c..a74dc02a 100644 --- a/src/Velopack.Packaging/MarkdownSharp.cs +++ b/src/Velopack.Packaging/MarkdownSharp.cs @@ -161,8 +161,7 @@ public class Markdown /// /// use ">" for HTML output, or " />" for XHTML output /// - public string EmptyElementSuffix - { + public string EmptyElementSuffix { get { return _emptyElementSuffix; } set { _emptyElementSuffix = value; } } @@ -172,8 +171,7 @@ public class Markdown /// when false, email addresses will never be auto-linked /// WARNING: this is a significant deviation from the markdown spec /// - public bool LinkEmails - { + public bool LinkEmails { get { return _linkEmails; } set { _linkEmails = value; } } @@ -183,8 +181,7 @@ public class Markdown /// when true, bold and italic require non-word characters on either side /// WARNING: this is a significant deviation from the markdown spec /// - public bool StrictBoldItalic - { + public bool StrictBoldItalic { get { return _strictBoldItalic; } set { _strictBoldItalic = value; } } @@ -194,8 +191,7 @@ public class Markdown /// when true, RETURN becomes a literal newline /// WARNING: this is a significant deviation from the markdown spec /// - public bool AutoNewLines - { + public bool AutoNewLines { get { return _autoNewlines; } set { _autoNewlines = value; } } @@ -205,8 +201,7 @@ public class Markdown /// when true, (most) bare plain URLs are auto-hyperlinked /// WARNING: this is a significant deviation from the markdown spec /// - public bool AutoHyperlink - { + public bool AutoHyperlink { get { return _autoHyperlink; } set { _autoHyperlink = value; } } @@ -216,8 +211,7 @@ public class Markdown /// when true, problematic URL characters like [, ], (, and so forth will be encoded /// WARNING: this is a significant deviation from the markdown spec /// - public bool EncodeProblemUrlCharacters - { + public bool EncodeProblemUrlCharacters { get { return _encodeProblemUrlCharacters; } set { _encodeProblemUrlCharacters = value; } } @@ -276,8 +270,7 @@ public class Markdown string backslashPattern = ""; - foreach (char c in @"\`*_{}[]()>#+-.!/") - { + foreach (char c in @"\`*_{}[]()>#+-.!/") { string key = c.ToString(); string hash = GetHashKey(key, isHtmlBlock: false); _escapeTable.Add(key, hash); @@ -293,8 +286,7 @@ public class Markdown /// current version of MarkdownSharp; /// see http://code.google.com/p/markdownsharp/ for the latest code or to contribute /// - public string Version - { + public string Version { get { return _version; } } @@ -391,20 +383,15 @@ public class Markdown // split on two or more newlines string[] grafs = _newlinesMultiple.Split(_newlinesLeadingTrailing.Replace(text, "")); - for (int i = 0; i < grafs.Length; i++) - { - if (grafs[i].StartsWith("\x1AH")) - { + for (int i = 0; i < grafs.Length; i++) { + if (grafs[i].StartsWith("\x1AH")) { // unhashify HTML blocks - if (unhash) - { + if (unhash) { int sanityCheck = 50; // just for safety, guard against an infinite loop bool keepGoing = true; // as long as replacements where made, keep going - while (keepGoing && sanityCheck > 0) - { + while (keepGoing && sanityCheck > 0) { keepGoing = false; - grafs[i] = _htmlBlockHash.Replace(grafs[i], match => - { + grafs[i] = _htmlBlockHash.Replace(grafs[i], match => { keepGoing = true; return _htmlBlocks[match.Value]; }); @@ -417,9 +404,7 @@ public class Markdown // with the input that caused it. }*/ } - } - else - { + } else { // do span level processing inside the block, then wrap result in

tags grafs[i] = _leadingWhitespace.Replace(RunSpanGamut(grafs[i]), "

") + "

"; } @@ -700,7 +685,7 @@ public class Markdown private static string GetHashKey(string s, bool isHtmlBlock) { var delim = isHtmlBlock ? 'H' : 'E'; - return "\x1A" + delim + Math.Abs(s.GetHashCode()).ToString() + delim; + return "\x1A" + delim + Math.Abs(s.GetHashCode()).ToString() + delim; } private static Regex _htmlTokens = new Regex(@" @@ -726,8 +711,7 @@ public class Markdown // this regex is derived from the _tokenize() subroutine in Brad Choate's MTRegex plugin. // http://www.bradchoate.com/past/mtregex.php - foreach (Match m in _htmlTokens.Matches(text)) - { + foreach (Match m in _htmlTokens.Matches(text)) { tagStart = m.Index; if (pos < tagStart) @@ -824,24 +808,21 @@ public class Markdown if (linkID == "") linkID = linkText.ToLowerInvariant(); - if (_urls.ContainsKey(linkID)) - { + if (_urls.ContainsKey(linkID)) { string url = _urls[linkID]; url = EncodeProblemUrlChars(url); url = EscapeBoldItalic(url); result = ""; - } - else + } else result = wholeMatch; return result; @@ -855,24 +836,21 @@ public class Markdown string result; - if (_urls.ContainsKey(linkID)) - { + if (_urls.ContainsKey(linkID)) { string url = _urls[linkID]; url = EncodeProblemUrlChars(url); url = EscapeBoldItalic(url); result = ""; - } - else + } else result = wholeMatch; return result; @@ -893,8 +871,7 @@ public class Markdown result = string.Format(" - { - string list = match.Groups[1].Value; - string listType = Regex.IsMatch(match.Groups[3].Value, _markerUL) ? "ul" : "ol"; - string result; + return new MatchEvaluator(match => { + string list = match.Groups[1].Value; + string listType = Regex.IsMatch(match.Groups[3].Value, _markerUL) ? "ul" : "ol"; + string result; - result = ProcessListItems(list, listType == "ul" ? _markerUL : _markerOL, isInsideParagraphlessListItem); + result = ProcessListItems(list, listType == "ul" ? _markerUL : _markerOL, isInsideParagraphlessListItem); - result = string.Format("<{0}>\n{1}\n", listType, result); - return result; - }); + result = string.Format("<{0}>\n{1}\n", listType, result); + return result; + }); } /// @@ -1201,8 +1173,7 @@ public class Markdown bool lastItemHadADoubleNewline = false; // has to be a closure, so subsequent invocations can share the bool - MatchEvaluator ListItemEvaluator = (Match match) => - { + MatchEvaluator ListItemEvaluator = (Match match) => { string item = match.Groups[3].Value; bool endsWithDoubleNewline = item.EndsWith("\n\n"); @@ -1211,8 +1182,7 @@ public class Markdown if (containsDoubleNewline || lastItemHadADoubleNewline) // we could correct any bad indentation here.. item = RunBlockGamut(Outdent(item) + "\n", unhash: false); - else - { + else { // recursion for sub-lists item = DoLists(Outdent(item), isInsideParagraphlessListItem: true); item = item.TrimEnd('\n'); @@ -1327,13 +1297,10 @@ public class Markdown { // must go first, then - if (_strictBoldItalic) - { + if (_strictBoldItalic) { text = _strictBold.Replace(text, "$1$3"); text = _strictItalic.Replace(text, "$1$3"); - } - else - { + } else { text = _bold.Replace(text, "$2"); text = _italic.Replace(text, "$2"); } @@ -1418,30 +1385,23 @@ public class Markdown if (!link.EndsWith(")")) return "<" + protocol + link + ">"; var level = 0; - foreach (Match c in Regex.Matches(link, "[()]")) - { - if (c.Value == "(") - { + foreach (Match c in Regex.Matches(link, "[()]")) { + if (c.Value == "(") { if (level <= 0) level = 1; else level++; - } - else - { + } else { level--; } } var tail = ""; - if (level < 0) - { + if (level < 0) { link = Regex.Replace(link, @"\){1," + (-level) + "}$", m => { tail = m.Value; return ""; }); } - if (tail.Length > 0) - { + if (tail.Length > 0) { var lastChar = link[link.Length - 1]; - if (!_endCharRegex.IsMatch(lastChar.ToString())) - { + if (!_endCharRegex.IsMatch(lastChar.ToString())) { tail = lastChar + tail; link = link.Substring(0, link.Length - 1); } @@ -1458,8 +1418,7 @@ public class Markdown private string DoAutoLinks(string text) { - if (_autoHyperlink) - { + if (_autoHyperlink) { // fixup arbitrary URLs by adding Markdown < > so they get linked as well // note that at this point, all other URL in the text are already hyperlinked as // *except* for the case @@ -1469,8 +1428,7 @@ public class Markdown // Hyperlinks: text = Regex.Replace(text, "<((https?|ftp):[^'\">\\s]+)>", new MatchEvaluator(HyperlinkEvaluator)); - if (_linkEmails) - { + if (_linkEmails) { // Email addresses: string pattern = @"< @@ -1548,15 +1506,14 @@ public class Markdown var sb = new StringBuilder(addr.Length * 5); var rand = new Random(); int r; - foreach (char c in addr) - { + foreach (char c in addr) { r = rand.Next(1, 100); if ((r > 90 || c == ':') && c != '@') sb.Append(c); // m else if (r < 45) - sb.AppendFormat("&#x{0:x};", (int)c); // m + sb.AppendFormat("&#x{0:x};", (int) c); // m else - sb.AppendFormat("&#{0};", (int)c); // m + sb.AppendFormat("&#{0};", (int) c); // m } return sb.ToString(); } @@ -1572,20 +1529,19 @@ public class Markdown } private string EncodeCodeEvaluator(Match match) { - switch (match.Value) - { - // Encode all ampersands; HTML entities are not - // entities within a Markdown code span. - case "&": - return "&"; - // Do the angle bracket song and dance - case "<": - return "<"; - case ">": - return ">"; - // escape characters that are magic in Markdown - default: - return _escapeTable[match.Value]; + switch (match.Value) { + // Encode all ampersands; HTML entities are not + // entities within a Markdown code span. + case "&": + return "&"; + // Do the angle bracket song and dance + case "<": + return "<"; + case ">": + return ">"; + // escape characters that are magic in Markdown + default: + return _escapeTable[match.Value]; } } @@ -1660,15 +1616,14 @@ public class Markdown bool encode; char c; - for (int i = 0; i < url.Length; i++) - { + for (int i = 0; i < url.Length; i++) { c = url[i]; encode = Array.IndexOf(_problemUrlChars, c) != -1; if (encode && c == ':' && i < url.Length - 1) encode = !(url[i + 1] == '/') && !(url[i + 1] >= '0' && url[i + 1] <= '9'); if (encode) - sb.Append("%" + String.Format("{0:x}", (byte)c)); + sb.Append("%" + String.Format("{0:x}", (byte) c)); else sb.Append(c); } @@ -1691,12 +1646,10 @@ public class Markdown // now, rebuild text from the tokens var sb = new StringBuilder(text.Length); - foreach (var token in tokens) - { + foreach (var token in tokens) { string value = token.Value; - if (token.Type == TokenType.Tag) - { + if (token.Type == TokenType.Tag) { value = value.Replace(@"\", _escapeTable[@"\"]); if (_autoHyperlink && value.StartsWith(" Main(string[] args) diff --git a/src/Velopack.Vpk/Updates/UpdateChecker.cs b/src/Velopack.Vpk/Updates/UpdateChecker.cs index a9ee8671..72ac988e 100644 --- a/src/Velopack.Vpk/Updates/UpdateChecker.cs +++ b/src/Velopack.Vpk/Updates/UpdateChecker.cs @@ -1,5 +1,4 @@ using System.Threading; -using Velopack.Packaging; namespace Velopack.Vpk.Updates; diff --git a/src/Velopack/Compression/BinaryPatchUtility.cs b/src/Velopack/Compression/BinaryPatchUtility.cs index ccb33ac1..d4598159 100644 --- a/src/Velopack/Compression/BinaryPatchUtility.cs +++ b/src/Velopack/Compression/BinaryPatchUtility.cs @@ -52,14 +52,10 @@ namespace Velopack.Compression // solve it, just buys us more space. The solution is to rewrite Split // using iteration instead of recursion, but that's Hard(tm). var ex = default(Exception); - var t = new Thread(() => - { - try - { + var t = new Thread(() => { + try { CreateInternal(oldData, newData, output); - } - catch (Exception exc) - { + } catch (Exception exc) { ex = exc; } }, 40 * 1048576); @@ -112,8 +108,7 @@ namespace Velopack.Compression int eblen = 0; using (WrappingStream wrappingStream = new WrappingStream(output, Ownership.None)) - using (var bz2Stream = new BZip2Stream(wrappingStream, CompressionMode.Compress, true)) - { + using (var bz2Stream = new BZip2Stream(wrappingStream, CompressionMode.Compress, true)) { // compute the differences, writing ctrl as we go int scan = 0; int pos = 0; @@ -121,16 +116,13 @@ namespace Velopack.Compression int lastscan = 0; int lastpos = 0; int lastoffset = 0; - while (scan < newData.Length) - { + while (scan < newData.Length) { int oldscore = 0; - for (int scsc = scan += len; scan < newData.Length; scan++) - { + for (int scsc = scan += len; scan < newData.Length; scan++) { len = Search(I, oldData, newData, scan, 0, oldData.Length, out pos); - for (; scsc < scan + len; scsc++) - { + for (; scsc < scan + len; scsc++) { if ((scsc + lastoffset < oldData.Length) && (oldData[scsc + lastoffset] == newData[scsc])) oldscore++; } @@ -142,54 +134,45 @@ namespace Velopack.Compression oldscore--; } - if (len != oldscore || scan == newData.Length) - { + if (len != oldscore || scan == newData.Length) { int s = 0; int sf = 0; int lenf = 0; - for (int i = 0; (lastscan + i < scan) && (lastpos + i < oldData.Length); ) - { + for (int i = 0; (lastscan + i < scan) && (lastpos + i < oldData.Length);) { if (oldData[lastpos + i] == newData[lastscan + i]) s++; i++; - if (s * 2 - i > sf * 2 - lenf) - { + if (s * 2 - i > sf * 2 - lenf) { sf = s; lenf = i; } } int lenb = 0; - if (scan < newData.Length) - { + if (scan < newData.Length) { s = 0; int sb = 0; - for (int i = 1; (scan >= lastscan + i) && (pos >= i); i++) - { + for (int i = 1; (scan >= lastscan + i) && (pos >= i); i++) { if (oldData[pos - i] == newData[scan - i]) s++; - if (s * 2 - i > sb * 2 - lenb) - { + if (s * 2 - i > sb * 2 - lenb) { sb = s; lenb = i; } } } - if (lastscan + lenf > scan - lenb) - { + if (lastscan + lenf > scan - lenb) { int overlap = (lastscan + lenf) - (scan - lenb); s = 0; int ss = 0; int lens = 0; - for (int i = 0; i < overlap; i++) - { + for (int i = 0; i < overlap; i++) { if (newData[lastscan + lenf - overlap + i] == oldData[lastpos + lenf - overlap + i]) s++; if (newData[scan - lenb + i] == oldData[pos - lenb + i]) s--; - if (s > ss) - { + if (s > ss) { ss = s; lens = i + 1; } @@ -200,7 +183,7 @@ namespace Velopack.Compression } for (int i = 0; i < lenf; i++) - db[dblen + i] = (byte)(newData[lastscan + i] - oldData[lastpos + i]); + db[dblen + i] = (byte) (newData[lastscan + i] - oldData[lastpos + i]); for (int i = 0; i < (scan - lenb) - (lastscan + lenf); i++) eb[eblen + i] = newData[lastscan + lenf + i]; @@ -230,8 +213,7 @@ namespace Velopack.Compression // write compressed diff data using (WrappingStream wrappingStream = new WrappingStream(output, Ownership.None)) - using (var bz2Stream = new BZip2Stream(wrappingStream, CompressionMode.Compress, true)) - { + using (var bz2Stream = new BZip2Stream(wrappingStream, CompressionMode.Compress, true)) { bz2Stream.Write(db, 0, dblen); } @@ -240,11 +222,9 @@ namespace Velopack.Compression WriteInt64(diffEndPosition - controlEndPosition, header, 16); // write compressed extra data, if any - if (eblen > 0) - { + if (eblen > 0) { using (WrappingStream wrappingStream = new WrappingStream(output, Ownership.None)) - using (var bz2Stream = new BZip2Stream(wrappingStream, CompressionMode.Compress, true)) - { + using (var bz2Stream = new BZip2Stream(wrappingStream, CompressionMode.Compress, true)) { bz2Stream.Write(eb, 0, eblen); } } @@ -290,8 +270,7 @@ namespace Velopack.Compression */ // read header long controlLength, diffLength, newSize; - using (Stream patchStream = openPatchStream()) - { + using (Stream patchStream = openPatchStream()) { // check patch stream capabilities if (!patchStream.CanRead) throw new ArgumentException("Patch stream must be readable.", "openPatchStream"); @@ -321,8 +300,7 @@ namespace Velopack.Compression // prepare to read three parts of the patch in parallel using (Stream compressedControlStream = openPatchStream()) using (Stream compressedDiffStream = openPatchStream()) - using (Stream compressedExtraStream = openPatchStream()) - { + using (Stream compressedExtraStream = openPatchStream()) { // seek to the start of each part compressedControlStream.Seek(c_headerSize, SeekOrigin.Current); compressedDiffStream.Seek(c_headerSize + controlLength, SeekOrigin.Current); @@ -334,18 +312,15 @@ namespace Velopack.Compression // decompress each part (to read it) using (var controlStream = new BZip2Stream(compressedControlStream, CompressionMode.Decompress, true)) using (var diffStream = new BZip2Stream(compressedDiffStream, CompressionMode.Decompress, true)) - using (var extraStream = hasExtraData ? new BZip2Stream(compressedExtraStream, CompressionMode.Decompress, true) : null) - { + using (var extraStream = hasExtraData ? new BZip2Stream(compressedExtraStream, CompressionMode.Decompress, true) : null) { long[] control = new long[3]; byte[] buffer = new byte[8]; int oldPosition = 0; int newPosition = 0; - while (newPosition < newSize) - { + while (newPosition < newSize) { // read control data - for (int i = 0; i < 3; i++) - { + for (int i = 0; i < 3; i++) { controlStream.ReadExactly(buffer, 0, 8); control[i] = ReadInt64(buffer, 0); } @@ -357,16 +332,15 @@ namespace Velopack.Compression // seek old file to the position that the new data is diffed against input.Position = oldPosition; - int bytesToCopy = (int)control[0]; - while (bytesToCopy > 0) - { + int bytesToCopy = (int) control[0]; + while (bytesToCopy > 0) { int actualBytesToCopy = Math.Min(bytesToCopy, c_bufferSize); // read diff string diffStream.ReadExactly(newData, 0, actualBytesToCopy); // add old data to diff string - int availableInputBytes = Math.Min(actualBytesToCopy, (int)(input.Length - input.Position)); + int availableInputBytes = Math.Min(actualBytesToCopy, (int) (input.Length - input.Position)); input.ReadExactly(oldData, 0, availableInputBytes); for (int index = 0; index < availableInputBytes; index++) @@ -385,9 +359,8 @@ namespace Velopack.Compression throw new InvalidOperationException("Corrupt patch."); // read extra string - bytesToCopy = (int)control[1]; - while (bytesToCopy > 0) - { + bytesToCopy = (int) control[1]; + while (bytesToCopy > 0) { int actualBytesToCopy = Math.Min(bytesToCopy, c_bufferSize); extraStream.ReadExactly(newData, 0, actualBytesToCopy); @@ -398,7 +371,7 @@ namespace Velopack.Compression } // adjust position - oldPosition = (int)(oldPosition + control[2]); + oldPosition = (int) (oldPosition + control[2]); } } } @@ -406,8 +379,7 @@ namespace Velopack.Compression private static int CompareBytes(byte[] left, int leftOffset, byte[] right, int rightOffset) { - for (int index = 0; index < left.Length - leftOffset && index < right.Length - rightOffset; index++) - { + for (int index = 0; index < left.Length - leftOffset && index < right.Length - rightOffset; index++) { int diff = left[index + leftOffset] - right[index + rightOffset]; if (diff != 0) return diff; @@ -418,8 +390,7 @@ namespace Velopack.Compression private static int MatchLength(byte[] oldData, int oldOffset, byte[] newData, int newOffset) { int i; - for (i = 0; i < oldData.Length - oldOffset && i < newData.Length - newOffset; i++) - { + for (i = 0; i < oldData.Length - oldOffset && i < newData.Length - newOffset; i++) { if (oldData[i + oldOffset] != newData[i + newOffset]) break; } @@ -428,24 +399,18 @@ namespace Velopack.Compression private static int Search(int[] I, byte[] oldData, byte[] newData, int newOffset, int start, int end, out int pos) { - if (end - start < 2) - { + if (end - start < 2) { int startLength = MatchLength(oldData, I[start], newData, newOffset); int endLength = MatchLength(oldData, I[end], newData, newOffset); - if (startLength > endLength) - { + if (startLength > endLength) { pos = I[start]; return startLength; - } - else - { + } else { pos = I[end]; return endLength; } - } - else - { + } else { int midPoint = start + (end - start) / 2; return CompareBytes(oldData, I[midPoint], newData, newOffset) < 0 ? Search(I, oldData, newData, newOffset, midPoint, end, out pos) : @@ -455,22 +420,17 @@ namespace Velopack.Compression private static void Split(int[] I, int[] v, int start, int len, int h) { - if (len < 16) - { + if (len < 16) { int j; - for (int k = start; k < start + len; k += j) - { + for (int k = start; k < start + len; k += j) { j = 1; int x = v[I[k] + h]; - for (int i = 1; k + i < start + len; i++) - { - if (v[I[k + i] + h] < x) - { + for (int i = 1; k + i < start + len; i++) { + if (v[I[k + i] + h] < x) { x = v[I[k + i] + h]; j = 0; } - if (v[I[k + i] + h] == x) - { + if (v[I[k + i] + h] == x) { Swap(ref I[k + j], ref I[k + i]); j++; } @@ -480,14 +440,11 @@ namespace Velopack.Compression if (j == 1) I[k] = -1; } - } - else - { + } else { int x = v[I[start + len / 2] + h]; int jj = 0; int kk = 0; - for (int i2 = start; i2 < start + len; i2++) - { + for (int i2 = start; i2 < start + len; i2++) { if (v[I[i2] + h] < x) jj++; if (v[I[i2] + h] == x) @@ -499,32 +456,22 @@ namespace Velopack.Compression int i = start; int j = 0; int k = 0; - while (i < jj) - { - if (v[I[i] + h] < x) - { + while (i < jj) { + if (v[I[i] + h] < x) { i++; - } - else if (v[I[i] + h] == x) - { + } else if (v[I[i] + h] == x) { Swap(ref I[i], ref I[jj + j]); j++; - } - else - { + } else { Swap(ref I[i], ref I[kk + k]); k++; } } - while (jj + j < kk) - { - if (v[I[jj + j] + h] == x) - { + while (jj + j < kk) { + if (v[I[jj + j] + h] == x) { j++; - } - else - { + } else { Swap(ref I[jj + j], ref I[kk + k]); k++; } @@ -563,26 +510,20 @@ namespace Velopack.Compression for (int i = 0; i < oldData.Length; i++) v[i] = buckets[oldData[i]]; - for (int i = 1; i < 256; i++) - { + for (int i = 1; i < 256; i++) { if (buckets[i] == buckets[i - 1] + 1) I[buckets[i]] = -1; } I[0] = -1; - for (int h = 1; I[0] != -(oldData.Length + 1); h += h) - { + for (int h = 1; I[0] != -(oldData.Length + 1); h += h) { int len = 0; int i = 0; - while (i < oldData.Length + 1) - { - if (I[i] < 0) - { + while (i < oldData.Length + 1) { + if (I[i] < 0) { len -= I[i]; i -= I[i]; - } - else - { + } else { if (len != 0) I[i - len] = -len; len = v[I[i]] + 1 - i; @@ -613,8 +554,7 @@ namespace Velopack.Compression { long value = buf[offset + 7] & 0x7F; - for (int index = 6; index >= 0; index--) - { + for (int index = 6; index >= 0; index--) { value *= 256; value += buf[offset + index]; } @@ -629,9 +569,8 @@ namespace Velopack.Compression { long valueToWrite = value < 0 ? -value : value; - for (int byteIndex = 0; byteIndex < 8; byteIndex++) - { - buf[offset + byteIndex] = (byte)(valueToWrite % 256); + for (int byteIndex = 0; byteIndex < 8; byteIndex++) { + buf[offset + byteIndex] = (byte) (valueToWrite % 256); valueToWrite -= buf[offset + byteIndex]; valueToWrite /= 256; } @@ -672,8 +611,7 @@ namespace Velopack.Compression /// Gets a value indicating whether the current stream supports reading. /// /// true if the stream supports reading; otherwise, false. - public override bool CanRead - { + public override bool CanRead { get { return m_streamBase == null ? false : m_streamBase.CanRead; } } @@ -681,8 +619,7 @@ namespace Velopack.Compression /// Gets a value indicating whether the current stream supports seeking. /// /// true if the stream supports seeking; otherwise, false. - public override bool CanSeek - { + public override bool CanSeek { get { return m_streamBase == null ? false : m_streamBase.CanSeek; } } @@ -690,24 +627,21 @@ namespace Velopack.Compression /// Gets a value indicating whether the current stream supports writing. /// /// true if the stream supports writing; otherwise, false. - public override bool CanWrite - { + public override bool CanWrite { get { return m_streamBase == null ? false : m_streamBase.CanWrite; } } /// /// Gets the length in bytes of the stream. /// - public override long Length - { + public override long Length { get { ThrowIfDisposed(); return m_streamBase.Length; } } /// /// Gets or sets the position within the current stream. /// - public override long Position - { + public override long Position { get { ThrowIfDisposed(); return m_streamBase.Position; } set { ThrowIfDisposed(); m_streamBase.Position = value; } } @@ -821,8 +755,7 @@ namespace Velopack.Compression /// Gets the wrapped stream. /// /// The wrapped stream. - protected Stream WrappedStream - { + protected Stream WrappedStream { get { return m_streamBase; } } @@ -832,18 +765,14 @@ namespace Velopack.Compression /// true to release both managed and unmanaged resources; false to release only unmanaged resources. protected override void Dispose(bool disposing) { - try - { + try { // doesn't close the base stream, but just prevents access to it through this WrappingStream - if (disposing) - { + if (disposing) { if (m_streamBase != null && m_ownership == Ownership.Owns) m_streamBase.Dispose(); m_streamBase = null; } - } - finally - { + } finally { base.Dispose(disposing); } } @@ -916,8 +845,7 @@ namespace Velopack.Compression if (count < 0 || buffer.Length - offset < count) throw new ArgumentOutOfRangeException("count"); - while (count > 0) - { + while (count > 0) { // read data int bytesRead = stream.Read(buffer, offset, count); diff --git a/src/Velopack/Compression/DeltaPackage.cs b/src/Velopack/Compression/DeltaPackage.cs index fd8f81ea..6968ee36 100644 --- a/src/Velopack/Compression/DeltaPackage.cs +++ b/src/Velopack/Compression/DeltaPackage.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; using Microsoft.Extensions.Logging; -using Velopack.Locators; // https://dev.to/emrahsungu/how-to-compare-two-files-using-net-really-really-fast-2pd9 // https://github.com/SnowflakePowered/vcdiff diff --git a/src/Velopack/Internal/ProcessExtensions.cs b/src/Velopack/Internal/ProcessExtensions.cs index cb00fce8..d1efd23f 100644 --- a/src/Velopack/Internal/ProcessExtensions.cs +++ b/src/Velopack/Internal/ProcessExtensions.cs @@ -4,7 +4,6 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text; -using System.Threading.Tasks; using Microsoft.Extensions.Logging; namespace Velopack diff --git a/src/Velopack/Internal/Utility.cs b/src/Velopack/Internal/Utility.cs index 77a1a695..dde4c038 100644 --- a/src/Velopack/Internal/Utility.cs +++ b/src/Velopack/Internal/Utility.cs @@ -10,7 +10,6 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; -using Velopack.NuGet; namespace Velopack { diff --git a/src/Velopack/Locators/TestVelopackLocator.cs b/src/Velopack/Locators/TestVelopackLocator.cs index 2009f8ba..a9925ddc 100644 --- a/src/Velopack/Locators/TestVelopackLocator.cs +++ b/src/Velopack/Locators/TestVelopackLocator.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.Extensions.Logging; using NuGet.Versioning; diff --git a/src/Velopack/Locators/VelopackLocator.cs b/src/Velopack/Locators/VelopackLocator.cs index d5fbfd94..53970415 100644 --- a/src/Velopack/Locators/VelopackLocator.cs +++ b/src/Velopack/Locators/VelopackLocator.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Text; diff --git a/src/Velopack/Locators/WindowsVelopackLocator.cs b/src/Velopack/Locators/WindowsVelopackLocator.cs index 89fdca88..de14c9bb 100644 --- a/src/Velopack/Locators/WindowsVelopackLocator.cs +++ b/src/Velopack/Locators/WindowsVelopackLocator.cs @@ -1,7 +1,6 @@ using System; using System.IO; using System.Runtime.Versioning; -using System.Text.RegularExpressions; using Microsoft.Extensions.Logging; using NuGet.Versioning; using Velopack.NuGet; diff --git a/src/Velopack/NuGet/ZipPackage.cs b/src/Velopack/NuGet/ZipPackage.cs index 0898b147..a4363bc8 100644 --- a/src/Velopack/NuGet/ZipPackage.cs +++ b/src/Velopack/NuGet/ZipPackage.cs @@ -4,10 +4,6 @@ using System.Collections.Generic; using System.IO; using System.IO.Compression; using System.Linq; -using System.Runtime.Versioning; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; namespace Velopack.NuGet { diff --git a/src/Velopack/NuGet/ZipPackageFile.cs b/src/Velopack/NuGet/ZipPackageFile.cs index 43c4daea..c4048347 100644 --- a/src/Velopack/NuGet/ZipPackageFile.cs +++ b/src/Velopack/NuGet/ZipPackageFile.cs @@ -1,8 +1,5 @@ #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; namespace Velopack.NuGet { diff --git a/src/Velopack/ReleaseEntry.cs b/src/Velopack/ReleaseEntry.cs index e8548be0..70296ff8 100644 --- a/src/Velopack/ReleaseEntry.cs +++ b/src/Velopack/ReleaseEntry.cs @@ -9,7 +9,6 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using NuGet.Versioning; -using Velopack.NuGet; namespace Velopack { @@ -185,7 +184,7 @@ namespace Velopack if (filename.IndexOfAny(new[] { '\"', '/', '\\', '<', '>', '|', '\0' }) > -1) { throw new Exception("Filename can either be an absolute HTTP[s] URL, *or* a file name"); } - + long size = Int64.Parse(m.Groups[3].Value); return new ReleaseEntry(m.Groups[1].Value, filename, size, baseUrl, query, stagingPercentage); } diff --git a/src/Velopack/ReleaseEntryName.cs b/src/Velopack/ReleaseEntryName.cs index d2f6002e..3cf5674a 100644 --- a/src/Velopack/ReleaseEntryName.cs +++ b/src/Velopack/ReleaseEntryName.cs @@ -1,5 +1,4 @@ using System; -using System.CodeDom; using System.IO; using System.Text.RegularExpressions; using NuGet.Versioning; diff --git a/src/Velopack/UpdateInfo.cs b/src/Velopack/UpdateInfo.cs index 86f430d6..7d1db591 100644 --- a/src/Velopack/UpdateInfo.cs +++ b/src/Velopack/UpdateInfo.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; - -namespace Velopack +namespace Velopack { /// /// Holds information about the current version and pending updates, such as how many there are, and access to release notes. diff --git a/src/Velopack/VelopackApp.cs b/src/Velopack/VelopackApp.cs index 88a24bd7..0cea79cc 100644 --- a/src/Velopack/VelopackApp.cs +++ b/src/Velopack/VelopackApp.cs @@ -1,10 +1,7 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.Versioning; -using System.Text; -using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using NuGet.Versioning; diff --git a/src/Velopack/Windows/RuntimeInfo.cs b/src/Velopack/Windows/RuntimeInfo.cs index 39aa5384..78034234 100644 --- a/src/Velopack/Windows/RuntimeInfo.cs +++ b/src/Velopack/Windows/RuntimeInfo.cs @@ -5,7 +5,6 @@ using System.IO; using System.Linq; using System.Runtime.Versioning; using System.Text.RegularExpressions; -using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.Win32; diff --git a/src/Velopack/Windows/Runtimes.cs b/src/Velopack/Windows/Runtimes.cs index 51087d6c..c1c7d3d0 100644 --- a/src/Velopack/Windows/Runtimes.cs +++ b/src/Velopack/Windows/Runtimes.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Runtime.Versioning; -using NuGet.Versioning; namespace Velopack.Windows { diff --git a/test/LegacyTestApp/Program.cs b/test/LegacyTestApp/Program.cs index 15a33043..008bc07c 100644 --- a/test/LegacyTestApp/Program.cs +++ b/test/LegacyTestApp/Program.cs @@ -3,7 +3,6 @@ using System.Diagnostics; using System.IO; using System.Reflection; using Squirrel; -using Squirrel.SimpleSplat; [assembly: AssemblyMetadata("SquirrelAwareVersion", "1")] diff --git a/test/LegacyTestApp/SquirrelLogger.cs b/test/LegacyTestApp/SquirrelLogger.cs index a80de5f5..de8a5df5 100644 --- a/test/LegacyTestApp/SquirrelLogger.cs +++ b/test/LegacyTestApp/SquirrelLogger.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace LegacyTestApp { diff --git a/test/TestApp/Program.cs b/test/TestApp/Program.cs index a64da1e7..46648b84 100644 --- a/test/TestApp/Program.cs +++ b/test/TestApp/Program.cs @@ -1,6 +1,5 @@ #pragma warning disable CA1416 // Validate platform compatibility using System.Diagnostics; -using System.Reflection.Metadata; using Velopack; using Velopack.Locators; diff --git a/test/Velopack.CommandLine.Tests/TempFileTestBase.cs b/test/Velopack.CommandLine.Tests/TempFileTestBase.cs index 8cf8ac38..84968035 100644 --- a/test/Velopack.CommandLine.Tests/TempFileTestBase.cs +++ b/test/Velopack.CommandLine.Tests/TempFileTestBase.cs @@ -1,5 +1,4 @@ -using System.Threading; -using Xunit.Sdk; +using Xunit.Sdk; namespace Velopack.CommandLine.Tests; diff --git a/test/Velopack.Packaging.Tests/Init.cs b/test/Velopack.Packaging.Tests/Init.cs index 18408dd2..1d09d448 100644 --- a/test/Velopack.Packaging.Tests/Init.cs +++ b/test/Velopack.Packaging.Tests/Init.cs @@ -1,8 +1,4 @@ -using System.IO; -using System.Reflection; -using Velopack.Packaging; -using Xunit.Abstractions; -using Xunit.Sdk; +using Xunit.Sdk; [assembly: TestFramework("Velopack.Packaging.Tests.TestsInit", "Velopack.Packaging.Tests")] diff --git a/test/Velopack.Packaging.Tests/Properties/AssemblyInfo.cs b/test/Velopack.Packaging.Tests/Properties/AssemblyInfo.cs index 568ac081..4ed1c90a 100644 --- a/test/Velopack.Packaging.Tests/Properties/AssemblyInfo.cs +++ b/test/Velopack.Packaging.Tests/Properties/AssemblyInfo.cs @@ -1,7 +1,6 @@ using System.Reflection; using System.Runtime.InteropServices; -using Xunit; [assembly: ComVisible(false)] -[assembly: CollectionBehavior(MaxParallelThreads=1, DisableTestParallelization=true)] +[assembly: CollectionBehavior(MaxParallelThreads = 1, DisableTestParallelization = true)] [assembly: AssemblyMetadata("SquirrelAwareVersion", "1")] \ No newline at end of file diff --git a/test/Velopack.Packaging.Tests/WindowsPackTests.cs b/test/Velopack.Packaging.Tests/WindowsPackTests.cs index d61f1a30..c6e344fa 100644 --- a/test/Velopack.Packaging.Tests/WindowsPackTests.cs +++ b/test/Velopack.Packaging.Tests/WindowsPackTests.cs @@ -1,17 +1,11 @@ - -using System; -using System.Data.Common; -using System.Diagnostics; +using System.Diagnostics; using System.Globalization; -using System.IO; using System.Runtime.Versioning; using System.Text; using System.Xml.Linq; -using Microsoft.Extensions.Logging; using Microsoft.Win32; using NuGet.Packaging; using Velopack.Compression; -using Velopack.Packaging; using Velopack.Packaging.Commands; using Velopack.Packaging.Windows.Commands; using Velopack.Windows; diff --git a/test/Velopack.Tests/ContentTypeTests.cs b/test/Velopack.Tests/ContentTypeTests.cs index 76331341..f45ab533 100644 --- a/test/Velopack.Tests/ContentTypeTests.cs +++ b/test/Velopack.Tests/ContentTypeTests.cs @@ -1,13 +1,5 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Xml; -using Velopack; +using System.Xml; using Velopack.NuGet; -using Velopack.Tests.TestHelpers; -using Xunit; namespace Velopack.Tests { diff --git a/test/Velopack.Tests/OldSquirrel/ReleaseEntry.cs b/test/Velopack.Tests/OldSquirrel/ReleaseEntry.cs index 195b1094..d8d405b9 100644 --- a/test/Velopack.Tests/OldSquirrel/ReleaseEntry.cs +++ b/test/Velopack.Tests/OldSquirrel/ReleaseEntry.cs @@ -1,14 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.Contracts; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using NuGet; +using System.Diagnostics.Contracts; using System.Runtime.Serialization; -using System.Threading.Tasks; -using System.Collections.Concurrent; +using System.Text.RegularExpressions; namespace Velopack.Tests.OldSquirrel { diff --git a/test/Velopack.Tests/OldSquirrel/ReleaseExtensions.cs b/test/Velopack.Tests/OldSquirrel/ReleaseExtensions.cs index 2335f5c7..3ea46d41 100644 --- a/test/Velopack.Tests/OldSquirrel/ReleaseExtensions.cs +++ b/test/Velopack.Tests/OldSquirrel/ReleaseExtensions.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; +using System.Text.RegularExpressions; namespace Velopack.Tests.OldSquirrel { diff --git a/test/Velopack.Tests/OldSquirrel/SemanticVersion.cs b/test/Velopack.Tests/OldSquirrel/SemanticVersion.cs index ed6a277a..5e0a2bda 100644 --- a/test/Velopack.Tests/OldSquirrel/SemanticVersion.cs +++ b/test/Velopack.Tests/OldSquirrel/SemanticVersion.cs @@ -1,7 +1,4 @@ - -using System; -using System.ComponentModel; -using System.Globalization; +using System.Globalization; using System.Text.RegularExpressions; namespace Velopack.Tests.OldSquirrel diff --git a/test/Velopack.Tests/OldSquirrel/Utility.cs b/test/Velopack.Tests/OldSquirrel/Utility.cs index cf73b259..8b624ee5 100644 --- a/test/Velopack.Tests/OldSquirrel/Utility.cs +++ b/test/Velopack.Tests/OldSquirrel/Utility.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Velopack.Tests.OldSquirrel +namespace Velopack.Tests.OldSquirrel { internal static class Utility { diff --git a/test/Velopack.Tests/ReleaseEntryTests.cs b/test/Velopack.Tests/ReleaseEntryTests.cs index 110a557e..dc00d52e 100644 --- a/test/Velopack.Tests/ReleaseEntryTests.cs +++ b/test/Velopack.Tests/ReleaseEntryTests.cs @@ -1,11 +1,5 @@ -using System; -using System.IO; -using System.Linq; -using System.Security.Cryptography; -using System.Text; +using System.Text; using NuGet.Versioning; -using Velopack.Tests.TestHelpers; -using Xunit; using OldReleaseEntry = Velopack.Tests.OldSquirrel.ReleaseEntry; using OldSemanticVersion = Velopack.Tests.OldSquirrel.SemanticVersion; diff --git a/test/Velopack.Tests/RuntimeTests.cs b/test/Velopack.Tests/RuntimeTests.cs index ad13650d..fcc0ae2e 100644 --- a/test/Velopack.Tests/RuntimeTests.cs +++ b/test/Velopack.Tests/RuntimeTests.cs @@ -1,8 +1,4 @@ -using System; -using System.Net.Http; -using System.Threading.Tasks; -using Xunit; -using Velopack.Windows; +using Velopack.Windows; namespace Velopack.Tests { diff --git a/test/Velopack.Tests/TestHelpers/AssertExtensions.cs b/test/Velopack.Tests/TestHelpers/AssertExtensions.cs index 30ecfe2d..6a2e57d6 100644 --- a/test/Velopack.Tests/TestHelpers/AssertExtensions.cs +++ b/test/Velopack.Tests/TestHelpers/AssertExtensions.cs @@ -1,8 +1,5 @@ -using System; -using System.Collections; +using System.Collections; using System.Globalization; -using System.IO; -using Xunit; namespace Velopack.Tests.TestHelpers { diff --git a/test/Velopack.Tests/TestHelpers/FakeDownloader.cs b/test/Velopack.Tests/TestHelpers/FakeDownloader.cs index 3679a017..75bf87f9 100644 --- a/test/Velopack.Tests/TestHelpers/FakeDownloader.cs +++ b/test/Velopack.Tests/TestHelpers/FakeDownloader.cs @@ -1,7 +1,4 @@ -using System; -using System.IO; -using System.Text; -using System.Threading.Tasks; +using System.Text; namespace Velopack.Tests { diff --git a/test/Velopack.Tests/TestHelpers/FakeFixtureRepository.cs b/test/Velopack.Tests/TestHelpers/FakeFixtureRepository.cs index 82a55a8d..5d8857e2 100644 --- a/test/Velopack.Tests/TestHelpers/FakeFixtureRepository.cs +++ b/test/Velopack.Tests/TestHelpers/FakeFixtureRepository.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Text; using Velopack.Sources; namespace Velopack.Tests.TestHelpers @@ -47,7 +43,7 @@ namespace Velopack.Tests.TestHelpers var rel = _releases.FirstOrDefault(r => url.EndsWith(r.OriginalFilename)); if (rel == null) throw new Exception("Fake release not found: " + url); - + var filePath = PathHelper.GetFixture(rel.OriginalFilename); if (!File.Exists(filePath)) { throw new NotSupportedException("FakeFixtureRepository doesn't have: " + rel.OriginalFilename); diff --git a/test/Velopack.Tests/TestHelpers/StaticHttpServer.cs b/test/Velopack.Tests/TestHelpers/StaticHttpServer.cs index 88f9635e..582a3cea 100644 --- a/test/Velopack.Tests/TestHelpers/StaticHttpServer.cs +++ b/test/Velopack.Tests/TestHelpers/StaticHttpServer.cs @@ -1,9 +1,5 @@ -using System; -using System.IO; -using System.Net; +using System.Net; using System.Text; -using System.Threading; -using System.Threading.Tasks; namespace Velopack.Tests { diff --git a/test/Velopack.Tests/UpdateManagerTests.cs b/test/Velopack.Tests/UpdateManagerTests.cs index 76c7ab8a..7600016f 100644 --- a/test/Velopack.Tests/UpdateManagerTests.cs +++ b/test/Velopack.Tests/UpdateManagerTests.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; +using System.Text; using NuGet.Versioning; using Velopack.Locators; using Velopack.Sources; @@ -28,7 +22,7 @@ namespace Velopack.Tests using var _1 = Utility.GetTempDirectory(out var tempPath); string releasesSuffix = VelopackRuntimeInfo.IsOSX ? "-osx" : ""; - + File.WriteAllText(Path.Combine(tempPath, "RELEASES" + releasesSuffix), """ 3a2eadd15dd984e4559f2b4d790ec8badaeb6a39 MyCoolApp-1.1.0.nupkg 1040561 94689fede03fed7ab59c24337673a27837f0c3ec MyCoolApp-1.0.0.nupkg 1004502 diff --git a/test/Velopack.Tests/UtilityTests.cs b/test/Velopack.Tests/UtilityTests.cs index 34175006..06e2bb41 100644 --- a/test/Velopack.Tests/UtilityTests.cs +++ b/test/Velopack.Tests/UtilityTests.cs @@ -1,17 +1,8 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; +using System.Diagnostics; +using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; -using Velopack; -using Velopack.Tests.TestHelpers; -using Xunit; using Velopack.Windows; -using System.Collections.Generic; -using Xunit.Abstractions; -using System.Threading.Tasks; -using System.Runtime.Versioning; namespace Velopack.Tests { @@ -30,7 +21,7 @@ namespace Velopack.Tests [InlineData("/file", "\\file")] [InlineData("/file/", "\\file")] [InlineData("one\\two\\..\\file", "one\\file")] - [InlineData("C:/AnApp/file/", "C:\\AnApp\\file")] + [InlineData("C:/AnApp/file/", "C:\\AnApp\\file")] public void PathIsNormalized(string input, string expected) { Skip.IfNot(VelopackRuntimeInfo.IsWindows); diff --git a/test/Velopack.Tests/ZipPackageTests.cs b/test/Velopack.Tests/ZipPackageTests.cs index c240435f..632d2d5a 100644 --- a/test/Velopack.Tests/ZipPackageTests.cs +++ b/test/Velopack.Tests/ZipPackageTests.cs @@ -1,14 +1,7 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.Packaging; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO.Packaging; using NuGet.Versioning; using Velopack.NuGet; using Velopack.Tests.TestHelpers; -using Xunit; using ZipPackage = Velopack.NuGet.ZipPackage; namespace Velopack.Tests