From 8d694a9cbe4b7be12a806aa0764aac8eb8cf7c4d Mon Sep 17 00:00:00 2001 From: Vincent Wilms Date: Tue, 17 Dec 2024 22:27:27 +0100 Subject: [PATCH] Follow Nexus changes --- .github/workflows/build-and-publish.yml | 5 ++++ CHANGELOG.md | 4 +++ Directory.Build.props | 2 +- .../Nexus.Sources.StructuredFile.csproj | 2 +- .../StructuredFileDataSource.cs | 28 ++++++++----------- .../StructuredFileDataSourceTypes.cs | 16 +---------- .../Nexus.Sources.StructuredFile.Tests.csproj | 2 +- .../StructuredFileDataSourceTester.cs | 8 +++--- .../StructuredFileDataSourceTests.cs | 16 ++++++----- version.json | 2 +- 10 files changed, 38 insertions(+), 47 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index fc2ddeb..243a09e 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -35,6 +35,11 @@ jobs: if: ${{ env.IS_RELEASE == 'true' }} run: python build/create_tag_body.py + - name: Set up dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: "9.0.x" + - name: Build run: | dotnet build -c Release /p:GeneratePackage=true src/Nexus.Sources.StructuredFile/Nexus.Sources.StructuredFile.csproj diff --git a/CHANGELOG.md b/CHANGELOG.md index 30012f8..efbec15 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v2.0.0-beta.33 - 2024-12-17 + +- Follow Nexus changes + ## v2.0.0-beta.28 - 2024-08-26 - Improved test coverage and fixed the core file resolution algorithm diff --git a/Directory.Build.props b/Directory.Build.props index c5875f0..9e0f2a2 100755 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ true - net8.0 + net9.0 enable enable true diff --git a/src/Nexus.Sources.StructuredFile/Nexus.Sources.StructuredFile.csproj b/src/Nexus.Sources.StructuredFile/Nexus.Sources.StructuredFile.csproj index 8801b80..6d6cdcc 100644 --- a/src/Nexus.Sources.StructuredFile/Nexus.Sources.StructuredFile.csproj +++ b/src/Nexus.Sources.StructuredFile/Nexus.Sources.StructuredFile.csproj @@ -35,7 +35,7 @@ - + runtime;native diff --git a/src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs b/src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs index 258b09e..e7a0b3d 100644 --- a/src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs +++ b/src/Nexus.Sources.StructuredFile/StructuredFileDataSource.cs @@ -101,13 +101,13 @@ protected abstract Task GetCatalogRegistrationsAsync( // [".../2020-01-01.dat", ".../2020-06-01.dat" ]. /// - /// Gets the requested . + /// Enriches the provided . /// - /// The catalog identifier. + /// The catalog. /// A token to cancel the current operation. /// The catalog request task. - protected abstract Task GetCatalogAsync( - string catalogId, + protected abstract Task EnrichCatalogAsync( + ResourceCatalog catalog, CancellationToken cancellationToken); /// @@ -503,11 +503,11 @@ protected virtual async Task ReadAsync( var originalName = catalogItem.Resource.Properties? .GetStringValue(StructuredFileDataModelExtensions.OriginalNameKey)!; - return new StructuredFileReadRequest( + return new ReadRequest( + OriginalResourceName: originalName, CatalogItem: request.CatalogItem, Data: slicedData, - Status: slicedStatus, - OriginalName: originalName + Status: slicedStatus ); }).ToArray(); @@ -579,7 +579,7 @@ protected virtual async Task ReadAsync( /// The task. protected abstract Task ReadAsync( ReadInfo info, - StructuredFileReadRequest[] readRequests, + ReadRequest[] readRequests, CancellationToken cancellationToken); private protected Task<(DateTime RegularUtcFileBegin, (string FilePath, TimeSpan FileBeginOffset)[])> @@ -736,11 +736,11 @@ Task IDataSource.GetCatalogRegistrationsAsync( return GetCatalogRegistrationsAsync(path, cancellationToken); } - async Task IDataSource.GetCatalogAsync( - string catalogId, + async Task IDataSource.EnrichCatalogAsync( + ResourceCatalog catalog, CancellationToken cancellationToken) { - var catalog = await GetCatalogAsync(catalogId, cancellationToken); + catalog = await EnrichCatalogAsync(catalog, cancellationToken); if (catalog.Resources is not null) { @@ -751,12 +751,6 @@ async Task IDataSource.GetCatalogAsync( if (string.IsNullOrWhiteSpace(fileSourceId)) throw new Exception($"The resource {resource.Id} is missing the file source property."); - - // ensure original name - var originalName = resource.Properties?.GetStringValue(StructuredFileDataModelExtensions.OriginalNameKey); - - if (string.IsNullOrWhiteSpace(originalName)) - throw new Exception($"The resource {resource.Id} is missing the original name property."); } } diff --git a/src/Nexus.Sources.StructuredFile/StructuredFileDataSourceTypes.cs b/src/Nexus.Sources.StructuredFile/StructuredFileDataSourceTypes.cs index a06fb1e..c673691 100644 --- a/src/Nexus.Sources.StructuredFile/StructuredFileDataSourceTypes.cs +++ b/src/Nexus.Sources.StructuredFile/StructuredFileDataSourceTypes.cs @@ -53,18 +53,4 @@ public record ReadInfo( long FileOffset, long FileBlock, long FileLength -); - -/// -/// An read request with additional data. -/// -/// The CatalogItem to be read. -/// The data buffer. -/// The status buffer. A value of 0x01 ('1') indicates that the corresponding value in the data buffer is valid, otherwise it is treated as System.Double.NaN. -/// The original name of the resource to read. -public record StructuredFileReadRequest( - CatalogItem CatalogItem, - Memory Data, - Memory Status, - string OriginalName -) : ReadRequest(CatalogItem, Data, Status); \ No newline at end of file +); \ No newline at end of file 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 7065aad..79d6172 100644 --- a/tests/Nexus.Sources.StructuredFile.Tests/Nexus.Sources.StructuredFile.Tests.csproj +++ b/tests/Nexus.Sources.StructuredFile.Tests/Nexus.Sources.StructuredFile.Tests.csproj @@ -12,7 +12,7 @@ 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 be1064a..705ba8d 100644 --- a/tests/Nexus.Sources.StructuredFile.Tests/StructuredFileDataSourceTester.cs +++ b/tests/Nexus.Sources.StructuredFile.Tests/StructuredFileDataSourceTester.cs @@ -1,4 +1,5 @@ using Nexus.DataModel; +using Nexus.Extensibility; using System.Text.Json; namespace Nexus.Sources.Tests; @@ -43,7 +44,7 @@ protected override Task GetCatalogRegistrationsAsync(stri return Task.FromResult(new CatalogRegistration[] { new("/A/B/C", string.Empty) }); } - protected override Task GetCatalogAsync(string catalogId, CancellationToken cancellationToken) + protected override Task EnrichCatalogAsync(ResourceCatalog catalog, CancellationToken cancellationToken) { var representation = new Representation( dataType: NexusDataType.INT64, @@ -54,16 +55,15 @@ protected override Task GetCatalogAsync(string catalogId, Cance var resource = new ResourceBuilder(id: "Resource1") .WithFileSourceId(fileSourceId) - .WithOriginalName("Resource1") .AddRepresentation(representation) .Build(); - var catalog = new ResourceCatalog(id: "/A/B/C", resources: new List() { resource }); + catalog = catalog.Merge(new ResourceCatalog(id: "/A/B/C", resources: new List() { resource })); return Task.FromResult(catalog); } - protected override async Task ReadAsync(ReadInfo readInfo, StructuredFileReadRequest[] readRequests, CancellationToken cancellationToken) + protected override async Task ReadAsync(ReadInfo readInfo, ReadRequest[] readRequests, CancellationToken cancellationToken) { _onNewReadInfo?.Invoke(readInfo); diff --git a/tests/Nexus.Sources.StructuredFile.Tests/StructuredFileDataSourceTests.cs b/tests/Nexus.Sources.StructuredFile.Tests/StructuredFileDataSourceTests.cs index f5ae597..0cf3044 100644 --- a/tests/Nexus.Sources.StructuredFile.Tests/StructuredFileDataSourceTests.cs +++ b/tests/Nexus.Sources.StructuredFile.Tests/StructuredFileDataSourceTests.cs @@ -318,7 +318,7 @@ public async Task CanRead_ReadInfos(string database, string beginString, string await dataSource.SetContextAsync(context, NullLogger.Instance, CancellationToken.None); - var catalog = await dataSource.GetCatalogAsync("/A/B/C", CancellationToken.None); + var catalog = await dataSource.EnrichCatalogAsync(new("/A/B/C"), CancellationToken.None); var resource = catalog.Resources![0]; var representation = resource.Representations![0]; var catalogItem = new CatalogItem(catalog, resource, representation, default); @@ -327,7 +327,7 @@ public async Task CanRead_ReadInfos(string database, string beginString, string var end = DateTime.ParseExact(endString, "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal); var (data, status) = ExtensibilityUtilities.CreateBuffers(representation, begin, end); - var request = new ReadRequest(catalogItem, data, status); + var request = new ReadRequest(resource.Id, catalogItem, data, status); // Act await dataSource.ReadAsync( @@ -369,7 +369,7 @@ public async Task CanRead() await dataSource.SetContextAsync(context, NullLogger.Instance, CancellationToken.None); - var catalog = await dataSource.GetCatalogAsync("/A/B/C", CancellationToken.None); + var catalog = await dataSource.EnrichCatalogAsync(new("/A/B/C"), CancellationToken.None); var resource = catalog.Resources![0]; var representation = resource.Representations![0]; var catalogItem = new CatalogItem(catalog, resource, representation, default); @@ -399,7 +399,7 @@ void GenerateData(DateTimeOffset dateTime, int length) GenerateData(new DateTimeOffset(2020, 01, 02, 09, 40, 00, TimeSpan.Zero), length: 600); GenerateData(new DateTimeOffset(2020, 01, 02, 09, 50, 00, TimeSpan.Zero), length: 600); - var request = new ReadRequest(catalogItem, data, status); + var request = new ReadRequest(resource.Id, catalogItem, data, status); await dataSource.ReadAsync( begin, @@ -431,11 +431,11 @@ public async Task ReadSingleThrowsForInvalidTimePeriod(string beginString, strin await dataSource.SetContextAsync(context, NullLogger.Instance, CancellationToken.None); - var catalog = await dataSource.GetCatalogAsync("/A/B/C", CancellationToken.None); + var catalog = await dataSource.EnrichCatalogAsync(new("/A/B/C"), CancellationToken.None); var resource = catalog.Resources![0]; var representation = resource.Representations![0]; var catalogItem = new CatalogItem(catalog, resource, representation, default); - var request = new ReadRequest(catalogItem, default, default); + var request = new ReadRequest(resource.Id, catalogItem, default, default); await Assert.ThrowsAsync(() => dataSource.ReadAsync( @@ -444,6 +444,8 @@ await Assert.ThrowsAsync(() => [request], default!, default!, - CancellationToken.None)); + CancellationToken.None + ) + ); } } \ No newline at end of file diff --git a/version.json b/version.json index bad48eb..eef8daf 100755 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { "version": "2.0.0", - "suffix": "beta.28" + "suffix": "beta.33" } \ No newline at end of file