ModernUO/Projects/UOContent/Gumps
Kamron Batman c9831b9680
fix: TextDefinition was uneditable in the props gump, and where parsed constants its own way (#2624)
## Pressing `>` on a TextDefinition did nothing useful

`#1217` moved `TextDefinition` into the Server project for serialization support and added `[PropertyObject]` along the way. `PropsGump` checks that attribute **before** its parsable fallback, so from that commit on the button either drilled into a read-only `Number`/`String` page (both get-only since `#1221`, so no `>` buttons — a dead end) or, when the value was null, re-sent the same page and looked inert.

Worth being clear that `#765` — which replaced the hand-maintained type list with a generic `IsParsable` branch — was **not** the regression. At that commit `TextDefinition` was `[Parsable]` only, fell through to the new branch, and the editor worked. Only the later attribute hijacked the routing.

`TextDefinition` is now caught ahead of the `[PropertyObject]` branch and routed to `SetGump`, which has had `TextDefinition`-specific code at line 35 all along.

## `0` and `"0"` could not be told apart

`Commands.Split` strips quotes before any parser runs, so this was never fixable in `TextDefinition.Parse` alone — the information is gone two layers earlier. The markers now travel inside the value:

| Input | Result |
|---|---|
| `1060847` | cliloc (unchanged) |
| `#1060847` | cliloc, explicit — the form `ToString()` already writes |
| `@"1060847"` | the literal string |
| `hello` | string (unchanged) |
| `(-null-)` | null (unchanged) |

`GetValue()` quotes a string that would not survive the trip back. That check is a real round trip through the parser rather than a pattern match, so it cannot drift from it. `Types.TryParse` decodes the same escape for plain strings — which is what `[get` has always written for the literal `"null"` without `[set` ever reading it back.

**Saved data is untouched.** Serialization reads a discriminated flag plus int/string (`IGenericReader.cs:175`) and the JSON converter switches on token type; neither calls `Parse`, so a stored string `"1060847"` stays a string and spawner JSON is unchanged. The new syntax stays in the text and command layer, where it reaches `[set`, `[add`, spawner props, the props gump and Advanced Search.

## `where` still parsed its constants its own way

`#2625` carried the hand-rolled constant parser across to `PropertyExpressions.Parse` unchanged. It looks for a static `Parse` overload on the property type and gives up if there is none — and `Type` and `IEntity` have neither:

```
where Subject Kind  = Static     ->  Unable to convert string "Static" into type 'System.Type'.
where Subject Owner = 0x1        ->  Unable to convert string "0x1" into type 'Server.Mobile'.
```

Both resolve fine for every other command. Routing through `Types.TryParse` picks up type-name lookup, entity resolution by serial, and the `@"..."` literal convention, so a value that works in one place now works everywhere. It also deletes the duplicate parser (−56 lines in `PropertyExpressions`).

Two things are load-bearing and preserved. `where` has always spelled a null constant as a bare `null`, where `[set` uses `(-null-)`; the shared parser reads a bare `null` as the text, so the null case is handled ahead of it and `= null` keeps meaning null. And nullable targets still unwrap first, so `where <int? prop> = 5` is unaffected.

Bare and hex integers, enums, bools, strings, `Map`, and TextDefinition's `#` / `@"..."` markers all resolve exactly as before — 13 of the 15 tests in `WhereConstantParsingTests` pin that and passed before the change as well as after.

## Documentation

The generic command system had no documentation anywhere in the repo: scopes, `where` and its operators, dot notation, `order by` / `distinct` / `limit`, the value and quoting syntax, `[interface` and `[batch` were all learn-by-reading-the-source. `dev-docs/generic-commands.md` covers them, linked from `CLAUDE.md` and `commands-targeting.md`, and points at <https://muo.gg/commands> for the per-command list rather than duplicating it.

Two behaviours it records that were news to me while writing it:

- `Contained` honours conditions on the normal command path but never sets `SupportsConditionals`, and `[batch` is the only place that reads the flag — so the same condition works typed directly and is refused under batch.
- `Multi`, `Single`, `Self` and `Serial` do not parse modifiers at all, so a `where` clause there is passed to the command as ordinary arguments rather than rejected.

Comments in the changed code were trimmed to what is not evident from the code itself; the rationale they carried is either in the doc now or in the commit that introduced it.

## Behavior changes worth a reviewer's attention

Two things go beyond strict bug-fixing, both deliberate:

- **Hex now parses into a TextDefinition.** Consolidating the three `Parse` overloads onto one span codec means `[set Message 0x102CE7` is cliloc 1060847 rather than the string. Previously only the 1-arg `Parse(string)` did hex and nothing called it. This makes the props gump's own `1060847 (0x102CE7)` display typeable.
- **`@"..."` decodes generally for strings**, not only the exact token `@"null"`. So `[set Name @"hello"` sets `hello`. A half-working escape seemed more surprising than a general one, and the `where` path already decoded it — but narrowing it back is a one-line change if preferred.

## Testing

40 tests, each written first and watched fail for the right reason. They cover the props gump routing (populated and null), cliloc/string/quoted parsing and `GetValue` round trips, `where` constant resolution for Type- and entity-valued properties, and the bare-`null` vs `@"null"` distinction that must not drift.

One sort case is added that #2625 left uncovered: ordering a value-typed chain whose intermediate is null, which reads as `default(int)` rather than throwing. Two other tests from the pre-rebase branch were dropped as duplicates of `ConditionalCompilerEdgeTests`.

Rebased onto `535a09899`. `dotnet build` clean, 0 warnings. **902 UOContent** and **869 Server** tests pass, 0 failures.

## Known gaps

- `Nullable<T>` comparisons work via #2625's lifted operators; nothing here changes that.
- Spawner **Params** are split on plain spaces (`BaseSpawner.cs:1035`) rather than through `Commands.Split`, so a constructor argument still cannot contain one. Untouched here — a tokenizer issue, not a TextDefinition one.
- `Types.ParseStringNumericParamTypes` is now unreferenced. Left in place because it is public and shards may use it.
2026-09-10 19:36:30 -07:00
..
Base fix: Warn when sending empty gumps (#2563) 2026-08-08 00:55:12 -07:00
Go perf: Migrate Travel/Moongate gumps to DynamicGump (#2412) 2026-04-25 17:03:24 -07:00
Guilds perf: Migrates New Guild System gumps from legacy Gump. (#2422) 2026-05-03 00:09:22 -07:00
Houses perf: Migrate HouseGumpAOS to DynamicGump (#2429) 2026-05-03 09:52:17 -07:00
Props fix: TextDefinition was uneditable in the props gump, and where parsed constants its own way (#2624) 2026-09-10 19:36:30 -07:00
AddDoorGump.cs fix: Rewrites AddDoor command, fixes gump and returning to correct page. (#2056) 2025-01-08 10:32:37 -08:00
AdminGump.cs fix: harden idle-sleep scheduling against bad config and misattributed saves (#2567) 2026-08-09 22:05:18 -07:00
BanDurationGump.cs chore: Removes dead gump code (#2403) 2026-04-08 08:39:23 -06:00
BaseConfirmGump.cs fix: Fixes issue with cached static gump strings. Fixes bad gump colors (#1771) 2024-05-10 22:44:16 -07:00
BaseGridGump.cs fix: Consolidates Color/Center html (#1762) 2024-05-07 23:56:32 -07:00
BaseImageTileButtonsGump.cs fix: Optimizes gump relay info (Prep for Static Gumps) (#1698) 2024-03-07 20:54:53 -08:00
ClientGump.cs feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257) 2025-11-23 11:35:31 -08:00
CommentsGump.cs perf: Migrate NPC and Skill UI gumps to DynamicGump/StaticGump (#2414) 2026-04-25 19:51:42 -07:00
ConfirmBreakCrystalGump.cs Fixes brace style (#248) 2020-09-13 21:49:46 -07:00
ConfirmHeritageGump.cs perf: Migrate Item Interaction gumps to DynamicGump/StaticGump (#2421) 2026-04-26 11:31:49 -07:00
ConfirmReleaseGump.cs fix: pets freeze, forget their orders, obey the wrong players, and fight when told not to (#2614) 2026-09-10 19:28:13 -07:00
HeritageTokenGump.cs perf: Migrate Item Interaction gumps to DynamicGump/StaticGump (#2421) 2026-04-26 11:31:49 -07:00
NoticeGump.cs fix: Adds static warning/notice gumps. (#1741) 2024-04-26 17:19:16 -07:00
PetResurrectGump.cs feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257) 2025-11-23 11:35:31 -08:00
PlayerVendorGumps.cs perf: Migrate PlayerVendor gumps to DynamicGump/StaticGump (#2430) 2026-05-03 10:04:12 -07:00
PolymorphGump.cs chore: Removes dead gump code (#2403) 2026-04-08 08:39:23 -06:00
ReclaimVendorGump.cs perf: Migrate vendor management gumps to DynamicGump/StaticGump (#2431) 2026-05-03 10:19:12 -07:00
ResurrectGump.cs fix: Fixes priced healer resurrection when not choosing the correct option (#2276) 2025-11-23 09:58:33 -08:00
RewardGump.cs perf: Migrate RewardGump to DynamicGump (#2432) 2026-05-03 10:22:52 -07:00
RunebookGump.cs fix: Actions on gump crash when Runebook has no entries (#1964) 2024-09-27 10:17:22 -07:00
SelectAddonDirectionGump.cs feat: Standardizes South/East selection gumps (#1839) 2025-02-14 00:15:14 -08:00
SkillsGump.cs feat: Consolidates staff gump layouts (#2404) 2026-04-08 11:42:46 -06:00
StaticNoticeGump.cs fix: Adds static warning/notice gumps. (#1741) 2024-04-26 17:19:16 -07:00
StaticWarningGump.cs feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257) 2025-11-23 11:35:31 -08:00
TithingGump.cs fix: Adds missing string interpolation handler for SetStringSlot (#2123) 2025-02-13 19:30:47 -08:00
ToTAdminGump.cs chore: Removes dead gump code (#2403) 2026-04-08 08:39:23 -06:00
VendorInventoryGump.cs feat: Pre-Publish 14 Crafting (supersedes #2181, #2381) (#2476) 2026-06-07 20:27:22 -07:00
VendorRentalGumps.cs perf: Migrate vendor management gumps to DynamicGump/StaticGump (#2431) 2026-05-03 10:19:12 -07:00
ViewHousesGump.cs feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257) 2025-11-23 11:35:31 -08:00
VirtualCheckGump.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
WarningGump.cs fix: Fixes issue with cached static gump strings. Fixes bad gump colors (#1771) 2024-05-10 22:44:16 -07:00
WhoGump.cs feat: Consolidates staff gump layouts (#2404) 2026-04-08 11:42:46 -06:00
YoungGumps.cs feat: Restyle young player gumps (#1917) 2024-08-10 11:06:18 -07:00