Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The opt-in lives in `.sonarlint/sonar-local.props` (analyzer package) and `.sona
| `Semantics.Music` | Immutable musical value types (`Pitch`, `Interval`, `Scale`, `Chord`, `Key`, `Duration`, `TimeSignature`) plus an analysis aggregate layer (`Progression`, `Section`, `Arrangement`, `Form`) computing roman numerals, cadences, key inference, chromatic identification, and named forms. Targets `net8.0`–`net10.0` + `netstandard2.0`/`netstandard2.1`. |
| `Semantics.Color` | Physically-grounded color types. Canonical linear-RGB `Color` hub plus color-space satellites (`Srgb`, `Hsl`, `Hsv`, `Oklab`, `Oklch`); every type converts to and from every other, routed through the nearest shared hub (`Srgb` within the sRGB family, `Oklab` within the perceptual family, linear `Color` across families) so no conversion takes a redundant gamma round-trip. Also WCAG accessibility tooling, HSL/perceptual adjustment operations (lighten/saturate/hue/invert), and `NamedColors`. Targets `net8.0`–`net10.0` + `netstandard2.0`/`netstandard2.1`. |
| `Semantics.Quantities` | Hand-written runtime types (`PhysicalQuantity<TSelf, T>`, `IVector0`..`IVector4`, `UnitSystem`) plus generator output under `Generated/`. |
| `Semantics.SourceGenerators` | Roslyn incremental generators that emit quantity types, units, conversions, magnitudes, physical constants, and storage-type helpers from metadata. The C# syntax templates now come from `ktsu.CodeBlocker.Templates`; `CodeGen/` holds what is left that is not specific to physics — the metadata-driven generator base, metadata loading, the diagnostic catalogue — and is being extracted into a shared toolkit (#181). |
| `Semantics.SourceGenerators` | Roslyn incremental generators that emit quantity types, units, conversions, magnitudes, physical constants, and storage-type helpers from metadata. Only the physics-specific half lives here — `Models/`, `Metadata/`, `Generators/`, and the bindings in `SemanticsGenerator`/`SemanticsDiagnostics`/`Emit`. The C# syntax templates come from `ktsu.CodeBlocker.Templates`; the metadata-driven generator base, metadata loading and the diagnostic catalogue come from `ktsu.SourceGeneratorToolkit` (#181, #192). |
| `Semantics.Quantities.{Double,Float,Decimal}` | Props-only satellite packages. Each ships a `buildTransitive` props file (generated by `scripts/Generate-AliasProps.ps1`) that injects global-using aliases binding every quantity to one storage type, so consumers write `Mass` instead of `Mass<double>`. |
| `Semantics.Test` | MSTest project covering all of the above. |

Expand Down Expand Up @@ -170,7 +170,7 @@ var converted = sourceString.As<SourceType, TargetType>();

### Working with the source generator

- A generator declares the metadata files it reads via `MetadataFileNames` and derives from `SemanticsGenerator<T>` (one file) or `SemanticsMultiFileGenerator` (several). Neither needs to override `Initialize`.
- A generator declares the metadata files it reads via `MetadataFileNames` and derives from `SemanticsGenerator<T>` (one file) or `SemanticsMultiFileGenerator` (several). Neither needs to override `Initialize`. Those two bind this repository's diagnostic catalogue and file header onto `GeneratorBase`/`GeneratorBase<T>` from `ktsu.SourceGeneratorToolkit`; that binding is the seam that keeps the package consumer-agnostic, so keep repository-specific detail on this side of it.
- Emitted C# is described with the template model from `ktsu.CodeBlocker.Templates` — `SourceFileTemplate`, `ClassTemplate`, `FieldTemplate`, `MethodTemplate` and friends. The model owns punctuation, spacing, member ordering and indentation, so a `BodyFactory` writes only the body: `=> Create(value);` for an expression body, or a braced block. Do **not** prefix it with a space; the model supplies the separator.
- A type's declaration keyword comes from `ClassTemplate.Kind` (`TypeKind.Class`, `TypeKind.Record`, …), not from `Keywords`, which carries only modifiers. Collection properties are read-only, so use collection-initializer syntax (`Keywords = { "public" }`) rather than assignment, or the `WithComments`/`WithInterfaces` helpers when you already hold a sequence.
- Edit `Semantics.SourceGenerators/Metadata/dimensions.json` to add a dimension, vector form, semantic overload, or relationship.
Expand Down
2 changes: 2 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<PackageVersion Include="System.Numerics.Vectors" Version="4.6.1" />
<!-- Source generator packages -->
<PackageVersion Include="ktsu.CodeBlocker" Version="2.0.4" />
<PackageVersion Include="ktsu.SourceGeneratorToolkit" Version="1.0.0" />
<PackageVersion Include="ktsu.SourceGeneratorToolkit.Testing" Version="1.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.9.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.9.0" />
<!-- Build-time only: the generator reads its metadata with it. No shipping project
Expand Down
21 changes: 0 additions & 21 deletions Semantics.SourceGenerators/CodeGen/CSharpKeywords.cs

This file was deleted.

103 changes: 0 additions & 103 deletions Semantics.SourceGenerators/CodeGen/DiagnosticCatalog.cs

This file was deleted.

205 changes: 0 additions & 205 deletions Semantics.SourceGenerators/CodeGen/GeneratorBase.cs

This file was deleted.

Loading
Loading