$npx -y skills add DevExpress/agent-skills --skill devexpress-office-file-api-unit-conversionBuild .NET applications with the DevExpress Unit Conversion API for converting between metric and US units of measurement with type-safe fluent syntax. Use when converting distances, lengths, weights, temperatures, areas, volumes, speeds, or metric prefixes in .NET applications.
| 1 | # DevExpress Unit Conversion API |
| 2 | |
| 3 | A lightweight .NET library for converting between metric and US customary units of measurement using a type-safe fluent API. Supports distance, mass, temperature, area, volume, speed, and metric prefix conversions. The API requires no external dependencies beyond the `DevExpress.Document.Processor` NuGet package and works identically on .NET 8+ and .NET Framework 4.6.2+. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | Use this skill when you need to: |
| 8 | |
| 9 | - Convert distances or lengths (meters, feet, miles, kilometers, inches, yards, nautical miles) |
| 10 | - Convert mass/weight values (grams, kilograms, pounds, ounces, metric tons) |
| 11 | - Convert temperatures (Celsius, Fahrenheit, Kelvin) |
| 12 | - Convert area measurements (square meters, square feet, acres, hectares, square miles) |
| 13 | - Convert volumes (liters, gallons, cubic meters, cubic feet, fluid ounces, pints, quarts) |
| 14 | - Convert speeds (km/h, m/s, mph, knots, feet per second) |
| 15 | - Convert between metric prefixes (kilo, mega, milli, micro, etc.) |
| 16 | - Combine unit values with arithmetic (e.g., 5 feet + 4 inches, then convert to meters) |
| 17 | - Build type-safe unit-aware calculations without manual conversion factors |
| 18 | |
| 19 | ## Prerequisites & Installation |
| 20 | |
| 21 | ### NuGet Packages |
| 22 | |
| 23 | | Package | Purpose | |
| 24 | |---------|---------| |
| 25 | | `DevExpress.Document.Processor` | Unit Conversion API (included in the package) | |
| 26 | |
| 27 | ### .NET (8/9/10+) |
| 28 | |
| 29 | ```bash |
| 30 | dotnet add package DevExpress.Document.Processor |
| 31 | ``` |
| 32 | |
| 33 | ### .NET Framework (4.6.2+) |
| 34 | |
| 35 | ``` |
| 36 | Install-Package DevExpress.Document.Processor |
| 37 | ``` |
| 38 | |
| 39 | Or add a direct reference to `DevExpress.Docs.v26.1.dll`. |
| 40 | |
| 41 | **Important**: All DevExpress packages in a project must share the same version number. A valid DevExpress license is required. |
| 42 | |
| 43 | ### Package Versions |
| 44 | |
| 45 | Unless the user explicitly requests a specific version, always target the latest DevExpress release (v26.1 at the time of writing). `dotnet add package <PackageName>` without `--version` installs the latest stable version — prefer this form. Never pin an older version in project files, Dockerfiles, or CI/CD pipelines unless the user asks for it. This is especially important in integration scenarios (Docker, cloud deployments). All `DevExpress.*` packages in a project must share the same version. |
| 46 | |
| 47 | ## Before You Start — Ask the Developer |
| 48 | |
| 49 | If the host agent has a structured question-asking tool available, use it to ask these questions one at a time with clear options — for example, Claude Code's `AskUserQuestion` tool or GitHub Copilot's `askQuestions` tool. If no such tool is available, ask the questions directly in the chat response before generating code. |
| 50 | |
| 51 | Before generating code, ask these questions to avoid rework: |
| 52 | |
| 53 | ### General Questions |
| 54 | 1. **Target framework**: Are you using .NET 8+ or .NET Framework 4.x? |
| 55 | 2. **New or existing project?**: Creating new or adding to existing? |
| 56 | 3. **Hosting model**: Console app, ASP.NET Core, Blazor, MAUI, WinForms, or something else? |
| 57 | |
| 58 | ### Unit Conversion-Specific Questions |
| 59 | 4. **Measurement category**: Which category? (length / weight / temperature / area / volume / speed / metric prefix) |
| 60 | 5. **Conversion direction**: Metric to US, US to metric, between metric prefixes, or both directions? |
| 61 | |
| 62 | > **Rule**: If the developer's answer is ambiguous or missing, ask before generating code. Do not guess. |
| 63 | |
| 64 | ## Component Overview |
| 65 | |
| 66 | The Unit Conversion API provides two usage patterns: |
| 67 | |
| 68 | - **Fluent extension methods** on numeric types (`double`, `int`, `float`) — create a `QuantityValue<T>`, then call `To{Unit}()` to convert. `QuantityValue<T>` implicitly converts to `double`, so you can use it directly in arithmetic or string formatting. |
| 69 | - **Static converter classes** accessed via `Units.*` — call `.Convert(value, fromUnit, toUnit)` for direct scalar conversion without creating `QuantityValue<T>` objects. |
| 70 | |
| 71 | Key classes: |
| 72 | |
| 73 | - **`QuantityValue<T>`** (`struct`) — holds a value in a specific unit. Supports `+`, `-`, `*`, `/` operators. Implicitly converts to `double`. |
| 74 | - **`Units`** (`static class`) — entry point for converter instances: `Units.Distance`, `Units.Mass`, `Units.Temperature`, `Units.Area`, `Units.Volume`, `Units.Speed`, `Units.Metric`. |
| 75 | - **`Distance`, `Mass`, `Temperature`, `Area`, `Volume`, `Speed`, `MetricPrefix`** — enums listing available unit values for each category. |
| 76 | - **`DistanceUnitsCo |