From 26095bcf80af696a898bbfe62cf72ed1649d9eea Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 20 Jan 2024 18:34:47 -0600 Subject: resolve warnings --- src/slskd/Common/Authentication/ApiKeyAuthentication.cs | 6 ++---- src/slskd/Common/Authentication/PassthroughAuthentication.cs | 5 ++--- src/slskd/Common/Exceptions/ApplicationShutdownException.cs | 12 ------------ src/slskd/Common/Exceptions/GitHubException.cs | 12 ------------ .../Common/Exceptions/IntentionalDisconnectException.cs | 12 ------------ src/slskd/Common/Exceptions/NotFoundException.cs | 12 ------------ src/slskd/Common/Exceptions/OutOfRangeException.cs | 10 ---------- src/slskd/Common/Exceptions/RelayException.cs | 11 ----------- src/slskd/Common/Exceptions/RetryException.cs | 12 ------------ src/slskd/Common/Exceptions/ShareInitializationException.cs | 12 ------------ src/slskd/Common/Exceptions/ShareScanInProgressException.cs | 12 ------------ src/slskd/Common/Exceptions/ShareValidationException.cs | 12 ------------ src/slskd/Common/Exceptions/SlskdException.cs | 12 ------------ src/slskd/Common/Exceptions/UnauthorizedException.cs | 12 ------------ src/slskd/Transfers/API/Controllers/TransfersController.cs | 2 +- src/slskd/Transfers/Uploads/UploadService.cs | 6 +++++- src/slskd/slskd.csproj | 4 ++-- 17 files changed, 12 insertions(+), 152 deletions(-) (limited to 'src') diff --git a/src/slskd/Common/Authentication/ApiKeyAuthentication.cs b/src/slskd/Common/Authentication/ApiKeyAuthentication.cs index b27c4c05..1aaa4a4f 100644 --- a/src/slskd/Common/Authentication/ApiKeyAuthentication.cs +++ b/src/slskd/Common/Authentication/ApiKeyAuthentication.cs @@ -49,14 +49,12 @@ namespace slskd.Authentication /// The security service. /// A logger factory. /// A url encoder. - /// A system clock interface. public ApiKeyAuthenticationHandler( IOptionsMonitor apiKeyOptionsMonitor, ISecurityService securityService, ILoggerFactory logger, - UrlEncoder urlEncoder, - ISystemClock systemClock) - : base(apiKeyOptionsMonitor, logger, urlEncoder, systemClock) + UrlEncoder urlEncoder) + : base(apiKeyOptionsMonitor, logger, urlEncoder) { Security = securityService; } diff --git a/src/slskd/Common/Authentication/PassthroughAuthentication.cs b/src/slskd/Common/Authentication/PassthroughAuthentication.cs index 5f186aea..510e4a19 100644 --- a/src/slskd/Common/Authentication/PassthroughAuthentication.cs +++ b/src/slskd/Common/Authentication/PassthroughAuthentication.cs @@ -46,9 +46,8 @@ namespace slskd.Authentication /// An options monitor. /// A logger factory. /// A url encoder. - /// A system clock interface. - public PassthroughAuthenticationHandler(IOptionsMonitor optionsMonitor, ILoggerFactory logger, UrlEncoder urlEncoder, ISystemClock systemClock) - : base(optionsMonitor, logger, urlEncoder, systemClock) + public PassthroughAuthenticationHandler(IOptionsMonitor optionsMonitor, ILoggerFactory logger, UrlEncoder urlEncoder) + : base(optionsMonitor, logger, urlEncoder) { } diff --git a/src/slskd/Common/Exceptions/ApplicationShutdownException.cs b/src/slskd/Common/Exceptions/ApplicationShutdownException.cs index e30b5c79..310b317c 100644 --- a/src/slskd/Common/Exceptions/ApplicationShutdownException.cs +++ b/src/slskd/Common/Exceptions/ApplicationShutdownException.cs @@ -19,13 +19,11 @@ namespace slskd { using System; using System.Diagnostics.CodeAnalysis; - using System.Runtime.Serialization; /// /// Represents a normal application shutdown. /// [ExcludeFromCodeCoverage] - [Serializable] public class ApplicationShutdownException : SlskdException { /// @@ -58,15 +56,5 @@ namespace slskd : base(message, innerException) { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The SerializationInfo that holds the serialized object data about the exception being thrown. - /// The StreamingContext that contains contextual information about the source or destination. - protected ApplicationShutdownException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/slskd/Common/Exceptions/GitHubException.cs b/src/slskd/Common/Exceptions/GitHubException.cs index 75c72826..697ae49a 100644 --- a/src/slskd/Common/Exceptions/GitHubException.cs +++ b/src/slskd/Common/Exceptions/GitHubException.cs @@ -19,13 +19,11 @@ namespace slskd { using System; using System.Diagnostics.CodeAnalysis; - using System.Runtime.Serialization; /// /// Represents a normal application shutdown. /// [ExcludeFromCodeCoverage] - [Serializable] public class GitHubException : Exception { /// @@ -58,15 +56,5 @@ namespace slskd : base(message, innerException) { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The SerializationInfo that holds the serialized object data about the exception being thrown. - /// The StreamingContext that contains contextual information about the source or destination. - protected GitHubException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/slskd/Common/Exceptions/IntentionalDisconnectException.cs b/src/slskd/Common/Exceptions/IntentionalDisconnectException.cs index d5293e63..c2f09c4b 100644 --- a/src/slskd/Common/Exceptions/IntentionalDisconnectException.cs +++ b/src/slskd/Common/Exceptions/IntentionalDisconnectException.cs @@ -19,13 +19,11 @@ namespace slskd { using System; using System.Diagnostics.CodeAnalysis; - using System.Runtime.Serialization; /// /// Represents an intentional client disconnect. /// [ExcludeFromCodeCoverage] - [Serializable] public class IntentionalDisconnectException : SlskdException { /// @@ -58,15 +56,5 @@ namespace slskd : base(message, innerException) { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The SerializationInfo that holds the serialized object data about the exception being thrown. - /// The StreamingContext that contains contextual information about the source or destination. - protected IntentionalDisconnectException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/slskd/Common/Exceptions/NotFoundException.cs b/src/slskd/Common/Exceptions/NotFoundException.cs index cc0f6969..414ccb4b 100644 --- a/src/slskd/Common/Exceptions/NotFoundException.cs +++ b/src/slskd/Common/Exceptions/NotFoundException.cs @@ -19,13 +19,11 @@ namespace slskd { using System; using System.Diagnostics.CodeAnalysis; - using System.Runtime.Serialization; /// /// Represents errors that originate when a searched resource can't be located. /// [ExcludeFromCodeCoverage] - [Serializable] public class NotFoundException : SlskdException { /// @@ -58,15 +56,5 @@ namespace slskd : base(message, innerException) { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The SerializationInfo that holds the serialized object data about the exception being thrown. - /// The StreamingContext that contains contextual information about the source or destination. - protected NotFoundException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/slskd/Common/Exceptions/OutOfRangeException.cs b/src/slskd/Common/Exceptions/OutOfRangeException.cs index 7de8cc7b..3eb3ab6d 100644 --- a/src/slskd/Common/Exceptions/OutOfRangeException.cs +++ b/src/slskd/Common/Exceptions/OutOfRangeException.cs @@ -58,15 +58,5 @@ namespace slskd : base(message, innerException) { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The SerializationInfo that holds the serialized object data about the exception being thrown. - /// The StreamingContext that contains contextual information about the source or destination. - protected OutOfRangeException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/slskd/Common/Exceptions/RelayException.cs b/src/slskd/Common/Exceptions/RelayException.cs index 11a6bd9e..3b8a4fbe 100644 --- a/src/slskd/Common/Exceptions/RelayException.cs +++ b/src/slskd/Common/Exceptions/RelayException.cs @@ -19,7 +19,6 @@ namespace slskd { using System; using System.Diagnostics.CodeAnalysis; - using System.Runtime.Serialization; /// /// Represents an error related to the slskd relay feature. @@ -58,15 +57,5 @@ namespace slskd : base(message, innerException) { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The SerializationInfo that holds the serialized object data about the exception being thrown. - /// The StreamingContext that contains contextual information about the source or destination. - protected RelayException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/slskd/Common/Exceptions/RetryException.cs b/src/slskd/Common/Exceptions/RetryException.cs index c688f377..3adadd2e 100644 --- a/src/slskd/Common/Exceptions/RetryException.cs +++ b/src/slskd/Common/Exceptions/RetryException.cs @@ -19,13 +19,11 @@ namespace slskd { using System; using System.Diagnostics.CodeAnalysis; - using System.Runtime.Serialization; /// /// Represents erorrs that originate while attempting to execute retry logic. /// [ExcludeFromCodeCoverage] - [Serializable] public class RetryException : Exception { /// @@ -58,15 +56,5 @@ namespace slskd : base(message, innerException) { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The SerializationInfo that holds the serialized object data about the exception being thrown. - /// The StreamingContext that contains contextual information about the source or destination. - protected RetryException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/slskd/Common/Exceptions/ShareInitializationException.cs b/src/slskd/Common/Exceptions/ShareInitializationException.cs index 31e45b91..2624da21 100644 --- a/src/slskd/Common/Exceptions/ShareInitializationException.cs +++ b/src/slskd/Common/Exceptions/ShareInitializationException.cs @@ -19,13 +19,11 @@ namespace slskd { using System; using System.Diagnostics.CodeAnalysis; - using System.Runtime.Serialization; /// /// Represents an error that occurs when multiple share scans are attempted concurrently. /// [ExcludeFromCodeCoverage] - [Serializable] public class ShareInitializationException : SlskdException { /// @@ -58,15 +56,5 @@ namespace slskd : base(message, innerException) { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The SerializationInfo that holds the serialized object data about the exception being thrown. - /// The StreamingContext that contains contextual information about the source or destination. - protected ShareInitializationException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/slskd/Common/Exceptions/ShareScanInProgressException.cs b/src/slskd/Common/Exceptions/ShareScanInProgressException.cs index 2e548930..b6b1a719 100644 --- a/src/slskd/Common/Exceptions/ShareScanInProgressException.cs +++ b/src/slskd/Common/Exceptions/ShareScanInProgressException.cs @@ -19,13 +19,11 @@ namespace slskd { using System; using System.Diagnostics.CodeAnalysis; - using System.Runtime.Serialization; /// /// Represents an error that occurs when multiple share scans are attempted concurrently. /// [ExcludeFromCodeCoverage] - [Serializable] public class ShareScanInProgressException : SlskdException { /// @@ -58,15 +56,5 @@ namespace slskd : base(message, innerException) { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The SerializationInfo that holds the serialized object data about the exception being thrown. - /// The StreamingContext that contains contextual information about the source or destination. - protected ShareScanInProgressException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/slskd/Common/Exceptions/ShareValidationException.cs b/src/slskd/Common/Exceptions/ShareValidationException.cs index 97a3e126..c214556e 100644 --- a/src/slskd/Common/Exceptions/ShareValidationException.cs +++ b/src/slskd/Common/Exceptions/ShareValidationException.cs @@ -19,13 +19,11 @@ namespace slskd { using System; using System.Diagnostics.CodeAnalysis; - using System.Runtime.Serialization; /// /// Represents an error that occurs when multiple share scans are attempted concurrently. /// [ExcludeFromCodeCoverage] - [Serializable] public class ShareValidationException : SlskdException { /// @@ -58,15 +56,5 @@ namespace slskd : base(message, innerException) { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The SerializationInfo that holds the serialized object data about the exception being thrown. - /// The StreamingContext that contains contextual information about the source or destination. - protected ShareValidationException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/slskd/Common/Exceptions/SlskdException.cs b/src/slskd/Common/Exceptions/SlskdException.cs index 6b4cfc2a..22676161 100644 --- a/src/slskd/Common/Exceptions/SlskdException.cs +++ b/src/slskd/Common/Exceptions/SlskdException.cs @@ -19,13 +19,11 @@ namespace slskd { using System; using System.Diagnostics.CodeAnalysis; - using System.Runtime.Serialization; /// /// Represents erorrs that originate from slskd logic. /// [ExcludeFromCodeCoverage] - [Serializable] public class SlskdException : Exception { /// @@ -58,15 +56,5 @@ namespace slskd : base(message, innerException) { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The SerializationInfo that holds the serialized object data about the exception being thrown. - /// The StreamingContext that contains contextual information about the source or destination. - protected SlskdException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/slskd/Common/Exceptions/UnauthorizedException.cs b/src/slskd/Common/Exceptions/UnauthorizedException.cs index a7179c80..de1cac3e 100644 --- a/src/slskd/Common/Exceptions/UnauthorizedException.cs +++ b/src/slskd/Common/Exceptions/UnauthorizedException.cs @@ -19,13 +19,11 @@ namespace slskd { using System; using System.Diagnostics.CodeAnalysis; - using System.Runtime.Serialization; /// /// Represents errors that originate when a restricted resources is accessed without authorization. /// [ExcludeFromCodeCoverage] - [Serializable] public class UnauthorizedException : SlskdException { /// @@ -58,15 +56,5 @@ namespace slskd : base(message, innerException) { } - - /// - /// Initializes a new instance of the class with serialized data. - /// - /// The SerializationInfo that holds the serialized object data about the exception being thrown. - /// The StreamingContext that contains contextual information about the source or destination. - protected UnauthorizedException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/slskd/Transfers/API/Controllers/TransfersController.cs b/src/slskd/Transfers/API/Controllers/TransfersController.cs index ad984a4c..b5cbf885 100644 --- a/src/slskd/Transfers/API/Controllers/TransfersController.cs +++ b/src/slskd/Transfers/API/Controllers/TransfersController.cs @@ -374,7 +374,7 @@ namespace slskd.Transfers.API return Forbid(); } - // todo: refactor this so it doesn't return the world. start and end time params + // todo: refactor this so it doesn't return the world. start and end time params // should be required. consider pagination. var uploads = Transfers.Uploads.List(t => true, includeRemoved: includeRemoved); diff --git a/src/slskd/Transfers/Uploads/UploadService.cs b/src/slskd/Transfers/Uploads/UploadService.cs index 55b6b39a..c3c726df 100644 --- a/src/slskd/Transfers/Uploads/UploadService.cs +++ b/src/slskd/Transfers/Uploads/UploadService.cs @@ -340,7 +340,7 @@ namespace slskd.Transfers.Uploads SynchronizedUpdate(transfer); }), seekInputStreamAutomatically: false, - disposeInputStreamOnCompletion: true, + disposeInputStreamOnCompletion: true, // note: don't set this to false! governor: (tx, req, ct) => Governor.GetBytesAsync(tx.Username, req, ct), reporter: (tx, att, grant, act) => Governor.ReturnBytes(tx.Username, att, grant, act), slotAwaiter: (tx, ct) => Queue.AwaitStartAsync(tx.Username, tx.Filename), @@ -354,7 +354,11 @@ namespace slskd.Transfers.Uploads size: localFileLength, inputStreamFactory: (startOffset) => { + #pragma warning disable S2930 // "IDisposables" should be disposed + // disposeInputStreamOnCompletion takes care of this var stream = new FileStream(localFilename, FileMode.Open, FileAccess.Read); + #pragma warning restore S2930 // "IDisposables" should be disposed + stream.Seek(startOffset, SeekOrigin.Begin); return Task.FromResult((Stream)stream); }, diff --git a/src/slskd/slskd.csproj b/src/slskd/slskd.csproj index 346046e0..78f31d1d 100644 --- a/src/slskd/slskd.csproj +++ b/src/slskd/slskd.csproj @@ -16,11 +16,11 @@ - 1701;1702;1591;S1133;S2094;S1135 + 1701;1702;1591;S1133;S2094;S1135;S3925;S125 - 1591;S1133;S2094;S1135 + 1591;S1133;S2094;S1135;S3925;S125 -- cgit v1.2.3