Credits: credit the works whose notice is only a source header; test scans headers

Commit 16cb82d09 said every third-party work whose own text states holder and licence
was credited. That was false: header-only notices were missed. Now credited, holder
and licence taken from each file's own text: Academy of Motion Picture Arts and
Sciences (ACES.hlsl, 2015), Unity Technologies 2016 MIT (the built-in shader sources
Particle Standard Unlit, StretchedSkybox, MaskedWorldSpaceUI, MaskedWorldSpaceAdditiveUI
and the three AdditiveUI shaders), Supyrb 2017 (AdditiveUI shaders; the header states
no licence for that portion), and Stefan Gustavson 2011 MIT (Celestial Body
SimplexNoise2.cginc).

The discovery test now also scans every Copyright line in .shader/.hlsl/.cginc/.cs/.compute
under Assets; its holder must appear in a credit notice or in ReviewedHeaders with the
reason. Microsoft Open Technologies (UniRx headers, no licence stated, points at a
License.txt that is not in the repo) is the one reviewed entry. The Unity headers point
at a license.txt that is likewise not in the repo.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Nibu 2026-11-12 16:16:25 +00:00
commit 43be42fb52
2 changed files with 89 additions and 2 deletions

View file

@ -27,6 +27,11 @@ public static class Credits
public const string AmbientCgFile = "Assets/Materials/PBR/SOURCES.md";
public const string KdTreeFile = "Assets/Scripts/ServerShared/NIH/KDTree/KDTree.cs";
public const string SimplexNoiseFile = "Assets/Plugins/GPU Noise/SimplexNoise2D.cginc";
// Works whose notice is only a source-file header; each answers through the file whose header states it.
public const string UnityShaderFile = "Assets/Shaders/Particle Standard Unlit.shader";
public const string AdditiveUiFile = "Assets/Shaders/AdditiveUI.shader";
public const string AcesFile = "Assets/Shaders/CustomDoF/ACES.hlsl";
public const string ClassicNoiseFile = "Assets/Plugins/Celestial Body/Scripts/Shaders/Includes/SimplexNoise2.cginc";
// The first line of the attribution file; the icon credits are the lines after it.
public const string NounProjectHeading = "Noun Project";
// Where the player build loads the Noun Project credit lines from (Resources path, no extension).
@ -100,6 +105,39 @@ public static class Credits
LicenceFile = SimplexNoiseFile
},
new Credit
{
Name = "Celestial Body noise shaders",
Licence = "MIT",
Notice = "Copyright (C) 2011 Ashima Arts. Copyright (C) 2011 by Ashima Arts (Simplex noise). " +
"Copyright (C) 2011 by Stefan Gustavson (Classic noise).",
LicenceFile = ClassicNoiseFile
},
new Credit
{
Name = "Unity built-in shaders",
Licence = "MIT",
Notice = "Copyright (c) 2016 Unity Technologies. Shader source adapted from Unity's built-in shaders " +
"(Particle Standard Unlit, StretchedSkybox, MaskedWorldSpaceUI, MaskedWorldSpaceAdditiveUI).",
LicenceFile = UnityShaderFile
},
new Credit
{
Name = "AdditiveUI shaders",
Licence = "MIT for the Unity Technologies portion; the Supyrb portion states no licence",
Notice = "Copyright (c) 2017 Supyrb. All rights reserved. Author: Johannes Deml. " +
"Built on Unity's built-in UI shader, copyright (c) 2016 Unity Technologies, MIT.",
LicenceFile = AdditiveUiFile
},
new Credit
{
Name = "ACES colour transforms",
Licence = "Academy Color Encoding System licence",
Notice = "Copyright 2015 Academy of Motion Picture Arts and Sciences (A.M.P.A.S.). " +
"Portions contributed by others as indicated. All rights reserved. " +
"Source: https://github.com/ampas/aces-dev",
LicenceFile = AcesFile
},
new Credit
{
Name = "ambientCG PBR materials",
Licence = "CC0 1.0 Universal",

View file

@ -34,6 +34,12 @@ namespace Aetheria.Shared.Tests
["Assets/Plugins/Celestial Body/Textures/_Sources.txt"] = "URLs of the source textures only; states no licence",
};
// Copyright lines found in source headers whose holder no credit shows, each with the reason; keyed like HeaderKeys.
private static readonly System.Collections.Generic.Dictionary<string, string> ReviewedHeaders = new System.Collections.Generic.Dictionary<string, string>
{
["microsoftopen"] = "UniRx files derived from Rx.NET: the header names Microsoft Open Technologies and points at a License.txt that is not in the repo, so no licence is stated; decision owed",
};
// Bundled works with no licence-like file at all, found by reading Assets. Their licences are not stated in the
// repo, so they are not credited; each path must still exist, so this list cannot go stale unnoticed.
private static readonly string[] UnlicensedWorks =
@ -55,6 +61,10 @@ namespace Aetheria.Shared.Tests
(Credits.KdTreeFile, new[] { "Vili Vol\u010dini / viliwonka" }),
(Credits.SimplexNoiseFile, new[] { "Ashima Arts", "Ian McEwan", "Keijiro Takahashi" }),
(Credits.AmbientCgFile, new[] { "ambientCG" }),
(Credits.UnityShaderFile, new[] { "Unity Technologies" }),
(Credits.AdditiveUiFile, new[] { "Unity Technologies", "Supyrb", "Johannes Deml" }),
(Credits.AcesFile, new[] { "Academy of Motion Picture Arts and Sciences", "A.M.P.A.S." }),
(Credits.ClassicNoiseFile, new[] { "Ashima Arts", "Stefan Gustavson" }),
};
// Fonts that state holder and licence in their own name tables: the credit's LicenceFile is the first font, and
@ -130,6 +140,45 @@ namespace Aetheria.Shared.Tests
private static string[] Unaccounted(string[] found, System.Collections.Generic.IEnumerable<string> credited) =>
found.Where(path => !credited.Contains(path) && !ReviewedNotCredited.ContainsKey(path)).ToArray();
// The holder keys of every "Copyright ..." line in the source files under Assets: the year (when there is one) and
// the first two words of the holder, letters and digits only, lower case. Credits.cs is the credit text itself.
private static readonly Regex HeaderCopyright = new Regex(@"Copyright\s*(?:\([cC]\))?\s*(?:by\s+)?[<\[]?((?:\d{4}|[A-Z])[^\r\n]*)", RegexOptions.CultureInvariant);
private static string Key(string text) => new string(text.Where(char.IsLetterOrDigit).ToArray()).ToLowerInvariant();
private static System.Collections.Generic.Dictionary<string, string> HeaderKeys()
{
var root = Root();
var keys = new System.Collections.Generic.Dictionary<string, string>();
foreach (var path in Directory.EnumerateFiles(Path.Combine(root, "Assets"), "*", SearchOption.AllDirectories)
.Select(path => Path.GetRelativePath(root, path).Replace('\\', '/'))
.Where(path => new[] { ".shader", ".hlsl", ".cginc", ".cs", ".compute" }.Any(ext => path.EndsWith(ext)) && path != "Assets/Scripts/ServerShared/Credits.cs"))
foreach (var line in Read(path).Split('\n'))
foreach (Match match in HeaderCopyright.Matches(line))
{
var words = Regex.Replace(Regex.Replace(match.Groups[1].Value, @"\.\s.*", ""), @"[<>,]", " ").Split(' ', StringSplitOptions.RemoveEmptyEntries)
.Where(word => word != "by").ToArray();
var year = words.Length > 0 && Regex.IsMatch(words[0], @"^\d{4}") ? 1 : 0;
if (year == 0 && !Regex.IsMatch(line, @"\([cC]\)")) continue;
keys.TryAdd(Key(string.Concat(words.Take(year + 2))), path);
}
return keys;
}
// A copyright line in a source header is a notice the licence requires shown, so its holder is in a credit or in
// ReviewedHeaders with the reason; a removed credit, or a newly pasted header, fails here.
[Fact]
public void EveryCopyrightHolderInASourceHeaderIsCreditedOrReviewed()
{
var keys = HeaderKeys();
Assert.Contains("2015academyof", keys.Keys);
Assert.Contains("2016unitytechnologies", keys.Keys);
Assert.Contains("2017supyrb", keys.Keys);
var shown = Key(string.Join(" ", Load().Select(credit => Normal(credit.Notice))));
Assert.Equal(Array.Empty<string>(), keys.Where(k => !shown.Contains(k.Key) && !ReviewedHeaders.ContainsKey(k.Key)).Select(k => $"{k.Key} in {k.Value}").ToArray());
Assert.Equal(Array.Empty<string>(), ReviewedHeaders.Keys.Where(k => !keys.ContainsKey(k)).ToArray());
}
[Fact]
public void EveryLicenceLikeFileUnderAssetsIsCreditedOrReviewed()
{
@ -167,7 +216,7 @@ namespace Aetheria.Shared.Tests
{
var match = CopyrightLine.Match(line);
if (!match.Success) continue;
var body = Regex.Replace(match.Groups[1].Value.Replace("[", "").Replace("]", "").Trim(), @"(\s*All rights reserved)?\.?$", "", RegexOptions.IgnoreCase);
var body = Regex.Replace(match.Groups[1].Value.Replace("[", "").Replace("]", "").Trim(), @"(\.\s.*|\s*All rights reserved)?\.?$", "", RegexOptions.IgnoreCase);
Assert.True(notice.Contains(Normal(body)), $"the credit for {file} omits its copyright line '{body}'");
}
}
@ -176,7 +225,7 @@ namespace Aetheria.Shared.Tests
private static readonly Regex CopyrightLine = new Regex(@"copyright\s*(?:\(c\)|\u00a9)?\s*(\[?\d.*)$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
// Dash variants and case folded, so the file's en dash and the screen's hyphen compare equal.
private static string Normal(string text) => text.Replace('\u2013', '-').Replace('\u2014', '-').Replace("\r", "").ToLowerInvariant();
private static string Normal(string text) => text.Replace('\u2013', '-').Replace('\u2014', '-').Replace("\r", "").Replace(" by ", " ").ToLowerInvariant();
// The credit text is typed; the font files are the authority on who holds them. A wrong holder, or a font in the
// family that does not carry it, fails here.