acdream/tests/AcDream.Platform.Tests/PlatformDependencyBoundaryTests.cs
Erik a49e92df3a fix(platform): Campaign LA LA0 review fixes — CI Linux lanes, arch doc, self-guard
Opus dual-lens review of cb6502c8 passed with six findings; this lands
the fix round:
1. headless-portability.yml: AcDream.Platform src/tests join both path
   triggers and the presentation-free build/test arrays — the moved XDG
   tests run on ubuntu-latest again (they had fallen out of every Linux
   lane).
2. acdream-architecture.md: AcDream.Platform gets its own layer block;
   Runtime may-reference clause updated (the guard changed in cb6502c8,
   its human-readable twin had not).
3. PlatformDependencyBoundaryTests: the BCL-only contract (zero
   project/package references) is now enforced, not just observed.
4. memory/project_linux_graphical.md canonical seam renamed.
5. Plan LA0 recon corrected: the K0 Headless guard was never the guard
   needing amendment (it asserts Headless own refs); Runtime own-refs
   guard was — the commit did the right thing, the plan text now says so.
6. App declares its AcDream.Platform reference explicitly per its own
   convention instead of riding transitivity.

Platform.Tests: 4 passed (3 moved + the new guard).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-14 15:30:04 +02:00

62 lines
2 KiB
C#

using System.Runtime.CompilerServices;
using System.Xml.Linq;
namespace AcDream.Platform.Tests;
// Campaign LA LA0 review finding 3: AcDream.Platform's entire premise is
// being the BCL-only assembly the external launcher can reference without
// pulling any gameplay code. That contract is what this guard enforces —
// the csproj must declare zero ProjectReference and zero PackageReference
// entries, forever, in the same spirit as Runtime's and Headless's
// dependency-boundary guards.
public sealed class PlatformDependencyBoundaryTests
{
[Fact]
public void PlatformProjectDeclaresNoProjectOrPackageDependencies()
{
var repositoryRoot = FindRepositoryRoot();
var projectPath = Path.Combine(
repositoryRoot,
"src",
"AcDream.Platform",
"AcDream.Platform.csproj");
var project = XDocument.Load(projectPath);
Assert.Empty(project.Descendants("ProjectReference"));
Assert.Empty(project.Descendants("PackageReference"));
}
private static string FindRepositoryRoot(
[CallerFilePath] string sourcePath = "")
{
string[] starts =
{
Path.GetDirectoryName(sourcePath) ?? string.Empty,
Directory.GetCurrentDirectory(),
AppContext.BaseDirectory,
};
foreach (string start in starts)
{
if (string.IsNullOrEmpty(start))
{
continue;
}
var directory = new DirectoryInfo(start);
while (directory is not null)
{
if (File.Exists(Path.Combine(
directory.FullName,
"AcDream.slnx")))
{
return directory.FullName;
}
directory = directory.Parent;
}
}
throw new DirectoryNotFoundException(
"Could not find AcDream.slnx above the source, working, or output directory.");
}
}