From 1b57e958c580f7d3279a413c8cfeef34a7a169de Mon Sep 17 00:00:00 2001
From: mahach666 <79989386+mahach666@users.noreply.github.com>
Date: Mon, 16 Nov 2026 18:59:50 +0300
Subject: [PATCH 1/2] Follow the IOExtend release order in release.yml
The workflow pushes the NuGet packages before the GitHub release is created (a refused first publication can be fixed and the job re-run), publishes a hyphen tag as a prerelease, and checks the changelog section before anything is published. The README states the ecosystem position and the adapter trigger; CONTRIBUTING describes the new order; CHANGELOG records the change.
---
.github/workflows/release.yml | 40 ++++++++++++++++++++++-------------
CHANGELOG.md | 9 ++++++++
CONTRIBUTING.md | 7 ++++--
README.md | 5 +++++
4 files changed, 44 insertions(+), 17 deletions(-)
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 1c09294..47ba54a 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -31,6 +31,17 @@ jobs:
if ($env:GITHUB_REF_NAME -cne "v$($version.Trim())") {
throw "The release tag must match the package version v$($version.Trim())."
}
+ # Before anything is published: a tag whose commit has no changelog section for the version fails here.
+ - name: Extract release notes
+ shell: pwsh
+ run: |
+ $version = $env:GITHUB_REF_NAME.Substring(1)
+ $changelog = Get-Content -LiteralPath CHANGELOG.md -Encoding utf8
+ $start = [array]::FindIndex($changelog, [Predicate[string]] { param($line) $line.StartsWith("## [$version]") })
+ if ($start -lt 0) { throw "CHANGELOG.md has no entry for $version" }
+ $notes = @()
+ for ($i = $start + 1; $i -lt $changelog.Count -and -not $changelog[$i].StartsWith('## ['); $i++) { $notes += $changelog[$i] }
+ $notes | Set-Content -LiteralPath release-notes.md -Encoding utf8
- run: dotnet restore PlaIO.slnx
- run: dotnet build PlaIO.slnx -c Release --no-restore
- run: dotnet test PlaIO.slnx -c Release --no-build
@@ -41,21 +52,8 @@ jobs:
with:
name: packages
path: artifacts/*
- - name: Create release
- shell: pwsh
- env:
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
- $version = $env:GITHUB_REF_NAME.Substring(1)
- $changelog = Get-Content -LiteralPath CHANGELOG.md -Encoding utf8
- $start = [array]::FindIndex($changelog, [Predicate[string]] { param($line) $line.StartsWith("## [$version]") })
- if ($start -lt 0) { throw "CHANGELOG.md has no entry for $version" }
- $notes = @()
- for ($i = $start + 1; $i -lt $changelog.Count -and -not $changelog[$i].StartsWith('## ['); $i++) { $notes += $changelog[$i] }
- $notes | Set-Content -LiteralPath release-notes.md -Encoding utf8
- $files = @(Get-ChildItem artifacts -File | ForEach-Object { $_.FullName })
- gh release create $env:GITHUB_REF_NAME --title $env:GITHUB_REF_NAME --notes-file release-notes.md @files
- if ($LASTEXITCODE -ne 0) { throw "gh release create failed with exit code $LASTEXITCODE" }
+ # The push comes before the GitHub release: a refused first publication of a package id can be fixed and the
+ # job run again, because --skip-duplicate makes the push repeatable and no release exists yet.
# Trusted publishing: the NuGet policy for this repository and workflow file exchanges the GitHub OIDC token for a short-lived key.
- uses: NuGet/login@v1
id: nuget-login
@@ -68,3 +66,15 @@ jobs:
dotnet nuget push $package.FullName --api-key '${{ steps.nuget-login.outputs.NUGET_API_KEY }}' --source https://api.nuget.org/v3/index.json --skip-duplicate
if ($LASTEXITCODE -ne 0) { throw "dotnet nuget push failed for $($package.Name) with exit code $LASTEXITCODE" }
}
+ - name: Create release
+ shell: pwsh
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ $version = $env:GITHUB_REF_NAME.Substring(1)
+ $files = @(Get-ChildItem artifacts -File | ForEach-Object { $_.FullName })
+ # A version with a hyphen is a prerelease.
+ $flags = @()
+ if ($version.Contains('-')) { $flags += '--prerelease' }
+ gh release create $env:GITHUB_REF_NAME --title $env:GITHUB_REF_NAME --notes-file release-notes.md @flags @files
+ if ($LASTEXITCODE -ne 0) { throw "gh release create failed with exit code $LASTEXITCODE" }
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dff1a25..79d13c0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,15 @@ All notable changes are documented here. The format follows [Keep a Changelog](h
and the project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html); versions before 1.0 may change the
API between minor releases.
+## [Unreleased]
+
+### Changed
+
+- The release workflow follows the IOExtend release order: the NuGet packages are pushed before the GitHub release is
+ created (a refused first publication can be fixed and the job re-run, because `--skip-duplicate` makes the push
+ repeatable), and a tag whose version contains a hyphen is published as a prerelease. The changelog section for the
+ version is checked before anything is published.
+
## [0.1.0] - 2026-11-12
### Added
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index e92cbab..276277c 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -100,8 +100,11 @@ Write commit messages in the imperative mood, for example,
## Releases
Push a tag matching the package version, such as `v0.1.0`, to run `release.yml`.
-The workflow builds and tests the solution, attaches packages, symbols, source and checksums to a GitHub release published at once (not a draft),
-and publishes the NuGet packages through Trusted Publishing. The release notes are the section of `CHANGELOG.md` for the version, so add that section before the tag.
+The workflow builds and tests the solution, packs it, and pushes the NuGet packages first, through Trusted Publishing
+(`--skip-duplicate` makes a repeated run idempotent). Only then does it attach packages, symbols, source and checksums
+to a GitHub release published at once (not a draft). A tag whose version contains a hyphen, such as `v0.2.0-preview.1`,
+is published as a prerelease. This is the IOExtend release order: NuGet first, the GitHub release second.
+The release notes are the section of `CHANGELOG.md` for the version, so add that section before the tag.
The NuGet policy must name this repository (`IOExtend/PlaIO`), `release.yml`, the configured NuGet profile and the `PlaIO*` package pattern.
The repository variable `NUGET_USER` must hold the name of that NuGet profile; the workflow reads it for the Trusted Publishing login.
diff --git a/README.md b/README.md
index f07ad76..7405f32 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,11 @@
PlaIO is a pure managed .NET library and command line tool that reads the container of Archicad project files (`.pla`,
`.pln`) and the cover image of BIMx files (`.bimx`) directly from disk, without Archicad and without native dependencies.
+In the [IOExtend](https://github.com/IOExtend) ecosystem PlaIO is a leaf engine: it depends on no other IOExtend package
+and on no scene type. A `PlaIO.Scene` adapter, planned in this repository, will turn an Archicad model into an `IOScene`
+scene document for [IOViewer](https://github.com/IOExtend/IOViewer) and coordination tools once the reader decodes
+elements and geometry; PlaIO has no scene adapter today.
+
## What it does
- Detects the file kind from the first bytes: the container shared by `.pla` and `.pln`, or `.bimx`.
From 7408a3a62a90279cf0b5737a102577d699f99637 Mon Sep 17 00:00:00 2001
From: mahach666 <79989386+mahach666@users.noreply.github.com>
Date: Mon, 16 Nov 2026 19:43:13 +0300
Subject: [PATCH 2/2] Add the PlaIO.Scene adapter scaffold
The separation of responsibilities of the target architecture: the core stays a leaf, the scene mapping lives in src/PlaIO.Scene, the viewer stays IOViewer. PlaSceneReader.Read(path) produces a valid scene of one model (the frozen Key derivation, SourceFormat pla/pln, the container-only diagnostic) and no elements while the container reader decodes none. The project is IsPackable=false and is not published; it ships on a PlaIO tag when the reader decodes elements and geometry. Tests in PlaIO.Tests freeze the key derivation; docs/scene.md documents the mapping, the limits and the publication rule.
---
.github/workflows/docs.yml | 2 +
CHANGELOG.md | 8 ++
Directory.Packages.props | 6 ++
PlaIO.slnx | 1 +
README.md | 7 +-
docfx.json | 3 +-
docs/dependencies.md | 12 ++-
docs/scene.md | 42 +++++++++
docs/toc.yml | 2 +
src/PlaIO.Scene/PlaIO.Scene.csproj | 34 ++++++++
src/PlaIO.Scene/PlaSceneOptions.cs | 10 +++
src/PlaIO.Scene/PlaSceneReader.cs | 65 ++++++++++++++
src/PlaIO.Scene/PlaSceneResult.cs | 14 +++
tests/PlaIO.Tests/PlaIO.Tests.csproj | 2 +
tests/PlaIO.Tests/PlaSceneReaderTests.cs | 104 +++++++++++++++++++++++
15 files changed, 304 insertions(+), 8 deletions(-)
create mode 100644 docs/scene.md
create mode 100644 src/PlaIO.Scene/PlaIO.Scene.csproj
create mode 100644 src/PlaIO.Scene/PlaSceneOptions.cs
create mode 100644 src/PlaIO.Scene/PlaSceneReader.cs
create mode 100644 src/PlaIO.Scene/PlaSceneResult.cs
create mode 100644 tests/PlaIO.Tests/PlaSceneReaderTests.cs
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 1110ee9..fabcea0 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -8,6 +8,7 @@ on:
- 'docfx.json'
- '.config/dotnet-tools.json'
- 'src/PlaIO/**'
+ - 'src/PlaIO.Scene/**'
- '.github/workflows/docs.yml'
pull_request:
paths:
@@ -15,6 +16,7 @@ on:
- 'docfx.json'
- '.config/dotnet-tools.json'
- 'src/PlaIO/**'
+ - 'src/PlaIO.Scene/**'
- '.github/workflows/docs.yml'
workflow_dispatch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 79d13c0..b307db4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,14 @@ API between minor releases.
## [Unreleased]
+### Added
+
+- The `PlaIO.Scene` adapter project (namespace `PlaIO.Scene`): `PlaSceneReader.Read(path)` turns a `.pla` or `.pln`
+ container into an `IOScene` `SceneDocument` — one model per file with the frozen `Key` derivation (the
+ `PlaSceneOptions.ModelKey`, else the file name), no elements yet (the container reader does not decode element
+ contents), and the `container-only` diagnostic. The project is `IsPackable=false` and is not published; it ships on a
+ `PlaIO` release tag when the reader decodes elements and geometry. See `docs/scene.md`.
+
### Changed
- The release workflow follows the IOExtend release order: the NuGet packages are pushed before the GitHub release is
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 6c4d9d3..fb361bf 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -6,6 +6,12 @@
+
+
+
+
+
diff --git a/PlaIO.slnx b/PlaIO.slnx
index 46c9a25..f593f20 100644
--- a/PlaIO.slnx
+++ b/PlaIO.slnx
@@ -2,6 +2,7 @@
+
diff --git a/README.md b/README.md
index 7405f32..3f1877c 100644
--- a/README.md
+++ b/README.md
@@ -6,9 +6,10 @@ PlaIO is a pure managed .NET library and command line tool that reads the contai
`.pln`) and the cover image of BIMx files (`.bimx`) directly from disk, without Archicad and without native dependencies.
In the [IOExtend](https://github.com/IOExtend) ecosystem PlaIO is a leaf engine: it depends on no other IOExtend package
-and on no scene type. A `PlaIO.Scene` adapter, planned in this repository, will turn an Archicad model into an `IOScene`
-scene document for [IOViewer](https://github.com/IOExtend/IOViewer) and coordination tools once the reader decodes
-elements and geometry; PlaIO has no scene adapter today.
+and on no scene type. The `PlaIO.Scene` adapter in this repository turns an Archicad container into an `IOScene` scene
+document for [IOViewer](https://github.com/IOExtend/IOViewer) and coordination tools; while the reader decodes only the
+container, the scene holds one model and no elements, and the adapter is not published yet — it ships on a `PlaIO`
+release tag when the reader decodes elements and geometry (see [the scene adapter](docs/scene.md)).
## What it does
diff --git a/docfx.json b/docfx.json
index 9f75def..b62c18f 100644
--- a/docfx.json
+++ b/docfx.json
@@ -2,7 +2,8 @@
"metadata": [
{
"src": [
- { "src": "src/PlaIO", "files": ["PlaIO.csproj"] }
+ { "src": "src/PlaIO", "files": ["PlaIO.csproj"] },
+ { "src": "src/PlaIO.Scene", "files": ["PlaIO.Scene.csproj"] }
],
"dest": "docs/api",
"properties": { "TargetFramework": "net10.0" },
diff --git a/docs/dependencies.md b/docs/dependencies.md
index 1657b96..e3a1a3d 100644
--- a/docs/dependencies.md
+++ b/docs/dependencies.md
@@ -7,7 +7,11 @@ Build settings shared by every project live in `Directory.Build.props`; the SDK
## Runtime packages (library and tool)
None. The library and the command line tool use only the .NET base class library, so the published packages bring no
-third-party code with them.
+third-party code with them. No engine package depends on another IOExtend package.
+
+The `PlaIO.Scene` adapter (not published yet) depends on [`IOScene`](https://github.com/IOExtend/IOScene)
+`[0.1.1, 0.2.0-0.0)`: any patch of the IOScene 0.1 line, no preview of the next (breaking) minor. `IOScene` itself has
+no dependencies.
## Build-time packages
@@ -19,7 +23,7 @@ It is referenced by every project with `PrivateAssets` all, so it is not a depen
## Test packages
-Pinned to exact versions: Microsoft.NET.Test.Sdk 18.11.0, xunit 2.9.3 and xunit.runner.visualstudio 4.0.1.
+Pinned to exact versions: Microsoft.NET.Test.Sdk 18.12.0, xunit 2.9.3 and xunit.runner.visualstudio 4.0.1.
They are referenced only by `tests/PlaIO.Tests`, which is not packed.
## Auditing
@@ -42,5 +46,5 @@ Re-run the audit when changing dependencies.
and `ContinuousIntegrationBuild` true when `CI`, `GITHUB_ACTIONS` or `TF_BUILD` is set. It also sets `PathMap` on every
build, not only on CI, so the folder of the build machine does not appear in PDBs and binaries. `src/Directory.Build.props`
and `tests/Directory.Build.props` import it and set `TreatWarningsAsErrors` true; the tests file also turns
-`GenerateDocumentationFile` off. The library generates its XML documentation file, which feeds the
-[API reference](api/PlaIO.yml). The library, the CLI and the tests target `net8.0` and `net10.0`.
+`GenerateDocumentationFile` off. The library and the adapter generate their XML documentation files, which feed the
+[API reference](api/PlaIO.yml). The library, the CLI, the adapter and the tests target `net8.0` and `net10.0`.
diff --git a/docs/scene.md b/docs/scene.md
new file mode 100644
index 0000000..b86ba40
--- /dev/null
+++ b/docs/scene.md
@@ -0,0 +1,42 @@
+# The scene adapter
+
+`PlaIO.Scene` (namespace `PlaIO.Scene`) turns an Archicad container read by PlaIO into an `IOScene`
+[`SceneDocument`](https://github.com/IOExtend/IOScene/blob/main/docs/contract.md) — the neutral scene model that
+[IOViewer](https://github.com/IOExtend/IOViewer) and the coordination tools consume. The adapter uses only the public
+API of the `PlaIO` library and depends on the exact `PlaIO` version it ships with.
+
+## What the scene holds today
+
+- One `SceneModel` for the file: `Key` and `Name` (see [Frozen derivations](#frozen-derivations)), `SourceFormat`
+ (`pla` or `pln`, the lower-case file extension) and `Producer` (`PlaIO.Scene `).
+- No elements, no geometry, no property sets: the container reader does not decode element contents yet. Mode 2 (LZ)
+ payloads, the meaning of the object directory records and the class names are research items (repository issues #7,
+ #8, #9). The scene holds no guesses: what cannot be read exactly is not written, and the `container-only` diagnostic
+ says so.
+
+A geometry-free scene file is a valid scene document: a consumer that reads it shows the model with no content to draw.
+
+## Frozen derivations
+
+The consumers of a scene store `SceneModel.Key` together with the source id of an element, so a change of the
+derivation is a breaking release of `PlaIO.Scene`:
+
+- `Key` is `PlaSceneOptions.ModelKey` when given; otherwise the file name with its extension, without its directory.
+- The key never switches to a better identifier. A better identifier, once the format gives the adapter one, goes into
+ a new `SceneModel` member, not into the key.
+
+The identity tests of the derivation are in `tests/PlaIO.Tests/PlaSceneReaderTests.cs`.
+
+## Diagnostics
+
+| Severity | Code | Meaning |
+|---|---|---|
+| Info | `container-only` | The reader decodes the container only: elements, properties and geometry are not read yet, so the scene has no elements. |
+
+## Publication
+
+The project is `IsPackable=false` and is not published on NuGet: it ships on a `PlaIO` release tag, with an exact
+`[X.Y.Z]` dependency on `PlaIO` and an `IOScene [0.1.1, 0.2.0-0.0)` range, when the reader decodes elements and
+geometry — the adapter trigger of the [target architecture](https://github.com/IOExtend/.github/blob/main/profile/README.md)
+("PlaIO decodes geometry / has elements to export / has a writer"). Until then nothing publishes, so no consumer can
+build on an empty mapping.
diff --git a/docs/toc.yml b/docs/toc.yml
index 47eadc1..21511c5 100644
--- a/docs/toc.yml
+++ b/docs/toc.yml
@@ -7,6 +7,8 @@
href: public-api.md
- name: Command line and exit codes
href: cli.md
+ - name: Scene adapter
+ href: scene.md
- name: Dependencies
href: dependencies.md
- name: Private test fixtures
diff --git a/src/PlaIO.Scene/PlaIO.Scene.csproj b/src/PlaIO.Scene/PlaIO.Scene.csproj
new file mode 100644
index 0000000..99541ab
--- /dev/null
+++ b/src/PlaIO.Scene/PlaIO.Scene.csproj
@@ -0,0 +1,34 @@
+
+
+
+ Turns Archicad containers read by PlaIO into IOScene scene documents. Unpublished while the reader decodes only the container; it ships when elements and geometry are read.
+ net8.0;net10.0
+ true
+
+ false
+
+ $(NoWarn);NU5104
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_Pinned Include="@(_ProjectReferencesWithVersions)">[%(_ProjectReferencesWithVersions.ProjectVersion)]
+ <_ProjectReferencesWithVersions Remove="@(_ProjectReferencesWithVersions)" />
+ <_ProjectReferencesWithVersions Include="@(_Pinned)" />
+
+
+
+
diff --git a/src/PlaIO.Scene/PlaSceneOptions.cs b/src/PlaIO.Scene/PlaSceneOptions.cs
new file mode 100644
index 0000000..aa58f9a
--- /dev/null
+++ b/src/PlaIO.Scene/PlaSceneOptions.cs
@@ -0,0 +1,10 @@
+namespace PlaIO.Scene;
+
+/// Options of .
+public sealed class PlaSceneOptions
+{
+ /// The key of the model in the scene (SceneModel.Key). Together with the source ids of the elements it
+ /// identifies an element outside the scene once the adapter writes them, so it must stay the same for every conversion
+ /// of one file. Null takes the file name with its extension, without its directory.
+ public string? ModelKey { get; set; }
+}
diff --git a/src/PlaIO.Scene/PlaSceneReader.cs b/src/PlaIO.Scene/PlaSceneReader.cs
new file mode 100644
index 0000000..2a38782
--- /dev/null
+++ b/src/PlaIO.Scene/PlaSceneReader.cs
@@ -0,0 +1,65 @@
+using System.Reflection;
+using IOScene;
+
+namespace PlaIO.Scene;
+
+///
+/// Turns an Archicad container (a .pla or .pln file) into a scene (): one model for the file,
+/// without elements, properties or geometry while the container reader does not decode them yet.
+///
+///
+/// The model's Key is the , else the file name without its directory.
+/// The derivation is frozen: the key never switches to a better identifier, and the elements this adapter will write get
+/// their persisted identity from it. SourceFormat is the lower-case file extension (pla or pln),
+/// Producer this assembly's name and version.
+/// The scene holds no guesses: what the container reader cannot decode yet (element contents, class names, the
+/// meaning of the object directory records) is not written, and the container-only diagnostic says so.
+///
+public static class PlaSceneReader
+{
+ private const int ModelId = 1;
+
+ /// Reads the container at and turns it into a scene.
+ /// is empty, or is empty.
+ public static PlaSceneResult Read(string path, PlaSceneOptions? options = null)
+ {
+ ArgumentException.ThrowIfNullOrEmpty(path);
+ string key = options?.ModelKey ?? Path.GetFileName(path);
+ if (key.Length == 0) throw new ArgumentException("The model key is empty.", nameof(options));
+ return Map(path, key);
+ }
+
+ private static PlaSceneResult Map(string path, string key)
+ {
+ using var document = PlaDocument.Open(path);
+ var scene = new SceneDocument { Title = key };
+ scene.Models.Add(new SceneModel
+ {
+ Id = ModelId,
+ Key = key,
+ Name = key,
+ SourceFormat = SourceFormat(path),
+ Producer = Producer,
+ });
+ return new PlaSceneResult
+ {
+ Document = scene,
+ Diagnostics =
+ [
+ new(SceneSeverity.Info, "container-only",
+ "The reader decodes the container only: elements, properties and geometry are not read yet, so the scene has no elements."),
+ ],
+ };
+ }
+
+ private static string? SourceFormat(string path)
+ {
+ string extension = Path.GetExtension(path).TrimStart('.').ToLowerInvariant();
+ return extension is "pla" or "pln" ? extension : null;
+ }
+
+ /// "PlaIO.Scene" and the version of this assembly without the source revision.
+ private static string Producer { get; } = "PlaIO.Scene " + (typeof(PlaSceneReader).Assembly
+ .GetCustomAttribute()?.InformationalVersion.Split('+')[0]
+ ?? typeof(PlaSceneReader).Assembly.GetName().Version?.ToString(3));
+}
diff --git a/src/PlaIO.Scene/PlaSceneResult.cs b/src/PlaIO.Scene/PlaSceneResult.cs
new file mode 100644
index 0000000..00177bb
--- /dev/null
+++ b/src/PlaIO.Scene/PlaSceneResult.cs
@@ -0,0 +1,14 @@
+using IOScene;
+
+namespace PlaIO.Scene;
+
+/// The scene made from one Archicad container by , and what the read reported.
+public sealed class PlaSceneResult
+{
+ /// The scene: one model, without elements while the reader decodes only the container.
+ public required SceneDocument Document { get; init; }
+
+ /// What the scene does not hold yet: container-only while elements, properties and geometry are not
+ /// read. Empty when the container was read whole.
+ public IReadOnlyList Diagnostics { get; init; } = [];
+}
diff --git a/tests/PlaIO.Tests/PlaIO.Tests.csproj b/tests/PlaIO.Tests/PlaIO.Tests.csproj
index ec66eb9..13e0240 100644
--- a/tests/PlaIO.Tests/PlaIO.Tests.csproj
+++ b/tests/PlaIO.Tests/PlaIO.Tests.csproj
@@ -18,6 +18,8 @@
+
+
diff --git a/tests/PlaIO.Tests/PlaSceneReaderTests.cs b/tests/PlaIO.Tests/PlaSceneReaderTests.cs
new file mode 100644
index 0000000..5cfe9fd
--- /dev/null
+++ b/tests/PlaIO.Tests/PlaSceneReaderTests.cs
@@ -0,0 +1,104 @@
+using IOScene;
+using PlaIO.Scene;
+using Xunit;
+
+namespace PlaIO.Tests;
+
+/// The tests of on synthetic containers. The identity tests are golden: the model
+/// key derivation is what the consumers of a scene store together with the source ids of the elements, so a change of
+/// these literals is a breaking release of PlaIO.Scene.
+public class PlaSceneReaderTests
+{
+ [Fact]
+ public void OneModelWithTheFileNameAsItsKey()
+ {
+ using var scope = TempContainer("sample.pla");
+
+ var result = PlaSceneReader.Read(scope.Path);
+ var document = result.Document;
+ var model = Assert.Single(document.Models);
+
+ // The frozen identity derivation: the file name with its extension, without its directory.
+ Assert.Equal("sample.pla", model.Key);
+ Assert.Equal("sample.pla", model.Name);
+ Assert.Equal("pla", model.SourceFormat);
+ Assert.Equal(1, model.Id);
+ Assert.StartsWith("PlaIO.Scene ", model.Producer);
+ Assert.Equal("sample.pla", document.Title);
+
+ // The container reader decodes no elements yet, so the scene is geometry-free and property-free.
+ Assert.Empty(document.Elements);
+ Assert.Empty(document.Geometries);
+ Assert.Empty(document.Instances);
+ Assert.Empty(document.PropertySets);
+ Assert.Empty(document.Validate());
+
+ var diagnostic = Assert.Single(result.Diagnostics);
+ Assert.Equal(SceneSeverity.Info, diagnostic.Severity);
+ Assert.Equal("container-only", diagnostic.Code);
+ }
+
+ [Fact]
+ public void PlnExtensionIsTheSourceFormat()
+ {
+ using var scope = TempContainer("project.pln");
+
+ var model = Assert.Single(PlaSceneReader.Read(scope.Path).Document.Models);
+
+ Assert.Equal("project.pln", model.Key);
+ Assert.Equal("pln", model.SourceFormat);
+ }
+
+ [Fact]
+ public void AnotherExtensionWritesNoSourceFormat()
+ {
+ using var scope = TempContainer("container.dat");
+
+ var model = Assert.Single(PlaSceneReader.Read(scope.Path).Document.Models);
+
+ Assert.Equal("container.dat", model.Key);
+ Assert.Null(model.SourceFormat);
+ }
+
+ [Fact]
+ public void ModelKeyOptionReplacesTheFileName()
+ {
+ using var scope = TempContainer("sample.pla");
+
+ var model = Assert.Single(PlaSceneReader.Read(scope.Path, new PlaSceneOptions { ModelKey = "campus" }).Document.Models);
+
+ Assert.Equal("campus", model.Key);
+ Assert.Equal("campus", model.Name);
+ }
+
+ [Fact]
+ public void AnEmptyPathThrows()
+ {
+ Assert.Throws(() => PlaSceneReader.Read(""));
+ }
+
+ [Fact]
+ public void AnEmptyModelKeyThrows()
+ {
+ using var scope = TempContainer("sample.pla");
+
+ Assert.Throws(() => PlaSceneReader.Read(scope.Path, new PlaSceneOptions { ModelKey = "" }));
+ }
+
+ /// A synthetic container written to a file of the given name in its own temporary directory.
+ private static TempScope TempContainer(string fileName)
+ {
+ var directory = Path.Combine(Path.GetTempPath(), $"plaio-scene-{Guid.NewGuid():N}");
+ Directory.CreateDirectory(directory);
+ var path = Path.Combine(directory, fileName);
+ File.WriteAllBytes(path, Synthetic.Fdb(Synthetic.Block(PlaBlockMode.Raw, [0x01, 0x02, 0x03])));
+ return new TempScope(path, directory);
+ }
+
+ private sealed class TempScope(string path, string directory) : IDisposable
+ {
+ public string Path { get; } = path;
+
+ public void Dispose() => Directory.Delete(directory, recursive: true);
+ }
+}