Skip to content

Commit

Permalink
Follow Nexus changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollo3zehn committed Mar 15, 2024
1 parent fca30e0 commit 36b5f62
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 57 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
12 changes: 3 additions & 9 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,16 @@

<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworkVersion>net7.0</TargetFrameworkVersion>
<TargetFrameworkVersion>net8.0</TargetFrameworkVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<LangVersion>latest</LangVersion>
<RestoreAdditionalProjectSources>
https://www.myget.org/F/apollo3zehn-dev/api/v3/index.json
</RestoreAdditionalProjectSources>
</PropertyGroup>

<PropertyGroup>
<ArtifactsPath>$([MSBuild]::NormalizePath($(MSBuildThisFileDirectory)artifacts))</ArtifactsPath>
<BaseIntermediateOutputPath>$(ArtifactsPath)/obj/$(MSBuildProjectName)</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)/$(Configuration)</IntermediateOutputPath>
<OutputPath>$(ArtifactsPath)/bin/$(MSBuildProjectName)/$(Configuration)</OutputPath>
<PackageOutputPath>$(ArtifactsPath)/packages</PackageOutputPath>
<UseArtifactsOutput>true</UseArtifactsOutput>
<ArtifactsPath>$(MSBuildThisFileDirectory)artifacts</ArtifactsPath>
</PropertyGroup>

</Project>
12 changes: 6 additions & 6 deletions src/Nexus.Sources.StructuredFile/CustomDateTimeOffset.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Globalization;

internal record struct CustomDateTimeOffset
internal readonly record struct CustomDateTimeOffset
{
public CustomDateTimeOffset(DateTime dateTime, TimeSpan offset)
{
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -61,7 +61,7 @@ out var tmpDateTimeOffset
*/
if (
/* AdjustToUniversal = UTC */
tmpDateTime.Date !=
tmpDateTime.Date !=
/* UtcDateTime = UTC */
tmpDateTimeOffset.UtcDateTime.Date
)
Expand All @@ -82,7 +82,7 @@ out var tmpDateTimeOffset
{
dateTimeOffset = new CustomDateTimeOffset
(
dateTimeOffset.DateTime,
dateTimeOffset.DateTime,
utcOffset
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Nexus.Extensibility" Version="2.0.0-beta.15">
<PackageReference Include="Nexus.Extensibility" Version="2.0.0-beta.24">
<!-- This is important! Took me 1 day to figure out why suddenly there are MissingMethodExceptions! -->
<ExcludeAssets>runtime;native</ExcludeAssets>
</PackageReference>
Expand Down
38 changes: 14 additions & 24 deletions src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -46,12 +44,6 @@ public abstract class StructuredFileDataSource : IDataSource
//
// (6) Only file URLs are supported

#region

#endregion

#region Properties

/// <summary>
/// Gets the root path of the database.
/// </summary>
Expand All @@ -69,8 +61,6 @@ public abstract class StructuredFileDataSource : IDataSource

private Func<string, Dictionary<string, IReadOnlyList<FileSource>>> FileSourceProvider { get; set; } = default!;

#endregion

#region Protected API as seen by subclass

/// <summary>
Expand Down Expand Up @@ -231,7 +221,7 @@ protected virtual Task<double> GetAvailabilityAsync(

var files = candidateFiles
.Where(
current => begin <= current.DateTimeOffset.UtcDateTime &&
current => begin <= current.DateTimeOffset.UtcDateTime &&
current.DateTimeOffset.UtcDateTime < end)
.ToList();

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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) };
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Nexus.Extensibility" Version="2.0.0-beta.15" />
<PackageReference Include="Nexus.Extensibility" Version="2.0.0-beta.24" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ namespace Nexus.Sources.Tests;

public class StructuredFileDataSourceTester : StructuredFileDataSource
{
#region Properties

public Dictionary<string, Dictionary<string, IReadOnlyList<FileSource>>> Config { get; private set; } = default!;

#endregion

#region Methods

protected override async Task InitializeAsync(CancellationToken cancellationToken)
{
var configFilePath = Path.Combine(Root, "config.json");
Expand Down Expand Up @@ -69,6 +63,4 @@ protected override async Task ReadAsync(ReadInfo readInfo, StructuredFileReadReq
.Fill(1);
}
}

#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text.Json;
using Xunit;

Expand Down Expand Up @@ -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);

Expand All @@ -68,7 +67,7 @@ public void CanTryParseToUtc(

Assert.True(success);
Assert.Equal(expected, actual);
}
}

[Fact]
public async Task CanProvideFirstFile()
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.0.0",
"suffix": "beta.14"
"suffix": "beta.24"
}

0 comments on commit 36b5f62

Please sign in to comment.