Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 Cleanup and update dependencies #2983

Merged
merged 2 commits into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#---------------------------------#

# Build worker image (VM template)
image: Visual Studio 2017
image: Visual Studio 2019

# scripts that are called at very beginning, before repo cloning
# init:
Expand Down
2 changes: 1 addition & 1 deletion shadowsocks-csharp/Controller/HotkeyReg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static bool RegHotkeyFromString(string hotkeyStr, string callbackName, Ac

var callback = _callback as HotKeys.HotKeyCallBackHandler;

if (hotkeyStr.IsNullOrEmpty())
if (string.IsNullOrEmpty(hotkeyStr))
{
HotKeys.UnregExistingHotkey(callback);
onComplete?.Invoke(RegResult.UnregSuccess);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private void UpdateRecords()
AppendRecord(id, record);
}
}
catch (Exception e)
catch
{
logger.Debug("config changed asynchrously, just ignore this server");
}
Expand Down
8 changes: 3 additions & 5 deletions shadowsocks-csharp/Controller/Service/GeositeUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,14 @@ private static string MergePACFile(IList<DomainObject> domains, bool blacklist)
return abpContent;
}

private static readonly IEnumerable<char> IgnoredLineBegins = new[] { '!', '[' };

private static List<string> PreProcessGFWList(string content)
{
List<string> valid_lines = new List<string>();
using (var sr = new StringReader(content))
using (var stringReader = new StringReader(content))
{
foreach (var line in sr.NonWhiteSpaceLines())
for (string line = stringReader.ReadLine(); line != null; line = stringReader.ReadLine())
{
if (line.BeginWithAny(IgnoredLineBegins))
if (string.IsNullOrWhiteSpace(line) || line.StartsWith("!") || line.StartsWith("["))
continue;
valid_lines.Add(line);
}
Expand Down
3 changes: 2 additions & 1 deletion shadowsocks-csharp/Controller/Service/Sip003Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,13 @@ public bool StartIfNeeded()

public string ExpandEnvironmentVariables(string name, StringDictionary environmentVariables = null)
{
name = name.ToLower();
// Expand the environment variables from the new process itself
if (environmentVariables != null)
{
foreach(string key in environmentVariables.Keys)
{
name = name.Replace($"%{key}%", environmentVariables[key], StringComparison.OrdinalIgnoreCase);
name = name.Replace($"%{key.ToLower()}%", environmentVariables[key]);
}
}
// Also expand the environment variables from current main process (system)
Expand Down
2 changes: 1 addition & 1 deletion shadowsocks-csharp/Controller/ShadowsocksController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public bool AddServerBySSURL(string ssURL)
{
try
{
if (ssURL.IsNullOrEmpty() || ssURL.IsWhiteSpace())
if (string.IsNullOrWhiteSpace(ssURL))
return false;

var servers = Server.GetServers(ssURL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void InitInstance(ShadowsocksController controller)
/// <returns></returns>
public static Delegate GetCallback(string methodname)
{
if (methodname.IsNullOrEmpty()) throw new ArgumentException(nameof(methodname));
if (string.IsNullOrEmpty(methodname)) throw new ArgumentException(nameof(methodname));
MethodInfo dynMethod = typeof(HotkeyCallbacks).GetMethod(methodname,
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.IgnoreCase);
return dynMethod == null ? null : Delegate.CreateDelegate(typeof(HotKeys.HotKeyCallBackHandler), Instance, dynMethod);
Expand Down
2 changes: 1 addition & 1 deletion shadowsocks-csharp/Controller/System/Hotkeys/Hotkeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static HotKey Str2HotKey(string s)
{
try
{
if (s.IsNullOrEmpty()) return null;
if (string.IsNullOrEmpty(s)) return null;
int offset = s.LastIndexOf("+", StringComparison.OrdinalIgnoreCase);
if (offset <= 0) return null;
string modifierStr = s.Substring(0, offset).Trim();
Expand Down
2 changes: 1 addition & 1 deletion shadowsocks-csharp/Controller/System/SystemProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void Update(Configuration config, bool forceDisable, PACServer pac
else
{
string pacUrl;
if (config.useOnlinePac && !config.pacUrl.IsNullOrEmpty())
if (config.useOnlinePac && !string.IsNullOrEmpty(config.pacUrl))
{
pacUrl = config.pacUrl;
}
Expand Down
2 changes: 1 addition & 1 deletion shadowsocks-csharp/Encryption/EncryptorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static EncryptorFactory()

public static IEncryptor GetEncryptor(string method, string password)
{
if (method.IsNullOrEmpty())
if (string.IsNullOrEmpty(method))
{
method = Model.Server.DefaultMethod;
}
Expand Down
8 changes: 4 additions & 4 deletions shadowsocks-csharp/Model/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,13 @@ public static void CheckLocalPort(int port)

private static void CheckPassword(string password)
{
if (password.IsNullOrEmpty())
if (string.IsNullOrEmpty(password))
throw new ArgumentException(I18N.GetString("Password can not be blank"));
}

public static void CheckServer(string server)
{
if (server.IsNullOrEmpty())
if (string.IsNullOrEmpty(server))
throw new ArgumentException(I18N.GetString("Server IP can not be blank"));
}

Expand All @@ -311,13 +311,13 @@ public static void CheckTimeout(int timeout, int maxTimeout)

public static void CheckProxyAuthUser(string user)
{
if (user.IsNullOrEmpty())
if (string.IsNullOrEmpty(user))
throw new ArgumentException(I18N.GetString("Auth user can not be blank"));
}

public static void CheckProxyAuthPwd(string pwd)
{
if (pwd.IsNullOrEmpty())
if (string.IsNullOrEmpty(pwd))
throw new ArgumentException(I18N.GetString("Auth pwd can not be blank"));
}
}
Expand Down
12 changes: 6 additions & 6 deletions shadowsocks-csharp/Model/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ public override int GetHashCode()

public override string ToString()
{
if (server.IsNullOrEmpty())
if (string.IsNullOrEmpty(server))
{
return I18N.GetString("New server");
}

string serverStr = $"{FormalHostName}:{server_port}";
return remarks.IsNullOrEmpty()
return string.IsNullOrEmpty(remarks)
? serverStr
: $"{remarks} ({serverStr})";
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public string GetURL(bool legacyUrl = false)
server_port
);

if (!plugin.IsNullOrWhiteSpace())
if (!string.IsNullOrWhiteSpace(plugin))
{

string pluginPart = plugin;
Expand All @@ -112,7 +112,7 @@ public string GetURL(bool legacyUrl = false)
}
}

if (!remarks.IsNullOrEmpty())
if (!string.IsNullOrEmpty(remarks))
{
tag = $"#{HttpUtility.UrlEncode(remarks, Encoding.UTF8)}";
}
Expand Down Expand Up @@ -157,7 +157,7 @@ private static Server ParseLegacyURL(string ssURL)
Server server = new Server();
var base64 = match.Groups["base64"].Value.TrimEnd('/');
var tag = match.Groups["tag"].Value;
if (!tag.IsNullOrEmpty())
if (!string.IsNullOrEmpty(tag))
{
server.remarks = HttpUtility.UrlDecode(tag, Encoding.UTF8);
}
Expand All @@ -183,7 +183,7 @@ private static Server ParseLegacyURL(string ssURL)
public static Server ParseURL(string serverUrl)
{
string _serverUrl = serverUrl.Trim();
if (!_serverUrl.BeginWith("ss://", StringComparison.InvariantCultureIgnoreCase))
if (!_serverUrl.StartsWith("ss://", StringComparison.InvariantCultureIgnoreCase))
{
return null;
}
Expand Down
4 changes: 1 addition & 3 deletions shadowsocks-csharp/Proxy/HttpProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ private class HttpState

public object AsyncState { get; set; }

public int BytesToRead;

public Exception ex { get; set; }
}

Expand Down Expand Up @@ -199,7 +197,7 @@ private bool OnLineRead(string line, object state)
}
else
{
if (line.IsNullOrEmpty())
if (string.IsNullOrEmpty(line))
{
return true;
}
Expand Down
Loading