Skip to content

Commit c5555c3

Browse files
committed
Update disposal check for .NET version compatibility
Refactored ThrowIfDisposed to use ObjectDisposedException.ThrowIf for .NET 7.0 or greater, while retaining the previous pattern for .NET 6.0. This improves code compatibility and leverages newer framework features where available.
1 parent daa130d commit c5555c3

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/Zetian/SmtpServer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,14 @@ private void OnErrorOccurred(ErrorEventArgs args)
400400

401401
private void ThrowIfDisposed()
402402
{
403+
#if NET6_0
403404
if (_disposed)
404405
{
405406
throw new ObjectDisposedException(GetType().FullName);
406407
}
408+
#elif NET7_0_OR_GREATER
409+
ObjectDisposedException.ThrowIf(_disposed, this);
410+
#endif
407411
}
408412

409413
/// <inheritdoc />

0 commit comments

Comments
 (0)