Files
frameledger/tests/FrameLedger.Agent.Tests/AssemblyIdentityTests.cs
poli0981andClaude Opus 5.5 d565760830 feat(build): every managed binary names FrameLedger and carries the native copyright line; versioninfo-check reads both kinds (beta.14 PR-6, D50) (#269)
Owner request 2026-10-05 ("Thêm Assembly metadata"); D50: company and product "FrameLedger", the copyright the
native FL_COPYRIGHT word for word.

Measured before the change, from the built binaries: FrameLedger.Agent.exe/.dll read Company and Product
"FrameLedger.Agent" and FileDescription "FrameLedger.Agent" (what Task Manager lists); each library its own assembly
name; every managed LegalCopyright was one space; the apphost's OriginalFilename is its assembly's (FrameLedger.dll).
tools/versioninfo-check.ps1 read the five native binaries and nothing else.

- Directory.Build.props: Company, Product, Authors, Copyright, Description (the native blocks' sentence, the Comments
  field), RepositoryUrl (stamped as AssemblyMetadata by the SDK); the FrameLedgerSourceRef metadata moved here from the
  App csproj, and release.yml passes the same ref to the Agent's publish.
- App: AssemblyTitle "FrameLedger" and a Description. Agent: AssemblyTitle "FrameLedger Agent" and a Description.
- versioninfo-check.ps1: the rules in one function over a block, a managed half (-ManagedDir, -ExpectedProductVersion -
  required, -ManagedOnly), one LegalCopyright across every binary read, the apphost carrying its assembly's block,
  Company as well as Product = FrameLedger, and -SelfTest: ten cases, nine RED, each for the reason it names (four
  mutations of the rules each turn the self-test red). build.ps1 runs the self-test and both halves (the managed half
  alone under -SkipNative); release.yml reads out/app with the tag's version.
- AssemblyIdentityTests (App, Agent): company, product, copyright = FL_COPYRIGHT parsed from CMakeLists.txt,
  description, RepositoryUrl = IssueLink.Repository, and the Win32 block Explorer shows. Red on the source before.

Docs: 12_BUILD (Identity table, the gate, the publish lines), 13_CI_CD, 19_SAFETY, FORKING (what a fork changes),
CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 04:33:07 +07:00

47 lines
2.2 KiB
C#

// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Diagnostics;
using System.Reflection;
using System.Text.RegularExpressions;
using FluentAssertions;
using FrameLedger.Agent.Composition;
namespace FrameLedger.Agent.Tests;
/// <summary>
/// beta.14 (D50): Task Manager lists a process by its file description, and until beta.14 the Agent's read
/// "FrameLedger.Agent" — the SDK's default, the assembly name, with the same company and product and no copyright. The
/// Agent is the process that injects; it says plainly what it is and who wrote it, as the native binaries always have.
/// </summary>
public sealed class AssemblyIdentityTests
{
private static string RepoRoot()
{
for (DirectoryInfo? dir = new(AppContext.BaseDirectory); dir is not null; dir = dir.Parent)
{
if (File.Exists(Path.Combine(dir.FullName, "FrameLedger.slnx")))
{
return dir.FullName;
}
}
throw new InvalidOperationException("the repository root (FrameLedger.slnx) is not above " + AppContext.BaseDirectory);
}
[Fact]
public void TheAgentNamesItselfAndCarriesTheNativeCopyright()
{
Assembly agent = typeof(AgentIdentityFactory).Assembly;
FileVersionInfo block = FileVersionInfo.GetVersionInfo(agent.Location);
Match native = Regex.Match(File.ReadAllText(Path.Combine(RepoRoot(), "src", "native", "CMakeLists.txt")),
"^set\\(FL_COPYRIGHT\\s+\"(?<text>[^\"]+)\"\\)", RegexOptions.Multiline | RegexOptions.ExplicitCapture | RegexOptions.CultureInvariant, TimeSpan.FromSeconds(1));
(block.FileDescription, block.CompanyName, block.ProductName).Should().Be(("FrameLedger Agent", "FrameLedger", "FrameLedger"),
"the apphost FrameLedger.Agent.exe carries a copy of this block, and Task Manager shows its description");
native.Success.Should().BeTrue("src/native/CMakeLists.txt sets FL_COPYRIGHT");
block.LegalCopyright.Should().Be(native.Groups["text"].Value, "one product, one copyright");
(agent.GetCustomAttribute<AssemblyDescriptionAttribute>()?.Description).Should().NotBeNullOrWhiteSpace();
}
}