Skip to content

Commit 0e083cf

Browse files
committed
Move Extensions to Renci.SshNet.Common namespace.
Moved Dispose(this Socket socket) and Dispose(this WaitHandle handle) to Extensions.cs.
1 parent f08d7a6 commit 0e083cf

File tree

48 files changed

+110
-193
lines changed

Some content is hidden

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

48 files changed

+110
-193
lines changed

src/Renci.SshNet.NET35/Common/Extensions.NET35.cs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,15 @@
11
using System;
22
using System.Diagnostics;
3-
using System.Net.Sockets;
43
using System.Security.Cryptography;
54
using System.Text;
6-
using System.Threading;
75

8-
namespace Renci.SshNet
6+
namespace Renci.SshNet.Common
97
{
108
/// <summary>
119
/// Collection of different extension method specific for .NET 3.5
1210
/// </summary>
1311
internal static partial class Extensions
1412
{
15-
/// <summary>
16-
/// Disposes the specified socket.
17-
/// </summary>
18-
/// <param name="socket">The socket.</param>
19-
[DebuggerNonUserCode]
20-
internal static void Dispose(this Socket socket)
21-
{
22-
if (socket == null)
23-
throw new NullReferenceException();
24-
25-
socket.Close();
26-
}
27-
28-
/// <summary>
29-
/// Disposes the specified handle.
30-
/// </summary>
31-
/// <param name="handle">The handle.</param>
32-
[DebuggerNonUserCode]
33-
internal static void Dispose(this WaitHandle handle)
34-
{
35-
if (handle == null)
36-
throw new NullReferenceException();
37-
38-
handle.Close();
39-
}
40-
4113
/// <summary>
4214
/// Disposes the specified algorithm.
4315
/// </summary>

src/Renci.SshNet.Tests/Classes/Channels/ChannelDirectTcpipTest_Dispose_SessionIsConnectedAndChannelIsOpen.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
using System.Threading;
66
using Microsoft.VisualStudio.TestTools.UnitTesting;
77
using Moq;
8+
#if !FEATURE_SOCKET_DISPOSE
9+
using Renci.SshNet.Common;
10+
#endif // !FEATURE_SOCKET_DISPOSE
811
using Renci.SshNet.Channels;
912
using Renci.SshNet.Messages.Connection;
1013
using Renci.SshNet.Tests.Common;

src/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_IsEqualTo_ByteArray.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using System.Diagnostics;
33
using System.Diagnostics.CodeAnalysis;
4-
using System.Linq;
54
using Microsoft.VisualStudio.TestTools.UnitTesting;
5+
using Renci.SshNet.Common;
66

77
namespace Renci.SshNet.Tests.Classes.Common
88
{
@@ -76,7 +76,7 @@ public void ShouldThrowArgumentNullExceptionWhenLeftAndRightAreNull()
7676
public void ShouldReturnFalseWhenLeftIsNotEqualToRight()
7777
{
7878
Assert.IsFalse(Extensions.IsEqualTo(new byte[] {0x0a}, new byte[] {0x0a, 0x0d}));
79-
Assert.IsFalse(Extensions.IsEqualTo(new byte[] { 0x0a, 0x0d }, new byte[] { 0x0a }));
79+
Assert.IsFalse(Extensions.IsEqualTo(new byte[] {0x0a, 0x0d}, new byte[] {0x0a}));
8080
Assert.IsFalse(Extensions.IsEqualTo(new byte[0], new byte[] { 0x0a }));
8181
Assert.IsFalse(Extensions.IsEqualTo(new byte[] { 0x0a, 0x0d }, new byte[0]));
8282
}
@@ -103,7 +103,7 @@ public void Performance_LargeArray_Equal()
103103
{
104104
var buffer = CreateBuffer(50000);
105105
var left = buffer.Concat(new byte[] {0x0a});
106-
var right = buffer.Concat(new byte[] { 0x0a });
106+
var right = buffer.Concat(new byte[] {0x0a});
107107
const int runs = 10000;
108108

109109
Performance(left, right, runs);
@@ -126,8 +126,8 @@ public void Performance_LargeArray_NotEqual_DifferentLength()
126126
public void Performance_LargeArray_NotEqual_SameLength()
127127
{
128128
var buffer = CreateBuffer(50000);
129-
var left = buffer.Concat(new byte[] { 0x0a });
130-
var right = buffer.Concat(new byte[] { 0x0b });
129+
var left = buffer.Concat(new byte[] {0x0a});
130+
var right = buffer.Concat(new byte[] {0x0b});
131131
const int runs = 10000;
132132

133133
Performance(left, right, runs);
@@ -139,7 +139,7 @@ public void Performance_LargeArray_NotEqual_SameLength()
139139
public void Performance_LargeArray_Same()
140140
{
141141
var left = CreateBuffer(50000);
142-
var right = left.Concat(new byte[] { 0x0a });
142+
var right = left.Concat(new byte[] {0x0a});
143143
const int runs = 10000;
144144

145145
Performance(left, right, runs);
@@ -173,7 +173,7 @@ private static void Performance(byte[] left, byte[] right, int runs)
173173

174174
for (var i = 0; i < runs; i++)
175175
{
176-
var result = Enumerable.SequenceEqual(left, right);
176+
var result = System.Linq.Enumerable.SequenceEqual(left, right);
177177
}
178178

179179
GC.Collect();

src/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Reverse.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Diagnostics;
33
using System.Diagnostics.CodeAnalysis;
44
using Microsoft.VisualStudio.TestTools.UnitTesting;
5+
using Renci.SshNet.Common;
56

67
namespace Renci.SshNet.Tests.Classes.Common
78
{

src/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Take_Count.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics.CodeAnalysis;
44
using System.Linq;
55
using Microsoft.VisualStudio.TestTools.UnitTesting;
6+
using Renci.SshNet.Common;
67

78
namespace Renci.SshNet.Tests.Classes.Common
89
{

src/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_Take_OffsetAndCount.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.Diagnostics.CodeAnalysis;
33
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
using Renci.SshNet.Common;
45

56
namespace Renci.SshNet.Tests.Classes.Common
67
{

src/Renci.SshNet.Tests/Classes/Common/ExtensionsTest_TrimLeadingZeros.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.Diagnostics.CodeAnalysis;
33
using Microsoft.VisualStudio.TestTools.UnitTesting;
4+
using Renci.SshNet.Common;
45

56
namespace Renci.SshNet.Tests.Classes.Common
67
{

src/Renci.SshNet.Tests/Classes/ScpClientTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using Renci.SshNet.Common;
23
using Renci.SshNet.Tests.Common;
34
using Renci.SshNet.Tests.Properties;
45
using System;

src/Renci.SshNet.Tests/Classes/ScpClientTest_Upload_FileInfoAndPath_SendExecRequestReturnsFalse.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Globalization;
43
using System.IO;
54
using Microsoft.VisualStudio.TestTools.UnitTesting;
65
using Moq;

src/Renci.SshNet.Tests/Classes/Security/Cryptography/Ciphers/AesCipherTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using Renci.SshNet.Common;
23
using Renci.SshNet.Security.Cryptography.Ciphers;
34
using Renci.SshNet.Security.Cryptography.Ciphers.Modes;
45
using Renci.SshNet.Tests.Common;

0 commit comments

Comments
 (0)