Skip to content

Commit c0a353a

Browse files
mus65Rob-Hague
andauthored
Cleanup formatting and style and enforce it in CI (#1380)
* Preparation to enforce formatting and style in CI - enabled IDE0055 to enforce formatting on build - disabled SA1137 and SA1025 because they are already covered by IDE0055 - disabled SA1021 because it conflicts with csharp_space_after_cast * Cleanup formatting and style on codebase This commit has no manual changes, it is the result of running "dotnet format whitespace" and "dotnet format style" * new formatting fixes after merge * appveyor: set git autocrlf as suggested by sharwell to hopefully fix Windows CI. * use autocrlf input to hopefully fix Linux tests * fix formatting * use autocrlf input for Linux only * set csharp_space_after_cast to false * Revert SA1021 suppression --------- Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
1 parent 1de33c4 commit c0a353a

File tree

594 files changed

+3285
-2310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

594 files changed

+3285
-2310
lines changed

.editorconfig

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ dotnet_diagnostic.S1125.severity = none
6363
# This is a duplicate of MA0026.
6464
dotnet_diagnostic.S1135.severity = none
6565

66+
67+
# SA1137: Elements should have the same indentation
68+
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1137.md
69+
# duplicate of IDE0055
70+
dotnet_diagnostic.SA1137.severity = none
71+
6672
# S1168: Empty arrays and collections should be returned instead of null
6773
# https://rules.sonarsource.com/csharp/RSPEC-1168
6874
#
@@ -339,6 +345,11 @@ dotnet_diagnostic.SA1008.severity = none
339345
# var x = (int) z;
340346
dotnet_diagnostic.SA1009.severity = none
341347

348+
# SA1025: Code should not contain multiple whitespace in a row
349+
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1025.md
350+
# duplicate of IDE0055
351+
dotnet_diagnostic.SA1025.severity = none
352+
342353
# SA1101: Prefix local calls with this
343354
dotnet_diagnostic.SA1101.severity = none
344355

@@ -743,18 +754,6 @@ dotnet_diagnostic.IDE0046.severity = suggestion
743754
# Removing "unnecessary" parentheses is not always a clear win for readability.
744755
dotnet_diagnostic.IDE0047.severity = suggestion
745756

746-
# IDE0055: Fix formatting
747-
#
748-
# When enabled, diagnostics are reported for indented object initializers.
749-
# For example:
750-
# _content = new Person
751-
# {
752-
# Name = "\u13AAlarm"
753-
# };
754-
#
755-
# There are no settings to configure this correctly, unless https://github.com/dotnet/roslyn/issues/63256 (or similar) is ever implemented.
756-
dotnet_diagnostic.IDE0055.severity = none
757-
758757
# IDE0130: Namespace does not match folder structure
759758
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0130
760759
#
@@ -925,7 +924,7 @@ csharp_indent_block_contents = true
925924

926925
# Spacing options
927926

928-
csharp_space_after_cast = true
927+
csharp_space_after_cast = false
929928
csharp_space_after_keywords_in_control_flow_statements = true
930929
csharp_space_between_parentheses = false
931930
csharp_space_before_colon_in_inheritance_clause = true

appveyor.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ for:
1010
matrix:
1111
only:
1212
- image: Ubuntu2204
13+
14+
init:
15+
- git config --global core.autocrlf input
1316

1417
before_build:
1518
- sh: mkdir artifacts -p
@@ -30,6 +33,9 @@ for:
3033
only:
3134
- image: Visual Studio 2022
3235

36+
init:
37+
- git config --global core.autocrlf true
38+
3339
before_build:
3440
- ps: mkdir artifacts -f
3541

src/Renci.SshNet/Abstractions/CryptoAbstraction.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
23
using Renci.SshNet.Security.Cryptography;
34

45
namespace Renci.SshNet.Abstractions

src/Renci.SshNet/Abstractions/SocketAbstraction.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ private static void ConnectCore(Socket socket, IPEndPoint remoteEndpoint, TimeSp
6161
{
6262
var connectCompleted = new ManualResetEvent(initialState: false);
6363
var args = new SocketAsyncEventArgs
64-
{
65-
UserToken = connectCompleted,
66-
RemoteEndPoint = remoteEndpoint
67-
};
64+
{
65+
UserToken = connectCompleted,
66+
RemoteEndPoint = remoteEndpoint
67+
};
6868
args.Completed += ConnectCompleted;
6969

7070
if (socket.ConnectAsync(args))
@@ -96,7 +96,7 @@ private static void ConnectCore(Socket socket, IPEndPoint remoteEndpoint, TimeSp
9696

9797
if (args.SocketError != SocketError.Success)
9898
{
99-
var socketError = (int) args.SocketError;
99+
var socketError = (int)args.SocketError;
100100

101101
if (ownsSocket)
102102
{
@@ -374,7 +374,7 @@ public static bool IsErrorResumable(SocketError socketError)
374374

375375
private static void ConnectCompleted(object sender, SocketAsyncEventArgs e)
376376
{
377-
var eventWaitHandle = (ManualResetEvent) e.UserToken;
377+
var eventWaitHandle = (ManualResetEvent)e.UserToken;
378378
_ = eventWaitHandle?.Set();
379379
}
380380
}

src/Renci.SshNet/Abstractions/SocketExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static async Task ConnectAsync(this Socket socket, IPEndPoint remoteEndpo
9696
#if NET || NETSTANDARD2_1_OR_GREATER
9797
await using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
9898
#else
99-
using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs) o).SetCancelled(), args, useSynchronizationContext: false))
99+
using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false))
100100
#endif // NET || NETSTANDARD2_1_OR_GREATER
101101
{
102102
await args.ExecuteAsync(socket.ConnectAsync);
@@ -113,9 +113,9 @@ public static async Task<int> ReceiveAsync(this Socket socket, byte[] buffer, in
113113
args.SetBuffer(buffer, offset, length);
114114

115115
#if NET || NETSTANDARD2_1_OR_GREATER
116-
await using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs) o).SetCancelled(), args, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
116+
await using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false).ConfigureAwait(continueOnCapturedContext: false))
117117
#else
118-
using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs) o).SetCancelled(), args, useSynchronizationContext: false))
118+
using (cancellationToken.Register(o => ((AwaitableSocketAsyncEventArgs)o).SetCancelled(), args, useSynchronizationContext: false))
119119
#endif // NET || NETSTANDARD2_1_OR_GREATER
120120
{
121121
await args.ExecuteAsync(socket.ReceiveAsync);

src/Renci.SshNet/AuthenticationMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected AuthenticationMethod(string username)
6060
/// </returns>
6161
AuthenticationResult IAuthenticationMethod.Authenticate(ISession session)
6262
{
63-
return Authenticate((Session) session);
63+
return Authenticate((Session)session);
6464
}
6565
}
6666
}

src/Renci.SshNet/Channels/Channel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ private void OnChannelFailure(object sender, MessageEventArgs<ChannelFailureMess
763763

764764
private void AdjustDataWindow(byte[] messageData)
765765
{
766-
LocalWindowSize -= (uint) messageData.Length;
766+
LocalWindowSize -= (uint)messageData.Length;
767767

768768
// Adjust window if window size is too low
769769
if (LocalWindowSize < LocalPacketSize)
@@ -794,10 +794,10 @@ private int GetDataLengthThatCanBeSentInMessage(int messageLength)
794794
}
795795
else
796796
{
797-
var bytesThatCanBeSent = Math.Min(Math.Min(RemotePacketSize, (uint) messageLength),
797+
var bytesThatCanBeSent = Math.Min(Math.Min(RemotePacketSize, (uint)messageLength),
798798
serverWindowSize);
799799
RemoteWindowSize -= bytesThatCanBeSent;
800-
return (int) bytesThatCanBeSent;
800+
return (int)bytesThatCanBeSent;
801801
}
802802
}
803803

src/Renci.SshNet/Channels/ChannelDirectTcpip.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Net;
33
using System.Net.Sockets;
44
using System.Threading;
5+
56
using Renci.SshNet.Abstractions;
67
using Renci.SshNet.Common;
78
using Renci.SshNet.Messages.Connection;
@@ -59,13 +60,13 @@ public void Open(string remoteHost, uint port, IForwardedPort forwardedPort, Soc
5960
_forwardedPort = forwardedPort;
6061
_forwardedPort.Closing += ForwardedPort_Closing;
6162

62-
var ep = (IPEndPoint) socket.RemoteEndPoint;
63+
var ep = (IPEndPoint)socket.RemoteEndPoint;
6364

6465
// Open channel
6566
SendMessage(new ChannelOpenMessage(LocalChannelNumber,
6667
LocalWindowSize,
6768
LocalPacketSize,
68-
new DirectTcpipChannelInfo(remoteHost, port, ep.Address.ToString(), (uint) ep.Port)));
69+
new DirectTcpipChannelInfo(remoteHost, port, ep.Address.ToString(), (uint)ep.Port)));
6970

7071
// Wait for channel to open
7172
WaitOnHandle(_channelOpen);

src/Renci.SshNet/Channels/ChannelForwardedTcpip.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Net;
33
using System.Net.Sockets;
4+
45
using Renci.SshNet.Abstractions;
56
using Renci.SshNet.Common;
67
using Renci.SshNet.Messages.Connection;

src/Renci.SshNet/Channels/ClientChannel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
23
using Renci.SshNet.Common;
34
using Renci.SshNet.Messages.Connection;
45

0 commit comments

Comments
 (0)