From 36b5f6253e5db7230971c2a18b761306d3f90822 Mon Sep 17 00:00:00 2001 From: Apollo3zehn Date: Fri, 15 Mar 2024 22:30:24 +0100 Subject: [PATCH] Follow Nexus changes --- CHANGELOG.md | 4 ++ Directory.Build.props | 12 ++---- .../CustomDateTimeOffset.cs | 12 +++--- .../Nexus.Sources.StructuredFile.csproj | 2 +- .../StructuredFileDataSource.cs | 38 +++++++------------ .../Nexus.Sources.StructuredFile.Tests.csproj | 8 ++-- .../StructuredFileDataSourceTester.cs | 8 ---- .../StructuredFileDataSourceTests.cs | 7 ++-- version.json | 2 +- 9 files changed, 36 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 718488f..5c56277 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v2.0.0-beta.24 - 2024-03-15 + +- Follow Nexus changes. + ## v2.0.0-beta.14 - 2024-03-14 - Fix ignored timezone information problem. diff --git a/Directory.Build.props b/Directory.Build.props index 3ec0ddc..db678da 100755 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ true - net7.0 + net8.0 enable enable true @@ -10,14 +10,8 @@ https://www.myget.org/F/apollo3zehn-dev/api/v3/index.json - - - - $([MSBuild]::NormalizePath($(MSBuildThisFileDirectory)artifacts)) - $(ArtifactsPath)/obj/$(MSBuildProjectName) - $(BaseIntermediateOutputPath)/$(Configuration) - $(ArtifactsPath)/bin/$(MSBuildProjectName)/$(Configuration) - $(ArtifactsPath)/packages + true + $(MSBuildThisFileDirectory)artifacts \ No newline at end of file diff --git a/src/Nexus.Sources.StructuredFile/CustomDateTimeOffset.cs b/src/Nexus.Sources.StructuredFile/CustomDateTimeOffset.cs index 3f84b7f..caaf6ec 100644 --- a/src/Nexus.Sources.StructuredFile/CustomDateTimeOffset.cs +++ b/src/Nexus.Sources.StructuredFile/CustomDateTimeOffset.cs @@ -1,6 +1,6 @@ using System.Globalization; -internal record struct CustomDateTimeOffset +internal readonly record struct CustomDateTimeOffset { public CustomDateTimeOffset(DateTime dateTime, TimeSpan offset) { @@ -18,11 +18,11 @@ public CustomDateTimeOffset(DateTime dateTime, TimeSpan offset) public DateTime DateTime { get; } public DateTime UtcDateTime { get; } - + public TimeSpan Offset { get; } public static bool TryParseExact( - string input, + string input, string format, TimeSpan utcOffset, out CustomDateTimeOffset dateTimeOffset) @@ -34,7 +34,7 @@ public static bool TryParseExact( format, default, /* Detect if input string includes time-zone information */ - DateTimeStyles.AdjustToUniversal | + DateTimeStyles.AdjustToUniversal | /* Do not use today as date when input contains no date information */ DateTimeStyles.NoCurrentDateDefault, out var tmpDateTime @@ -61,7 +61,7 @@ out var tmpDateTimeOffset */ if ( /* AdjustToUniversal = UTC */ - tmpDateTime.Date != + tmpDateTime.Date != /* UtcDateTime = UTC */ tmpDateTimeOffset.UtcDateTime.Date ) @@ -82,7 +82,7 @@ out var tmpDateTimeOffset { dateTimeOffset = new CustomDateTimeOffset ( - dateTimeOffset.DateTime, + dateTimeOffset.DateTime, utcOffset ); } diff --git a/src/Nexus.Sources.StructuredFile/Nexus.Sources.StructuredFile.csproj b/src/Nexus.Sources.StructuredFile/Nexus.Sources.StructuredFile.csproj index d343b2b..ec82dfb 100644 --- a/src/Nexus.Sources.StructuredFile/Nexus.Sources.StructuredFile.csproj +++ b/src/Nexus.Sources.StructuredFile/Nexus.Sources.StructuredFile.csproj @@ -31,7 +31,7 @@ - + runtime;native diff --git a/src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs b/src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs index b881fc3..fe7d680 100644 --- a/src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs +++ b/src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs @@ -1,6 +1,4 @@ -using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Globalization; using System.Text.RegularExpressions; using Microsoft.Extensions.Logging; using Nexus.DataModel; @@ -46,12 +44,6 @@ public abstract class StructuredFileDataSource : IDataSource // // (6) Only file URLs are supported - #region - - #endregion - - #region Properties - /// /// Gets the root path of the database. /// @@ -69,8 +61,6 @@ public abstract class StructuredFileDataSource : IDataSource private Func>> FileSourceProvider { get; set; } = default!; - #endregion - #region Protected API as seen by subclass /// @@ -231,7 +221,7 @@ protected virtual Task GetAvailabilityAsync( var files = candidateFiles .Where( - current => begin <= current.DateTimeOffset.UtcDateTime && + current => begin <= current.DateTimeOffset.UtcDateTime && current.DateTimeOffset.UtcDateTime < end) .ToList(); @@ -577,7 +567,7 @@ protected abstract Task ReadAsync( var utcFileBegin = new CustomDateTimeOffset ( - DateTime.SpecifyKind(localFileBegin, DateTimeKind.Unspecified), + DateTime.SpecifyKind(localFileBegin, DateTimeKind.Unspecified), fileSource.UtcOffset ).UtcDateTime; @@ -726,12 +716,12 @@ async Task IDataSource.ReadAsync( var candidateFolders = fileSource.PathSegments.Length >= 1 ? GetCandidateFolders( - rootPath, - default, - begin, - end, - fileSource, - fileSource.PathSegments, + rootPath, + default, + begin, + end, + fileSource, + fileSource.PathSegments, cancellationToken) : new List<(string, CustomDateTimeOffset)>() { (rootPath, default) }; @@ -746,9 +736,9 @@ async Task IDataSource.ReadAsync( .Select(filePath => { var success = TryGetFileBeginByPath( - filePath, - fileSource, - out var fileBegin, + filePath, + fileSource, + out var fileBegin, folderBegin: currentFolder.DateTime); return (success, filePath, fileBegin); @@ -914,9 +904,9 @@ internal static bool TryGetFileBeginByPath( if (folderBegin != default) { fileBegin = new CustomDateTimeOffset( - new DateTime(folderBegin.DateTime.Date.Ticks + fileBegin.DateTime.TimeOfDay.Ticks), + new DateTime(folderBegin.DateTime.Date.Ticks + fileBegin.DateTime.TimeOfDay.Ticks), fileBegin.Offset); - + isSuccess = true; } @@ -926,7 +916,7 @@ internal static bool TryGetFileBeginByPath( folderBegin = GetFolderBegin_AnyKind(filePath, fileSource); fileBegin = new CustomDateTimeOffset( - new DateTime(folderBegin.DateTime.Ticks + fileBegin.DateTime.TimeOfDay.Ticks), + new DateTime(folderBegin.DateTime.Ticks + fileBegin.DateTime.TimeOfDay.Ticks), fileBegin.Offset); isSuccess = folderBegin != default; diff --git a/tests/Nexus.Sources.StructuredFile.Tests/Nexus.Sources.StructuredFile.Tests.csproj b/tests/Nexus.Sources.StructuredFile.Tests/Nexus.Sources.StructuredFile.Tests.csproj index c5fa6d6..8c54c49 100644 --- a/tests/Nexus.Sources.StructuredFile.Tests/Nexus.Sources.StructuredFile.Tests.csproj +++ b/tests/Nexus.Sources.StructuredFile.Tests/Nexus.Sources.StructuredFile.Tests.csproj @@ -6,13 +6,13 @@ - - - + + + all runtime; build; native; contentfiles; analyzers - + diff --git a/tests/Nexus.Sources.StructuredFile.Tests/StructuredFileDataSourceTester.cs b/tests/Nexus.Sources.StructuredFile.Tests/StructuredFileDataSourceTester.cs index d4b7ef5..3e269be 100644 --- a/tests/Nexus.Sources.StructuredFile.Tests/StructuredFileDataSourceTester.cs +++ b/tests/Nexus.Sources.StructuredFile.Tests/StructuredFileDataSourceTester.cs @@ -5,14 +5,8 @@ namespace Nexus.Sources.Tests; public class StructuredFileDataSourceTester : StructuredFileDataSource { - #region Properties - public Dictionary>> Config { get; private set; } = default!; - #endregion - - #region Methods - protected override async Task InitializeAsync(CancellationToken cancellationToken) { var configFilePath = Path.Combine(Root, "config.json"); @@ -69,6 +63,4 @@ protected override async Task ReadAsync(ReadInfo readInfo, StructuredFileReadReq .Fill(1); } } - - #endregion } diff --git a/tests/Nexus.Sources.StructuredFile.Tests/StructuredFileDataSourceTests.cs b/tests/Nexus.Sources.StructuredFile.Tests/StructuredFileDataSourceTests.cs index 37f0337..54acbd7 100644 --- a/tests/Nexus.Sources.StructuredFile.Tests/StructuredFileDataSourceTests.cs +++ b/tests/Nexus.Sources.StructuredFile.Tests/StructuredFileDataSourceTests.cs @@ -4,7 +4,6 @@ using System.Globalization; using System.Reflection; using System.Runtime.InteropServices; -using System.Security.Principal; using System.Text.Json; using Xunit; @@ -46,8 +45,8 @@ public void CanTryParseToUtc( var utcOffset = TimeSpan.ParseExact(utcOffsetString, "hh\\:mm", default); var success = CustomDateTimeOffset.TryParseExact( - input, - format, + input, + format, utcOffset, out var actual); @@ -68,7 +67,7 @@ public void CanTryParseToUtc( Assert.True(success); Assert.Equal(expected, actual); -} + } [Fact] public async Task CanProvideFirstFile() diff --git a/version.json b/version.json index 82cf187..d5c1679 100755 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { "version": "2.0.0", - "suffix": "beta.14" + "suffix": "beta.24" } \ No newline at end of file