Skip to content

refactor(winrm): alias-based tags via tag! macro#36

Merged
irvingouj@Devolutions (irvingoujAtDevolution) merged 3 commits into
masterfrom
stack/xml-fromxml-tag-macro
Jun 25, 2026
Merged

refactor(winrm): alias-based tags via tag! macro#36
irvingouj@Devolutions (irvingoujAtDevolution) merged 3 commits into
masterfrom
stack/xml-fromxml-tag-macro

Conversation

@irvingoujAtDevolution

Copy link
Copy Markdown
Collaborator

Part 4/6. Base: stack/xml-fromxml-rm-deadcode.

Introduces the tag! macro and type aliases over Tag<'a, V, N>, dropping the raw Tag<V,N> spelling from APIs while keeping compile-time tag-name safety. Reduces verbosity without weakening typing.

FromXml stack (review/merge bottom-up):

  1. core + winrm migration (feat(xml): namespace-correct FromXml core + winrm migration #33)
  2. nested-tag descend fix
  3. delete dead AnyTag/TagList + markers
  4. tag! macro + aliases
  5. harden / reject malformed XML
  6. tests

…a NamedTag

Two steps toward de-uglifying the Tag layer, both behavior-preserving:

1. `NamedTag` trait: exposes a tag's (TAG_NAME, NAMESPACE) at the type level,
   forwarding from `N: TagName`. `#[derive(FromXml)]` now reads identity via
   `<FieldType as NamedTag>` instead of syntactically extracting the `N` param —
   so it will keep working once fields become type aliases for `Tag<'a, V, N>`.

2. Delete `AnyTag` + `TagList`: the dynamic heterogeneous-list escape hatch.
   `TagList::with_tag` was never called (never built with content), its ~45
   AnyTag variants were dead (SOAP envelope/header/body are typed structs now;
   the PSRP CLIXML tags belong to ps_value), and the four `Tag<TagList, _>`
   bodies on SoapBody (pull/release/get_status/command) were never populated and
   only checked for `.is_none()` in tests. Removed the fields, the two files,
   and the stale test assertions.

Verified: workspace tests pass; real-server matrix 10/10.
With AnyTag gone, ~22 TagName markers had no remaining referent: the PSRP
CLIXML set (Obj, MS, TN, T, S, B, Nil, DCT, En, Key, Value, ToString,
I32TagName, BA, Version), the InitRunspacepool set (MinRunspaces, MaxRunspaces,
PSThreadOptions, ApartmentState, HostInfo, ApplicationArguments — ps_value's
job), and FaultTo / From / FragmentTransfer. Removed. Workspace compiles, so
nothing referenced them.
…rom APIs

Keeps the compile-time tag safety (Tag<'a, V, N> with an N: TagName marker is
still the enforcer) but hides the verbosity behind a `tag!` macro that, per tag,
generates the marker (`<Alias>Tag`, internal) plus an ergonomic type alias
`Alias<'a> = Tag<'a, V, AliasTag>`. Fields and construction now read `Get<'a>` /
`Get::new(..)` instead of `Tag<'a, Text<'a>, Get>` / `Tag::from_name(Get)...`.

- `#[derive(FromXml)]` reads identity via `NamedTag` on the field type, so it
  works through the aliases (added in the prior commit).
- Leaf-valued tags (Text/WsUuid/Time/Empty/…) are a readable table in
  cores/tag_name.rs; composite-valued tags (Shell=ShellValue, Body=SoapBody, …)
  are defined with `tag!` next to their value struct — no cores→domain dep
  inversion.
- Multi-value names get distinct aliases sharing a wire name
  (LocaleEmpty/LocaleText, DataLocaleEmpty/DataLocaleText). Only genuinely
  value-varying construction (CommandLine's <Command>) keeps an explicit marker.

Verified: fmt + clippy (-D warnings) clean, workspace tests pass, real-server
transport×auth×sealing matrix 10/10.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant