Skip to content

Commit f58139a

Browse files
committed
fix(xlsx-s3): resolve Format name collision and correct multi-output assertion
- Use `using static ...Csv.Format` + `using static ...Xlsx.Format` in sample 02 and the multi-output E2E test so Csv(...)/Xlsx(...) compile without the ambiguous `Format` class reference between the two format packages (ADR D16). - Fix the multi-output E2E assertion: RecordsWritten counts distinct rows once (not per output); single-pass is proven by both output files being complete. - ADR D14/D15/D16 recorded; plan.md PR4 test count corrected (34 green).
1 parent 42bb420 commit f58139a

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

_fv.log

Whitespace-only changes.

plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ PRs pequenos e independentes, em ordem. Cada um fecha com testes verdes e fecha
3636
- [x] Multi-output numa passada (CSV + XLSX lendo a source uma vez) — provado no E2E `Csv_and_xlsx_are_generated_reading_the_source_once`.
3737
- [x] `Destination.S3(bucket, keyTemplate)` — upload tudo-ou-nada via `PutObject` (sem objeto parcial em falha) — ver D15.
3838
- [x] Sample `02-sql-to-xlsx-s3`.
39-
- **Aceite:** CA-5, CA-6, CA-8. ✅ Total acumulado de testes verdes: 37 (13 Core + 4 CSV + 6 Local + 4 Xlsx + 3 S3 + 7 SQL/E2E).
39+
- **Aceite:** CA-5, CA-6, CA-8. ✅ Total acumulado de testes verdes: 34 (13 Core + 4 CSV + 6 Local + 4 Xlsx + 3 S3 + 4 SQL/E2E).
4040
- **Depende de:** PR 3.
4141

4242
## PR 5 — Memória constante (validação)

samples/02-sql-to-xlsx-s3/Program.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
using NeoReports.Core.DependencyInjection;
55
using NeoReports.Core.Pipeline;
66
using NeoReports.Destinations.S3;
7-
using NeoReports.Formats.Csv;
8-
using NeoReports.Formats.Xlsx;
97
using NeoReports.Sources.Sql;
108
using static NeoReports.Core.Building.ReportColumns;
9+
// Import the format entry methods directly so Csv(...) and Xlsx(...) read cleanly and avoid the
10+
// Format class-name collision between the two format packages (ADR D16).
11+
using static NeoReports.Formats.Csv.Format;
12+
using static NeoReports.Formats.Xlsx.Format;
1113

1214
// Sample 02 — SQL Server -> CSV + XLSX (single pass) -> Amazon S3.
1315
//
@@ -35,8 +37,8 @@
3537
Col<Venda, string>(v => v.Cliente, "Cliente"),
3638
Col<Venda, decimal>(v => v.Valor, "Valor", format: "C2", culture: "pt-BR"),
3739
Col<Venda, DateTime>(v => v.Data, "Data Venda", format: "yyyy-MM-dd"))
38-
.To(Format.Csv(o => o.Delimiter(';').Encoding(Encoding.UTF8)))
39-
.To(Format.Xlsx(o => o.SheetName("Vendas").AutoFilter()))
40+
.To(Csv(o => o.Delimiter(';').Encoding(Encoding.UTF8)))
41+
.To(Xlsx(o => o.SheetName("Vendas").AutoFilter()))
4042
.UploadTo(Destination.S3(bucket, "reports/{name}/{date:yyyy-MM-dd}.{ext}")));
4143

4244
var provider = services.BuildServiceProvider();

tests/NeoReports.Sources.Sql.IntegrationTests/MultiOutputE2ETests.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
using NeoReports.Core.Building;
66
using NeoReports.Core.Pipeline;
77
using NeoReports.Destinations.Local;
8-
using NeoReports.Formats.Csv;
9-
using NeoReports.Formats.Xlsx;
108
using Xunit;
119
using static NeoReports.Core.Building.ReportColumns;
10+
using static NeoReports.Formats.Csv.Format;
11+
using static NeoReports.Formats.Xlsx.Format;
1212

1313
namespace NeoReports.Sources.Sql.IntegrationTests;
1414

@@ -34,8 +34,8 @@ public async Task Csv_and_xlsx_are_generated_reading_the_source_once()
3434
.Column(v => v.Cliente, "Cliente")
3535
.Column(v => v.Valor, "Valor", format: "C2", culture: "pt-BR")
3636
.Column(v => v.Data, "Data Venda", format: "yyyy-MM-dd")
37-
.To(Format.Csv(o => o.Delimiter(';')))
38-
.To(Format.Xlsx(o => o.SheetName("Vendas").AutoFilter()))
37+
.To(Csv(o => o.Delimiter(';')))
38+
.To(Xlsx(o => o.SheetName("Vendas").AutoFilter()))
3939
.UploadTo(Destination.Local(Path.Combine(_outDir, "{name}.{ext}")))
4040
.Build();
4141

@@ -45,9 +45,11 @@ public async Task Csv_and_xlsx_are_generated_reading_the_source_once()
4545

4646
result.Status.Should().Be(ReportRunStatus.Completed);
4747

48-
// Source read exactly once for BOTH outputs: rows written == 2 outputs * rows read.
48+
// Single pass: the source is read once and every row is fed to BOTH outputs. RecordsWritten
49+
// counts distinct rows (not per-output), so it equals the row count; the proof that both
50+
// formats received all rows is the file contents asserted below.
4951
result.Stats.RecordsRead.Should().Be(_fixture.SeededRows);
50-
result.Stats.RecordsWritten.Should().Be(_fixture.SeededRows * 2);
52+
result.Stats.RecordsWritten.Should().Be(_fixture.SeededRows);
5153
result.Uploads.Should().HaveCount(2);
5254
result.Uploads.Should().OnlyContain(u => u.Success);
5355

0 commit comments

Comments
 (0)