From b8f517be6389aab67d8e764151640254566b5162 Mon Sep 17 00:00:00 2001 From: alexmg Date: Thu, 29 Aug 2024 22:48:34 +1000 Subject: [PATCH] refactor: Use source generator instead of T4 template Tweak source generator output Merge fixes --- Moniker.sln | 16 +- src/Directory.Build.props | 6 + src/Moniker.Cli/Moniker.Cli.csproj | 1 - src/Moniker.Cli/Program.cs | 4 +- .../Moniker.Generator.csproj | 18 + src/Moniker.Generator/Utf8StringsGenerator.cs | 112 ++ src/Moniker/Moniker.cs | 6 - src/Moniker/Moniker.csproj | 26 +- src/Moniker/Moniker.g.cs | 1186 ----------------- src/Moniker/Moniker.g.tt | 98 -- src/Moniker/NameGenerator.cs | 6 +- src/Moniker/Utf8Strings.cs | 41 +- test/Moniker.Tests/Moniker.Tests.csproj | 9 +- test/Moniker.Tests/StringDataTests.cs | 50 +- 14 files changed, 217 insertions(+), 1362 deletions(-) create mode 100644 src/Moniker.Generator/Moniker.Generator.csproj create mode 100644 src/Moniker.Generator/Utf8StringsGenerator.cs delete mode 100644 src/Moniker/Moniker.cs delete mode 100644 src/Moniker/Moniker.g.cs delete mode 100644 src/Moniker/Moniker.g.tt diff --git a/Moniker.sln b/Moniker.sln index 1f15b65..bf79db5 100644 --- a/Moniker.sln +++ b/Moniker.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29411.108 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35208.52 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moniker", "src\Moniker\Moniker.csproj", "{4AE3D031-1238-4411-BB00-59A5308A2467}" EndProject @@ -13,13 +13,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject .gitignore = .gitignore src\Directory.Build.props = src\Directory.Build.props - README.md = README.md GitVersion.yml = GitVersion.yml + README.md = README.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moniker.PerformanceTests", "test\Moniker.PerformanceTests\Moniker.PerformanceTests.csproj", "{FF324EAB-F8AE-4B7E-B8E0-07BD24B537DD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moniker.PerformanceTests", "test\Moniker.PerformanceTests\Moniker.PerformanceTests.csproj", "{FF324EAB-F8AE-4B7E-B8E0-07BD24B537DD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moniker.ApprovalTests", "test\Moniker.ApprovalTests\Moniker.ApprovalTests.csproj", "{C0555388-7087-408C-93C5-22D3FC2DA574}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moniker.ApprovalTests", "test\Moniker.ApprovalTests\Moniker.ApprovalTests.csproj", "{C0555388-7087-408C-93C5-22D3FC2DA574}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Moniker.Generator", "src\Moniker.Generator\Moniker.Generator.csproj", "{1780C6FE-1D7D-41A9-A652-69203E4A5D6F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -47,6 +49,10 @@ Global {C0555388-7087-408C-93C5-22D3FC2DA574}.Debug|Any CPU.Build.0 = Debug|Any CPU {C0555388-7087-408C-93C5-22D3FC2DA574}.Release|Any CPU.ActiveCfg = Release|Any CPU {C0555388-7087-408C-93C5-22D3FC2DA574}.Release|Any CPU.Build.0 = Release|Any CPU + {1780C6FE-1D7D-41A9-A652-69203E4A5D6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1780C6FE-1D7D-41A9-A652-69203E4A5D6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1780C6FE-1D7D-41A9-A652-69203E4A5D6F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1780C6FE-1D7D-41A9-A652-69203E4A5D6F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Directory.Build.props b/src/Directory.Build.props index d0cba61..a7d22ad 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -12,6 +12,12 @@ https://github.com/alexmg/Moniker + + latest + true + enable + + diff --git a/src/Moniker.Cli/Moniker.Cli.csproj b/src/Moniker.Cli/Moniker.Cli.csproj index e1fb380..71dc893 100644 --- a/src/Moniker.Cli/Moniker.Cli.csproj +++ b/src/Moniker.Cli/Moniker.Cli.csproj @@ -4,7 +4,6 @@ Moniker CLI is a tiny .NET Core Global Tool for generating fun names. Exe net8.0 - latest true moniker diff --git a/src/Moniker.Cli/Program.cs b/src/Moniker.Cli/Program.cs index 6018eb6..90fea1a 100644 --- a/src/Moniker.Cli/Program.cs +++ b/src/Moniker.Cli/Program.cs @@ -34,8 +34,8 @@ public int OnExecute() private static int Main(string[] args) => CommandLineApplication.Execute(args); - private static string GetVersion() => - (string)typeof(Program).Assembly + private static string? GetVersion() => + (string?)typeof(Program).Assembly .GetType("GitVersionInformation")! .GetField("FullSemVer")! .GetValue(null); diff --git a/src/Moniker.Generator/Moniker.Generator.csproj b/src/Moniker.Generator/Moniker.Generator.csproj new file mode 100644 index 0000000..cce7ecc --- /dev/null +++ b/src/Moniker.Generator/Moniker.Generator.csproj @@ -0,0 +1,18 @@ + + + + netstandard2.0 + enable + true + false + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + \ No newline at end of file diff --git a/src/Moniker.Generator/Utf8StringsGenerator.cs b/src/Moniker.Generator/Utf8StringsGenerator.cs new file mode 100644 index 0000000..77a465f --- /dev/null +++ b/src/Moniker.Generator/Utf8StringsGenerator.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Text; + +namespace Moniker.Generator; + +/// +[Generator] +public class Utf8StringsGenerator : ISourceGenerator +{ + /// + public void Initialize(GeneratorInitializationContext context) + { + // No initialization required + } + + /// + public void Execute(GeneratorExecutionContext context) + { + var additionalFiles = context.AdditionalFiles + .Where(f => Path.GetExtension(f.Path).Equals(".txt", StringComparison.OrdinalIgnoreCase)); + + foreach (var file in additionalFiles) + { + var className = Path.GetFileNameWithoutExtension(file.Path); + var sourceText = GenerateSourceForFile(className, file); + + context.AddSource($"{className}.g.cs", SourceText.From(sourceText, Encoding.UTF8)); + } + } + + private static string GenerateSourceForFile(string className, AdditionalText file) + { + var offsets = new List(); + var charCounts = new List(); + var offset = 0; + var stringBuilder = new StringBuilder(); + + stringBuilder.AppendLine("//------------------------------------------------------------------------------"); + stringBuilder.AppendLine("// "); + stringBuilder.AppendLine("// This code was generated by a tool."); + stringBuilder.AppendLine("// Changes to this file may cause incorrect behavior and will be lost if"); + stringBuilder.AppendLine("// the code is re-generated."); + stringBuilder.AppendLine("// "); + stringBuilder.AppendLine("//------------------------------------------------------------------------------"); + stringBuilder.AppendLine("#nullable enable"); + stringBuilder.AppendLine(); + stringBuilder.AppendLine("using System;"); + stringBuilder.AppendLine(); + stringBuilder.AppendLine("namespace Moniker;"); + stringBuilder.AppendLine(); + stringBuilder.AppendLine($"internal static class {className}"); + stringBuilder.AppendLine("{"); + stringBuilder.AppendLine(" public static Utf8Strings Strings => new(Count, Data, Offsets, CharCounts);"); + stringBuilder.AppendLine(); + stringBuilder.AppendLine(" private static ReadOnlySpan Data =>"); + + foreach (var textLine in file.GetText()?.Lines.ToArray() ?? []) + { + var line = textLine.ToString().Trim(); + if (line.Length == 0 || line[0] == '#') + continue; + + var byteLength = Encoding.UTF8.GetByteCount(line); + + if (line.Length > 0) + { + stringBuilder.AppendLine($" \"{line}\"u8 + // [{offset}..{offset + byteLength}]"); + } + + offsets.Add(offset); + charCounts.Add(line.Length); + offset += byteLength; + } + + offsets.Add(offset); + stringBuilder.AppendLine(" \"\"u8;"); + stringBuilder.AppendLine(); + stringBuilder.AppendLine($" private const int Size = {offsets.Last()};"); + stringBuilder.AppendLine(); + stringBuilder.AppendLine($" public const int Count = {offsets.Count - 1};"); + stringBuilder.AppendLine(); + + AppendReadOnlySpan(stringBuilder, "Offsets", "int", offsets); + stringBuilder.AppendLine(); + AppendReadOnlySpan(stringBuilder, "CharCounts", "byte", charCounts); + + stringBuilder.AppendLine("}"); + + return stringBuilder.ToString(); + } + + private static void AppendReadOnlySpan(StringBuilder stringBuilder, string name, string type, List values) + { + stringBuilder.AppendLine($" private static ReadOnlySpan<{type}> {name} =>"); + stringBuilder.AppendLine(" ["); + + var groups = from e in values.Select((v, i) => (Index: i, Value: v)) + group e.Value.ToString() by e.Index / 15; + + foreach (var group in groups) + { + stringBuilder.AppendLine($" {string.Join(", ", group)},"); + } + + stringBuilder.AppendLine(" ];"); + } +} \ No newline at end of file diff --git a/src/Moniker/Moniker.cs b/src/Moniker/Moniker.cs deleted file mode 100644 index f8cd099..0000000 --- a/src/Moniker/Moniker.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Moniker; - -static partial class MobyAdjectives; -static partial class MobySurnames; -static partial class MonikerAnimals; -static partial class MonikerDescriptors; diff --git a/src/Moniker/Moniker.csproj b/src/Moniker/Moniker.csproj index d85133a..8b4d654 100644 --- a/src/Moniker/Moniker.csproj +++ b/src/Moniker/Moniker.csproj @@ -3,14 +3,12 @@ Moniker is a tiny .NET library for generating fun names. net8.0 - latest - true true - - <_Parameter1>Moniker.Tests + + <_Parameter1>$(AssemblyName).Tests @@ -21,22 +19,22 @@ - - TextTemplatingFileGenerator - Moniker.g.cs - + + - + - - True - True - Moniker.g.tt - + + + + + diff --git a/src/Moniker/Moniker.g.cs b/src/Moniker/Moniker.g.cs deleted file mode 100644 index b33397d..0000000 --- a/src/Moniker/Moniker.g.cs +++ /dev/null @@ -1,1186 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is re-generated. -// -//------------------------------------------------------------------------------ - -#nullable enable - -namespace Moniker; - -using System; - -partial class MobyAdjectives // MobyAdjectives.txt -{ - public static Utf8Strings Strings => new(Count, Data, Offsets, CharCounts); - - static ReadOnlySpan Data => - """admiring"""u8 + // [0..8] - """adoring"""u8 + // [8..15] - """affectionate"""u8 + // [15..27] - """agitated"""u8 + // [27..35] - """amazing"""u8 + // [35..42] - """angry"""u8 + // [42..47] - """awesome"""u8 + // [47..54] - """beautiful"""u8 + // [54..63] - """blissful"""u8 + // [63..71] - """bold"""u8 + // [71..75] - """boring"""u8 + // [75..81] - """brave"""u8 + // [81..86] - """busy"""u8 + // [86..90] - """charming"""u8 + // [90..98] - """clever"""u8 + // [98..104] - """cool"""u8 + // [104..108] - """compassionate"""u8 + // [108..121] - """competent"""u8 + // [121..130] - """condescending"""u8 + // [130..143] - """confident"""u8 + // [143..152] - """cranky"""u8 + // [152..158] - """crazy"""u8 + // [158..163] - """dazzling"""u8 + // [163..171] - """determined"""u8 + // [171..181] - """distracted"""u8 + // [181..191] - """dreamy"""u8 + // [191..197] - """eager"""u8 + // [197..202] - """ecstatic"""u8 + // [202..210] - """elastic"""u8 + // [210..217] - """elated"""u8 + // [217..223] - """elegant"""u8 + // [223..230] - """eloquent"""u8 + // [230..238] - """epic"""u8 + // [238..242] - """exciting"""u8 + // [242..250] - """fervent"""u8 + // [250..257] - """festive"""u8 + // [257..264] - """flamboyant"""u8 + // [264..274] - """focused"""u8 + // [274..281] - """friendly"""u8 + // [281..289] - """frosty"""u8 + // [289..295] - """funny"""u8 + // [295..300] - """gallant"""u8 + // [300..307] - """gifted"""u8 + // [307..313] - """goofy"""u8 + // [313..318] - """gracious"""u8 + // [318..326] - """great"""u8 + // [326..331] - """happy"""u8 + // [331..336] - """hardcore"""u8 + // [336..344] - """heuristic"""u8 + // [344..353] - """hopeful"""u8 + // [353..360] - """hungry"""u8 + // [360..366] - """infallible"""u8 + // [366..376] - """inspiring"""u8 + // [376..385] - """interesting"""u8 + // [385..396] - """intelligent"""u8 + // [396..407] - """jolly"""u8 + // [407..412] - """jovial"""u8 + // [412..418] - """keen"""u8 + // [418..422] - """kind"""u8 + // [422..426] - """laughing"""u8 + // [426..434] - """loving"""u8 + // [434..440] - """lucid"""u8 + // [440..445] - """magical"""u8 + // [445..452] - """mystifying"""u8 + // [452..462] - """modest"""u8 + // [462..468] - """musing"""u8 + // [468..474] - """naughty"""u8 + // [474..481] - """nervous"""u8 + // [481..488] - """nice"""u8 + // [488..492] - """nifty"""u8 + // [492..497] - """nostalgic"""u8 + // [497..506] - """objective"""u8 + // [506..515] - """optimistic"""u8 + // [515..525] - """peaceful"""u8 + // [525..533] - """pedantic"""u8 + // [533..541] - """pensive"""u8 + // [541..548] - """practical"""u8 + // [548..557] - """priceless"""u8 + // [557..566] - """quirky"""u8 + // [566..572] - """quizzical"""u8 + // [572..581] - """recursing"""u8 + // [581..590] - """relaxed"""u8 + // [590..597] - """reverent"""u8 + // [597..605] - """romantic"""u8 + // [605..613] - """sad"""u8 + // [613..616] - """serene"""u8 + // [616..622] - """sharp"""u8 + // [622..627] - """silly"""u8 + // [627..632] - """sleepy"""u8 + // [632..638] - """stoic"""u8 + // [638..643] - """strange"""u8 + // [643..650] - """stupefied"""u8 + // [650..659] - """suspicious"""u8 + // [659..669] - """sweet"""u8 + // [669..674] - """tender"""u8 + // [674..680] - """thirsty"""u8 + // [680..687] - """trusting"""u8 + // [687..695] - """unruffled"""u8 + // [695..704] - """upbeat"""u8 + // [704..710] - """vibrant"""u8 + // [710..717] - """vigilant"""u8 + // [717..725] - """vigorous"""u8 + // [725..733] - """wizardly"""u8 + // [733..741] - """wonderful"""u8 + // [741..750] - """xenodochial"""u8 + // [750..761] - """youthful"""u8 + // [761..769] - """zealous"""u8 + // [769..776] - """zen"""u8 + // [776..779] - ""u8; - - const int size = 779; - - public const int Count = 108; - - static ReadOnlySpan Offsets => - [ - 0, 8, 15, 27, 35, 42, 47, 54, 63, 71, 75, 81, 86, 90, 98, - 104, 108, 121, 130, 143, 152, 158, 163, 171, 181, 191, 197, 202, 210, 217, - 223, 230, 238, 242, 250, 257, 264, 274, 281, 289, 295, 300, 307, 313, 318, - 326, 331, 336, 344, 353, 360, 366, 376, 385, 396, 407, 412, 418, 422, 426, - 434, 440, 445, 452, 462, 468, 474, 481, 488, 492, 497, 506, 515, 525, 533, - 541, 548, 557, 566, 572, 581, 590, 597, 605, 613, 616, 622, 627, 632, 638, - 643, 650, 659, 669, 674, 680, 687, 695, 704, 710, 717, 725, 733, 741, 750, - 761, 769, 776, 779, - ]; - - static ReadOnlySpan CharCounts => - [ - 8, 7, 12, 8, 7, 5, 7, 9, 8, 4, 6, 5, 4, 8, 6, 4, 13, 9, 13, 9, - 6, 5, 8, 10, 10, 6, 5, 8, 7, 6, 7, 8, 4, 8, 7, 7, 10, 7, 8, 6, - 5, 7, 6, 5, 8, 5, 5, 8, 9, 7, 6, 10, 9, 11, 11, 5, 6, 4, 4, 8, - 6, 5, 7, 10, 6, 6, 7, 7, 4, 5, 9, 9, 10, 8, 8, 7, 9, 9, 6, 9, - 9, 7, 8, 8, 3, 6, 5, 5, 6, 5, 7, 9, 10, 5, 6, 7, 8, 9, 6, 7, - 8, 8, 8, 9, 11, 8, 7, 3, - ]; -} - -partial class MobySurnames // MobySurnames.txt -{ - public static Utf8Strings Strings => new(Count, Data, Offsets, CharCounts); - - static ReadOnlySpan Data => - """albattani"""u8 + // [0..9] - """allen"""u8 + // [9..14] - """almeida"""u8 + // [14..21] - """antonelli"""u8 + // [21..30] - """agnesi"""u8 + // [30..36] - """archimedes"""u8 + // [36..46] - """ardinghelli"""u8 + // [46..57] - """aryabhata"""u8 + // [57..66] - """austin"""u8 + // [66..72] - """babbage"""u8 + // [72..79] - """banach"""u8 + // [79..85] - """banzai"""u8 + // [85..91] - """bardeen"""u8 + // [91..98] - """bartik"""u8 + // [98..104] - """bassi"""u8 + // [104..109] - """beaver"""u8 + // [109..115] - """bell"""u8 + // [115..119] - """benz"""u8 + // [119..123] - """bhabha"""u8 + // [123..129] - """bhaskara"""u8 + // [129..137] - """black"""u8 + // [137..142] - """blackburn"""u8 + // [142..151] - """blackwell"""u8 + // [151..160] - """bohr"""u8 + // [160..164] - """booth"""u8 + // [164..169] - """borg"""u8 + // [169..173] - """bose"""u8 + // [173..177] - """bouman"""u8 + // [177..183] - """boyd"""u8 + // [183..187] - """brahmagupta"""u8 + // [187..198] - """brattain"""u8 + // [198..206] - """brown"""u8 + // [206..211] - """burnell"""u8 + // [211..218] - """buck"""u8 + // [218..222] - """cannon"""u8 + // [222..228] - """carson"""u8 + // [228..234] - """cartwright"""u8 + // [234..244] - """cerf"""u8 + // [244..248] - """chandrasekhar"""u8 + // [248..261] - """chaplygin"""u8 + // [261..270] - """chatelet"""u8 + // [270..278] - """chatterjee"""u8 + // [278..288] - """chebyshev"""u8 + // [288..297] - """cohen"""u8 + // [297..302] - """chaum"""u8 + // [302..307] - """clarke"""u8 + // [307..313] - """colden"""u8 + // [313..319] - """cori"""u8 + // [319..323] - """cray"""u8 + // [323..327] - """curran"""u8 + // [327..333] - """curie"""u8 + // [333..338] - """darwin"""u8 + // [338..344] - """davinci"""u8 + // [344..351] - """dewdney"""u8 + // [351..358] - """dhawan"""u8 + // [358..364] - """diffie"""u8 + // [364..370] - """dijkstra"""u8 + // [370..378] - """dirac"""u8 + // [378..383] - """driscoll"""u8 + // [383..391] - """dubinsky"""u8 + // [391..399] - """easley"""u8 + // [399..405] - """edison"""u8 + // [405..411] - """einstein"""u8 + // [411..419] - """elbakyan"""u8 + // [419..427] - """elgamal"""u8 + // [427..434] - """elion"""u8 + // [434..439] - """ellis"""u8 + // [439..444] - """engelbart"""u8 + // [444..453] - """euclid"""u8 + // [453..459] - """euler"""u8 + // [459..464] - """faraday"""u8 + // [464..471] - """feistel"""u8 + // [471..478] - """fermat"""u8 + // [478..484] - """fermi"""u8 + // [484..489] - """feynman"""u8 + // [489..496] - """franklin"""u8 + // [496..504] - """gagarin"""u8 + // [504..511] - """galileo"""u8 + // [511..518] - """galois"""u8 + // [518..524] - """ganguly"""u8 + // [524..531] - """gates"""u8 + // [531..536] - """gauss"""u8 + // [536..541] - """germain"""u8 + // [541..548] - """goldberg"""u8 + // [548..556] - """goldstine"""u8 + // [556..565] - """goldwasser"""u8 + // [565..575] - """golick"""u8 + // [575..581] - """goodall"""u8 + // [581..588] - """gould"""u8 + // [588..593] - """greider"""u8 + // [593..600] - """grothendieck"""u8 + // [600..612] - """haibt"""u8 + // [612..617] - """hamilton"""u8 + // [617..625] - """haslett"""u8 + // [625..632] - """hawking"""u8 + // [632..639] - """hellman"""u8 + // [639..646] - """heisenberg"""u8 + // [646..656] - """hermann"""u8 + // [656..663] - """herschel"""u8 + // [663..671] - """hertz"""u8 + // [671..676] - """heyrovsky"""u8 + // [676..685] - """hodgkin"""u8 + // [685..692] - """hofstadter"""u8 + // [692..702] - """hoover"""u8 + // [702..708] - """hopper"""u8 + // [708..714] - """hugle"""u8 + // [714..719] - """hypatia"""u8 + // [719..726] - """ishizaka"""u8 + // [726..734] - """jackson"""u8 + // [734..741] - """jang"""u8 + // [741..745] - """jennings"""u8 + // [745..753] - """jepsen"""u8 + // [753..759] - """johnson"""u8 + // [759..766] - """joliot"""u8 + // [766..772] - """jones"""u8 + // [772..777] - """kalam"""u8 + // [777..782] - """kapitsa"""u8 + // [782..789] - """kare"""u8 + // [789..793] - """keldysh"""u8 + // [793..800] - """keller"""u8 + // [800..806] - """kepler"""u8 + // [806..812] - """khayyam"""u8 + // [812..819] - """khorana"""u8 + // [819..826] - """kilby"""u8 + // [826..831] - """kirch"""u8 + // [831..836] - """knuth"""u8 + // [836..841] - """kowalevski"""u8 + // [841..851] - """lalande"""u8 + // [851..858] - """lamarr"""u8 + // [858..864] - """lamport"""u8 + // [864..871] - """leakey"""u8 + // [871..877] - """leavitt"""u8 + // [877..884] - """lederberg"""u8 + // [884..893] - """lehmann"""u8 + // [893..900] - """lewin"""u8 + // [900..905] - """lichterman"""u8 + // [905..915] - """liskov"""u8 + // [915..921] - """lovelace"""u8 + // [921..929] - """lumiere"""u8 + // [929..936] - """mahavira"""u8 + // [936..944] - """margulis"""u8 + // [944..952] - """matsumoto"""u8 + // [952..961] - """maxwell"""u8 + // [961..968] - """mayer"""u8 + // [968..973] - """mccarthy"""u8 + // [973..981] - """mcclintock"""u8 + // [981..991] - """mclaren"""u8 + // [991..998] - """mclean"""u8 + // [998..1004] - """mcnulty"""u8 + // [1004..1011] - """mendel"""u8 + // [1011..1017] - """mendeleev"""u8 + // [1017..1026] - """meitner"""u8 + // [1026..1033] - """meninsky"""u8 + // [1033..1041] - """merkle"""u8 + // [1041..1047] - """mestorf"""u8 + // [1047..1054] - """mirzakhani"""u8 + // [1054..1064] - """moore"""u8 + // [1064..1069] - """morse"""u8 + // [1069..1074] - """murdock"""u8 + // [1074..1081] - """moser"""u8 + // [1081..1086] - """napier"""u8 + // [1086..1092] - """nash"""u8 + // [1092..1096] - """neumann"""u8 + // [1096..1103] - """newton"""u8 + // [1103..1109] - """nightingale"""u8 + // [1109..1120] - """nobel"""u8 + // [1120..1125] - """noether"""u8 + // [1125..1132] - """northcutt"""u8 + // [1132..1141] - """noyce"""u8 + // [1141..1146] - """panini"""u8 + // [1146..1152] - """pare"""u8 + // [1152..1156] - """pascal"""u8 + // [1156..1162] - """pasteur"""u8 + // [1162..1169] - """payne"""u8 + // [1169..1174] - """perlman"""u8 + // [1174..1181] - """pike"""u8 + // [1181..1185] - """poincare"""u8 + // [1185..1193] - """poitras"""u8 + // [1193..1200] - """proskuriakova"""u8 + // [1200..1213] - """ptolemy"""u8 + // [1213..1220] - """raman"""u8 + // [1220..1225] - """ramanujan"""u8 + // [1225..1234] - """ride"""u8 + // [1234..1238] - """montalcini"""u8 + // [1238..1248] - """ritchie"""u8 + // [1248..1255] - """rhodes"""u8 + // [1255..1261] - """robinson"""u8 + // [1261..1269] - """roentgen"""u8 + // [1269..1277] - """rosalind"""u8 + // [1277..1285] - """rubin"""u8 + // [1285..1290] - """saha"""u8 + // [1290..1294] - """sammet"""u8 + // [1294..1300] - """sanderson"""u8 + // [1300..1309] - """satoshi"""u8 + // [1309..1316] - """shamir"""u8 + // [1316..1322] - """shannon"""u8 + // [1322..1329] - """shaw"""u8 + // [1329..1333] - """shirley"""u8 + // [1333..1340] - """shockley"""u8 + // [1340..1348] - """shtern"""u8 + // [1348..1354] - """sinoussi"""u8 + // [1354..1362] - """snyder"""u8 + // [1362..1368] - """solomon"""u8 + // [1368..1375] - """spence"""u8 + // [1375..1381] - """stonebraker"""u8 + // [1381..1392] - """sutherland"""u8 + // [1392..1402] - """swanson"""u8 + // [1402..1409] - """swartz"""u8 + // [1409..1415] - """swirles"""u8 + // [1415..1422] - """taussig"""u8 + // [1422..1429] - """tereshkova"""u8 + // [1429..1439] - """tesla"""u8 + // [1439..1444] - """tharp"""u8 + // [1444..1449] - """thompson"""u8 + // [1449..1457] - """torvalds"""u8 + // [1457..1465] - """tu"""u8 + // [1465..1467] - """turing"""u8 + // [1467..1473] - """varahamihira"""u8 + // [1473..1485] - """vaughan"""u8 + // [1485..1492] - """visvesvaraya"""u8 + // [1492..1504] - """volhard"""u8 + // [1504..1511] - """villani"""u8 + // [1511..1518] - """wescoff"""u8 + // [1518..1525] - """wilbur"""u8 + // [1525..1531] - """wiles"""u8 + // [1531..1536] - """williams"""u8 + // [1536..1544] - """williamson"""u8 + // [1544..1554] - """wilson"""u8 + // [1554..1560] - """wing"""u8 + // [1560..1564] - """wozniak"""u8 + // [1564..1571] - """wright"""u8 + // [1571..1577] - """wu"""u8 + // [1577..1579] - """yalow"""u8 + // [1579..1584] - """yonath"""u8 + // [1584..1590] - """zhukovsky"""u8 + // [1590..1599] - ""u8; - - const int size = 1599; - - public const int Count = 235; - - static ReadOnlySpan Offsets => - [ - 0, 9, 14, 21, 30, 36, 46, 57, 66, 72, 79, 85, 91, 98, 104, - 109, 115, 119, 123, 129, 137, 142, 151, 160, 164, 169, 173, 177, 183, 187, - 198, 206, 211, 218, 222, 228, 234, 244, 248, 261, 270, 278, 288, 297, 302, - 307, 313, 319, 323, 327, 333, 338, 344, 351, 358, 364, 370, 378, 383, 391, - 399, 405, 411, 419, 427, 434, 439, 444, 453, 459, 464, 471, 478, 484, 489, - 496, 504, 511, 518, 524, 531, 536, 541, 548, 556, 565, 575, 581, 588, 593, - 600, 612, 617, 625, 632, 639, 646, 656, 663, 671, 676, 685, 692, 702, 708, - 714, 719, 726, 734, 741, 745, 753, 759, 766, 772, 777, 782, 789, 793, 800, - 806, 812, 819, 826, 831, 836, 841, 851, 858, 864, 871, 877, 884, 893, 900, - 905, 915, 921, 929, 936, 944, 952, 961, 968, 973, 981, 991, 998, 1004, 1011, - 1017, 1026, 1033, 1041, 1047, 1054, 1064, 1069, 1074, 1081, 1086, 1092, 1096, 1103, 1109, - 1120, 1125, 1132, 1141, 1146, 1152, 1156, 1162, 1169, 1174, 1181, 1185, 1193, 1200, 1213, - 1220, 1225, 1234, 1238, 1248, 1255, 1261, 1269, 1277, 1285, 1290, 1294, 1300, 1309, 1316, - 1322, 1329, 1333, 1340, 1348, 1354, 1362, 1368, 1375, 1381, 1392, 1402, 1409, 1415, 1422, - 1429, 1439, 1444, 1449, 1457, 1465, 1467, 1473, 1485, 1492, 1504, 1511, 1518, 1525, 1531, - 1536, 1544, 1554, 1560, 1564, 1571, 1577, 1579, 1584, 1590, 1599, - ]; - - static ReadOnlySpan CharCounts => - [ - 9, 5, 7, 9, 6, 10, 11, 9, 6, 7, 6, 6, 7, 6, 5, 6, 4, 4, 6, 8, - 5, 9, 9, 4, 5, 4, 4, 6, 4, 11, 8, 5, 7, 4, 6, 6, 10, 4, 13, 9, - 8, 10, 9, 5, 5, 6, 6, 4, 4, 6, 5, 6, 7, 7, 6, 6, 8, 5, 8, 8, - 6, 6, 8, 8, 7, 5, 5, 9, 6, 5, 7, 7, 6, 5, 7, 8, 7, 7, 6, 7, - 5, 5, 7, 8, 9, 10, 6, 7, 5, 7, 12, 5, 8, 7, 7, 7, 10, 7, 8, 5, - 9, 7, 10, 6, 6, 5, 7, 8, 7, 4, 8, 6, 7, 6, 5, 5, 7, 4, 7, 6, - 6, 7, 7, 5, 5, 5, 10, 7, 6, 7, 6, 7, 9, 7, 5, 10, 6, 8, 7, 8, - 8, 9, 7, 5, 8, 10, 7, 6, 7, 6, 9, 7, 8, 6, 7, 10, 5, 5, 7, 5, - 6, 4, 7, 6, 11, 5, 7, 9, 5, 6, 4, 6, 7, 5, 7, 4, 8, 7, 13, 7, - 5, 9, 4, 10, 7, 6, 8, 8, 8, 5, 4, 6, 9, 7, 6, 7, 4, 7, 8, 6, - 8, 6, 7, 6, 11, 10, 7, 6, 7, 7, 10, 5, 5, 8, 8, 2, 6, 12, 7, 12, - 7, 7, 7, 6, 5, 8, 10, 6, 4, 7, 6, 2, 5, 6, 9, - ]; -} - -partial class MonikerAnimals // MonikerAnimals.txt -{ - public static Utf8Strings Strings => new(Count, Data, Offsets, CharCounts); - - static ReadOnlySpan Data => - """aardvark"""u8 + // [0..8] - """aardwolf"""u8 + // [8..16] - """abalone"""u8 + // [16..23] - """albatross"""u8 + // [23..32] - """alligator"""u8 + // [32..41] - """alpaca"""u8 + // [41..47] - """anaconda"""u8 + // [47..55] - """angelfish"""u8 + // [55..64] - """ant"""u8 + // [64..67] - """anteater"""u8 + // [67..75] - """antelope"""u8 + // [75..83] - """arachnid"""u8 + // [83..91] - """armadillo"""u8 + // [91..100] - """badger"""u8 + // [100..106] - """bat"""u8 + // [106..109] - """bear"""u8 + // [109..113] - """bee"""u8 + // [113..116] - """beetle"""u8 + // [116..122] - """billygoat"""u8 + // [122..131] - """bird"""u8 + // [131..135] - """bison"""u8 + // [135..140] - """blackbird"""u8 + // [140..149] - """bobcat"""u8 + // [149..155] - """boxer"""u8 + // [155..160] - """bronco"""u8 + // [160..166] - """buffalo"""u8 + // [166..173] - """buffoon"""u8 + // [173..180] - """bumblebee"""u8 + // [180..189] - """bunny"""u8 + // [189..194] - """butterfly"""u8 + // [194..203] - """camel"""u8 + // [203..208] - """cardinal"""u8 + // [208..216] - """cat"""u8 + // [216..219] - """catfish"""u8 + // [219..226] - """cheetah"""u8 + // [226..233] - """chicken"""u8 + // [233..240] - """chimp"""u8 + // [240..245] - """chinchilla"""u8 + // [245..255] - """chipmunk"""u8 + // [255..263] - """clam"""u8 + // [263..267] - """clownfish"""u8 + // [267..276] - """condor"""u8 + // [276..282] - """coral"""u8 + // [282..287] - """cow"""u8 + // [287..290] - """crab"""u8 + // [290..294] - """cricket"""u8 + // [294..301] - """crocodile"""u8 + // [301..310] - """dachshund"""u8 + // [310..319] - """deer"""u8 + // [319..323] - """dingo"""u8 + // [323..328] - """dog"""u8 + // [328..331] - """dolphin"""u8 + // [331..338] - """donkey"""u8 + // [338..344] - """dragon"""u8 + // [344..350] - """dragonfly"""u8 + // [350..359] - """duck"""u8 + // [359..363] - """eagle"""u8 + // [363..368] - """echidna"""u8 + // [368..375] - """eel"""u8 + // [375..378] - """elephant"""u8 + // [378..386] - """elk"""u8 + // [386..389] - """emu"""u8 + // [389..392] - """ferret"""u8 + // [392..398] - """fish"""u8 + // [398..402] - """flee"""u8 + // [402..406] - """fly"""u8 + // [406..409] - """fox"""u8 + // [409..412] - """frog"""u8 + // [412..416] - """garfish"""u8 + // [416..423] - """gecko"""u8 + // [423..428] - """gerbil"""u8 + // [428..434] - """gibbon"""u8 + // [434..440] - """giraffe"""u8 + // [440..447] - """gnat"""u8 + // [447..451] - """goat"""u8 + // [451..455] - """goose"""u8 + // [455..460] - """gopher"""u8 + // [460..466] - """gorilla"""u8 + // [466..473] - """grasshopper"""u8 + // [473..484] - """greyhound"""u8 + // [484..493] - """grizzly"""u8 + // [493..500] - """guppy"""u8 + // [500..505] - """hamster"""u8 + // [505..512] - """hare"""u8 + // [512..516] - """hedgehog"""u8 + // [516..524] - """heron"""u8 + // [524..529] - """hog"""u8 + // [529..532] - """horse"""u8 + // [532..537] - """hound"""u8 + // [537..542] - """hummingbird"""u8 + // [542..553] - """hydra"""u8 + // [553..558] - """hyena"""u8 + // [558..563] - """ibex"""u8 + // [563..567] - """ibis"""u8 + // [567..571] - """iguana"""u8 + // [571..577] - """indri"""u8 + // [577..582] - """jackal"""u8 + // [582..588] - """jaguar"""u8 + // [588..594] - """jellyfish"""u8 + // [594..603] - """joey"""u8 + // [603..607] - """kangaroo"""u8 + // [607..615] - """kitten"""u8 + // [615..621] - """kiwi"""u8 + // [621..625] - """koala"""u8 + // [625..630] - """kudu"""u8 + // [630..634] - """labradoodle"""u8 + // [634..645] - """ladybird"""u8 + // [645..653] - """ladybug"""u8 + // [653..660] - """lamb"""u8 + // [660..664] - """lambkin"""u8 + // [664..671] - """lemur"""u8 + // [671..676] - """leopard"""u8 + // [676..683] - """liger"""u8 + // [683..688] - """lightningbug"""u8 + // [688..700] - """lion"""u8 + // [700..704] - """lionfish"""u8 + // [704..712] - """lizard"""u8 + // [712..718] - """llama"""u8 + // [718..723] - """lobster"""u8 + // [723..730] - """lynx"""u8 + // [730..734] - """macaw"""u8 + // [734..739] - """magpie"""u8 + // [739..745] - """maltese"""u8 + // [745..752] - """manatee"""u8 + // [752..759] - """mandrill"""u8 + // [759..767] - """manta"""u8 + // [767..772] - """markhor"""u8 + // [772..779] - """marmot"""u8 + // [779..785] - """marsupial"""u8 + // [785..794] - """mastiff"""u8 + // [794..801] - """meerkat"""u8 + // [801..808] - """mink"""u8 + // [808..812] - """mite"""u8 + // [812..816] - """mole"""u8 + // [816..820] - """molly"""u8 + // [820..825] - """mongoose"""u8 + // [825..833] - """monkey"""u8 + // [833..839] - """moose"""u8 + // [839..844] - """moth"""u8 + // [844..848] - """mouse"""u8 + // [848..853] - """mule"""u8 + // [853..857] - """narwhal"""u8 + // [857..864] - """newt"""u8 + // [864..868] - """nightingale"""u8 + // [868..879] - """numbat"""u8 + // [879..885] - """ocelot"""u8 + // [885..891] - """octopus"""u8 + // [891..898] - """olm"""u8 + // [898..901] - """opossum"""u8 + // [901..908] - """orangutan"""u8 + // [908..917] - """ostrich"""u8 + // [917..924] - """otter"""u8 + // [924..929] - """owl"""u8 + // [929..932] - """oyster"""u8 + // [932..938] - """panda"""u8 + // [938..943] - """panther"""u8 + // [943..950] - """parrot"""u8 + // [950..956] - """peacock"""u8 + // [956..963] - """peahen"""u8 + // [963..969] - """penguin"""u8 + // [969..976] - """pig"""u8 + // [976..979] - """pika"""u8 + // [979..983] - """pike"""u8 + // [983..987] - """platypus"""u8 + // [987..995] - """poodle"""u8 + // [995..1001] - """porcupine"""u8 + // [1001..1010] - """possum"""u8 + // [1010..1016] - """prawn"""u8 + // [1016..1021] - """pronghorn"""u8 + // [1021..1030] - """puffin"""u8 + // [1030..1036] - """pug"""u8 + // [1036..1039] - """puma"""u8 + // [1039..1043] - """quail"""u8 + // [1043..1048] - """quetzal"""u8 + // [1048..1055] - """quokka"""u8 + // [1055..1061] - """quoll"""u8 + // [1061..1066] - """rabbit"""u8 + // [1066..1072] - """raccoon"""u8 + // [1072..1079] - """ragdoll"""u8 + // [1079..1086] - """rat"""u8 + // [1086..1089] - """rattlesnake"""u8 + // [1089..1100] - """robin"""u8 + // [1100..1105] - """rodent"""u8 + // [1105..1111] - """rottweiler"""u8 + // [1111..1121] - """sabertooth"""u8 + // [1121..1131] - """salamander"""u8 + // [1131..1141] - """saola"""u8 + // [1141..1146] - """sasquatch"""u8 + // [1146..1155] - """scorpion"""u8 + // [1155..1163] - """seagull"""u8 + // [1163..1170] - """seahorse"""u8 + // [1170..1178] - """seal"""u8 + // [1178..1182] - """seastar"""u8 + // [1182..1189] - """serval"""u8 + // [1189..1195] - """shark"""u8 + // [1195..1200] - """sheep"""u8 + // [1200..1205] - """shrimp"""u8 + // [1205..1211] - """skunk"""u8 + // [1211..1216] - """sloth"""u8 + // [1216..1221] - """snail"""u8 + // [1221..1226] - """snake"""u8 + // [1226..1231] - """spaniel"""u8 + // [1231..1238] - """sparrow"""u8 + // [1238..1245] - """sponge"""u8 + // [1245..1251] - """squid"""u8 + // [1251..1256] - """squirrel"""u8 + // [1256..1264] - """starfish"""u8 + // [1264..1272] - """stingray"""u8 + // [1272..1280] - """stoat"""u8 + // [1280..1285] - """swan"""u8 + // [1285..1289] - """tapir"""u8 + // [1289..1294] - """tarsier"""u8 + // [1294..1301] - """termite"""u8 + // [1301..1308] - """terrier"""u8 + // [1308..1315] - """tiger"""u8 + // [1315..1320] - """toad"""u8 + // [1320..1324] - """tortoise"""u8 + // [1324..1332] - """toucan"""u8 + // [1332..1338] - """tuatara"""u8 + // [1338..1345] - """turkey"""u8 + // [1345..1351] - """turtle"""u8 + // [1351..1357] - """uakari"""u8 + // [1357..1363] - """umbrellabird"""u8 + // [1363..1375] - """unicorn"""u8 + // [1375..1382] - """vulture"""u8 + // [1382..1389] - """wallaby"""u8 + // [1389..1396] - """walrus"""u8 + // [1396..1402] - """warthog"""u8 + // [1402..1409] - """wasp"""u8 + // [1409..1413] - """waterbuffalo"""u8 + // [1413..1425] - """whale"""u8 + // [1425..1430] - """whippet"""u8 + // [1430..1437] - """wildebeest"""u8 + // [1437..1447] - """wolf"""u8 + // [1447..1451] - """wolverine"""u8 + // [1451..1460] - """wombat"""u8 + // [1460..1466] - """woodpecker"""u8 + // [1466..1476] - """worm"""u8 + // [1476..1480] - """yak"""u8 + // [1480..1483] - """zebra"""u8 + // [1483..1488] - """zebu"""u8 + // [1488..1492] - """zorse"""u8 + // [1492..1497] - ""u8; - - const int size = 1497; - - public const int Count = 242; - - static ReadOnlySpan Offsets => - [ - 0, 8, 16, 23, 32, 41, 47, 55, 64, 67, 75, 83, 91, 100, 106, - 109, 113, 116, 122, 131, 135, 140, 149, 155, 160, 166, 173, 180, 189, 194, - 203, 208, 216, 219, 226, 233, 240, 245, 255, 263, 267, 276, 282, 287, 290, - 294, 301, 310, 319, 323, 328, 331, 338, 344, 350, 359, 363, 368, 375, 378, - 386, 389, 392, 398, 402, 406, 409, 412, 416, 423, 428, 434, 440, 447, 451, - 455, 460, 466, 473, 484, 493, 500, 505, 512, 516, 524, 529, 532, 537, 542, - 553, 558, 563, 567, 571, 577, 582, 588, 594, 603, 607, 615, 621, 625, 630, - 634, 645, 653, 660, 664, 671, 676, 683, 688, 700, 704, 712, 718, 723, 730, - 734, 739, 745, 752, 759, 767, 772, 779, 785, 794, 801, 808, 812, 816, 820, - 825, 833, 839, 844, 848, 853, 857, 864, 868, 879, 885, 891, 898, 901, 908, - 917, 924, 929, 932, 938, 943, 950, 956, 963, 969, 976, 979, 983, 987, 995, - 1001, 1010, 1016, 1021, 1030, 1036, 1039, 1043, 1048, 1055, 1061, 1066, 1072, 1079, 1086, - 1089, 1100, 1105, 1111, 1121, 1131, 1141, 1146, 1155, 1163, 1170, 1178, 1182, 1189, 1195, - 1200, 1205, 1211, 1216, 1221, 1226, 1231, 1238, 1245, 1251, 1256, 1264, 1272, 1280, 1285, - 1289, 1294, 1301, 1308, 1315, 1320, 1324, 1332, 1338, 1345, 1351, 1357, 1363, 1375, 1382, - 1389, 1396, 1402, 1409, 1413, 1425, 1430, 1437, 1447, 1451, 1460, 1466, 1476, 1480, 1483, - 1488, 1492, 1497, - ]; - - static ReadOnlySpan CharCounts => - [ - 8, 8, 7, 9, 9, 6, 8, 9, 3, 8, 8, 8, 9, 6, 3, 4, 3, 6, 9, 4, - 5, 9, 6, 5, 6, 7, 7, 9, 5, 9, 5, 8, 3, 7, 7, 7, 5, 10, 8, 4, - 9, 6, 5, 3, 4, 7, 9, 9, 4, 5, 3, 7, 6, 6, 9, 4, 5, 7, 3, 8, - 3, 3, 6, 4, 4, 3, 3, 4, 7, 5, 6, 6, 7, 4, 4, 5, 6, 7, 11, 9, - 7, 5, 7, 4, 8, 5, 3, 5, 5, 11, 5, 5, 4, 4, 6, 5, 6, 6, 9, 4, - 8, 6, 4, 5, 4, 11, 8, 7, 4, 7, 5, 7, 5, 12, 4, 8, 6, 5, 7, 4, - 5, 6, 7, 7, 8, 5, 7, 6, 9, 7, 7, 4, 4, 4, 5, 8, 6, 5, 4, 5, - 4, 7, 4, 11, 6, 6, 7, 3, 7, 9, 7, 5, 3, 6, 5, 7, 6, 7, 6, 7, - 3, 4, 4, 8, 6, 9, 6, 5, 9, 6, 3, 4, 5, 7, 6, 5, 6, 7, 7, 3, - 11, 5, 6, 10, 10, 10, 5, 9, 8, 7, 8, 4, 7, 6, 5, 5, 6, 5, 5, 5, - 5, 7, 7, 6, 5, 8, 8, 8, 5, 4, 5, 7, 7, 7, 5, 4, 8, 6, 7, 6, - 6, 6, 12, 7, 7, 7, 6, 7, 4, 12, 5, 7, 10, 4, 9, 6, 10, 4, 3, 5, - 4, 5, - ]; -} - -partial class MonikerDescriptors // MonikerDescriptors.txt -{ - public static Utf8Strings Strings => new(Count, Data, Offsets, CharCounts); - - static ReadOnlySpan Data => - """affable"""u8 + // [0..7] - """aged"""u8 + // [7..11] - """agile"""u8 + // [11..16] - """alert"""u8 + // [16..21] - """alliterating"""u8 + // [21..33] - """altered"""u8 + // [33..40] - """alternating"""u8 + // [40..51] - """amber"""u8 + // [51..56] - """angry"""u8 + // [56..61] - """anxious"""u8 + // [61..68] - """ardent"""u8 + // [68..74] - """aspiring"""u8 + // [74..82] - """austere"""u8 + // [82..89] - """auxiliary"""u8 + // [89..98] - """awesome"""u8 + // [98..105] - """bailing"""u8 + // [105..112] - """bald"""u8 + // [112..116] - """banking"""u8 + // [116..123] - """belligerent"""u8 + // [123..134] - """billowing"""u8 + // [134..143] - """binging"""u8 + // [143..150] - """boiling"""u8 + // [150..157] - """boisterous"""u8 + // [157..167] - """bold"""u8 + // [167..171] - """braided"""u8 + // [171..178] - """brawny"""u8 + // [178..184] - """brazen"""u8 + // [184..190] - """broken"""u8 + // [190..196] - """brown"""u8 + // [196..201] - """bulging"""u8 + // [201..208] - """bumptious"""u8 + // [208..217] - """bunking"""u8 + // [217..224] - """busted"""u8 + // [224..230] - """calico"""u8 + // [230..236] - """calling"""u8 + // [236..243] - """callous"""u8 + // [243..250] - """cantankerous"""u8 + // [250..262] - """cautious"""u8 + // [262..270] - """cloying"""u8 + // [270..277] - """clunky"""u8 + // [277..283] - """coiled"""u8 + // [283..289] - """coiling"""u8 + // [289..296] - """cold"""u8 + // [296..300] - """contrasting"""u8 + // [300..311] - """coy"""u8 + // [311..314] - """crabby"""u8 + // [314..320] - """cranky"""u8 + // [320..326] - """crazy"""u8 + // [326..331] - """crusty"""u8 + // [331..337] - """dandy"""u8 + // [337..342] - """dangling"""u8 + // [342..350] - """dapper"""u8 + // [350..356] - """deadly"""u8 + // [356..362] - """dealing"""u8 + // [362..369] - """dining"""u8 + // [369..375] - """dinky"""u8 + // [375..380] - """doltish"""u8 + // [380..387] - """donating"""u8 + // [387..395] - """dozing"""u8 + // [395..401] - """dull"""u8 + // [401..405] - """dunking"""u8 + // [405..412] - """dusty"""u8 + // [412..417] - """eager"""u8 + // [417..422] - """early"""u8 + // [422..427] - """eating"""u8 + // [427..433] - """edgy"""u8 + // [433..437] - """eerie"""u8 + // [437..442] - """elder"""u8 + // [442..447] - """elegant"""u8 + // [447..454] - """elevated"""u8 + // [454..462] - """eloping"""u8 + // [462..469] - """enervated"""u8 + // [469..478] - """eponymous"""u8 + // [478..487] - """errant"""u8 + // [487..493] - """erstwhile"""u8 + // [493..502] - """esteemed"""u8 + // [502..510] - """estranged"""u8 + // [510..519] - """exacerbated"""u8 + // [519..530] - """exasperated"""u8 + // [530..541] - """excited"""u8 + // [541..548] - """exciting"""u8 + // [548..556] - """exegetical"""u8 + // [556..566] - """exhaling"""u8 + // [566..574] - """exiled"""u8 + // [574..580] - """existing"""u8 + // [580..588] - """eyewitness"""u8 + // [588..598] - """factual"""u8 + // [598..605] - """fair"""u8 + // [605..609] - """fallacious"""u8 + // [609..619] - """falling"""u8 + // [619..626] - """famous"""u8 + // [626..632] - """fancy"""u8 + // [632..637] - """fantastic"""u8 + // [637..646] - """fashionable"""u8 + // [646..657] - """filled"""u8 + // [657..663] - """flabby"""u8 + // [663..669] - """flailing"""u8 + // [669..677] - """flippant"""u8 + // [677..685] - """foiled"""u8 + // [685..691] - """foolhardy"""u8 + // [691..700] - """foolish"""u8 + // [700..707] - """foppish"""u8 + // [707..714] - """full"""u8 + // [714..718] - """fun"""u8 + // [718..721] - """funky"""u8 + // [721..726] - """funny"""u8 + // [726..731] - """fuzzy"""u8 + // [731..736] - """gangly"""u8 + // [736..742] - """garish"""u8 + // [742..748] - """gauche"""u8 + // [748..754] - """gaudy"""u8 + // [754..759] - """geared"""u8 + // [759..765] - """giddy"""u8 + // [765..770] - """giggly"""u8 + // [770..776] - """gilded"""u8 + // [776..782] - """gone"""u8 + // [782..786] - """good"""u8 + // [786..790] - """goodly"""u8 + // [790..796] - """guiding"""u8 + // [796..803] - """halting"""u8 + // [803..810] - """handy"""u8 + // [810..815] - """happy"""u8 + // [815..820] - """hardy"""u8 + // [820..825] - """harping"""u8 + // [825..832] - """hasty"""u8 + // [832..837] - """hazy"""u8 + // [837..841] - """hipster"""u8 + // [841..848] - """hissing"""u8 + // [848..855] - """historical"""u8 + // [855..865] - """honest"""u8 + // [865..871] - """honking"""u8 + // [871..878] - """honorary"""u8 + // [878..886] - """hoping"""u8 + // [886..892] - """hopping"""u8 + // [892..899] - """iced"""u8 + // [899..903] - """icy"""u8 + // [903..906] - """ideal"""u8 + // [906..911] - """idle"""u8 + // [911..915] - """idolized"""u8 + // [915..923] - """ignoble"""u8 + // [923..930] - """ignorant"""u8 + // [930..938] - """ill"""u8 + // [938..941] - """illmannered"""u8 + // [941..952] - """illocutionary"""u8 + // [952..965] - """imprecise"""u8 + // [965..974] - """impressive"""u8 + // [974..984] - """incendiary"""u8 + // [984..994] - """inclined"""u8 + // [994..1002] - """independent"""u8 + // [1002..1013] - """inky"""u8 + // [1013..1017] - """innocent"""u8 + // [1017..1025] - """insipid"""u8 + // [1025..1032] - """intended"""u8 + // [1032..1040] - """intent"""u8 + // [1040..1046] - """intentional"""u8 + // [1046..1057] - """interested"""u8 + // [1057..1067] - """interesting"""u8 + // [1067..1078] - """invincible"""u8 + // [1078..1088] - """invisible"""u8 + // [1088..1097] - """invited"""u8 + // [1097..1104] - """iron"""u8 + // [1104..1108] - """ironic"""u8 + // [1108..1114] - """irreverent"""u8 + // [1114..1124] - """jaundiced"""u8 + // [1124..1133] - """jaunty"""u8 + // [1133..1139] - """jazzed"""u8 + // [1139..1145] - """jazzy"""u8 + // [1145..1150] - """jittery"""u8 + // [1150..1157] - """joking"""u8 + // [1157..1163] - """jolly"""u8 + // [1163..1168] - """joyous"""u8 + // [1168..1174] - """juiced"""u8 + // [1174..1180] - """jumpy"""u8 + // [1180..1185] - """khaki"""u8 + // [1185..1190] - """killer"""u8 + // [1190..1196] - """killjoy"""u8 + // [1196..1203] - """kilted"""u8 + // [1203..1209] - """kind"""u8 + // [1209..1213] - """kindled"""u8 + // [1213..1220] - """kindly"""u8 + // [1220..1226] - """kindred"""u8 + // [1226..1233] - """kissable"""u8 + // [1233..1241] - """kissed"""u8 + // [1241..1247] - """kissing"""u8 + // [1247..1254] - """kneeling"""u8 + // [1254..1262] - """knobby"""u8 + // [1262..1268] - """knotted"""u8 + // [1268..1275] - """lame"""u8 + // [1275..1279] - """lanky"""u8 + // [1279..1284] - """laughing"""u8 + // [1284..1292] - """lazy"""u8 + // [1292..1296] - """left"""u8 + // [1296..1300] - """limping"""u8 + // [1300..1307] - """linting"""u8 + // [1307..1314] - """listening"""u8 + // [1314..1323] - """listless"""u8 + // [1323..1331] - """littering"""u8 + // [1331..1340] - """loitering"""u8 + // [1340..1349] - """lolling"""u8 + // [1349..1356] - """looming"""u8 + // [1356..1363] - """looping"""u8 + // [1363..1370] - """loopy"""u8 + // [1370..1375] - """loping"""u8 + // [1375..1381] - """lopsided"""u8 + // [1381..1389] - """lovely"""u8 + // [1389..1395] - """lucky"""u8 + // [1395..1400] - """lumbering"""u8 + // [1400..1409] - """luminous"""u8 + // [1409..1417] - """lumpy"""u8 + // [1417..1422] - """lunging"""u8 + // [1422..1429] - """manageable"""u8 + // [1429..1439] - """mangy"""u8 + // [1439..1444] - """masked"""u8 + // [1444..1450] - """maudlin"""u8 + // [1450..1457] - """mean"""u8 + // [1457..1461] - """measly"""u8 + // [1461..1467] - """melting"""u8 + // [1467..1474] - """messy"""u8 + // [1474..1479] - """mewing"""u8 + // [1479..1485] - """misty"""u8 + // [1485..1490] - """modest"""u8 + // [1490..1496] - """moldy"""u8 + // [1496..1501] - """mollified"""u8 + // [1501..1510] - """morbid"""u8 + // [1510..1516] - """mortal"""u8 + // [1516..1522] - """mothy"""u8 + // [1522..1527] - """mottled"""u8 + // [1527..1534] - """mouthy"""u8 + // [1534..1540] - """muddled"""u8 + // [1540..1547] - """musty"""u8 + // [1547..1552] - """named"""u8 + // [1552..1557] - """nasal"""u8 + // [1557..1562] - """needled"""u8 + // [1562..1569] - """newbie"""u8 + // [1569..1575] - """nihilist"""u8 + // [1575..1583] - """nobby"""u8 + // [1583..1588] - """nomadic"""u8 + // [1588..1595] - """nonexistent"""u8 + // [1595..1606] - """nonplussed"""u8 + // [1606..1616] - """nordic"""u8 + // [1616..1622] - """nosy"""u8 + // [1622..1626] - """nuanced"""u8 + // [1626..1633] - """odd"""u8 + // [1633..1636] - """oily"""u8 + // [1636..1640] - """old"""u8 + // [1640..1643] - """oldfashioned"""u8 + // [1643..1655] - """olfactory"""u8 + // [1655..1664] - """open"""u8 + // [1664..1668] - """operatic"""u8 + // [1668..1676] - """opining"""u8 + // [1676..1683] - """opinionated"""u8 + // [1683..1694] - """opulent"""u8 + // [1694..1701] - """orange"""u8 + // [1701..1707] - """orbiting"""u8 + // [1707..1715] - """ordered"""u8 + // [1715..1722] - """orderly"""u8 + // [1722..1729] - """original"""u8 + // [1729..1737] - """ornery"""u8 + // [1737..1743] - """peddling"""u8 + // [1743..1751] - """peeking"""u8 + // [1751..1758] - """pilfering"""u8 + // [1758..1767] - """pining"""u8 + // [1767..1773] - """pioneering"""u8 + // [1773..1783] - """piquant"""u8 + // [1783..1790] - """plinking"""u8 + // [1790..1798] - """plucking"""u8 + // [1798..1806] - """plundering"""u8 + // [1806..1816] - """pondering"""u8 + // [1816..1825] - """ponderous"""u8 + // [1825..1834] - """pouring"""u8 + // [1834..1841] - """precise"""u8 + // [1841..1848] - """prodding"""u8 + // [1848..1856] - """pruning"""u8 + // [1856..1863] - """pugnacious"""u8 + // [1863..1873] - """punk"""u8 + // [1873..1877] - """quaffing"""u8 + // [1877..1885] - """quarreling"""u8 + // [1885..1895] - """quarrelsome"""u8 + // [1895..1906] - """queenly"""u8 + // [1906..1913] - """quelling"""u8 + // [1913..1921] - """quiet"""u8 + // [1921..1926] - """quieting"""u8 + // [1926..1934] - """quoting"""u8 + // [1934..1941] - """rafting"""u8 + // [1941..1948] - """ranting"""u8 + // [1948..1955] - """reeling"""u8 + // [1955..1962] - """right"""u8 + // [1962..1967] - """righteous"""u8 + // [1967..1976] - """ringed"""u8 + // [1976..1982] - """riotous"""u8 + // [1982..1989] - """roiling"""u8 + // [1989..1996] - """rolling"""u8 + // [1996..2003] - """romping"""u8 + // [2003..2010] - """rousing"""u8 + // [2010..2017] - """rude"""u8 + // [2017..2021] - """running"""u8 + // [2021..2028] - """sad"""u8 + // [2028..2031] - """sanguine"""u8 + // [2031..2039] - """sappy"""u8 + // [2039..2044] - """sartorial"""u8 + // [2044..2053] - """saucy"""u8 + // [2053..2058] - """silly"""u8 + // [2058..2063] - """singed"""u8 + // [2063..2069] - """singing"""u8 + // [2069..2076] - """smelly"""u8 + // [2076..2082] - """snug"""u8 + // [2082..2086] - """soft"""u8 + // [2086..2090] - """solemn"""u8 + // [2090..2096] - """solid"""u8 + // [2096..2101] - """solitary"""u8 + // [2101..2109] - """steely"""u8 + // [2109..2115] - """stultified"""u8 + // [2115..2125] - """sullen"""u8 + // [2125..2131] - """sweet"""u8 + // [2131..2136] - """tailored"""u8 + // [2136..2144] - """tan"""u8 + // [2144..2147] - """telling"""u8 + // [2147..2154] - """terrific"""u8 + // [2154..2162] - """terrifying"""u8 + // [2162..2172] - """tinseled"""u8 + // [2172..2180] - """toned"""u8 + // [2180..2185] - """torpid"""u8 + // [2185..2191] - """torrid"""u8 + // [2191..2197] - """trendsetting"""u8 + // [2197..2209] - """trendy"""u8 + // [2209..2215] - """triangular"""u8 + // [2215..2225] - """truculent"""u8 + // [2225..2234] - """tufted"""u8 + // [2234..2240] - """turbulent"""u8 + // [2240..2249] - """ugly"""u8 + // [2249..2253] - """ulterior"""u8 + // [2253..2261] - """undercooked"""u8 + // [2261..2272] - """understood"""u8 + // [2272..2282] - """ungaged"""u8 + // [2282..2289] - """unhinged"""u8 + // [2289..2297] - """unrealistic"""u8 + // [2297..2308] - """unrealized"""u8 + // [2308..2318] - """unsung"""u8 + // [2318..2324] - """veering"""u8 + // [2324..2331] - """vehement"""u8 + // [2331..2339] - """vested"""u8 + // [2339..2345] - """vetoed"""u8 + // [2345..2351] - """viable"""u8 + // [2351..2357] - """vigilant"""u8 + // [2357..2365] - """virtuous"""u8 + // [2365..2373] - """virulent"""u8 + // [2373..2381] - """vocal"""u8 + // [2381..2386] - """vociferous"""u8 + // [2386..2396] - """volted"""u8 + // [2396..2402] - """voting"""u8 + // [2402..2408] - """wandering"""u8 + // [2408..2417] - """wanton"""u8 + // [2417..2423] - """warped"""u8 + // [2423..2429] - """washed"""u8 + // [2429..2435] - """washing"""u8 + // [2435..2442] - """waxen"""u8 + // [2442..2447] - """wayfaring"""u8 + // [2447..2456] - """whimsical"""u8 + // [2456..2465] - """whopping"""u8 + // [2465..2473] - """wiggly"""u8 + // [2473..2479] - """willing"""u8 + // [2479..2486] - """winning"""u8 + // [2486..2493] - """winsome"""u8 + // [2493..2500] - """wintering"""u8 + // [2500..2509] - """wise"""u8 + // [2509..2513] - """wishful"""u8 + // [2513..2520] - """wishing"""u8 + // [2520..2527] - """wistful"""u8 + // [2527..2534] - """wizened"""u8 + // [2534..2541] - """wobbling"""u8 + // [2541..2549] - """wobbly"""u8 + // [2549..2555] - """womping"""u8 + // [2555..2562] - """wonderful"""u8 + // [2562..2571] - """wondering"""u8 + // [2571..2580] - """worn"""u8 + // [2580..2584] - """wrapping"""u8 + // [2584..2592] - """wrinkled"""u8 + // [2592..2600] - """xrayed"""u8 + // [2600..2606] - """yellow"""u8 + // [2606..2612] - """yodeling"""u8 + // [2612..2620] - """youngling"""u8 + // [2620..2629] - """your"""u8 + // [2629..2633] - """youthful"""u8 + // [2633..2641] - """yucky"""u8 + // [2641..2646] - """yummy"""u8 + // [2646..2651] - """zealous"""u8 + // [2651..2658] - """zeroed"""u8 + // [2658..2664] - """zinc"""u8 + // [2664..2668] - """zooming"""u8 + // [2668..2675] - ""u8; - - const int size = 2675; - - public const int Count = 389; - - static ReadOnlySpan Offsets => - [ - 0, 7, 11, 16, 21, 33, 40, 51, 56, 61, 68, 74, 82, 89, 98, - 105, 112, 116, 123, 134, 143, 150, 157, 167, 171, 178, 184, 190, 196, 201, - 208, 217, 224, 230, 236, 243, 250, 262, 270, 277, 283, 289, 296, 300, 311, - 314, 320, 326, 331, 337, 342, 350, 356, 362, 369, 375, 380, 387, 395, 401, - 405, 412, 417, 422, 427, 433, 437, 442, 447, 454, 462, 469, 478, 487, 493, - 502, 510, 519, 530, 541, 548, 556, 566, 574, 580, 588, 598, 605, 609, 619, - 626, 632, 637, 646, 657, 663, 669, 677, 685, 691, 700, 707, 714, 718, 721, - 726, 731, 736, 742, 748, 754, 759, 765, 770, 776, 782, 786, 790, 796, 803, - 810, 815, 820, 825, 832, 837, 841, 848, 855, 865, 871, 878, 886, 892, 899, - 903, 906, 911, 915, 923, 930, 938, 941, 952, 965, 974, 984, 994, 1002, 1013, - 1017, 1025, 1032, 1040, 1046, 1057, 1067, 1078, 1088, 1097, 1104, 1108, 1114, 1124, 1133, - 1139, 1145, 1150, 1157, 1163, 1168, 1174, 1180, 1185, 1190, 1196, 1203, 1209, 1213, 1220, - 1226, 1233, 1241, 1247, 1254, 1262, 1268, 1275, 1279, 1284, 1292, 1296, 1300, 1307, 1314, - 1323, 1331, 1340, 1349, 1356, 1363, 1370, 1375, 1381, 1389, 1395, 1400, 1409, 1417, 1422, - 1429, 1439, 1444, 1450, 1457, 1461, 1467, 1474, 1479, 1485, 1490, 1496, 1501, 1510, 1516, - 1522, 1527, 1534, 1540, 1547, 1552, 1557, 1562, 1569, 1575, 1583, 1588, 1595, 1606, 1616, - 1622, 1626, 1633, 1636, 1640, 1643, 1655, 1664, 1668, 1676, 1683, 1694, 1701, 1707, 1715, - 1722, 1729, 1737, 1743, 1751, 1758, 1767, 1773, 1783, 1790, 1798, 1806, 1816, 1825, 1834, - 1841, 1848, 1856, 1863, 1873, 1877, 1885, 1895, 1906, 1913, 1921, 1926, 1934, 1941, 1948, - 1955, 1962, 1967, 1976, 1982, 1989, 1996, 2003, 2010, 2017, 2021, 2028, 2031, 2039, 2044, - 2053, 2058, 2063, 2069, 2076, 2082, 2086, 2090, 2096, 2101, 2109, 2115, 2125, 2131, 2136, - 2144, 2147, 2154, 2162, 2172, 2180, 2185, 2191, 2197, 2209, 2215, 2225, 2234, 2240, 2249, - 2253, 2261, 2272, 2282, 2289, 2297, 2308, 2318, 2324, 2331, 2339, 2345, 2351, 2357, 2365, - 2373, 2381, 2386, 2396, 2402, 2408, 2417, 2423, 2429, 2435, 2442, 2447, 2456, 2465, 2473, - 2479, 2486, 2493, 2500, 2509, 2513, 2520, 2527, 2534, 2541, 2549, 2555, 2562, 2571, 2580, - 2584, 2592, 2600, 2606, 2612, 2620, 2629, 2633, 2641, 2646, 2651, 2658, 2664, 2668, 2675, - ]; - - static ReadOnlySpan CharCounts => - [ - 7, 4, 5, 5, 12, 7, 11, 5, 5, 7, 6, 8, 7, 9, 7, 7, 4, 7, 11, 9, - 7, 7, 10, 4, 7, 6, 6, 6, 5, 7, 9, 7, 6, 6, 7, 7, 12, 8, 7, 6, - 6, 7, 4, 11, 3, 6, 6, 5, 6, 5, 8, 6, 6, 7, 6, 5, 7, 8, 6, 4, - 7, 5, 5, 5, 6, 4, 5, 5, 7, 8, 7, 9, 9, 6, 9, 8, 9, 11, 11, 7, - 8, 10, 8, 6, 8, 10, 7, 4, 10, 7, 6, 5, 9, 11, 6, 6, 8, 8, 6, 9, - 7, 7, 4, 3, 5, 5, 5, 6, 6, 6, 5, 6, 5, 6, 6, 4, 4, 6, 7, 7, - 5, 5, 5, 7, 5, 4, 7, 7, 10, 6, 7, 8, 6, 7, 4, 3, 5, 4, 8, 7, - 8, 3, 11, 13, 9, 10, 10, 8, 11, 4, 8, 7, 8, 6, 11, 10, 11, 10, 9, 7, - 4, 6, 10, 9, 6, 6, 5, 7, 6, 5, 6, 6, 5, 5, 6, 7, 6, 4, 7, 6, - 7, 8, 6, 7, 8, 6, 7, 4, 5, 8, 4, 4, 7, 7, 9, 8, 9, 9, 7, 7, - 7, 5, 6, 8, 6, 5, 9, 8, 5, 7, 10, 5, 6, 7, 4, 6, 7, 5, 6, 5, - 6, 5, 9, 6, 6, 5, 7, 6, 7, 5, 5, 5, 7, 6, 8, 5, 7, 11, 10, 6, - 4, 7, 3, 4, 3, 12, 9, 4, 8, 7, 11, 7, 6, 8, 7, 7, 8, 6, 8, 7, - 9, 6, 10, 7, 8, 8, 10, 9, 9, 7, 7, 8, 7, 10, 4, 8, 10, 11, 7, 8, - 5, 8, 7, 7, 7, 7, 5, 9, 6, 7, 7, 7, 7, 7, 4, 7, 3, 8, 5, 9, - 5, 5, 6, 7, 6, 4, 4, 6, 5, 8, 6, 10, 6, 5, 8, 3, 7, 8, 10, 8, - 5, 6, 6, 12, 6, 10, 9, 6, 9, 4, 8, 11, 10, 7, 8, 11, 10, 6, 7, 8, - 6, 6, 6, 8, 8, 8, 5, 10, 6, 6, 9, 6, 6, 6, 7, 5, 9, 9, 8, 6, - 7, 7, 7, 9, 4, 7, 7, 7, 7, 8, 6, 7, 9, 9, 4, 8, 8, 6, 6, 8, - 9, 4, 8, 5, 5, 7, 6, 4, 7, - ]; -} diff --git a/src/Moniker/Moniker.g.tt b/src/Moniker/Moniker.g.tt deleted file mode 100644 index 805fd74..0000000 --- a/src/Moniker/Moniker.g.tt +++ /dev/null @@ -1,98 +0,0 @@ -<#@ template debug="false" hostspecific="true" language="C#" #> -<#@ output extension=".cs" encoding="utf-8" #> -<#@ assembly name="System.Core" #> -<#@ import namespace="System.Collections.Generic" #> -<#@ import namespace="System.Globalization" #> -<#@ import namespace="System.IO" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.Text.RegularExpressions" #> -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is re-generated. -// -//------------------------------------------------------------------------------ - -#nullable enable - -namespace <#= Regex.Replace(Path.GetFileNameWithoutExtension(Host.TemplateFile), @"\.g(enerated)?$", string.Empty) #>; - -using System; -<# - var thisDir = new DirectoryInfo(Host.ResolvePath(".")); - foreach (var file in thisDir.EnumerateFiles("*.txt")) - { - var className = Path.GetFileNameWithoutExtension(file.Name); - using var reader = file.OpenText(); -#> - -partial class <#= className #> // <#= file.Name #> -{ - public static Utf8Strings Strings => new(Count, Data, Offsets, CharCounts); - - static ReadOnlySpan Data => -<# - var offset = 0; - var offsets = new List(); - var charCounts = new List(); - - while (reader.ReadLine() is { } line) - { - line = line.Trim(); - if (line.Length == 0 || line[0] == '#') - continue; - - var byteLength = Encoding.UTF8.GetByteCount(line); - - if (line.Length > 0) - { -#> - """<#= line #>"""u8 + // [<#= offset #>..<#= offset + byteLength #>] -<# - } - - offsets.Add(offset); - charCounts.Add(line.Length); - offset += byteLength; - } - - offsets.Add(offset); -#> - ""u8; - - const int size = <#= offsets[offsets.Count - 1] #>; - - public const int Count = <#= offsets.Count - 1 #>; - - static ReadOnlySpan Offsets => - [ -<# - foreach (var group in from e in offsets.Select((v, i) => (Index: i, Value: v)) - group e.Value.ToString(CultureInfo.InvariantCulture) by e.Index / 15) - { -#> - <#= string.Join(", ", group) #>, -<# - } -#> - ]; - - static ReadOnlySpan CharCounts => - [ -<# - foreach (var group in from e in charCounts.Select((v, i) => (Index: i, Value: v)) - group e.Value.ToString(CultureInfo.InvariantCulture) by e.Index / 20) - { -#> - <#= string.Join(", ", group) #>, -<# - } -#> - ]; -} -<# - } -#> diff --git a/src/Moniker/NameGenerator.cs b/src/Moniker/NameGenerator.cs index 84f352a..0f4e986 100644 --- a/src/Moniker/NameGenerator.cs +++ b/src/Moniker/NameGenerator.cs @@ -43,9 +43,7 @@ public static string GenerateMoniker(string delimiter = DefaultDelimiter) /// An optional delimiter to use between adjective and noun. /// The generated random name. public static string GenerateMoby(string delimiter = DefaultDelimiter) - { - return BuildNamePair(MobyAdjectives.Strings, MobySurnames.Strings, delimiter); - } + => BuildNamePair(MobyAdjectives.Strings, MobySurnames.Strings, delimiter); private static string BuildNamePair( Utf8Strings adjectives, @@ -77,7 +75,7 @@ private static void BuildNamePair( adjective = GetRandomEntry(adjectives); noun = GetRandomEntry(nouns); } - while (adjective == "boring"u8 && noun == "wozniak"u8);// Steve Wozniak is not boring + while (adjective == "boring"u8 && noun == "wozniak"u8); // Steve Wozniak is not boring } private static Utf8String GetRandomEntry(Utf8Strings entries) diff --git a/src/Moniker/Utf8Strings.cs b/src/Moniker/Utf8Strings.cs index 60382a4..4ef2256 100644 --- a/src/Moniker/Utf8Strings.cs +++ b/src/Moniker/Utf8Strings.cs @@ -6,22 +6,22 @@ namespace Moniker; -readonly ref struct Utf8String(ReadOnlySpan bytes, int charCount) +internal readonly ref struct Utf8String(ReadOnlySpan bytes, int charCount) { public readonly ReadOnlySpan Bytes = bytes; public readonly int CharCount = charCount; - public int GetChars(Span chars) => Encoding.UTF8.GetChars(this.Bytes, chars); + public int GetChars(Span chars) => Encoding.UTF8.GetChars(Bytes, chars); - public override string ToString() => Encoding.UTF8.GetString(this.Bytes); + public override string ToString() => Encoding.UTF8.GetString(Bytes); // Equality members - public bool Equals(ReadOnlySpan other) => this.Bytes.SequenceEqual(other); - public static bool operator ==(Utf8String left, ReadOnlySpan right) => left.Equals(right); public static bool operator !=(Utf8String left, ReadOnlySpan right) => !left.Equals(right); + private bool Equals(ReadOnlySpan other) => Bytes.SequenceEqual(other); + // Unsupported equality members because this type cannot be boxed public override int GetHashCode() => throw new NotSupportedException(); @@ -32,11 +32,12 @@ readonly ref struct Utf8String(ReadOnlySpan bytes, int charCount) public static implicit operator ReadOnlySpan(Utf8String data) => data.Bytes; } -readonly ref struct Utf8Strings +internal readonly ref struct Utf8Strings { - public readonly ReadOnlySpan Data; - public readonly ReadOnlySpan Offsets; - public readonly ReadOnlySpan CharCounts; + private readonly ReadOnlySpan _data; + private readonly ReadOnlySpan _offsets; + private readonly ReadOnlySpan _charCounts; + public readonly int Count; public Utf8Strings(int count, ReadOnlySpan data, ReadOnlySpan offsets, ReadOnlySpan charCounts) @@ -46,34 +47,34 @@ public Utf8Strings(int count, ReadOnlySpan data, ReadOnlySpan offsets Debug.Assert(charCounts.Length == count); Count = count; - Data = data; - Offsets = offsets; - CharCounts = charCounts; + _data = data; + _offsets = offsets; + _charCounts = charCounts; } - public Utf8String this[int index] => new(this.Data[Offsets[index]..this.Offsets[index + 1]], CharCounts[index]); + public Utf8String this[int index] => new(_data[_offsets[index].._offsets[index + 1]], _charCounts[index]); - public override string ToString() => $"{{ Count = {this.Count}, Size = {this.Data.Length} }}"; + public override string ToString() => $"{{ Count = {Count}, Size = {_data.Length} }}"; public Enumerator GetEnumerator() => new(this); public ref struct Enumerator(Utf8Strings strings) { - int index = -1; - readonly Utf8Strings strings = strings; + private int _index = -1; + private readonly Utf8Strings _strings = strings; /// /// Behaviour is undefined if has never been called or returned /// . /// - public Utf8String Current => this.strings[index]; + public Utf8String Current => _strings[_index]; public bool MoveNext() { - var newIndex = this.index + 1; - if (newIndex == this.strings.Count) + var newIndex = _index + 1; + if (newIndex == _strings.Count) return false; - this.index = newIndex; + _index = newIndex; return true; } } diff --git a/test/Moniker.Tests/Moniker.Tests.csproj b/test/Moniker.Tests/Moniker.Tests.csproj index 44007aa..1787fe5 100644 --- a/test/Moniker.Tests/Moniker.Tests.csproj +++ b/test/Moniker.Tests/Moniker.Tests.csproj @@ -6,19 +6,12 @@ - - - - + - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - all diff --git a/test/Moniker.Tests/StringDataTests.cs b/test/Moniker.Tests/StringDataTests.cs index 168e93f..d366eda 100644 --- a/test/Moniker.Tests/StringDataTests.cs +++ b/test/Moniker.Tests/StringDataTests.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Text; +using FluentAssertions; using Xunit; namespace Moniker.Tests; @@ -19,37 +20,41 @@ public StringDataTests() } [Fact] - public void MobyAdjectivesData() - { - Test(ThisAssembly.Resources.MobyAdjectives.Text, MobyAdjectives.Strings, - MobyAdjectives.Count, expectedCount: 108); - } + public void MobyAdjectivesData() => + Test(GetEmbeddedResource("MobyAdjectives.txt"), + MobyAdjectives.Strings, + MobyAdjectives.Count, + expectedCount: 108); [Fact] - public void MobySurnamesData() - { - Test(ThisAssembly.Resources.MobySurnames.Text, MobySurnames.Strings, - MobySurnames.Count, expectedCount: 235); - } + public void MobySurnamesData() => + Test(GetEmbeddedResource("MobySurnames.txt"), + MobySurnames.Strings, + MobySurnames.Count, + expectedCount: 235); [Fact] public void MonikerDescriptorsData() { - Test(ThisAssembly.Resources.MonikerDescriptors.Text, MonikerDescriptors.Strings, - MonikerDescriptors.Count, expectedCount: 389); + Test(GetEmbeddedResource("MonikerDescriptors.txt"), + MonikerDescriptors.Strings, + MonikerDescriptors.Count, + expectedCount: 389); } [Fact] public void MonikerAnimalsData() { - Test(ThisAssembly.Resources.MonikerAnimals.Text, MonikerAnimals.Strings, - MonikerAnimals.Count, expectedCount: 242); + Test(GetEmbeddedResource("MonikerAnimals.txt"), + MonikerAnimals.Strings, + MonikerAnimals.Count, + expectedCount: 242); } - static void Test(string source, Utf8Strings strings, int count, int expectedCount) + private static void Test(string source, Utf8Strings strings, int count, int expectedCount) { - Assert.Equal(expectedCount, count); - Assert.Equal(expectedCount, strings.Count); + count.Should().Be(expectedCount); + strings.Count.Should().Be(expectedCount); var lines = from e in ReadLines(source) select e.Trim() @@ -82,10 +87,19 @@ into e Assert.Equal(i, strings.Count); } - static IEnumerable ReadLines(string text) + private static IEnumerable ReadLines(string text) { using var reader = new StringReader(text); while (reader.ReadLine() is { } line) yield return line; } + + private static string GetEmbeddedResource(string fileName) + { + var assembly = typeof(StringDataTests).Assembly; + var assemblyName = assembly.GetName().Name; + using var stream = assembly.GetManifestResourceStream($"{assemblyName}.{fileName}"); + using var reader = new StreamReader(stream!); + return reader.ReadToEnd(); + } }