Skip to content

Commit

Permalink
style: Same code style with VS
Browse files Browse the repository at this point in the history
  • Loading branch information
HMBSbige committed Sep 8, 2021
1 parent e22773c commit 3e7de63
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 35 deletions.
7 changes: 4 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion

# 缩进首选项
csharp_indent_case_contents_when_block = false

# ReSharper properties
resharper_align_multiline_binary_expressions_chain = false
resharper_autodetect_indent_settings = true
Expand All @@ -59,7 +62,7 @@ resharper_braces_for_foreach = required
resharper_braces_for_ifelse = required
resharper_braces_for_while = required
resharper_braces_redundant = false
resharper_csharp_alignment_tab_fill_style = optimal_fill
resharper_csharp_alignment_tab_fill_style = use_tabs_only
resharper_csharp_blank_lines_around_invocable = 0
resharper_csharp_indent_style = tab
resharper_csharp_insert_final_newline = true
Expand All @@ -76,8 +79,6 @@ resharper_csharp_wrap_before_first_type_parameter_constraint = true
resharper_csharp_wrap_before_invocation_rpar = true
resharper_csharp_wrap_lines = false
resharper_csharp_wrap_multiple_type_parameter_constraints_style = chop_always
resharper_int_align_switch_expressions = true
resharper_int_align_switch_sections = true
resharper_keep_existing_declaration_block_arrangement = true
resharper_keep_existing_declaration_parens_arrangement = false
resharper_keep_existing_embedded_arrangement = false
Expand Down
8 changes: 4 additions & 4 deletions HttpProxy/HttpUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ internal static string BuildErrorResponse(ConnectionErrorResult error, string ht
return error switch
{
ConnectionErrorResult.AuthenticationError => $"{httpVersion} 401 Unauthorized\r\n\r\n",
ConnectionErrorResult.HostUnreachable => $"{httpVersion} 502 {error}\r\n\r\n",
ConnectionErrorResult.ConnectionRefused => $"{httpVersion} 502 {error}\r\n\r\n",
ConnectionErrorResult.ConnectionReset => $"{httpVersion} 502 {error}\r\n\r\n",
_ => $"{httpVersion} 500 Internal Server Error\r\nX-Proxy-Error-Type: {error}\r\n\r\n"
ConnectionErrorResult.HostUnreachable => $"{httpVersion} 502 {error}\r\n\r\n",
ConnectionErrorResult.ConnectionRefused => $"{httpVersion} 502 {error}\r\n\r\n",
ConnectionErrorResult.ConnectionReset => $"{httpVersion} 502 {error}\r\n\r\n",
_ => $"{httpVersion} 500 Internal Server Error\r\nX-Proxy-Error-Type: {error}\r\n\r\n"
};
}

Expand Down
6 changes: 3 additions & 3 deletions Pipelines.Extensions/ReadOnlySequenceStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public override long Seek(long offset, SeekOrigin origin)

var pos = origin switch
{
SeekOrigin.Begin => default,
SeekOrigin.Begin => default,
SeekOrigin.Current => Position,
SeekOrigin.End => _readOnlySequence.Length,
_ => throw Requires.FailRange(nameof(origin))
SeekOrigin.End => _readOnlySequence.Length,
_ => throw Requires.FailRange(nameof(origin))
};

_position = _readOnlySequence.GetPosition(offset + pos);
Expand Down
44 changes: 22 additions & 22 deletions Shadowsocks.Crypto/ShadowsocksCrypto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,29 @@ public static IShadowsocksCrypto Create(string method, string password)
{
return method switch
{
NoneMethod or PlainMethod => new NoneShadowsocksCrypto(password),
Rc4Method => new Rc4ShadowsocksCrypto(password),
Rc4Md5Method => new Rc4Md5ShadowsocksCrypto(password),
Rc4Md56Method => new Rc4Md56ShadowsocksCrypto(password),
Aes128CtrMethod => new Aes128CtrShadowsocksCrypto(password),
Aes192CtrMethod => new Aes192CtrShadowsocksCrypto(password),
Aes256CtrMethod => new Aes256CtrShadowsocksCrypto(password),
Aes128CfbMethod => new Aes128CfbShadowsocksCrypto(password),
Aes192CfbMethod => new Aes192CfbShadowsocksCrypto(password),
Aes256CfbMethod => new Aes256CfbShadowsocksCrypto(password),
ChaCha20IetfMethod => new ChaCha20IETFShadowsocksCrypto(password),
ChaCha20Method => new ChaCha20ShadowsocksCrypto(password),
Salsa20Method => new Salsa20ShadowsocksCrypto(password),
XSalsa20Method => new XSalsa20ShadowsocksCrypto(password),
XChaCha20Method => new XChaCha20ShadowsocksCrypto(password),
Sm4CtrMethod => new Sm4CtrShadowsocksCrypto(password),
Aes128GcmMethod => new Aes128GcmShadowsocksCrypto(password),
Aes192GcmMethod => new Aes192GcmShadowsocksCrypto(password),
Aes256GcmMethod => new Aes256GcmShadowsocksCrypto(password),
ChaCha20IetfPoly1305Method => new ChaChaPoly1305ShadowsocksCrypto(password),
NoneMethod or PlainMethod => new NoneShadowsocksCrypto(password),
Rc4Method => new Rc4ShadowsocksCrypto(password),
Rc4Md5Method => new Rc4Md5ShadowsocksCrypto(password),
Rc4Md56Method => new Rc4Md56ShadowsocksCrypto(password),
Aes128CtrMethod => new Aes128CtrShadowsocksCrypto(password),
Aes192CtrMethod => new Aes192CtrShadowsocksCrypto(password),
Aes256CtrMethod => new Aes256CtrShadowsocksCrypto(password),
Aes128CfbMethod => new Aes128CfbShadowsocksCrypto(password),
Aes192CfbMethod => new Aes192CfbShadowsocksCrypto(password),
Aes256CfbMethod => new Aes256CfbShadowsocksCrypto(password),
ChaCha20IetfMethod => new ChaCha20IETFShadowsocksCrypto(password),
ChaCha20Method => new ChaCha20ShadowsocksCrypto(password),
Salsa20Method => new Salsa20ShadowsocksCrypto(password),
XSalsa20Method => new XSalsa20ShadowsocksCrypto(password),
XChaCha20Method => new XChaCha20ShadowsocksCrypto(password),
Sm4CtrMethod => new Sm4CtrShadowsocksCrypto(password),
Aes128GcmMethod => new Aes128GcmShadowsocksCrypto(password),
Aes192GcmMethod => new Aes192GcmShadowsocksCrypto(password),
Aes256GcmMethod => new Aes256GcmShadowsocksCrypto(password),
ChaCha20IetfPoly1305Method => new ChaChaPoly1305ShadowsocksCrypto(password),
XChaCha20IetfPoly1305Method => new XChaChaPoly1305ShadowsocksCrypto(password),
Sm4GcmMethod => new Sm4GcmShadowsocksCrypto(password),
_ => throw new ArgumentException($@"Invalid method: {method}", nameof(method))
Sm4GcmMethod => new Sm4GcmShadowsocksCrypto(password),
_ => throw new ArgumentException($@"Invalid method: {method}", nameof(method))
};
}
}
Expand Down
8 changes: 7 additions & 1 deletion Shadowsocks.Protocol/ListenServices/UdpListenService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ public async ValueTask StartAsync()
//TODO .NET6.0
var message = await UdpListener.ReceiveAsync();
#if DEBUG
_logger.LogDebug(@"{0}: {1} bytes {2} => {3}", LoggerHeader, message.Buffer.Length, message.RemoteEndPoint, UdpListener.Client.LocalEndPoint);
_logger.LogDebug(
@"{0}: {1} bytes {2} => {3}",
LoggerHeader,
message.Buffer.Length,
message.RemoteEndPoint,
UdpListener.Client.LocalEndPoint
);
#endif
HandleAsync(message, _cts.Token).Forget();
}
Expand Down
2 changes: 1 addition & 1 deletion Shadowsocks.Protocol/LocalTcpServices/Socks5Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public async ValueTask HandleAsync(IDuplexPipe pipe, CancellationToken token = d
var target = socks5.Target.Type switch
{
AddressType.Domain => socks5.Target.Domain!,
_ => socks5.Target.Address!.ToString()
_ => socks5.Target.Address!.ToString()
};

await using var client = await _serversController.GetServerAsync(target);
Expand Down
2 changes: 1 addition & 1 deletion Shadowsocks.Protocol/LocalUdpServices/Socks5UdpService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public async ValueTask HandleAsync(UdpReceiveResult receiveResult, UdpClient inc
var target = socks5UdpPacket.Type switch
{
AddressType.Domain => socks5UdpPacket.Domain!,
_ => socks5UdpPacket.Address!.ToString()
_ => socks5UdpPacket.Address!.ToString()
};

if (!_cache.TryGetValue(receiveResult.RemoteEndPoint, out IUdpClient client))
Expand Down

0 comments on commit 3e7de63

Please sign in to comment.