diff --git a/starsky/starsky.feature.thumbnail/Services/ManualThumbnailGenerationService.cs b/starsky/starsky.feature.thumbnail/Services/ManualThumbnailGenerationService.cs index 84c8583600..1339460874 100644 --- a/starsky/starsky.feature.thumbnail/Services/ManualThumbnailGenerationService.cs +++ b/starsky/starsky.feature.thumbnail/Services/ManualThumbnailGenerationService.cs @@ -82,7 +82,7 @@ internal static List WhichFilesNeedToBePushedForUpdates(List(); var searchFor = getAllFilesAsync.Where(item => - thumbs.FirstOrDefault(p => p.SubPath == item.FilePath && item.Tags != null) + thumbs.Find(p => p.SubPath == item.FilePath && item.Tags != null) ?.Success == true).DistinctBy(p => p.FilePath); foreach ( var item in searchFor ) { diff --git a/starsky/starsky.feature.webhtmlpublish/Helpers/ToBase64DataUriList.cs b/starsky/starsky.feature.webhtmlpublish/Helpers/ToBase64DataUriList.cs index 5eeeefc972..405618d129 100644 --- a/starsky/starsky.feature.webhtmlpublish/Helpers/ToBase64DataUriList.cs +++ b/starsky/starsky.feature.webhtmlpublish/Helpers/ToBase64DataUriList.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using starsky.foundation.database.Models; using starsky.foundation.platform.Helpers; @@ -24,6 +25,9 @@ public ToBase64DataUriList(IStorage iStorage, IStorage thumbnailStorage, IWebLog _appSettings = appSettings; } + [SuppressMessage("Usage", "S3966: Resource 'memoryStream' has " + + "already been disposed explicitly or through a using statement implicitly. " + + "Remove the redundant disposal.")] public async Task Create(List fileIndexList) { var base64ImageArray = new string[fileIndexList.Count]; diff --git a/starsky/starsky.foundation.database/Models/ImportIndexItem.cs b/starsky/starsky.foundation.database/Models/ImportIndexItem.cs index 3fc95dd6ae..a349868d06 100644 --- a/starsky/starsky.foundation.database/Models/ImportIndexItem.cs +++ b/starsky/starsky.foundation.database/Models/ImportIndexItem.cs @@ -127,7 +127,9 @@ public DateTime ParseDateTimeFromFileName() // Replace asterisk > escape all options var structuredFileName = Structure.Split("/".ToCharArray()).LastOrDefault(); - if ( structuredFileName == null || string.IsNullOrEmpty(fileName) ) return new DateTime(); + if ( structuredFileName == null || string.IsNullOrEmpty(fileName) ) { + return new DateTime(0, DateTimeKind.Utc); + } structuredFileName = structuredFileName.Replace("*", ""); structuredFileName = structuredFileName.Replace(".ext", string.Empty); structuredFileName = structuredFileName.Replace("{filenamebase}", string.Empty); diff --git a/starsky/starsky.foundation.platform/Helpers/DateAssembly.cs b/starsky/starsky.foundation.platform/Helpers/DateAssembly.cs index ad18d92022..a34536ebe9 100644 --- a/starsky/starsky.foundation.platform/Helpers/DateAssembly.cs +++ b/starsky/starsky.foundation.platform/Helpers/DateAssembly.cs @@ -39,7 +39,9 @@ internal static DateTime ParseBuildTime(string value) } value = value.Substring(index + buildVersionMetadataPrefix.Length); return DateTime.TryParseExact(value, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, - DateTimeStyles.AssumeUniversal, out var result) ? result : new DateTime(); + DateTimeStyles.AssumeUniversal, out var result) ? + result : + new DateTime(0, DateTimeKind.Utc); } } } diff --git a/starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs b/starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs index 8463cf5043..77ea5281fa 100644 --- a/starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs +++ b/starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; @@ -23,6 +24,9 @@ [assembly: InternalsVisibleTo("starskytest")] namespace starsky.foundation.readmeta.ReadMetaHelpers { + [SuppressMessage("Usage", "S3966: Resource '_iStorage.ReadStream' has " + + "already been disposed explicitly or through a using statement implicitly. " + + "Remove the redundant disposal.")] public sealed class ReadMetaExif { private readonly IStorage _iStorage; @@ -346,7 +350,8 @@ private static string GetMakeModel(List allExifItems, bool isMake) } var quickTimeMetaDataDirectory = allExifItems.OfType().FirstOrDefault(); - var tagMakeModelQuickTime = isMake ? QuickTimeMetadataHeaderDirectory.TagMake : QuickTimeMetadataHeaderDirectory.TagModel; + var tagMakeModelQuickTime = isMake ? + QuickTimeMetadataHeaderDirectory.TagMake : QuickTimeMetadataHeaderDirectory.TagModel; var captionQuickTime = quickTimeMetaDataDirectory?.GetDescription(tagMakeModelQuickTime); return !string.IsNullOrEmpty(captionQuickTime) ? captionQuickTime : string.Empty; @@ -418,7 +423,8 @@ private static string GetXmpData(Directory exifItem, string propertyPath) if ( exifItem is not XmpDirectory xmpDirectory || xmpDirectory.XmpMeta == null ) return string.Empty; - return ( from property in xmpDirectory.XmpMeta.Properties.Where(p => !string.IsNullOrEmpty(p.Value)) + return ( from property in xmpDirectory.XmpMeta. + Properties.Where(p => !string.IsNullOrEmpty(p.Value)) where property.Path == propertyPath select property.Value ).FirstOrDefault(); } @@ -541,8 +547,8 @@ internal static DateTime ParseSubIfdDateTime(IEnumerable allExifItems var exifSubIfdList = allExifItems.OfType().ToList(); foreach ( var exifSubIfd in exifSubIfdList ) { - // https://odedcoster.com/blog/2011/12/13/date-and-time-format-strings-in-net-understanding-format-strings/ - // 2018:01:01 11:29:36 + // https://odedcoster.com/blog/2011/12/13/date-and-time-format-strings-in-net-understanding-format-strings/ + // 2018:01:01 11:29:36 var tagDateTimeDigitized = exifSubIfd.GetDescription(ExifDirectoryBase.TagDateTimeDigitized); DateTime.TryParseExact(tagDateTimeDigitized, pattern, provider, DateTimeStyles.AdjustToUniversal, out var itemDateTimeDigitized); @@ -560,7 +566,7 @@ internal static DateTime ParseSubIfdDateTime(IEnumerable allExifItems } } - return new DateTime(); + return new DateTime(0, DateTimeKind.Utc); } internal DateTime ParseQuickTimeDateTime(CameraMakeModel cameraMakeModel, @@ -568,7 +574,7 @@ internal DateTime ParseQuickTimeDateTime(CameraMakeModel cameraMakeModel, { if ( _appSettings == null ) Console.WriteLine("[ParseQuickTimeDateTime] app settings is null"); if ( cameraMakeModel == null ) cameraMakeModel = new CameraMakeModel(); - var useUseLocalTime = _appSettings?.VideoUseLocalTime?.Any(p => + var useUseLocalTime = _appSettings?.VideoUseLocalTime?.Exists(p => string.Equals(p.Make, cameraMakeModel.Make, StringComparison.InvariantCultureIgnoreCase) && ( string.Equals(p.Model, cameraMakeModel.Model, StringComparison.InvariantCultureIgnoreCase) || string.IsNullOrEmpty(p.Model) )); @@ -793,7 +799,8 @@ private static double GetGeoLocationLongitude(List allExifItems) if (!string.IsNullOrWhiteSpace(longitudeString)) { - var longitude = GeoParser.ConvertDegreeMinutesSecondsToDouble(longitudeString, longitudeRef); + var longitude = GeoParser. + ConvertDegreeMinutesSecondsToDouble(longitudeString, longitudeRef); longitude = Math.Floor(longitude * 10000000000) / 10000000000; return longitude; } @@ -914,7 +921,8 @@ private static double GetFocalLength(Directory exifItem) focalLengthString = focalLengthString.Replace(" mm", string.Empty); // Note: focalLengthString: (Dutch) 2,2 or (English) 2.2 based CultureInfo.CurrentCulture - float.TryParse(focalLengthString, NumberStyles.Number, CultureInfo.CurrentCulture, out var focalLength); + float.TryParse(focalLengthString, NumberStyles.Number, + CultureInfo.CurrentCulture, out var focalLength); return Math.Round(focalLength, 5); } @@ -965,7 +973,8 @@ private static string GetShutterSpeedValue(Directory exifItem) // XMP,http://ns.adobe.com/exif/1.0/,exif:ExposureTime,1/20 var exposureTimeXmp = GetXmpData(exifItem, "exif:ExposureTime"); - if (string.IsNullOrEmpty(shutterSpeedString) && !string.IsNullOrEmpty(exposureTimeXmp) && exposureTimeXmp.Length <= 20) + if (string.IsNullOrEmpty(shutterSpeedString) && + !string.IsNullOrEmpty(exposureTimeXmp) && exposureTimeXmp.Length <= 20) { return exposureTimeXmp; } @@ -998,8 +1007,10 @@ private static int GetIsoSpeedValue(Directory exifItem) p.DirectoryName == "Canon Makernote" && p.Name == "Base ISO")?.Description; if ( !string.IsNullOrEmpty(autoIso) && !string.IsNullOrEmpty(baseIso) ) { - int.TryParse(autoIso, NumberStyles.Number, CultureInfo.InvariantCulture, out var autoIsoSpeed); - int.TryParse(baseIso, NumberStyles.Number, CultureInfo.InvariantCulture, out var baseIsoSpeed); + int.TryParse(autoIso, NumberStyles.Number, + CultureInfo.InvariantCulture, out var autoIsoSpeed); + int.TryParse(baseIso, NumberStyles.Number, + CultureInfo.InvariantCulture, out var baseIsoSpeed); return baseIsoSpeed * autoIsoSpeed / 100; } } diff --git a/starsky/starsky.foundation.storage/Storage/StorageHostFullPathFilesystem.cs b/starsky/starsky.foundation.storage/Storage/StorageHostFullPathFilesystem.cs index f9988e0764..e3fcc7782e 100644 --- a/starsky/starsky.foundation.storage/Storage/StorageHostFullPathFilesystem.cs +++ b/starsky/starsky.foundation.storage/Storage/StorageHostFullPathFilesystem.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -312,6 +313,9 @@ bool LocalRun() return RetryHelper.Do(LocalRun, TimeSpan.FromSeconds(2),5); } + [SuppressMessage("Usage", "S3966: Resource '_iStorage.ReadStream' has " + + "already been disposed explicitly or through a using statement implicitly. " + + "Remove the redundant disposal.")] public bool WriteStream(Stream stream, string path) { if ( !stream.CanRead ) return false; diff --git a/starsky/starsky.foundation.sync/Helpers/SyncCli.cs b/starsky/starsky.foundation.sync/Helpers/SyncCli.cs index a64ad758e1..ea2890d175 100644 --- a/starsky/starsky.foundation.sync/Helpers/SyncCli.cs +++ b/starsky/starsky.foundation.sync/Helpers/SyncCli.cs @@ -54,7 +54,7 @@ public async Task Sync(string[] args) var stopWatch = Stopwatch.StartNew(); _console.WriteLine($"Start indexing {subPath}"); var result = await _synchronize.Sync(subPath); - if ( result.All(p => p.FilePath != subPath) ) + if ( result.TrueForAll(p => p.FilePath != subPath) ) { _console.WriteLine($"Not Found: {subPath}"); } diff --git a/starsky/starsky.foundation.sync/SyncServices/SyncSingleFile.cs b/starsky/starsky.foundation.sync/SyncServices/SyncSingleFile.cs index a4f8f69ce6..7a782fc66a 100644 --- a/starsky/starsky.foundation.sync/SyncServices/SyncSingleFile.cs +++ b/starsky/starsky.foundation.sync/SyncServices/SyncSingleFile.cs @@ -81,7 +81,7 @@ internal async Task> SingleFile(string subPath, var dbItems = await _query.GetObjectsByFilePathAsync(subPath,true); foreach ( var item in statusItems ) { - var dbItem = dbItems.FirstOrDefault(p => item.FilePath == p.FilePath); + var dbItem = dbItems.Find(p => item.FilePath == p.FilePath); if ( dbItem != null ) { scanItems.Add(dbItem);