Osy#the first language built for agents
Agents firstAgentic appsWorkflowsDurable Execution — built inSecurityTestingThe editorThe UI modelOne program

Reference / Function

Enum.Label, Enum.Description, Enum.Name

value.Label / value.Description / value.Name → string (Enum.Label / Enum.Description / Enum.Name)

Read the human-facing words of an enum value in code: its Label (the [Label] text, or the member name when there is none), its Description (the member's doc comment), and its Name (the member's identifier). The screen shows the label for you automatically; reach for these only when a function needs the words.

stable2 examples compiled by CIfunctionenumdisplaystdlib

Summary#

An enum member has three faces you can read in code from a value: value.Name is the member's identifier ("Placed"), value.Label is what a person reads (the [Label("…")] text, or the name when there is none), and value.Description is the member's doc-comment sentence. They lower to the stdlib calls Enum.Name, Enum.Label and Enum.Description.

Signature#

value.Name         -> string      // the member identifier, e.g. "Placed"    (Enum.Name)
value.Label        -> string      // the [Label] label, else the name       (Enum.Label)
value.Description  -> string      // the member's /// doc comment              (Enum.Description)

Description#

These read the words declared with the enum ([Label], [Icon], [Tone] — what a human reads): [Label("…")] sets the label, a /// doc comment sets the description, and the member identifier is the name.

  • value.Label is the display text. If the member has a [Label("…")], that is the label; otherwise the label falls back to the member name, because the name is usually already readable.
  • value.Description is the longer sentence from the member's doc comment — the help text under an option, for instance. A member with no doc comment has an empty description.
  • value.Name is always the raw identifier, ignoring any [Label].

You rarely need these for display. Showing an enum-typed value on a screen already renders its label for you ([Label], [Icon], [Tone] — what a human reads) — reach for .Label/.Description/.Name when a function needs the words: building a message, an export column, an audit line.

Because the words come from the app's model (which the client already has), these run in the browser with no round trip, just like the rest of the pure surface (execution side).

Examples#

enum OrderStatus {
  /// The order is placed but has not shipped yet.
  [Label("Awaiting shipment")] Placed,

  Shipped,
}

// Build a one-line status message from the words, not the stored value.
string StatusLine(OrderStatus s) {
  return s.Label + " — " + s.Description;
}
[Test]
void Enum_words() {
  // a member WITH a [Label] and a doc comment
  Assert.Equal("Placed", OrderStatus.Placed.Name);                 // the identifier
  Assert.Equal("Awaiting shipment", OrderStatus.Placed.Label);      // the [Label] text
  Assert.Equal("The order is placed but has not shipped yet.", OrderStatus.Placed.Description);

  // a member WITHOUT a [Label]: the label falls back to the name
  Assert.Equal("Shipped", OrderStatus.Shipped.Name);
  Assert.Equal("Shipped", OrderStatus.Shipped.Label);              // no [Label] → the name

  Assert.Equal("Awaiting shipment — The order is placed but has not shipped yet.",
    StatusLine(OrderStatus.Placed));
}

See also#

Related

[Label], [Icon], [Tone] — what a human reads

An enum member stores a compact value but shows a human-readable label. [Label("…")] gives a member its label…

enum

A fixed set of named values, used as a member type. Stored as a number by default, or as the member's own name with…

switch

Branch on a value against constant case labels. Only the matched section runs (no fall-through); a default section…

execution side

Where a function runs. Osy# infers it from the body: a function that reads data runs on the server, a function that…