From 68db37fbc161e31308634d8b18bfbe395ec52b11 Mon Sep 17 00:00:00 2001 From: Jochen Jonckheere Date: Wed, 4 Jan 2023 22:14:42 +0100 Subject: [PATCH] Fix all errors and made a lot of class internal --- SynoAI.Tests/SynoAI.Tests.csproj | 2 +- SynoAI/AIs/AI.cs | 2 +- SynoAI/AIs/DeepStack/DeepStackAI.cs | 8 ++++---- SynoAI/App/HttpClientWrapper.cs | 2 +- SynoAI/App/Shared.cs | 2 +- SynoAI/Config.cs | 2 +- SynoAI/Constants.cs | 2 +- SynoAI/Controllers/CameraController.cs | 8 ++++---- SynoAI/Controllers/HomeController.cs | 2 +- SynoAI/Extensions/StringExtensions.cs | 4 ++-- SynoAI/Models/Camera.cs | 1 + SynoAI/Models/CameraQuality.cs | 2 +- SynoAI/Models/Notification.cs | 2 +- SynoAI/Models/ProcessedImage.cs | 5 +++++ SynoAI/Models/SaveSnapshotMode.cs | 2 +- SynoAI/Models/SynologyApiInfoResponse.cs | 2 +- SynoAI/Models/SynologyCameras.cs | 2 +- SynoAI/Models/SynologyError.cs | 2 +- SynoAI/Models/SynologyLogin.cs | 2 +- SynoAI/Models/SynologyResponse.cs | 4 ++-- SynoAI/Notifiers/Discord/Discord.cs | 4 ++-- SynoAI/Notifiers/Discord/DiscordFactory.cs | 2 +- SynoAI/Notifiers/Email/Email.cs | 2 +- SynoAI/Notifiers/Email/EmailFactory.cs | 4 ++-- SynoAI/Notifiers/INotifier.cs | 2 +- SynoAI/Notifiers/Mqtt/Mqtt.cs | 2 +- SynoAI/Notifiers/Mqtt/MqttFactory.cs | 2 +- SynoAI/Notifiers/NotifierBase.cs | 12 ++++++------ SynoAI/Notifiers/NotifierFactory.cs | 2 +- SynoAI/Notifiers/Pushbullet/Pushbullet.cs | 2 +- SynoAI/Notifiers/Pushbullet/PushbulletError.cs | 2 +- .../Notifiers/Pushbullet/PushbulletErrorResponse.cs | 2 +- SynoAI/Notifiers/Pushbullet/PushbulletFactory.cs | 2 +- SynoAI/Notifiers/Pushbullet/PushbulletPush.cs | 2 +- SynoAI/Notifiers/Pushover/Pushover.cs | 2 +- SynoAI/Notifiers/Pushover/PushoverFactory.cs | 2 +- SynoAI/Notifiers/SynologyChat/SynologyChat.cs | 2 +- .../SynologyChat/SynologyChatErrorReasonResponse.cs | 2 +- .../SynologyChat/SynologyChatErrorResponse.cs | 2 +- SynoAI/Notifiers/SynologyChat/SynologyChatFactory.cs | 2 +- .../Notifiers/SynologyChat/SynologyChatResponse.cs | 2 +- SynoAI/Notifiers/Telegram/Telegram.cs | 2 +- SynoAI/Notifiers/Telegram/TelegramFactory.cs | 2 +- SynoAI/Notifiers/Webhook/AuthorizationMethod.cs | 2 +- SynoAI/Notifiers/Webhook/Webhook.cs | 2 +- SynoAI/Notifiers/Webhook/WebhookFactory.cs | 2 +- SynoAI/Services/AIService.cs | 4 ++-- SynoAI/Services/SnapshotManager.cs | 3 +-- SynoAI/Services/SynologyService.cs | 10 +++++----- SynoAI/SynoAI.csproj | 6 +++--- 50 files changed, 76 insertions(+), 71 deletions(-) diff --git a/SynoAI.Tests/SynoAI.Tests.csproj b/SynoAI.Tests/SynoAI.Tests.csproj index cfbfd01..d6b4d64 100644 --- a/SynoAI.Tests/SynoAI.Tests.csproj +++ b/SynoAI.Tests/SynoAI.Tests.csproj @@ -7,7 +7,7 @@ false enable true - latest-recommended + 6.0-recommended diff --git a/SynoAI/AIs/AI.cs b/SynoAI/AIs/AI.cs index c9d529a..3a14ec1 100644 --- a/SynoAI/AIs/AI.cs +++ b/SynoAI/AIs/AI.cs @@ -2,7 +2,7 @@ namespace SynoAI.AIs { - public abstract class AI + internal abstract class AI { public abstract Task> Process(ILogger logger, Camera camera, byte[] image); } diff --git a/SynoAI/AIs/DeepStack/DeepStackAI.cs b/SynoAI/AIs/DeepStack/DeepStackAI.cs index 3151beb..3c7c38d 100644 --- a/SynoAI/AIs/DeepStack/DeepStackAI.cs +++ b/SynoAI/AIs/DeepStack/DeepStackAI.cs @@ -5,9 +5,9 @@ namespace SynoAI.AIs.DeepStack { - public class DeepStackAI : AI + internal class DeepStackAI : AI { - public async override Task> Process(ILogger logger, Camera camera, byte[] image) + public override async Task> Process(ILogger logger, Camera camera, byte[] image) { Stopwatch stopwatch = Stopwatch.StartNew(); @@ -69,7 +69,7 @@ public async override Task> Process(ILogger logger, Ca /// /// /// A for the combined base and resource. - protected Uri GetUri(string basePath, string resourcePath) + protected static Uri GetUri(string basePath, string resourcePath) { Uri baseUri = new(basePath); return new Uri(baseUri, resourcePath); @@ -82,7 +82,7 @@ protected Uri GetUri(string basePath, string resourcePath) /// The message to parse. /// /// A usable object. - private async Task GetResponse(ILogger logger, Camera camera, HttpResponseMessage message) + private static async Task GetResponse(ILogger logger, Camera camera, HttpResponseMessage message) { string content = await message.Content.ReadAsStringAsync(); logger.LogDebug($"{camera.Name}: DeepStackAI: Responded with {content}."); diff --git a/SynoAI/App/HttpClientWrapper.cs b/SynoAI/App/HttpClientWrapper.cs index 1f9ee29..531249c 100644 --- a/SynoAI/App/HttpClientWrapper.cs +++ b/SynoAI/App/HttpClientWrapper.cs @@ -1,6 +1,6 @@ namespace SynoAI.App { - public class HttpClientWrapper : HttpClient, IHttpClient + internal class HttpClientWrapper : HttpClient, IHttpClient { } } diff --git a/SynoAI/App/Shared.cs b/SynoAI/App/Shared.cs index 8fae41e..34d4260 100644 --- a/SynoAI/App/Shared.cs +++ b/SynoAI/App/Shared.cs @@ -1,6 +1,6 @@ namespace SynoAI.App { - public static class Shared + internal static class Shared { public static IHttpClient HttpClient = new HttpClientWrapper(); } diff --git a/SynoAI/Config.cs b/SynoAI/Config.cs index 771e82f..31f9fac 100644 --- a/SynoAI/Config.cs +++ b/SynoAI/Config.cs @@ -8,7 +8,7 @@ namespace SynoAI /// /// Represents the system configuration. /// - public static class Config + internal static class Config { /// /// The URL to the synology API. diff --git a/SynoAI/Constants.cs b/SynoAI/Constants.cs index b05b575..6853309 100644 --- a/SynoAI/Constants.cs +++ b/SynoAI/Constants.cs @@ -1,6 +1,6 @@ namespace SynoAI { - public static class Constants + internal static class Constants { public const string DIRECTORY_CAPTURES = "Captures"; } diff --git a/SynoAI/Controllers/CameraController.cs b/SynoAI/Controllers/CameraController.cs index 1ca5025..892e89e 100644 --- a/SynoAI/Controllers/CameraController.cs +++ b/SynoAI/Controllers/CameraController.cs @@ -182,8 +182,8 @@ public async void Get(string id) // Save the original unprocessed image if required if (Config.SaveOriginalSnapshot == SaveSnapshotMode.Always || - (Config.SaveOriginalSnapshot == SaveSnapshotMode.WithPredictions && predictions.Count() > 0) || - (Config.SaveOriginalSnapshot == SaveSnapshotMode.WithValidPredictions && validPredictions.Count() > 0)) + (Config.SaveOriginalSnapshot == SaveSnapshotMode.WithPredictions && predictions.Any()) || + (Config.SaveOriginalSnapshot == SaveSnapshotMode.WithValidPredictions && validPredictions.Any())) { _logger.LogInformation($"{id}: Saving original image"); SnapshotManager.SaveOriginalImage(_logger, camera, snapshot); @@ -271,7 +271,7 @@ public void Post(string id, [FromBody]CameraOptionsDto options) private bool ShouldIncludePrediction(string id, Camera camera, Stopwatch overallStopwatch, AIPrediction prediction) { // Check if the prediction falls within the exclusion zones - if (camera.Exclusions != null && camera.Exclusions.Count() > 0) + if (camera.Exclusions != null && camera.Exclusions.Any()) { Rectangle boundary = new(prediction.MinX, prediction.MinY, prediction.SizeX, prediction.SizeY); foreach (Zone exclusion in camera.Exclusions) @@ -390,7 +390,7 @@ private byte[] PreProcessSnapshot(Camera camera, byte[] snapshot) /// The bitmap to rotate. /// The angle to rotate to. /// The rotated bitmap. - private SKBitmap Rotate(SKBitmap bitmap, double angle) + private static SKBitmap Rotate(SKBitmap bitmap, double angle) { double radians = Math.PI * angle / 180; float sine = (float)Math.Abs(Math.Sin(radians)); diff --git a/SynoAI/Controllers/HomeController.cs b/SynoAI/Controllers/HomeController.cs index 3197561..31a9007 100644 --- a/SynoAI/Controllers/HomeController.cs +++ b/SynoAI/Controllers/HomeController.cs @@ -253,7 +253,7 @@ private static int GetObjects(string filename) if (index != -1) { //try to extract the number of valid objects predicted inside this snapshot - if (!int.TryParse(name.Substring(index + 1), out objects)) + if (!int.TryParse(name.AsSpan(index + 1), out objects)) objects = 0; } else diff --git a/SynoAI/Extensions/StringExtensions.cs b/SynoAI/Extensions/StringExtensions.cs index 6305424..8920e7f 100644 --- a/SynoAI/Extensions/StringExtensions.cs +++ b/SynoAI/Extensions/StringExtensions.cs @@ -1,13 +1,13 @@ namespace SynoAI.Extensions { - public static class StringExtensions + internal static class StringExtensions { public static string FirstCharToUpper(this string input) => input switch { null => throw new ArgumentNullException(nameof(input)), "" => throw new ArgumentException($"{nameof(input)} cannot be empty", nameof(input)), - _ => input.First().ToString().ToUpper() + input.Substring(1) + _ => string.Concat(input.First().ToString().ToUpper(), input.AsSpan(1)) }; } } \ No newline at end of file diff --git a/SynoAI/Models/Camera.cs b/SynoAI/Models/Camera.cs index a821ca7..907d22b 100644 --- a/SynoAI/Models/Camera.cs +++ b/SynoAI/Models/Camera.cs @@ -115,6 +115,7 @@ public int GetDelayAfterSuccess() return DelayAfterSuccess ?? Config.DelayAfterSuccess ?? GetDelay(); } + /// public override string ToString() { return Name; diff --git a/SynoAI/Models/CameraQuality.cs b/SynoAI/Models/CameraQuality.cs index e54c3b9..d8c421f 100644 --- a/SynoAI/Models/CameraQuality.cs +++ b/SynoAI/Models/CameraQuality.cs @@ -1,6 +1,6 @@ namespace SynoAI.Models { - public enum CameraQuality + internal enum CameraQuality { High = 0, Balanced = 1, diff --git a/SynoAI/Models/Notification.cs b/SynoAI/Models/Notification.cs index 768e3f6..bf42cbc 100644 --- a/SynoAI/Models/Notification.cs +++ b/SynoAI/Models/Notification.cs @@ -2,7 +2,7 @@ namespace SynoAI.Models { - public class Notification + internal class Notification { /// /// Object for fetching the processed image diff --git a/SynoAI/Models/ProcessedImage.cs b/SynoAI/Models/ProcessedImage.cs index cf5664d..583d5af 100644 --- a/SynoAI/Models/ProcessedImage.cs +++ b/SynoAI/Models/ProcessedImage.cs @@ -14,6 +14,11 @@ public class ProcessedImage /// public readonly string FileName; + /// + /// Create a ProcessedImage + /// + /// + /// When filePath is null public ProcessedImage(string filePath) { if (string.IsNullOrWhiteSpace(filePath)) throw new ArgumentNullException(nameof(filePath)); diff --git a/SynoAI/Models/SaveSnapshotMode.cs b/SynoAI/Models/SaveSnapshotMode.cs index ca11e19..10d35ae 100644 --- a/SynoAI/Models/SaveSnapshotMode.cs +++ b/SynoAI/Models/SaveSnapshotMode.cs @@ -1,6 +1,6 @@ namespace SynoAI.Models { - public enum SaveSnapshotMode + internal enum SaveSnapshotMode { /// /// The snapshots are never saved. diff --git a/SynoAI/Models/SynologyApiInfoResponse.cs b/SynoAI/Models/SynologyApiInfoResponse.cs index af04fd7..32cf9c3 100644 --- a/SynoAI/Models/SynologyApiInfoResponse.cs +++ b/SynoAI/Models/SynologyApiInfoResponse.cs @@ -1,6 +1,6 @@ namespace SynoAI.Models { - public class SynologyApiInfoResponse : Dictionary + internal class SynologyApiInfoResponse : Dictionary { } } \ No newline at end of file diff --git a/SynoAI/Models/SynologyCameras.cs b/SynoAI/Models/SynologyCameras.cs index d21503c..dd62ed6 100644 --- a/SynoAI/Models/SynologyCameras.cs +++ b/SynoAI/Models/SynologyCameras.cs @@ -1,6 +1,6 @@ namespace SynoAI.Models { - public class SynologyCameras + internal class SynologyCameras { public IEnumerable Cameras { get; set; } } diff --git a/SynoAI/Models/SynologyError.cs b/SynoAI/Models/SynologyError.cs index ccd586a..b2f011f 100644 --- a/SynoAI/Models/SynologyError.cs +++ b/SynoAI/Models/SynologyError.cs @@ -1,6 +1,6 @@ namespace SynoAI.Models { - public class SynologyError + internal class SynologyError { public string Code { get; set; } } diff --git a/SynoAI/Models/SynologyLogin.cs b/SynoAI/Models/SynologyLogin.cs index 8d20445..cba8f43 100644 --- a/SynoAI/Models/SynologyLogin.cs +++ b/SynoAI/Models/SynologyLogin.cs @@ -1,6 +1,6 @@ namespace SynoAI.Models { - public class SynologyLogin + internal class SynologyLogin { public string SID { get; set; } } diff --git a/SynoAI/Models/SynologyResponse.cs b/SynoAI/Models/SynologyResponse.cs index bb80a58..2acff8d 100644 --- a/SynoAI/Models/SynologyResponse.cs +++ b/SynoAI/Models/SynologyResponse.cs @@ -1,11 +1,11 @@ namespace SynoAI.Models { - public class SynologyResponse : SynologyResponse + internal class SynologyResponse : SynologyResponse { public T Data { get; set; } } - public class SynologyResponse + internal class SynologyResponse { public bool Success { get; set; } public SynologyError Error { get; set; } diff --git a/SynoAI/Notifiers/Discord/Discord.cs b/SynoAI/Notifiers/Discord/Discord.cs index 7df67a3..5624251 100644 --- a/SynoAI/Notifiers/Discord/Discord.cs +++ b/SynoAI/Notifiers/Discord/Discord.cs @@ -3,7 +3,7 @@ namespace SynoAI.Notifiers.Discord { - public class Discord : NotifierBase + internal class Discord : NotifierBase { /// /// Discord Webhook Url. @@ -25,7 +25,7 @@ public override async Task SendAsync(Camera camera, Notification notification, I HttpResponseMessage responseMessage = await Shared.HttpClient.PostAsync(Url, formData); if (responseMessage.IsSuccessStatusCode) { - logger.LogInformation($"{camera.Name}: Discord: Notification sent successfully"); + logger.LogInformation("{CameraName}: Discord: Notification sent successfully", camera.Name); } else { diff --git a/SynoAI/Notifiers/Discord/DiscordFactory.cs b/SynoAI/Notifiers/Discord/DiscordFactory.cs index 6c1bf30..4c27d75 100644 --- a/SynoAI/Notifiers/Discord/DiscordFactory.cs +++ b/SynoAI/Notifiers/Discord/DiscordFactory.cs @@ -1,6 +1,6 @@ namespace SynoAI.Notifiers.Discord { - public class DiscordFactory : NotifierFactory + internal class DiscordFactory : NotifierFactory { public override INotifier Create(ILogger logger, IConfigurationSection section) { diff --git a/SynoAI/Notifiers/Email/Email.cs b/SynoAI/Notifiers/Email/Email.cs index f9e2e74..3211a69 100644 --- a/SynoAI/Notifiers/Email/Email.cs +++ b/SynoAI/Notifiers/Email/Email.cs @@ -8,7 +8,7 @@ namespace SynoAI.Notifiers.Email /// /// Calls a third party API. /// - public class Email : NotifierBase + internal class Email : NotifierBase { /// /// The email address to send the notification from. diff --git a/SynoAI/Notifiers/Email/EmailFactory.cs b/SynoAI/Notifiers/Email/EmailFactory.cs index aa796a5..55370e4 100644 --- a/SynoAI/Notifiers/Email/EmailFactory.cs +++ b/SynoAI/Notifiers/Email/EmailFactory.cs @@ -2,7 +2,7 @@ namespace SynoAI.Notifiers.Email { - public class EmailFactory : NotifierFactory + internal class EmailFactory : NotifierFactory { public override INotifier Create(ILogger logger, IConfigurationSection section) { @@ -31,7 +31,7 @@ public override INotifier Create(ILogger logger, IConfigurationSection section) } } - private SecureSocketOptions GetSecureSocketOptions(ILogger logger, IConfigurationSection section) + private static SecureSocketOptions GetSecureSocketOptions(ILogger logger, IConfigurationSection section) { string options = section.GetValue("Encryption", "None").ToUpper(); diff --git a/SynoAI/Notifiers/INotifier.cs b/SynoAI/Notifiers/INotifier.cs index b236119..8ef4c6f 100644 --- a/SynoAI/Notifiers/INotifier.cs +++ b/SynoAI/Notifiers/INotifier.cs @@ -2,7 +2,7 @@ namespace SynoAI.Notifiers { - public interface INotifier + internal interface INotifier { /// /// The list of camera names that the notifier is for. diff --git a/SynoAI/Notifiers/Mqtt/Mqtt.cs b/SynoAI/Notifiers/Mqtt/Mqtt.cs index b6b4a8b..c0101b9 100644 --- a/SynoAI/Notifiers/Mqtt/Mqtt.cs +++ b/SynoAI/Notifiers/Mqtt/Mqtt.cs @@ -7,7 +7,7 @@ namespace SynoAI.Notifiers.Mqtt /// /// Sends a message over MQTT. /// - public sealed class Mqtt : NotifierBase + internal sealed class Mqtt : NotifierBase { /// /// The username when using Basic authentication. diff --git a/SynoAI/Notifiers/Mqtt/MqttFactory.cs b/SynoAI/Notifiers/Mqtt/MqttFactory.cs index 8205d13..bfe355b 100644 --- a/SynoAI/Notifiers/Mqtt/MqttFactory.cs +++ b/SynoAI/Notifiers/Mqtt/MqttFactory.cs @@ -1,6 +1,6 @@ namespace SynoAI.Notifiers.Mqtt { - public class MqttFactory : NotifierFactory + internal class MqttFactory : NotifierFactory { public override INotifier Create(ILogger logger, IConfigurationSection section) { diff --git a/SynoAI/Notifiers/NotifierBase.cs b/SynoAI/Notifiers/NotifierBase.cs index 1d7588b..510ca78 100644 --- a/SynoAI/Notifiers/NotifierBase.cs +++ b/SynoAI/Notifiers/NotifierBase.cs @@ -4,7 +4,7 @@ namespace SynoAI.Notifiers { - public abstract class NotifierBase : INotifier + internal abstract class NotifierBase : INotifier { public IEnumerable Cameras { get; set; } public IEnumerable Types { get; set; } @@ -16,7 +16,7 @@ public abstract class NotifierBase : INotifier public virtual Task CleanupAsync(ILogger logger) { return Task.CompletedTask; } - protected string GetMessage(Camera camera, IEnumerable foundTypes, string errorMessage = null) + protected static string GetMessage(Camera camera, IEnumerable foundTypes, string errorMessage = null) { string result ; if (Config.AlternativeLabelling && Config.DrawMode == DrawMode.Matches) @@ -53,7 +53,7 @@ protected string GetMessage(Camera camera, IEnumerable foundTypes, strin return result; } - protected string GetImageUrl(Camera camera, Notification notification) + protected static string GetImageUrl(Camera camera, Notification notification) { if (Config.SynoAIUrL == null) { @@ -69,7 +69,7 @@ protected string GetImageUrl(Camera camera, Notification notification) /// /// Generates a JSON representation of the notification. /// - protected string GenerateJSON(Camera camera, Notification notification, bool sendImage) + protected static string GenerateJSON(Camera camera, Notification notification, bool sendImage) { dynamic jsonObject = new ExpandoObject(); @@ -95,7 +95,7 @@ protected string GenerateJSON(Camera camera, Notification notification, bool sen /// /// Returns FileStream data as a base64-encoded string /// - private string ToBase64String(FileStream fileStream) + private static string ToBase64String(FileStream fileStream) { byte[] buffer = new byte[fileStream.Length]; fileStream.Read(buffer, 0, (int)fileStream.Length); @@ -108,7 +108,7 @@ private string ToBase64String(FileStream fileStream) /// /// The message to parse. /// A usable object. - protected async Task GetResponse(HttpResponseMessage message) + protected static async Task GetResponse(HttpResponseMessage message) { string content = await message.Content.ReadAsStringAsync(); return JsonConvert.DeserializeObject(content); diff --git a/SynoAI/Notifiers/NotifierFactory.cs b/SynoAI/Notifiers/NotifierFactory.cs index d6d1fb3..9cccf0e 100644 --- a/SynoAI/Notifiers/NotifierFactory.cs +++ b/SynoAI/Notifiers/NotifierFactory.cs @@ -12,7 +12,7 @@ namespace SynoAI.Notifiers /// /// Handles the construction of the notifiers. /// - public abstract class NotifierFactory + internal abstract class NotifierFactory { public abstract INotifier Create(ILogger logger, IConfigurationSection section); diff --git a/SynoAI/Notifiers/Pushbullet/Pushbullet.cs b/SynoAI/Notifiers/Pushbullet/Pushbullet.cs index 98567d5..5bc56ea 100644 --- a/SynoAI/Notifiers/Pushbullet/Pushbullet.cs +++ b/SynoAI/Notifiers/Pushbullet/Pushbullet.cs @@ -8,7 +8,7 @@ namespace SynoAI.Notifiers.Pushbullet /// Configuration for sending a Pushbullet notification. /// https://docs.pushbullet.com/ /// - public class Pushbullet : NotifierBase + internal class Pushbullet : NotifierBase { //private const int MAX_FILE_SIZE = 26214400; diff --git a/SynoAI/Notifiers/Pushbullet/PushbulletError.cs b/SynoAI/Notifiers/Pushbullet/PushbulletError.cs index 268fded..a96cbc8 100644 --- a/SynoAI/Notifiers/Pushbullet/PushbulletError.cs +++ b/SynoAI/Notifiers/Pushbullet/PushbulletError.cs @@ -1,6 +1,6 @@ namespace SynoAI.Notifiers.Pushbullet { - public class PushbulletError + internal class PushbulletError { public string Code { get; set; } public string Type { get; set; } diff --git a/SynoAI/Notifiers/Pushbullet/PushbulletErrorResponse.cs b/SynoAI/Notifiers/Pushbullet/PushbulletErrorResponse.cs index c7549fc..aee5cf7 100644 --- a/SynoAI/Notifiers/Pushbullet/PushbulletErrorResponse.cs +++ b/SynoAI/Notifiers/Pushbullet/PushbulletErrorResponse.cs @@ -2,7 +2,7 @@ namespace SynoAI.Notifiers.Pushbullet { - public class PushbulletErrorResponse + internal class PushbulletErrorResponse { public PushbulletError Error { get; set; } [JsonProperty("error_code")] diff --git a/SynoAI/Notifiers/Pushbullet/PushbulletFactory.cs b/SynoAI/Notifiers/Pushbullet/PushbulletFactory.cs index 227d544..391c8de 100644 --- a/SynoAI/Notifiers/Pushbullet/PushbulletFactory.cs +++ b/SynoAI/Notifiers/Pushbullet/PushbulletFactory.cs @@ -1,6 +1,6 @@ namespace SynoAI.Notifiers.Pushbullet { - public class PushbulletFactory : NotifierFactory + internal class PushbulletFactory : NotifierFactory { public override INotifier Create(ILogger logger, IConfigurationSection section) { diff --git a/SynoAI/Notifiers/Pushbullet/PushbulletPush.cs b/SynoAI/Notifiers/Pushbullet/PushbulletPush.cs index a678629..b6c50dc 100644 --- a/SynoAI/Notifiers/Pushbullet/PushbulletPush.cs +++ b/SynoAI/Notifiers/Pushbullet/PushbulletPush.cs @@ -2,7 +2,7 @@ namespace SynoAI.Notifiers.Pushbullet { - public class PushbulletPush + internal class PushbulletPush { [JsonProperty("type")] public string Type { get; set; } diff --git a/SynoAI/Notifiers/Pushover/Pushover.cs b/SynoAI/Notifiers/Pushover/Pushover.cs index 0d5807e..5c89ea4 100644 --- a/SynoAI/Notifiers/Pushover/Pushover.cs +++ b/SynoAI/Notifiers/Pushover/Pushover.cs @@ -4,7 +4,7 @@ namespace SynoAI.Notifiers.Pushover { - public class Pushover : NotifierBase + internal class Pushover : NotifierBase { private readonly string URI_MESSAGE = "https://api.pushover.net/1/messages.json"; diff --git a/SynoAI/Notifiers/Pushover/PushoverFactory.cs b/SynoAI/Notifiers/Pushover/PushoverFactory.cs index 4da3588..908d3c1 100644 --- a/SynoAI/Notifiers/Pushover/PushoverFactory.cs +++ b/SynoAI/Notifiers/Pushover/PushoverFactory.cs @@ -1,6 +1,6 @@ namespace SynoAI.Notifiers.Pushover { - public class PushoverFactory : NotifierFactory + internal class PushoverFactory : NotifierFactory { public override INotifier Create(ILogger logger, IConfigurationSection section) { diff --git a/SynoAI/Notifiers/SynologyChat/SynologyChat.cs b/SynoAI/Notifiers/SynologyChat/SynologyChat.cs index 5fb8ba8..f692ab1 100644 --- a/SynoAI/Notifiers/SynologyChat/SynologyChat.cs +++ b/SynoAI/Notifiers/SynologyChat/SynologyChat.cs @@ -6,7 +6,7 @@ namespace SynoAI.Notifiers.SynologyChat /// /// Calls a third party API. /// - public class SynologyChat : NotifierBase + internal class SynologyChat : NotifierBase { /// /// The URL to send the request to including the token. diff --git a/SynoAI/Notifiers/SynologyChat/SynologyChatErrorReasonResponse.cs b/SynoAI/Notifiers/SynologyChat/SynologyChatErrorReasonResponse.cs index 37c815c..767d891 100644 --- a/SynoAI/Notifiers/SynologyChat/SynologyChatErrorReasonResponse.cs +++ b/SynoAI/Notifiers/SynologyChat/SynologyChatErrorReasonResponse.cs @@ -2,7 +2,7 @@ namespace SynoAI.Notifiers.SynologyChat { - public class SynologyChatErrorReasonResponse + internal class SynologyChatErrorReasonResponse { [JsonProperty("name")] public string Name { get; set; } diff --git a/SynoAI/Notifiers/SynologyChat/SynologyChatErrorResponse.cs b/SynoAI/Notifiers/SynologyChat/SynologyChatErrorResponse.cs index 1f64499..3c8fb5d 100644 --- a/SynoAI/Notifiers/SynologyChat/SynologyChatErrorResponse.cs +++ b/SynoAI/Notifiers/SynologyChat/SynologyChatErrorResponse.cs @@ -2,7 +2,7 @@ namespace SynoAI.Notifiers.SynologyChat { - public class SynologyChatErrorResponse + internal class SynologyChatErrorResponse { [JsonProperty("code")] public string Code { get; set; } diff --git a/SynoAI/Notifiers/SynologyChat/SynologyChatFactory.cs b/SynoAI/Notifiers/SynologyChat/SynologyChatFactory.cs index 3bb92de..b80cbb8 100644 --- a/SynoAI/Notifiers/SynologyChat/SynologyChatFactory.cs +++ b/SynoAI/Notifiers/SynologyChat/SynologyChatFactory.cs @@ -1,6 +1,6 @@ namespace SynoAI.Notifiers.SynologyChat { - public class SynologyChatFactory : NotifierFactory + internal class SynologyChatFactory : NotifierFactory { public override INotifier Create(ILogger logger, IConfigurationSection section) { diff --git a/SynoAI/Notifiers/SynologyChat/SynologyChatResponse.cs b/SynoAI/Notifiers/SynologyChat/SynologyChatResponse.cs index db6e00d..460a643 100644 --- a/SynoAI/Notifiers/SynologyChat/SynologyChatResponse.cs +++ b/SynoAI/Notifiers/SynologyChat/SynologyChatResponse.cs @@ -2,7 +2,7 @@ namespace SynoAI.Notifiers.SynologyChat { - public class SynologyChatResponse + internal class SynologyChatResponse { [JsonProperty("success")] public bool Success { get; set; } diff --git a/SynoAI/Notifiers/Telegram/Telegram.cs b/SynoAI/Notifiers/Telegram/Telegram.cs index a9985e2..8be2a34 100644 --- a/SynoAI/Notifiers/Telegram/Telegram.cs +++ b/SynoAI/Notifiers/Telegram/Telegram.cs @@ -6,7 +6,7 @@ namespace SynoAI.Notifiers.Telegram /// /// Calls a third party API. /// - public class Telegram : NotifierBase + internal class Telegram : NotifierBase { /// /// The ID of the chat to send notifications to diff --git a/SynoAI/Notifiers/Telegram/TelegramFactory.cs b/SynoAI/Notifiers/Telegram/TelegramFactory.cs index ae3d784..2edc824 100644 --- a/SynoAI/Notifiers/Telegram/TelegramFactory.cs +++ b/SynoAI/Notifiers/Telegram/TelegramFactory.cs @@ -1,6 +1,6 @@ namespace SynoAI.Notifiers.Telegram { - public class TelegramFactory : NotifierFactory + internal class TelegramFactory : NotifierFactory { public override INotifier Create(ILogger logger, IConfigurationSection section) { diff --git a/SynoAI/Notifiers/Webhook/AuthorizationMethod.cs b/SynoAI/Notifiers/Webhook/AuthorizationMethod.cs index 6efec82..cbe4b73 100644 --- a/SynoAI/Notifiers/Webhook/AuthorizationMethod.cs +++ b/SynoAI/Notifiers/Webhook/AuthorizationMethod.cs @@ -1,6 +1,6 @@ namespace SynoAI.Notifiers.Webhook { - public enum AuthorizationMethod + internal enum AuthorizationMethod { None, Basic, diff --git a/SynoAI/Notifiers/Webhook/Webhook.cs b/SynoAI/Notifiers/Webhook/Webhook.cs index 0b1db6f..ebe5235 100644 --- a/SynoAI/Notifiers/Webhook/Webhook.cs +++ b/SynoAI/Notifiers/Webhook/Webhook.cs @@ -8,7 +8,7 @@ namespace SynoAI.Notifiers.Webhook /// /// Calls a third party API. /// - public class Webhook : NotifierBase + internal class Webhook : NotifierBase { /// /// The URL to send the request to. diff --git a/SynoAI/Notifiers/Webhook/WebhookFactory.cs b/SynoAI/Notifiers/Webhook/WebhookFactory.cs index 3b960b7..3ae5779 100644 --- a/SynoAI/Notifiers/Webhook/WebhookFactory.cs +++ b/SynoAI/Notifiers/Webhook/WebhookFactory.cs @@ -1,6 +1,6 @@ namespace SynoAI.Notifiers.Webhook { - public class WebhookFactory : NotifierFactory + internal class WebhookFactory : NotifierFactory { public override INotifier Create(ILogger logger, IConfigurationSection section) { diff --git a/SynoAI/Services/AIService.cs b/SynoAI/Services/AIService.cs index b4bd732..7816c58 100644 --- a/SynoAI/Services/AIService.cs +++ b/SynoAI/Services/AIService.cs @@ -4,7 +4,7 @@ namespace SynoAI.Services { - public class AIService : IAIService + internal class AIService : IAIService { private readonly ILogger _logger; @@ -19,7 +19,7 @@ public async Task> ProcessAsync(Camera camera, byte[] return await ai.Process(_logger, camera, image); } - private AI GetAI() + private static AI GetAI() { switch (Config.AI) { diff --git a/SynoAI/Services/SnapshotManager.cs b/SynoAI/Services/SnapshotManager.cs index 4662aa9..08b1165 100644 --- a/SynoAI/Services/SnapshotManager.cs +++ b/SynoAI/Services/SnapshotManager.cs @@ -5,8 +5,7 @@ namespace SynoAI.Services { - - public class SnapshotManager + internal class SnapshotManager { /// /// Dresses the source image by adding the boundary boxes and saves the file locally. diff --git a/SynoAI/Services/SynologyService.cs b/SynoAI/Services/SynologyService.cs index a98b50e..15b7d4c 100644 --- a/SynoAI/Services/SynologyService.cs +++ b/SynoAI/Services/SynologyService.cs @@ -5,7 +5,7 @@ namespace SynoAI.Services { - public class SynologyService : ISynologyService + internal class SynologyService : ISynologyService { /// /// The current cookie with valid authentication. @@ -251,7 +251,7 @@ public async Task TakeSnapshotAsync(string cameraName) /// The type of the return 'data'. /// The message to parse. /// A Synology response object. - private async Task> GetResponse(HttpResponseMessage message) + private static async Task> GetResponse(HttpResponseMessage message) { string content = await message.Content.ReadAsStringAsync(); return JsonConvert.DeserializeObject>(content); @@ -262,7 +262,7 @@ private async Task> GetResponse(HttpResponseMessage messa /// /// The message to parse. /// A Synology response object. - private async Task GetErrorResponse(HttpResponseMessage message) + private static async Task GetErrorResponse(HttpResponseMessage message) { string content = await message.Content.ReadAsStringAsync(); return JsonConvert.DeserializeObject(content); @@ -346,7 +346,7 @@ public async Task InitialiseAsync() /// The base URI. /// The container for the cookies. /// An HttpClient. - private HttpClient GetHttpClient(string baseAddress, CookieContainer cookieContainer = null) + private static HttpClient GetHttpClient(string baseAddress, CookieContainer cookieContainer = null) { Uri uri = new Uri(baseAddress); return GetHttpClient(uri, cookieContainer); @@ -358,7 +358,7 @@ private HttpClient GetHttpClient(string baseAddress, CookieContainer cookieConta /// The base URI. /// The container for the cookies. /// An HttpClient. - private HttpClient GetHttpClient(Uri baseUri, CookieContainer cookieContainer = null) + private static HttpClient GetHttpClient(Uri baseUri, CookieContainer cookieContainer = null) { HttpClientHandler httpClientHandler = new HttpClientHandler(); if (cookieContainer != null) diff --git a/SynoAI/SynoAI.csproj b/SynoAI/SynoAI.csproj index 1c19570..57bdfb2 100644 --- a/SynoAI/SynoAI.csproj +++ b/SynoAI/SynoAI.csproj @@ -10,19 +10,19 @@ Linux enable true - latest-recommended + 6.0-minimum True True - CS1591;CA1416 + CS1591;CA1416;CA2254 True True - CS1591;CA1416 + CS1591;CA1416;CA2254