Skip to content

Commit a157dd3

Browse files
Remove unnecessary finalizers (#1209)
All of the finalizers in the library are no-ops, but their existence means that when Dispose (and thus GC.SuppressFinalize) is not called, the objects' lifetimes are extended unnecessarily while they are waiting to be finalized. Co-authored-by: Wojciech Nagórski <[email protected]>
1 parent d06dfa5 commit a157dd3

20 files changed

+0
-159
lines changed

src/Renci.SshNet/BaseClient.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -461,14 +461,6 @@ protected void CheckDisposed()
461461
#endif // NET7_0_OR_GREATER
462462
}
463463

464-
/// <summary>
465-
/// Finalizes an instance of the <see cref="BaseClient"/> class.
466-
/// </summary>
467-
~BaseClient()
468-
{
469-
Dispose(disposing: false);
470-
}
471-
472464
/// <summary>
473465
/// Stops the keep-alive timer, and waits until all timer callbacks have been
474466
/// executed.

src/Renci.SshNet/Channels/Channel.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -868,13 +868,5 @@ protected virtual void Dispose(bool disposing)
868868
_isDisposed = true;
869869
}
870870
}
871-
872-
/// <summary>
873-
/// Finalizes an instance of the <see cref="Channel"/> class.
874-
/// </summary>
875-
~Channel()
876-
{
877-
Dispose(disposing: false);
878-
}
879871
}
880872
}

src/Renci.SshNet/Compression/Compressor.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,5 @@ protected virtual void Dispose(bool disposing)
175175
_isDisposed = true;
176176
}
177177
}
178-
179-
/// <summary>
180-
/// Releases unmanaged resources and performs other cleanup operations before the <see cref="Compressor"/> is reclaimed
181-
/// by garbage collection.
182-
/// </summary>
183-
~Compressor()
184-
{
185-
Dispose(disposing: false);
186-
}
187178
}
188179
}

src/Renci.SshNet/ForwardedPortRemote.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,5 @@ protected override void Dispose(bool disposing)
379379

380380
_isDisposed = true;
381381
}
382-
383-
/// <summary>
384-
/// Finalizes an instance of the <see cref="ForwardedPortRemote"/> class.
385-
/// </summary>
386-
~ForwardedPortRemote()
387-
{
388-
Dispose(disposing: false);
389-
}
390382
}
391383
}

src/Renci.SshNet/KeyboardInteractiveAuthenticationMethod.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,5 @@ protected virtual void Dispose(bool disposing)
183183
_isDisposed = true;
184184
}
185185
}
186-
187-
/// <summary>
188-
/// Finalizes an instance of the <see cref="KeyboardInteractiveAuthenticationMethod"/> class.
189-
/// </summary>
190-
~KeyboardInteractiveAuthenticationMethod()
191-
{
192-
Dispose(disposing: false);
193-
}
194186
}
195187
}

src/Renci.SshNet/KeyboardInteractiveConnectionInfo.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,5 @@ protected virtual void Dispose(bool disposing)
174174
_isDisposed = true;
175175
}
176176
}
177-
178-
/// <summary>
179-
/// Finalizes an instance of the <see cref="KeyboardInteractiveConnectionInfo"/> class.
180-
/// </summary>
181-
~KeyboardInteractiveConnectionInfo()
182-
{
183-
Dispose(disposing: false);
184-
}
185177
}
186178
}

src/Renci.SshNet/NoneAuthenticationMethod.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,5 @@ protected virtual void Dispose(bool disposing)
121121
_isDisposed = true;
122122
}
123123
}
124-
125-
/// <summary>
126-
/// Finalizes an instance of the <see cref="NoneAuthenticationMethod"/> class.
127-
/// </summary>
128-
~NoneAuthenticationMethod()
129-
{
130-
Dispose(disposing: false);
131-
}
132124
}
133125
}

src/Renci.SshNet/PasswordAuthenticationMethod.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,5 @@ protected virtual void Dispose(bool disposing)
201201
_isDisposed = true;
202202
}
203203
}
204-
205-
/// <summary>
206-
/// Finalizes an instance of the <see cref="PasswordAuthenticationMethod"/> class.
207-
/// </summary>
208-
~PasswordAuthenticationMethod()
209-
{
210-
Dispose(disposing: false);
211-
}
212204
}
213205
}

src/Renci.SshNet/PasswordConnectionInfo.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,5 @@ protected virtual void Dispose(bool disposing)
291291
_isDisposed = true;
292292
}
293293
}
294-
295-
/// <summary>
296-
/// Finalizes an instance of the <see cref="PasswordConnectionInfo"/> class.
297-
/// </summary>
298-
~PasswordConnectionInfo()
299-
{
300-
Dispose(disposing: false);
301-
}
302294
}
303295
}

src/Renci.SshNet/PrivateKeyAuthenticationMethod.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,6 @@ protected virtual void Dispose(bool disposing)
191191
}
192192
}
193193

194-
/// <summary>
195-
/// Finalizes an instance of the <see cref="PrivateKeyAuthenticationMethod"/> class.
196-
/// </summary>
197-
~PrivateKeyAuthenticationMethod()
198-
{
199-
Dispose(disposing: false);
200-
}
201-
202194
private sealed class SignatureData : SshData
203195
{
204196
private readonly RequestMessagePublicKey _message;

0 commit comments

Comments
 (0)