Skip to content

PhysicalConstants are not exposed as PhysicalConstants.Generic<T>() per CLAUDE.md #53

@matt-edmondson

Description

@matt-edmondson

Summary

CLAUDE.md documents the public API as:

PhysicalConstants.Generic.SpeedOfLight<T>()
PhysicalConstants.Generic.PlanckConstant<T>()
PhysicalConstants.Conversion.FeetToMeters<T>()

The generated PhysicalConstants class does not expose any Generic or Conversion sub-class with type-parameterised accessors. It only emits non-generic PreciseNumber static readonly fields nested in domain-specific subclasses (AngularMechanics, Chemistry, …).

Evidence

Semantics.Quantities/Generated/.../PhysicalConstants.g.cs:16-50:

public static class PhysicalConstants {
    public static class AngularMechanics {
        public static readonly PreciseNumber DegreesPerRadian = PreciseNumber.Parse("...");
    }
    public static class Chemistry { ... }
    ...
}

No Generic or Conversion partition; no <T> accessors.

Impact

  • Public API surface mismatches CLAUDE.md and existing examples.
  • Generic physics quantity code that calls PhysicalConstants.Generic.PlanckConstant<T>() will not compile.
  • The PhysicalConstantsGenerator is partially wired up.

Suggested next step

Either:

  1. Extend PhysicalConstantsGenerator to also emit PhysicalConstants.Generic.{Constant}<T>() and PhysicalConstants.Conversion.{Factor}<T>() accessors that wrap the PreciseNumber values via T.CreateChecked(...), or
  2. Update CLAUDE.md and any docs/code samples to match the simpler nested-subclass shape.

Add coverage in Semantics.Test to lock in the chosen API.

Area / Severity

SourceGenerators / Quantities · incomplete

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions