From e266e6436bba908f5aa4ed1c2cbc6cf120cdf187 Mon Sep 17 00:00:00 2001 From: Dion Date: Sun, 30 Jul 2023 13:34:41 +0200 Subject: [PATCH 1/8] bug --- .../organisms/detail-view-sidebar/detail-view-sidebar.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/starsky/starsky/clientapp/src/components/organisms/detail-view-sidebar/detail-view-sidebar.tsx b/starsky/starsky/clientapp/src/components/organisms/detail-view-sidebar/detail-view-sidebar.tsx index 650e2d0109..649b5fd16c 100644 --- a/starsky/starsky/clientapp/src/components/organisms/detail-view-sidebar/detail-view-sidebar.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/detail-view-sidebar/detail-view-sidebar.tsx @@ -197,10 +197,10 @@ const DetailViewSidebar: React.FunctionComponent = state ); - const paste = new ClipboardHelper().PasteAsync(updateChange.Update); - - if (!paste) return; - setCopyPasteAction(MessagePasteLabels); + new ClipboardHelper().PasteAsync(updateChange.Update).then((paste) => { + if (!paste) return; + setCopyPasteAction(MessagePasteLabels); + }); }, [props] ); From 18226fa739b19766b6ac75a54b2e26af2e5142d2 Mon Sep 17 00:00:00 2001 From: Dion Date: Mon, 31 Jul 2023 12:51:16 +0200 Subject: [PATCH 2/8] code smells --- .../ManualThumbnailGenerationService.cs | 2 +- .../Helpers/ToBase64DataUriList.cs | 4 +++ .../Models/ImportIndexItem.cs | 4 ++- .../Helpers/DateAssembly.cs | 4 ++- .../ReadMetaHelpers/ReadMetaExif.cs | 33 ++++++++++++------- .../Storage/StorageHostFullPathFilesystem.cs | 4 +++ .../Helpers/SyncCli.cs | 2 +- .../SyncServices/SyncSingleFile.cs | 2 +- 8 files changed, 39 insertions(+), 16 deletions(-) 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); From 50005a3ee1f823be1459f1d07e832093b77c014b Mon Sep 17 00:00:00 2001 From: Dion Date: Mon, 31 Jul 2023 12:59:07 +0200 Subject: [PATCH 3/8] paste --- .../detail-view-sidebar.spec.tsx | 54 +++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/starsky/starsky/clientapp/src/components/organisms/detail-view-sidebar/detail-view-sidebar.spec.tsx b/starsky/starsky/clientapp/src/components/organisms/detail-view-sidebar/detail-view-sidebar.spec.tsx index a1bc5dc70d..81d6810728 100644 --- a/starsky/starsky/clientapp/src/components/organisms/detail-view-sidebar/detail-view-sidebar.spec.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/detail-view-sidebar/detail-view-sidebar.spec.tsx @@ -498,7 +498,7 @@ describe("DetailViewSidebar", () => { colorClassActiveList: [] } as any; - it("Press v to paste", () => { + it("Press v to paste return false", () => { let vPasteIsCalled = false; function keyboardCallback(regex: RegExp, callback: Function) { if (regex.source === "^v$") { @@ -527,9 +527,57 @@ describe("DetailViewSidebar", () => { .mockImplementationOnce(() => false); jest - .spyOn(ClipboardHelper.prototype, "Paste") + .spyOn(ClipboardHelper.prototype, "PasteAsync") .mockImplementationOnce(() => { - return false; + return Promise.resolve(false); + }); + + const component = render( + + ); + + expect(vPasteIsCalled).toBeTruthy(); + + component.unmount(); + }); + + it("Press v to paste return true", () => { + let vPasteIsCalled = false; + function keyboardCallback(regex: RegExp, callback: Function) { + if (regex.source === "^v$") { + const event = new KeyboardEvent("keydown", { + bubbles: true, + cancelable: true, + key: "v" + }); + vPasteIsCalled = true; + callback(event); + } + } + + jest + .spyOn(useKeyboardEvent, "default") + .mockImplementationOnce(keyboardCallback) + .mockImplementationOnce(keyboardCallback) + .mockImplementationOnce(keyboardCallback); + + jest + .spyOn(Keyboard.prototype, "SetFocusOnEndField") + .mockImplementationOnce(() => {}); + + jest + .spyOn(Keyboard.prototype, "isInForm") + .mockImplementationOnce(() => false); + + jest + .spyOn(ClipboardHelper.prototype, "PasteAsync") + .mockImplementationOnce(() => { + return Promise.resolve(true); }); const component = render( From cf1a671f66ca58a65ca6b09001f169ab9f282129 Mon Sep 17 00:00:00 2001 From: Dion Date: Mon, 31 Jul 2023 14:36:27 +0200 Subject: [PATCH 4/8] code smells --- .../atoms/notification/notification.tsx | 4 +-- .../search-pagination/search-pagination.tsx | 2 +- .../clientapp/src/interfaces/IArchive.ts | 4 +-- .../clientapp/src/interfaces/IDetailView.ts | 16 +++++----- .../clientapp/src/interfaces/IExifStatus.ts | 22 +++++++------- .../src/interfaces/IFileIndexItem.ts | 30 +++++++++---------- .../clientapp/src/pages/content-page.tsx | 7 +---- .../clientapp/src/shared/file-extensions.ts | 4 +-- .../starsky/clientapp/src/shared/keyboard.ts | 2 +- .../src/shared/select-check-if-active.ts | 2 +- .../clientapp/src/shared/string-options.ts | 2 +- 11 files changed, 45 insertions(+), 50 deletions(-) diff --git a/starsky/starsky/clientapp/src/components/atoms/notification/notification.tsx b/starsky/starsky/clientapp/src/components/atoms/notification/notification.tsx index 5424499439..26b65b0634 100644 --- a/starsky/starsky/clientapp/src/components/atoms/notification/notification.tsx +++ b/starsky/starsky/clientapp/src/components/atoms/notification/notification.tsx @@ -8,8 +8,8 @@ type NotificationPropTypes = { }; export enum NotificationType { - default = "default" as any, - danger = "danger" as any + default = "default", + danger = "danger" } const Notification: React.FunctionComponent = ({ diff --git a/starsky/starsky/clientapp/src/components/molecules/search-pagination/search-pagination.tsx b/starsky/starsky/clientapp/src/components/molecules/search-pagination/search-pagination.tsx index 9ef819fd35..36852ec3a0 100644 --- a/starsky/starsky/clientapp/src/components/molecules/search-pagination/search-pagination.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/search-pagination/search-pagination.tsx @@ -36,7 +36,7 @@ const SearchPagination: React.FunctionComponent = memo( setUrlObject(urlObjectLocal); }, [props, history.location.search]); - function prev(): JSX.Element { + function prev(): React.JSX.Element { if (!urlObject || !lastPageNumber) return <>; urlObject.p = urlObject.p ? urlObject.p : 0; const prevObject = { ...urlObject }; diff --git a/starsky/starsky/clientapp/src/interfaces/IArchive.ts b/starsky/starsky/clientapp/src/interfaces/IArchive.ts index 4aaadbdfe1..b525960d61 100644 --- a/starsky/starsky/clientapp/src/interfaces/IArchive.ts +++ b/starsky/starsky/clientapp/src/interfaces/IArchive.ts @@ -18,8 +18,8 @@ export interface IArchive { } export enum SortType { - fileName = "fileName" as any, - imageFormat = "imageFormat" as any + fileName = "fileName", + imageFormat = "imageFormat" } export function newIArchive(): IArchive { diff --git a/starsky/starsky/clientapp/src/interfaces/IDetailView.ts b/starsky/starsky/clientapp/src/interfaces/IDetailView.ts index 1c1edb3a4e..d510c33d28 100644 --- a/starsky/starsky/clientapp/src/interfaces/IDetailView.ts +++ b/starsky/starsky/clientapp/src/interfaces/IDetailView.ts @@ -1,14 +1,14 @@ import { IFileIndexItem } from "./IFileIndexItem"; export enum PageType { - Loading = "Loading" as any, - Archive = "Archive" as any, - DetailView = "DetailView" as any, - Search = "Search" as any, - ApplicationException = "ApplicationException" as any, - NotFound = "NotFound" as any, - Unauthorized = "Unauthorized" as any, - Trash = "Trash" as any + Loading = "Loading", + Archive = "Archive", + DetailView = "DetailView", + Search = "Search", + ApplicationException = "ApplicationException", + NotFound = "NotFound", + Unauthorized = "Unauthorized", + Trash = "Trash" } export interface IRelativeObjects { diff --git a/starsky/starsky/clientapp/src/interfaces/IExifStatus.ts b/starsky/starsky/clientapp/src/interfaces/IExifStatus.ts index 7ef61c8fd8..9bf390d035 100644 --- a/starsky/starsky/clientapp/src/interfaces/IExifStatus.ts +++ b/starsky/starsky/clientapp/src/interfaces/IExifStatus.ts @@ -1,13 +1,13 @@ export enum IExifStatus { - Default = "Default" as any, - ReadOnly = "ReadOnly" as any, - Ok = "Ok" as any, - OkAndSame = "OkAndSame" as any, - Deleted = "Deleted" as any, - NotFoundSourceMissing = "NotFoundSourceMissing" as any, - ServerError = "ServerError" as any, - IgnoredAlreadyImported = "IgnoredAlreadyImported" as any, - OperationNotSupported = "OperationNotSupported" as any, - NotFoundNotInIndex = "NotFoundNotInIndex" as any, - FileError = "FileError" as any + Default = "Default", + ReadOnly = "ReadOnly", + Ok = "Ok", + OkAndSame = "OkAndSame", + Deleted = "Deleted", + NotFoundSourceMissing = "NotFoundSourceMissing", + ServerError = "ServerError", + IgnoredAlreadyImported = "IgnoredAlreadyImported", + OperationNotSupported = "OperationNotSupported", + NotFoundNotInIndex = "NotFoundNotInIndex", + FileError = "FileError" } diff --git a/starsky/starsky/clientapp/src/interfaces/IFileIndexItem.ts b/starsky/starsky/clientapp/src/interfaces/IFileIndexItem.ts index 4c539aa96a..8a7e96d621 100644 --- a/starsky/starsky/clientapp/src/interfaces/IFileIndexItem.ts +++ b/starsky/starsky/clientapp/src/interfaces/IFileIndexItem.ts @@ -50,24 +50,24 @@ export interface IFileIndexItem { } export enum ImageFormat { - notfound = "notfound" as any, - unknown = "unknown" as any, - jpg = "jpg" as any, - tiff = "tiff" as any, - bmp = "bmp" as any, - gif = "gif" as any, - png = "png" as any, - xmp = "xmp" as any, - meta_json = "meta_json" as any, - gpx = "gpx" as any, - mp4 = "mp4" as any + notfound = "notfound", + unknown = "unknown", + jpg = "jpg", + tiff = "tiff", + bmp = "bmp", + gif = "gif", + png = "png", + xmp = "xmp", + meta_json = "meta_json", + gpx = "gpx", + mp4 = "mp4" } export enum Orientation { - Horizontal = "Horizontal" as any, - Rotate90Cw = "Rotate90Cw" as any, - Rotate180 = "Rotate180" as any, - Rotate270Cw = "Rotate270Cw" as any + Horizontal = "Horizontal", + Rotate90Cw = "Rotate90Cw", + Rotate180 = "Rotate180", + Rotate270Cw = "Rotate270Cw" } // Warning: Input elements should not switch from uncontrolled to controlled https://fb.me/react-controlled-components diff --git a/starsky/starsky/clientapp/src/pages/content-page.tsx b/starsky/starsky/clientapp/src/pages/content-page.tsx index 629b9ae387..aef1f9cf75 100644 --- a/starsky/starsky/clientapp/src/pages/content-page.tsx +++ b/starsky/starsky/clientapp/src/pages/content-page.tsx @@ -9,12 +9,7 @@ const ContentPage: FunctionComponent> = ( props ) => { // for some reason "name" here is possibly undefined - if ( - props && - props.location && - props.navigate && - !new BrowserDetect().IsLegacy() - ) { + if (props?.location && props?.navigate && !new BrowserDetect().IsLegacy()) { return ; } return null; diff --git a/starsky/starsky/clientapp/src/shared/file-extensions.ts b/starsky/starsky/clientapp/src/shared/file-extensions.ts index d9be95562e..1317c9c837 100644 --- a/starsky/starsky/clientapp/src/shared/file-extensions.ts +++ b/starsky/starsky/clientapp/src/shared/file-extensions.ts @@ -47,8 +47,8 @@ export class FileExtensions { const parentRegex = /.+(?=\/[^/]+$)/; // remove slash from end - if (filePath.length >= 2 && filePath[filePath.length - 1] === "/") { - filePath = filePath.substr(0, filePath.length - 1); + if (filePath.length >= 2 && filePath.endsWith("/")) { + filePath = filePath.slice(0, -1); } const parentMatchArray = filePath.match(parentRegex); diff --git a/starsky/starsky/clientapp/src/shared/keyboard.ts b/starsky/starsky/clientapp/src/shared/keyboard.ts index 5a2991d8b7..ec79422e88 100644 --- a/starsky/starsky/clientapp/src/shared/keyboard.ts +++ b/starsky/starsky/clientapp/src/shared/keyboard.ts @@ -7,7 +7,7 @@ export class Keyboard { if (!event) return null; const target = event.target as HTMLElement; - if (!target || !target.className) return null; + if (!target?.className) return null; return ( target.className.indexOf("form-control") !== -1 || target.className.indexOf("modal") !== -1 diff --git a/starsky/starsky/clientapp/src/shared/select-check-if-active.ts b/starsky/starsky/clientapp/src/shared/select-check-if-active.ts index 27bd25b417..0c2eab4240 100644 --- a/starsky/starsky/clientapp/src/shared/select-check-if-active.ts +++ b/starsky/starsky/clientapp/src/shared/select-check-if-active.ts @@ -21,7 +21,7 @@ export class SelectCheckIfActive { select.forEach((selectedPath) => { if (fileNameList.indexOf(selectedPath) === -1) { const selectIndex = select.indexOf(selectedPath); - delete select[selectIndex]; + select.splice(selectIndex, 1); } }); // remove emthy items from the list diff --git a/starsky/starsky/clientapp/src/shared/string-options.ts b/starsky/starsky/clientapp/src/shared/string-options.ts index 8ac0f9bc02..ed271bd0dd 100644 --- a/starsky/starsky/clientapp/src/shared/string-options.ts +++ b/starsky/starsky/clientapp/src/shared/string-options.ts @@ -4,6 +4,6 @@ export class StringOptions { public LimitLength(input: string, length: number) { if (input.length <= length) return input; - return input.substr(0, length) + "…"; // … HORIZONTAL ELLIPSIS + return input.substring(0, length) + "…"; // … HORIZONTAL ELLIPSIS } } From 51c15e8991276a9b1b42f6092fd0e80940424468 Mon Sep 17 00:00:00 2001 From: Dion Date: Mon, 31 Jul 2023 14:50:35 +0200 Subject: [PATCH 5/8] issues --- starsky/starsky/Controllers/MetaReplaceController.cs | 3 ++- starsky/starsky/Controllers/MetaUpdateController.cs | 5 +++-- starsky/starsky/Controllers/PublishController.cs | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/starsky/starsky/Controllers/MetaReplaceController.cs b/starsky/starsky/Controllers/MetaReplaceController.cs index 886762a33a..142b5aac85 100644 --- a/starsky/starsky/Controllers/MetaReplaceController.cs +++ b/starsky/starsky/Controllers/MetaReplaceController.cs @@ -77,7 +77,8 @@ await metaUpdateService }, string.Empty); // before sending not founds - new StopWatchLogger(_logger).StopUpdateReplaceStopWatch("update", f,collections, stopwatch); + new StopWatchLogger(_logger).StopUpdateReplaceStopWatch("update", + fileIndexResultsList.FirstOrDefault()?.FilePath, collections, stopwatch); // When all items are not found if (!resultsOkOrDeleteList.Any()) diff --git a/starsky/starsky/Controllers/MetaUpdateController.cs b/starsky/starsky/Controllers/MetaUpdateController.cs index 375fd55ab5..b84e10dcf7 100644 --- a/starsky/starsky/Controllers/MetaUpdateController.cs +++ b/starsky/starsky/Controllers/MetaUpdateController.cs @@ -74,7 +74,8 @@ public async Task UpdateAsync(FileIndexItem inputModel, string f, var stopwatch = StopWatchLogger.StartUpdateReplaceStopWatch(); - var (fileIndexResultsList, changedFileIndexItemName) = await _metaPreflight.PreflightAsync(inputModel, + var (fileIndexResultsList, changedFileIndexItemName) = + await _metaPreflight.PreflightAsync(inputModel, inputFilePaths.ToList(), append, collections, rotateClock); var operationId = HttpContext.GetOperationId(); @@ -112,7 +113,7 @@ await _bgTaskQueue.QueueBackgroundWorkItemAsync(async _ => _metaUpdateService.UpdateReadMetaCache(returnNewResultList); // Push direct to socket when update or replace to avoid undo after a second - _logger.LogInformation($"[UpdateController] send to socket {f}"); + _logger.LogInformation($"[UpdateController] send to socket {inputFilePaths.FirstOrDefault()}"); await Task.Run(async () => await UpdateWebSocketTaskRun(fileIndexResultsList)); diff --git a/starsky/starsky/Controllers/PublishController.cs b/starsky/starsky/Controllers/PublishController.cs index fc7ca4f19c..a450f13195 100644 --- a/starsky/starsky/Controllers/PublishController.cs +++ b/starsky/starsky/Controllers/PublishController.cs @@ -81,7 +81,6 @@ public async Task PublishCreateAsync(string f, string itemName, return BadRequest(preflightErrors); } - _webLogger.LogInformation($"[/api/publish/create] Press publish: {itemName} {f} {DateTime.UtcNow}"); var inputFilePaths = PathHelper.SplitInputFilePaths(f).ToList(); var info = _metaInfo.GetInfo(inputFilePaths, false); if ( info.TrueForAll(p => @@ -92,6 +91,8 @@ public async Task PublishCreateAsync(string f, string itemName, } var slugItemName = _appSettings.GenerateSlug(itemName, true); + _webLogger.LogInformation($"[/api/publish/create] Press publish: {slugItemName} {f} {DateTime.UtcNow}"); + var location = Path.Combine(_appSettings.TempFolder,slugItemName ); if ( CheckIfNameExist(slugItemName) ) From c06ed3882401c5b9b75512c2f015b55e645411cf Mon Sep 17 00:00:00 2001 From: Dion Date: Mon, 31 Jul 2023 16:13:05 +0200 Subject: [PATCH 6/8] wip --- .../ReadMetaHelpers/ReadMetaExif.cs | 2 +- .../Services/ReadMeta_ExifReadTest.cs | 36 ++++++++++++++----- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs b/starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs index 77ea5281fa..4ddff671e7 100644 --- a/starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs +++ b/starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs @@ -652,7 +652,7 @@ private static double GetGeoLocationLatitude(List allExifItems) } - private static double GetXmpGeoData(List allExifItems, string propertyPath) + internal static double GetXmpGeoData(List allExifItems, string propertyPath) { var latitudeString = string.Empty; var latitudeRef = string.Empty; diff --git a/starsky/starskytest/Services/ReadMeta_ExifReadTest.cs b/starsky/starskytest/Services/ReadMeta_ExifReadTest.cs index a9df358587..708a28ab5f 100644 --- a/starsky/starskytest/Services/ReadMeta_ExifReadTest.cs +++ b/starsky/starskytest/Services/ReadMeta_ExifReadTest.cs @@ -15,6 +15,7 @@ using starskycore.Attributes; using starskytest.FakeCreateAn; using starskytest.FakeMocks; +using starskytest.starsky.foundation.database.Helpers; using XmpCore; using XmpCore.Impl; @@ -367,14 +368,14 @@ public void LocationCountryCode() [TestMethod] public void LocationCountryCode_ListDir() { - var xmpData = "\n" + - "\n" + - "\n" + - " \n" + - " NLD\n" + - " \n\n" + - "\n"; + const string xmpData = "\n" + + "\n" + + "\n" + + " \n" + + " NLD\n" + + " \n\n" + + "\n"; var xmpMeta = XmpMetaFactory.ParseFromString(xmpData); @@ -800,5 +801,24 @@ public void GetOrientationFromExifItem_8() var rotation = ReadMetaExif.GetOrientationFromExifItem(dir3); Assert.AreEqual(FileIndexItem.Rotation.Rotate270Cw,rotation); } + + [TestMethod] + public void TestGetXmpGeoData() + { + // Arrange + var allExifItems = new List(); + var dir2 = new XmpDirectory(); + dir2.Set(GpsDirectory.TagLatitude, "45.5602777778"); + dir2.Set(GpsDirectory.TagLatitudeRef, "N"); + allExifItems.Add(dir2); + + var propertyPath = "exif:GPSLatitude"; + + // Act + var result = ReadMetaExif.GetXmpGeoData(allExifItems, propertyPath); + + // Assert + Assert.AreEqual(45.5602777778, result, 0.0000000001); + } } } From 6cc4ae3493ed8b5d53d77ad72f0d859fa267f76a Mon Sep 17 00:00:00 2001 From: Dion Date: Mon, 31 Jul 2023 16:33:11 +0200 Subject: [PATCH 7/8] fix test --- .../ReadMetaHelpers/ReadMetaExif.cs | 2 +- .../Services/ReadMeta_ExifReadTest.cs | 71 +++++++++++++++++-- 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs b/starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs index 4ddff671e7..50366824ca 100644 --- a/starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs +++ b/starsky/starsky.foundation.readmeta/ReadMetaHelpers/ReadMetaExif.cs @@ -666,7 +666,7 @@ internal static double GetXmpGeoData(List allExifItems, string proper RegexOptions.None, TimeSpan.FromMilliseconds(100)); if(split.Length != 2) continue; latitudeString = split[0]; - latitudeRef = latitudeLocal[latitudeLocal.Length-1].ToString(); + latitudeRef = latitudeLocal[^1].ToString(); } if ( string.IsNullOrWhiteSpace(latitudeString) ) return 0; diff --git a/starsky/starskytest/Services/ReadMeta_ExifReadTest.cs b/starsky/starskytest/Services/ReadMeta_ExifReadTest.cs index 708a28ab5f..a0091a355c 100644 --- a/starsky/starskytest/Services/ReadMeta_ExifReadTest.cs +++ b/starsky/starskytest/Services/ReadMeta_ExifReadTest.cs @@ -806,19 +806,76 @@ public void GetOrientationFromExifItem_8() public void TestGetXmpGeoData() { // Arrange - var allExifItems = new List(); + + const string xmpData = "\n" + + "\n\n " + + "\n" + + " ALB\n \n\n" + + " \n" + + " 800796/527\n" + + " 0\n" + + " 42,27.7005N\n" + + " 19,52.86888E\n" + + " \n\n \n" + + " Valbone\n" + + " Shqipëri\n" + + " 2023-06-29T11:21:36\n" + + " Kukes County\n " + + "\n\n\n\n"; + + var xmpMeta = XmpMetaFactory.ParseFromString(xmpData); + + var container = new List(); var dir2 = new XmpDirectory(); - dir2.Set(GpsDirectory.TagLatitude, "45.5602777778"); - dir2.Set(GpsDirectory.TagLatitudeRef, "N"); - allExifItems.Add(dir2); + dir2.SetXmpMeta(xmpMeta); + container.Add(dir2); + + const string propertyPath = "exif:GPSLatitude"; + + // Act + var result = ReadMetaExif.GetXmpGeoData(container, propertyPath); - var propertyPath = "exif:GPSLatitude"; + // Assert + Assert.AreEqual(42.461675, result, 0.0000000001); + } + + [TestMethod] + public void TestGetXmpGeoData2() + { + // Arrange + + const string xmpData = "\n" + + "\n\n " + + "\n" + + " ALB\n \n\n" + + " \n" + + " 800796/527\n" + + " 0\n" + + " 42,27.7005N\n" + + " 19,52.86888E\n" + + " \n\n \n" + + " Valbone\n" + + " Shqipëri\n" + + " 2023-06-29T11:21:36\n" + + " Kukes County\n " + + "\n\n\n\n"; + + var xmpMeta = XmpMetaFactory.ParseFromString(xmpData); + + var container = new List(); + var dir2 = new XmpDirectory(); + dir2.SetXmpMeta(xmpMeta); + container.Add(dir2); + + const string propertyPath = "exif:GPSLongitude"; // Act - var result = ReadMetaExif.GetXmpGeoData(allExifItems, propertyPath); + var result = ReadMetaExif.GetXmpGeoData(container, propertyPath); // Assert - Assert.AreEqual(45.5602777778, result, 0.0000000001); + Assert.AreEqual(19.881148, result, 0.0000000001); } } } From 8489ae501e64ce2cbf9405a75db4d44d4fc9a159 Mon Sep 17 00:00:00 2001 From: Dion Date: Mon, 31 Jul 2023 16:43:31 +0200 Subject: [PATCH 8/8] move to global namespace --- documentation/documentation.csproj | 1 - starsky/build/Build.cs | 480 +++++++++--------- starsky/build/Configuration.cs | 24 +- starsky/build/helpers/ClientHelper.cs | 2 +- starsky/build/helpers/DotnetGenericHelper.cs | 3 +- .../helpers/DotnetRuntimeSpecificHelper.cs | 1 - starsky/build/helpers/DotnetTestHelper.cs | 1 - .../ProjectCheckNetCoreCommandHelper.cs | 2 +- starsky/build/helpers/SonarQube.cs | 1 - starsky/build/helpers/ZipperHelper.cs | 1 - .../Services/ReadMeta_ExifReadTest.cs | 1 - 11 files changed, 251 insertions(+), 266 deletions(-) diff --git a/documentation/documentation.csproj b/documentation/documentation.csproj index 3160f15b4b..cbbfe84c3b 100644 --- a/documentation/documentation.csproj +++ b/documentation/documentation.csproj @@ -46,7 +46,6 @@ - diff --git a/starsky/build/Build.cs b/starsky/build/Build.cs index 477f957a96..e08605d14b 100644 --- a/starsky/build/Build.cs +++ b/starsky/build/Build.cs @@ -6,296 +6,292 @@ using Nuke.Common.CI; using Nuke.Common.ProjectModel; -// ReSharper disable once CheckNamespace -namespace build +[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", + "S3887:Use an immutable collection or reduce the " + + "accessibility of the non-private readonly field", + Justification = "Not production code.")] +[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", + "S2386:Use an immutable collection or reduce " + + "the accessibility of the non-private readonly field", + Justification = "Not production code.")] +[ShutdownDotNetAfterServerBuild] +public sealed class Build : NukeBuild { - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", - "S3887:Use an immutable collection or reduce the " + - "accessibility of the non-private readonly field", - Justification = "Not production code.")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", - "S2386:Use an immutable collection or reduce " + - "the accessibility of the non-private readonly field", - Justification = "Not production code.")] - [ShutdownDotNetAfterServerBuild] - public sealed class Build : NukeBuild - { - /// Support plugins are available for: - /// - JetBrains ReSharper https://nuke.build/resharper - /// - JetBrains Rider https://nuke.build/rider - /// - Microsoft VisualStudio https://nuke.build/visualstudio - /// - Microsoft VSCode https://nuke.build/vscode + /// Support plugins are available for: + /// - JetBrains ReSharper https://nuke.build/resharper + /// - JetBrains Rider https://nuke.build/rider + /// - Microsoft VisualStudio https://nuke.build/visualstudio + /// - Microsoft VSCode https://nuke.build/vscode - public static int Main () => Execute(x => x.Compile); + public static int Main () => Execute(x => x.Compile); - // Use `--target BuildNetCoreRuntimeSpecific --skip` parameter to run only this task + // Use `--target BuildNetCoreRuntimeSpecific --skip` parameter to run only this task - [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] - readonly Configuration Configuration = Configuration.Release; + [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] + readonly Configuration Configuration = Configuration.Release; - public const string GenericRuntimeName = "generic-netcore"; + public const string GenericRuntimeName = "generic-netcore"; - [Parameter("Runtime arg")] - readonly string Runtime = GenericRuntimeName; + [Parameter("Runtime arg")] + readonly string Runtime = GenericRuntimeName; - [Parameter("Is SonarQube Disabled")] - readonly bool NoSonar; + [Parameter("Is SonarQube Disabled")] + readonly bool NoSonar; - [Parameter("Is Unit Test Disabled (same as NoUnitTest, NoUnitTests, NoTest and NoTests)")] - readonly bool NoUnitTest; + [Parameter("Is Unit Test Disabled (same as NoUnitTest, NoUnitTests, NoTest and NoTests)")] + readonly bool NoUnitTest; - [Parameter("Is Unit Test Disabled (same as NoUnitTest, NoUnitTests, NoTest and NoTests)")] - readonly bool NoUnitTests; + [Parameter("Is Unit Test Disabled (same as NoUnitTest, NoUnitTests, NoTest and NoTests)")] + readonly bool NoUnitTests; - [Parameter("Is Unit Test Disabled (same as NoUnitTest, NoUnitTests, NoTest and NoTests)")] - readonly bool NoTest; + [Parameter("Is Unit Test Disabled (same as NoUnitTest, NoUnitTests, NoTest and NoTests)")] + readonly bool NoTest; - [Parameter("Is Unit Test Disabled (same as NoUnitTest, NoUnitTests, NoTest and NoTests)")] - readonly bool NoTests; + [Parameter("Is Unit Test Disabled (same as NoUnitTest, NoUnitTests, NoTest and NoTests)")] + readonly bool NoTests; - [Parameter("Skip clientside code")] - readonly bool NoClient; + [Parameter("Skip clientside code")] + readonly bool NoClient; - [Parameter("Skip Dependencies download e.g. exiftool / geo data, nuget/npm deps are always installed")] - readonly bool NoDependencies; + [Parameter("Skip Dependencies download e.g. exiftool / geo data, nuget/npm deps are always installed")] + readonly bool NoDependencies; - bool IsUnitTestDisabled() - { - // --no-unit-test, --no-unit-tests, --no-test, --no-tests - return NoUnitTest || NoUnitTests || NoTest || NoTests; - } + bool IsUnitTestDisabled() + { + // --no-unit-test, --no-unit-tests, --no-test, --no-tests + return NoUnitTest || NoUnitTests || NoTest || NoTests; + } - [Parameter("Skip Publish step")] - readonly bool NoPublish; + [Parameter("Skip Publish step")] + readonly bool NoPublish; - bool IsPublishDisabled() - { - // --no-publish - return NoPublish; - } + bool IsPublishDisabled() + { + // --no-publish + return NoPublish; + } - [Parameter("Overwrite branch name")] - readonly string Branch; - string GetBranchName() - { - var branchName = Branch; - if( !string.IsNullOrEmpty(branchName) && branchName.StartsWith("refs/heads/")) { - branchName = branchName.Replace("refs/heads/",""); - } - return branchName; + [Parameter("Overwrite branch name")] + readonly string Branch; + string GetBranchName() + { + var branchName = Branch; + if( !string.IsNullOrEmpty(branchName) && branchName.StartsWith("refs/heads/")) { + branchName = branchName.Replace("refs/heads/",""); } + return branchName; + } - List GetRuntimesWithoutGeneric() - { - return Runtime.Split(",", + List GetRuntimesWithoutGeneric() + { + return Runtime.Split(",", StringSplitOptions.TrimEntries).Where(p => p != GenericRuntimeName) - .ToList(); - } + .ToList(); + } - [Solution(SuppressBuildProjectCheck = true)] - readonly Solution Solution; + [Solution(SuppressBuildProjectCheck = true)] + readonly Solution Solution; - public static readonly List PublishProjectsList = new List - { - "starskyadmincli", - "starskygeocli", - "starskyimportercli", - "starskysynchronizecli", - "starskythumbnailcli", - "starskywebftpcli", - "starskywebhtmlcli", - "starskythumbnailmetacli", - "starsky" - }; + public static readonly List PublishProjectsList = new List + { + "starskyadmincli", + "starskygeocli", + "starskyimportercli", + "starskysynchronizecli", + "starskythumbnailcli", + "starskywebftpcli", + "starskywebhtmlcli", + "starskythumbnailmetacli", + "starsky" + }; - /// - /// Npm and node are required for preflight checks and building frontend code - /// - public const string NpmBaseCommand = "npm"; - public const string NodeBaseCommand = "node"; - public const string ClientAppFolder = "starsky/clientapp"; + /// + /// Npm and node are required for preflight checks and building frontend code + /// + public const string NpmBaseCommand = "npm"; + public const string NodeBaseCommand = "node"; + public const string ClientAppFolder = "starsky/clientapp"; - /// - /// Java is only needed for SonarQube, skip sonarCube with the --no-sonar flag - /// - public const string JavaBaseCommand = "java"; + /// + /// Java is only needed for SonarQube, skip sonarCube with the --no-sonar flag + /// + public const string JavaBaseCommand = "java"; - Target Client => _ => _ - .Executes(() => + Target Client => _ => _ + .Executes(() => + { + if ( NoClient ) { - if ( NoClient ) - { - Console.WriteLine("--no-client flag is used"); - return; - } - Console.WriteLine("> client"); - ShowSettingsInfo(); - ProjectCheckNetCoreCommandHelper.ProjectCheckNetCoreCommand(); - ClientHelper.NpmPreflight(); - ClientHelper.ClientCiCommand(); - ClientHelper.ClientBuildCommand(); - if ( !IsUnitTestDisabled() ) - { - ClientHelper.ClientTestCommand(); - } - else - { - Console.WriteLine("Test skipped due --no-unit-tests flag"); - } - }); + Console.WriteLine("--no-client flag is used"); + return; + } + Console.WriteLine("> client"); + ShowSettingsInfo(); + ProjectCheckNetCoreCommandHelper.ProjectCheckNetCoreCommand(); + ClientHelper.NpmPreflight(); + ClientHelper.ClientCiCommand(); + ClientHelper.ClientBuildCommand(); + if ( !IsUnitTestDisabled() ) + { + ClientHelper.ClientTestCommand(); + } + else + { + Console.WriteLine("Test skipped due --no-unit-tests flag"); + } + }); - void ShowSettingsInfo() - { - Console.WriteLine("SolutionParentFolder: " + WorkingDirectory.GetSolutionParentFolder()); + void ShowSettingsInfo() + { + Console.WriteLine("SolutionParentFolder: " + WorkingDirectory.GetSolutionParentFolder()); - Console.WriteLine("---"); - Console.WriteLine(IsUnitTestDisabled() - ? "Unit test disabled" - : "Unit test enabled"); + Console.WriteLine("---"); + Console.WriteLine(IsUnitTestDisabled() + ? "Unit test disabled" + : "Unit test enabled"); - Console.WriteLine(NoSonar - ? "Sonar disabled" - : "Sonar enabled"); + Console.WriteLine(NoSonar + ? "Sonar disabled" + : "Sonar enabled"); - Console.WriteLine("Branch:"); - Console.WriteLine(GetBranchName()); + Console.WriteLine("Branch:"); + Console.WriteLine(GetBranchName()); - Console.WriteLine("Runtime:"); - foreach ( var runtime in GetRuntimesWithoutGeneric() ) - { - Console.WriteLine(runtime); - } - - Console.WriteLine("---"); + Console.WriteLine("Runtime:"); + foreach ( var runtime in GetRuntimesWithoutGeneric() ) + { + Console.WriteLine(runtime); } + + Console.WriteLine("---"); + } - Target ShowSettingsInformation => _ => _ - .Executes(ShowSettingsInfo); + Target ShowSettingsInformation => _ => _ + .Executes(ShowSettingsInfo); - /// - /// Default Target - /// - Target Compile => _ => _ - .DependsOn(ShowSettingsInformation) - .DependsOn(Client) - .DependsOn(SonarBuildTest) - .DependsOn(BuildNetCoreRuntimeSpecific) - .DependsOn(CoverageReport) - .DependsOn(Zip); + /// + /// Default Target + /// + Target Compile => _ => _ + .DependsOn(ShowSettingsInformation) + .DependsOn(Client) + .DependsOn(SonarBuildTest) + .DependsOn(BuildNetCoreRuntimeSpecific) + .DependsOn(CoverageReport) + .DependsOn(Zip); - Target SonarBuildTest => _ => _ - .DependsOn(Client) - .Executes(() => - { - ShowSettingsInfo(); - ProjectCheckNetCoreCommandHelper.ProjectCheckNetCoreCommand(); - DotnetGenericHelper.RestoreNetCoreCommand(Solution); - SonarQube.InstallSonarTool(IsUnitTestDisabled(), NoSonar); - SonarQube.SonarBegin(IsUnitTestDisabled(),NoSonar,GetBranchName(), ClientHelper.GetClientAppFolder(), - "starskytest/coverage-merge-sonarqube.xml"); - DotnetGenericHelper.BuildNetCoreGenericCommand(Solution,Configuration); - DotnetTestHelper.TestNetCoreGenericCommand(Configuration,IsUnitTestDisabled()); - DotnetGenericHelper.DownloadDependencies(Solution,Configuration, - "starskygeocli/starskygeocli.csproj",NoDependencies, - "generic-netcore"); - MergeCoverageFiles.Merge(IsUnitTestDisabled()); - SonarQube.SonarEnd(IsUnitTestDisabled(),NoSonar); - DotnetGenericHelper.PublishNetCoreGenericCommand(Solution, Configuration, IsPublishDisabled()); - }); + Target SonarBuildTest => _ => _ + .DependsOn(Client) + .Executes(() => + { + ShowSettingsInfo(); + ProjectCheckNetCoreCommandHelper.ProjectCheckNetCoreCommand(); + DotnetGenericHelper.RestoreNetCoreCommand(Solution); + SonarQube.InstallSonarTool(IsUnitTestDisabled(), NoSonar); + SonarQube.SonarBegin(IsUnitTestDisabled(),NoSonar,GetBranchName(), ClientHelper.GetClientAppFolder(), + "starskytest/coverage-merge-sonarqube.xml"); + DotnetGenericHelper.BuildNetCoreGenericCommand(Solution,Configuration); + DotnetTestHelper.TestNetCoreGenericCommand(Configuration,IsUnitTestDisabled()); + DotnetGenericHelper.DownloadDependencies(Solution,Configuration, + "starskygeocli/starskygeocli.csproj",NoDependencies, + "generic-netcore"); + MergeCoverageFiles.Merge(IsUnitTestDisabled()); + SonarQube.SonarEnd(IsUnitTestDisabled(),NoSonar); + DotnetGenericHelper.PublishNetCoreGenericCommand(Solution, Configuration, IsPublishDisabled()); + }); - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", - "S1144:UnusedMember.Local", Justification = "Not production code.")] - // ReSharper disable once UnusedMember.Local - Target DownloadDependencies => _ => _ - .Executes(() => - { - DotnetGenericHelper.DownloadDependencies(Solution,Configuration, - "starskygeocli/starskygeocli.csproj",NoDependencies, - "generic-netcore"); - DotnetRuntimeSpecificHelper.CopyDependenciesFiles(NoDependencies, - "generic-netcore",GetRuntimesWithoutGeneric()); + [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", + "S1144:UnusedMember.Local", Justification = "Not production code.")] + // ReSharper disable once UnusedMember.Local + Target DownloadDependencies => _ => _ + .Executes(() => + { + DotnetGenericHelper.DownloadDependencies(Solution,Configuration, + "starskygeocli/starskygeocli.csproj",NoDependencies, + "generic-netcore"); + DotnetRuntimeSpecificHelper.CopyDependenciesFiles(NoDependencies, + "generic-netcore",GetRuntimesWithoutGeneric()); - }); + }); - Target BuildNetCoreRuntimeSpecific => _ => _ - .DependsOn(SonarBuildTest) - .Executes(() => + Target BuildNetCoreRuntimeSpecific => _ => _ + .DependsOn(SonarBuildTest) + .Executes(() => + { + if ( !GetRuntimesWithoutGeneric().Any() || IsPublishDisabled() ) { - if ( !GetRuntimesWithoutGeneric().Any() || IsPublishDisabled() ) + if ( IsPublishDisabled() ) { - if ( IsPublishDisabled() ) - { - Console.WriteLine("Publish is disabled " + IsPublishDisabled()); - return; - } - - Console.WriteLine("There are no runtime specific items selected"); + Console.WriteLine("Publish is disabled " + IsPublishDisabled()); return; } + + Console.WriteLine("There are no runtime specific items selected"); + return; + } - ShowSettingsInfo(); - DotnetRuntimeSpecificHelper.Clean(GetRuntimesWithoutGeneric()); - DotnetRuntimeSpecificHelper.RestoreNetCoreCommand(Solution, - GetRuntimesWithoutGeneric()); - DotnetRuntimeSpecificHelper.BuildNetCoreCommand(Solution, - GetRuntimesWithoutGeneric(),Configuration); - DotnetRuntimeSpecificHelper.PublishNetCoreGenericCommand(Solution, - GetRuntimesWithoutGeneric(),Configuration); - DotnetRuntimeSpecificHelper.CopyDependenciesFiles(NoDependencies, - "generic-netcore",GetRuntimesWithoutGeneric()); + ShowSettingsInfo(); + DotnetRuntimeSpecificHelper.Clean(GetRuntimesWithoutGeneric()); + DotnetRuntimeSpecificHelper.RestoreNetCoreCommand(Solution, + GetRuntimesWithoutGeneric()); + DotnetRuntimeSpecificHelper.BuildNetCoreCommand(Solution, + GetRuntimesWithoutGeneric(),Configuration); + DotnetRuntimeSpecificHelper.PublishNetCoreGenericCommand(Solution, + GetRuntimesWithoutGeneric(),Configuration); + DotnetRuntimeSpecificHelper.CopyDependenciesFiles(NoDependencies, + "generic-netcore",GetRuntimesWithoutGeneric()); - }); + }); - // ReSharper disable once UnusedMember.Local - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", - "S1144:UnusedMember.Local", Justification = "Not production code.")] - Target BuildNetCore => _ => _ - .Executes(() => - { - ShowSettingsInfo(); - ProjectCheckNetCoreCommandHelper.ProjectCheckNetCoreCommand(); - DotnetGenericHelper.RestoreNetCoreCommand(Solution); - DotnetGenericHelper.BuildNetCoreGenericCommand(Solution,Configuration); - }); + // ReSharper disable once UnusedMember.Local + [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", + "S1144:UnusedMember.Local", Justification = "Not production code.")] + Target BuildNetCore => _ => _ + .Executes(() => + { + ShowSettingsInfo(); + ProjectCheckNetCoreCommandHelper.ProjectCheckNetCoreCommand(); + DotnetGenericHelper.RestoreNetCoreCommand(Solution); + DotnetGenericHelper.BuildNetCoreGenericCommand(Solution,Configuration); + }); - // ReSharper disable once UnusedMember.Local - [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", - "S1144:UnusedMember.Local", Justification = "Not production code.")] - Target TestNetCore => _ => _ - .Executes(() => - { - ShowSettingsInfo(); - DotnetTestHelper.TestNetCoreGenericCommand(Configuration,IsUnitTestDisabled()); - }); + // ReSharper disable once UnusedMember.Local + [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", + "S1144:UnusedMember.Local", Justification = "Not production code.")] + Target TestNetCore => _ => _ + .Executes(() => + { + ShowSettingsInfo(); + DotnetTestHelper.TestNetCoreGenericCommand(Configuration,IsUnitTestDisabled()); + }); - Target Zip => _ => _ - .DependsOn(Client) - .DependsOn(SonarBuildTest) - .DependsOn(BuildNetCoreRuntimeSpecific) - .Executes(() => + Target Zip => _ => _ + .DependsOn(Client) + .DependsOn(SonarBuildTest) + .DependsOn(BuildNetCoreRuntimeSpecific) + .Executes(() => + { + if ( IsPublishDisabled() ) { - if ( IsPublishDisabled() ) - { - Console.WriteLine("Publish is disabled " + IsPublishDisabled()); - return; - } + Console.WriteLine("Publish is disabled " + IsPublishDisabled()); + return; + } - ShowSettingsInfo(); - ZipperHelper.ZipGeneric(); - ZipperHelper.ZipRuntimes(GetRuntimesWithoutGeneric()); - }); + ShowSettingsInfo(); + ZipperHelper.ZipGeneric(); + ZipperHelper.ZipRuntimes(GetRuntimesWithoutGeneric()); + }); - /// - /// Generates html coverage report - /// - Target CoverageReport => _ => _ - .DependsOn(Client) - .DependsOn(SonarBuildTest) - .Executes(() => - { - ShowSettingsInfo(); - var folder = CoverageReportHelper.GenerateHtml(IsUnitTestDisabled()); - ZipperHelper.ZipHtmlCoverageReport(folder, IsUnitTestDisabled()); - }); - } + /// + /// Generates html coverage report + /// + Target CoverageReport => _ => _ + .DependsOn(Client) + .DependsOn(SonarBuildTest) + .Executes(() => + { + ShowSettingsInfo(); + var folder = CoverageReportHelper.GenerateHtml(IsUnitTestDisabled()); + ZipperHelper.ZipHtmlCoverageReport(folder, IsUnitTestDisabled()); + }); } diff --git a/starsky/build/Configuration.cs b/starsky/build/Configuration.cs index c62a493618..1c6fc94a3a 100644 --- a/starsky/build/Configuration.cs +++ b/starsky/build/Configuration.cs @@ -2,21 +2,17 @@ using System.Diagnostics.CodeAnalysis; using Nuke.Common.Tooling; -namespace build +[TypeConverter(typeof(TypeConverter))] +[SuppressMessage("Usage", "CA2211:Non-constant fields should not be visible")] +[SuppressMessage("Usage", "S1104:Make this field 'private' and encapsulate it in a 'public' property")] +[SuppressMessage("Usage", "S2223:Make this field 'private' and encapsulate it in a 'public' property")] +[SuppressMessage("ReSharper", "UnusedMember.Global")] +public sealed class Configuration : Enumeration { - [TypeConverter(typeof(TypeConverter))] - [SuppressMessage("Usage", "CA2211:Non-constant fields should not be visible")] - [SuppressMessage("Usage", "S1104:Make this field 'private' and encapsulate it in a 'public' property")] - [SuppressMessage("Usage", "S2223:Make this field 'private' and encapsulate it in a 'public' property")] - [SuppressMessage("ReSharper", "UnusedMember.Global")] - public sealed class Configuration : Enumeration + public static Configuration Debug = new Configuration { Value = nameof(Debug) }; + public static Configuration Release = new Configuration { Value = nameof(Release) }; + public static implicit operator string(Configuration configuration) { - public static Configuration Debug = new Configuration { Value = nameof(Debug) }; - public static Configuration Release = new Configuration { Value = nameof(Release) }; - public static implicit operator string(Configuration configuration) - { - return configuration.Value; - } + return configuration.Value; } } - diff --git a/starsky/build/helpers/ClientHelper.cs b/starsky/build/helpers/ClientHelper.cs index b046b83a8e..37fa497b6d 100644 --- a/starsky/build/helpers/ClientHelper.cs +++ b/starsky/build/helpers/ClientHelper.cs @@ -1,7 +1,7 @@ using System; using System.IO; using static SimpleExec.Command; -using static build.Build; +using static Build; namespace helpers { diff --git a/starsky/build/helpers/DotnetGenericHelper.cs b/starsky/build/helpers/DotnetGenericHelper.cs index 9ccbd12246..b7a79f4b41 100644 --- a/starsky/build/helpers/DotnetGenericHelper.cs +++ b/starsky/build/helpers/DotnetGenericHelper.cs @@ -1,10 +1,9 @@ using System; using System.IO; -using build; using Nuke.Common.ProjectModel; using Nuke.Common.Tools.DotNet; using static Nuke.Common.Tools.DotNet.DotNetTasks; -using static build.Build; +using static Build; namespace helpers { diff --git a/starsky/build/helpers/DotnetRuntimeSpecificHelper.cs b/starsky/build/helpers/DotnetRuntimeSpecificHelper.cs index 231da723a2..ad76166b62 100644 --- a/starsky/build/helpers/DotnetRuntimeSpecificHelper.cs +++ b/starsky/build/helpers/DotnetRuntimeSpecificHelper.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Text.RegularExpressions; -using build; using Nuke.Common.IO; using Nuke.Common.ProjectModel; using Nuke.Common.Tooling; diff --git a/starsky/build/helpers/DotnetTestHelper.cs b/starsky/build/helpers/DotnetTestHelper.cs index bb42dabe6f..44055e23c5 100644 --- a/starsky/build/helpers/DotnetTestHelper.cs +++ b/starsky/build/helpers/DotnetTestHelper.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using build; using Nuke.Common.IO; using Nuke.Common.Tools.DotNet; using static Nuke.Common.IO.FileSystemTasks; diff --git a/starsky/build/helpers/ProjectCheckNetCoreCommandHelper.cs b/starsky/build/helpers/ProjectCheckNetCoreCommandHelper.cs index 908ab498ac..766e1e13ce 100644 --- a/starsky/build/helpers/ProjectCheckNetCoreCommandHelper.cs +++ b/starsky/build/helpers/ProjectCheckNetCoreCommandHelper.cs @@ -1,7 +1,7 @@ using System; using System.IO; using static SimpleExec.Command; -using static build.Build; +using static Build; namespace helpers { diff --git a/starsky/build/helpers/SonarQube.cs b/starsky/build/helpers/SonarQube.cs index 019974d0f2..f4e94f6d56 100644 --- a/starsky/build/helpers/SonarQube.cs +++ b/starsky/build/helpers/SonarQube.cs @@ -4,7 +4,6 @@ using System.IO; using System.Linq; using System.Text; -using build; using Nuke.Common.Tooling; using Nuke.Common.Tools.DotNet; using static Nuke.Common.Tools.DotNet.DotNetTasks; diff --git a/starsky/build/helpers/ZipperHelper.cs b/starsky/build/helpers/ZipperHelper.cs index 337884966d..b23da4bc36 100644 --- a/starsky/build/helpers/ZipperHelper.cs +++ b/starsky/build/helpers/ZipperHelper.cs @@ -3,7 +3,6 @@ using System.IO; using System.IO.Compression; using System.Linq; -using build; namespace helpers { diff --git a/starsky/starskytest/Services/ReadMeta_ExifReadTest.cs b/starsky/starskytest/Services/ReadMeta_ExifReadTest.cs index a0091a355c..92ae565a42 100644 --- a/starsky/starskytest/Services/ReadMeta_ExifReadTest.cs +++ b/starsky/starskytest/Services/ReadMeta_ExifReadTest.cs @@ -15,7 +15,6 @@ using starskycore.Attributes; using starskytest.FakeCreateAn; using starskytest.FakeMocks; -using starskytest.starsky.foundation.database.Helpers; using XmpCore; using XmpCore.Impl;