Skip to content

Include grouped clashes in BCF exports and the clash matrix - #145

Open
menes97 wants to merge 1 commit into
IOExtend:mainfrom
menes97:fix/bcf-grouped-clashes
Open

menes97 wants to merge 1 commit into
IOExtend:mainfrom
menes97:fix/bcf-grouped-clashes

Conversation

@menes97

@menes97 menes97 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #17

Grouping moves clashes from Results into Groups, but several export paths read only Results, so grouped clashes were silently left out. Following the issue's suggestion:

  • NwcClashBcfExporter gets Save(string, IEnumerable<NwcClashTest>, string) and Write(Stream, IEnumerable<NwcClashTest>, string). They write every test into one archive: a topic per group and a topic per ungrouped clash. The existing Write(Stream, NwcClashTest, string) now calls the new Write with its one test, so its output is unchanged.
  • NwcDocument.ExportClashBcf (both overloads), NwcAssembly.ExportClashBcf and NwcClashMatrix.SaveBcf pass their tests to these overloads. The CLI's --clash-bcf goes through ExportClashBcf, so --clash-group together with --clash-bcf now exports every clash.
  • NwcClashMatrixCell.Clashes returns ExecutedTest.AllClashes, and SaveJson lists AllClashes, so the clashes array agrees with clashesCount.

Ungrouped tests export the same topics as before. I left NwcGridSystem alone: it reads only Results when annotating grid locations, which is a separate behaviour.

Tests (ClashGroupingTests): each groups five clashes into two groups and one ungrouped clash.

  • Document_ExportClashBcf_IncludesGroupedClashes checks that NwcDocument.ExportClashBcf(Stream) writes 3 topics.
  • Assembly_And_Matrix_ExportClashBcf_IncludeGroupedClashes checks the same through NwcAssembly.ExportClashBcf and NwcClashMatrix.SaveBcf.
  • Matrix_ClashesAndJson_IncludeGroupedClashes checks that Clashes has 5 items, and that the SaveJson cell has clashesCount 5 and 5 entries in clashes.

All three fail without the change (1 topic, 1 clash). dotnet build NwcIO.slnx succeeds, and NwcIO.Tests passes locally: 242 passed, and 2 skipped because they need private Navisworks files (.NET 10.0.400 on Windows, with global.json pinned down to it temporarily; not committed).

🤖 Generated with Claude Code

Grouping moves clashes from Results into Groups, but ExportClashBcf on
documents and assemblies, the matrix's SaveBcf, SaveJson and
NwcClashMatrixCell.Clashes read only Results, so grouped clashes were
left out without notice, also through the CLI's --clash-group with
--clash-bcf.

The BCF paths now go through new NwcClashBcfExporter.Save/Write
overloads for several tests, which write a topic per group and per
ungrouped clash into one archive, like the existing single-test
overload that now uses them. The matrix lists AllClashes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mahach666 mahach666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the intended fix is useful, but the inline comment below describes a regression reproduced against the reviewed head and the unchanged base. Please address it and add the indicated regression test before merging.

Finding: Keep existing calls with an empty collection source-compatible.

/// <summary>
/// Saves clash tests, including both standalone results and grouped clashes, to one BCF 2.1 archive file.
/// </summary>
public static void Save(string path, IEnumerable<NwcClashTest> tests, string projectName = "Navisworks Clash Coordination")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Keep existing calls with an empty collection source-compatible

Adding a second public collection overload makes this existing C# call ambiguous:

NwcClashBcfExporter.Save("empty.bcfzip", []);

A separate consumer project compiles against the current main/base but fails against this PR with CS0121: IEnumerable<NwcClashResult> versus IEnumerable<NwcClashTest>. The new Write overload similarly breaks Write(stream, []).

Please use a distinct method name for exporting a collection of tests, or an internal helper for the document/assembly/matrix callers, so existing public calls continue to compile. Add a consumer compilation check covering the empty collection.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grouped clashes are dropped from BCF exports (ExportClashBcf, CLI --clash-group with --clash-bcf, clash matrix)

2 participants