Skip to content

Rename Composable to NavDestination for clarity - #223

Merged
jonathanpeppers merged 1 commit into
mainfrom
jonathanpeppers/rename-composable-to-navdestination
Jun 10, 2026
Merged

jonathanpeppers merged 1 commit into
mainfrom
jonathanpeppers/rename-composable-to-navdestination

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Owner

Why

The public sealed class AndroidX.Compose.Composable registers a route with a NavHost. The name was a footgun:

  • "Composable" in Compose vocabulary normally means an @Composable function.
  • Our own UI-node base class is ComposableNode — Composable sat awkwardly next to it (the two are not related; Composable doesn't derive from ComposableNode, it's a route registration).
  • Kotlin spells the API composable(route) { ... } (lowercase builder DSL), not a type. Translating it as a C# class called Composable is what introduced the conflict.

Rename to NavDestination (the actual concept). Reads naturally next to NavHost / NavController.

Before:

new NavHost(navController) {
    new Composable("home")  { new Text("Home") },
    new Composable("user/{id}", entry => new Text($"User {entry.Args["id"]}")),
}

After:

new NavHost(navController) {
    new NavDestination("home")  { new Text("Home") },
    new NavDestination("user/{id}", entry => new Text($"User {entry.Args["id"]}")),
}

Clean break — no [Obsolete] alias

All affected API lines live in PublicAPI.Unshipped.txt (never released in a stable build). Shipping an [Obsolete] Composable : NavDestination would just defer the same churn for downstream callers and clutter the public surface with two names for one concept.

Changes

Area Files Notes
Facade rename src/Microsoft.AndroidX.Compose/Composable.cs → NavDestination.cs Class + both ctors + XML <summary> + error string + internal Render comment
Facade internals NavHost.cs, NavController.cs, NavBackStackEntry.cs crefs, doc examples, List<Composable> field, Add(Composable?) param
Call sites (21) Jetchat (2), JetNews (3 + 1 string literal in PostsRepo.cs), Reply (5), Gallery scaffold (4), BottomNavOptionsDemo (3), NavHostRouteArgsDemo (3) new Composable(...) → new NavDestination(...)
Public API PublicAPI.Unshipped.txt 5 Composable.* lines → NavDestination.*; NavHost.Add(Composable?) → NavHost.Add(NavDestination?)

No doc/README edits needed — remaining Composable mentions in README.md, docs/*, and sample READMEs refer to Kotlin's @Composable annotation or our unrelated ComposableNode / ComposableLambdas, not the renamed type.

The internal helpers ComposableLambdas.InstantiateNavComposable and ComposeBridges.NavGraphBuilderComposable keep their names — they're named after the Kotlin runtime they wrap (composableLambdaInstance, composable()) and aren't the renamed public type.

Verification

  • dotnet test src/Microsoft.AndroidX.Compose.SourceGenerators.Tests — 130/130 passing.
  • dotnet build src/Microsoft.AndroidX.Compose — clean (BG8605/BG8606 pre-existing binding warnings unchanged; no new RS0016/RS0017).
  • dotnet build src/Microsoft.AndroidX.Compose.Gallery — 0 warnings, 0 errors.
  • No device deploy.

Co-authored-by: Copilot [email protected]

The public sealed class `AndroidX.Compose.Composable` registers a route
with a `NavHost`. Its name is a footgun:

- "Composable" in Compose vocabulary normally means an `@Composable`
  function.
- The base class for our own UI nodes is `ComposableNode` — `Composable`
  sits awkwardly next to it (the two are *not* related; `Composable`
  doesn't derive from `ComposableNode`).
- Kotlin spells the API `composable(route) { ... }` (lowercase builder
  DSL), not a type — so naming the C# type `Composable` is the
  conversion that introduced the conflict.

Rename to `NavDestination` (the actual concept). Clean break, no
`[Obsolete]` alias — all affected API lives in
`PublicAPI.Unshipped.txt` (never released), and an alias would just
defer the same churn for downstream callers.

Touches:
- Facade (4 files): `Composable.cs` → `NavDestination.cs`, plus crefs
  / collection types / doc examples in `NavHost.cs`, `NavController.cs`,
  `NavBackStackEntry.cs`.
- Call sites (21 hits across 7 files): Jetchat (2), JetNews (3 + 1
  string literal in `PostsRepo.cs`), Reply (5), Gallery scaffold (4),
  BottomNavOptionsDemo (3), NavHostRouteArgsDemo (3).
- `PublicAPI.Unshipped.txt`: 5 `Composable.*` lines retitled to
  `NavDestination.*`, plus `NavHost.Add(Composable?)` →
  `NavHost.Add(NavDestination?)`.

No doc/README edits needed — remaining `Composable` mentions there refer
to Kotlin's `@Composable` annotation or our `ComposableNode` /
`ComposableLambdas` (unrelated types), not the renamed nav-destination.

Verified with generator tests (130/130 passing), facade build (0
errors), and full gallery Android build (0 warnings, 0 errors).

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings June 10, 2026 00:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Renames the public Composable class to NavDestination to eliminate a naming collision with Kotlin's @Composable annotation and this repo's own ComposableNode base class. Since the old name only appeared in PublicAPI.Unshipped.txt (never released), no [Obsolete] shim is needed.

Changes:

  • Rename Composable → NavDestination in the facade (NavDestination.cs), including both ctors, error messages, and internal comments; update NavHost/NavController/NavBackStackEntry doc crefs and field types accordingly.
  • Update all 21 call sites across Gallery scaffolding, demo files, and three sample apps (Jetchat, JetNews, Reply) from new Composable(…) to new NavDestination(…), including a string literal in PostsRepo.cs.
  • Replace the 6 old Composable.* entries in PublicAPI.Unshipped.txt with their NavDestination.* equivalents and update NavHost.Add parameter type.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Microsoft.AndroidX.Compose/NavDestination.cs Rename class & ctors from Composable to NavDestination; update error string and doc comments
src/Microsoft.AndroidX.Compose/NavHost.cs Update List<Composable> → List<NavDestination>, Add(Composable?) → Add(NavDestination?), doc crefs
src/Microsoft.AndroidX.Compose/NavController.cs Update <see cref> in XML docs
src/Microsoft.AndroidX.Compose/NavBackStackEntry.cs Update <see cref> and code example in XML docs
src/Microsoft.AndroidX.Compose/PublicAPI.Unshipped.txt Remove old Composable entries, add NavDestination entries, update NavHost.Add param type
src/Microsoft.AndroidX.Compose.Gallery/GalleryScaffold.cs 4× new Composable(…) → new NavDestination(…)
src/Microsoft.AndroidX.Compose.Gallery/Demos/Navigation/NavHostRouteArgsDemo.cs 3× call-site rename
src/Microsoft.AndroidX.Compose.Gallery/Demos/Navigation/BottomNavOptionsDemo.cs 3× call-site rename
samples/Reply/ReplyApp.cs 5× call-site rename
samples/JetNews/PostsRepo.cs 2× string-literal rename in article content
samples/JetNews/JetnewsApp.cs 3× call-site rename
samples/Jetchat/JetchatApp.cs 2× call-site rename

@jonathanpeppers
jonathanpeppers enabled auto-merge (squash) June 10, 2026 00:50
@jonathanpeppers
jonathanpeppers merged commit d6ba4a5 into main Jun 10, 2026
2 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers/rename-composable-to-navdestination branch June 10, 2026 00:53
jonathanpeppers added a commit that referenced this pull request Jun 10, 2026
After [#221](../pull/221) (implicit `long → Color` conversion) and [#222](../pull/222) (theme reads off composer), the `*Argb` suffix on color properties is vestigial — callers can pass `scheme.OnSurface` (a `long`) straight to a `Color?` property and the implicit conversion does the rest. The five hand-written facades that still exposed `long? *Argb` are renamed here to match the shape the source-generated `Text` facade already uses (`public Color? Color`).

### Renames

| File | Before | After |
|------|--------|-------|
| `Icon.cs` | `long? TintArgb` | `Color? Tint` |
| `HorizontalDivider.cs` | `long? ColorArgb` | `Color? Color` |
| `VerticalDivider.cs` | `long? ColorArgb` | `Color? Color` |
| `CircularProgressIndicator.cs` | `long? ColorArgb`, `long? TrackColorArgb` | `Color? Color`, `Color? TrackColor` |
| `LinearProgressIndicator.cs` | `long? ColorArgb`, `long? TrackColorArgb` | `Color? Color`, `Color? TrackColor` |

The render bodies still call the bound `DividerKt` / `ProgressIndicatorKt` / `IconKt` bindings (and the `IconPainter` bridge) with a `long` color slot; the new properties are converted via `Color is { } c ? c : 0L`.

### No `[Obsolete]` aliases

Same rationale as [#221](../pull/221), [#223](../pull/223), [#225](../pull/225), [#226](../pull/226), [#229](../pull/229): every removed entry was in `PublicAPI.Unshipped.txt`, never `Shipped.txt`, so a clean break is acceptable pre-1.0. Verified — only `Color.FromArgb(...)` factories remain (intentional, those aren't being renamed).

### Sweep

19 callsite renames across two samples; JetNews and the Gallery had no references.

| Sample | File | Hits |
|--------|------|------|
| Jetchat | `Conversation.cs` | 5 |
| Jetchat | `Profile.cs` | 4 |
| Jetchat | `RecordButton.cs` | 2 |
| Jetchat | `JetchatIcon.cs` | 2 |
| Jetchat | `JetchatDrawer.cs` | 1 |
| Reply | `EmailDetailAppBar.cs` | 1 |
| Reply | `ReplyEmailListItem.cs` | 1 |
| Reply | `ReplyEmailThreadItem.cs` | 1 |
| Reply | `ReplyProfileImage.cs` | 1 |
| Reply | `ReplySearchBar.cs` | 1 |

### Verified

- ✅ `dotnet test src/Microsoft.AndroidX.Compose.SourceGenerators.Tests` — 132/132
- ✅ `dotnet build src/Microsoft.AndroidX.Compose` — clean (no RS0016/RS0017)
- ✅ `dotnet build src/Microsoft.AndroidX.Compose.Gallery`
- ✅ `dotnet build samples/Jetchat`
- ✅ `dotnet build samples/JetNews`
- ✅ `dotnet build samples/Reply`

Not deployed to a device — leaving smoke-test for the user.

### Coordination

Round-2 #2. Disjoint file set from sibling round-2 PRs except for `PublicAPI.Unshipped.txt` — expect a mechanical sort conflict on merge with round-2 #1 (`Modifier.Padding` defaults) and round-2 #3 (`Func<IComposer, ComposableNode>` implicit).

Co-authored-by: Copilot <[email protected]>
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