Skip to content

Add C# UnitTabulator code-generator and Rust unit_converter runtime#1255

Closed
Copilot wants to merge 1 commit intojohndo/unit-conversionfrom
copilot/sub-pr-1254
Closed

Add C# UnitTabulator code-generator and Rust unit_converter runtime#1255
Copilot wants to merge 1 commit intojohndo/unit-conversionfrom
copilot/sub-pr-1254

Conversation

Copy link
Contributor

Copilot AI commented Feb 24, 2026

Adds unit conversion support across the codegen pipeline and Rust facilities crate, backed by QUDT ontology data.

C# UnitTabulator (codegen2/src/Azure.Iot.Operations.UnitTabulator)

  • CLI tool that reads QUDT RDF turtle files (qudt.unit.ttl, qudt.quantityKind.ttl) and emits two Rust source files via T4 templates:
    • ece_codes.rs — static HashMap from UNECE common codes → QUDT unit names
    • unit_infos.rs — static HashMap from QUDT unit names → UnitInfo (kind, multiplier, offset)
  • Selects the canonical QuantityKind for each unit by picking the kind with the most applicable units (breaks ties toward units usable in real conversions)

Rust unit_converter (rust/azure_iot_operations_facilities/src/unit_converter)

  • get_converter(source_unit, target_unit) -> Result<UnitConverter, ConvertError> resolves units by ECE code, unit: term, or full QUDT URI and validates kind compatibility
  • UnitConverter { multiplier, offset } applies the affine transform val * multiplier + offset
  • ConvertError variants: SourceUnitUnrecognized, TargetUnitUnrecognized, UnitsOfDifferentKinds, UnrepresentableValue
  • Re-exported from crate root; integration tests in tests/unit_converter_tests.rs
let converter = get_converter("FAH", "unit:DEG_C")?;
let celsius = converter.convert(212.0)?; // 100.0

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Add C# UnitTabulator and Rust unit_converter Add C# UnitTabulator code-generator and Rust unit_converter runtime Feb 24, 2026
Copilot AI requested a review from jrdouceur February 24, 2026 23:12
@jrdouceur jrdouceur closed this Feb 24, 2026
@jrdouceur jrdouceur deleted the copilot/sub-pr-1254 branch February 24, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants