Skip to content

DelegateTransform.With(...) fails to compile (CS0234) from any code in a ktsu.* namespace, and the README's mapping example can't compile anywhere #76

Description

@matt-edmondson

What's wrong

1. The documented call form doesn't resolve inside ktsu.*

The library declares a static class DelegateTransform inside the namespace ktsu.DelegateTransform (DelegateTransform/DelegateTransform.cs:3,23). C# looks names up through the enclosing namespaces first. From code in namespace ktsu.Anything, the simple name DelegateTransform therefore resolves to the namespace ktsu.DelegateTransform, not to the class, even with using ktsu.DelegateTransform;.

using ktsu.DelegateTransform;
namespace ktsu.MyApp;
static class P { static void Main() { int r = DelegateTransform.With(5, x => x * 2); } }
  • Observed: error CS0234: The type or namespace name 'With' does not exist in the namespace 'ktsu.DelegateTransform'.
  • Workaround: ktsu.DelegateTransform.DelegateTransform.With(...) compiles and returns 10.

Every ktsu-dev consumer lives under ktsu.*, so this hits the library's main audience. The repo's own tests compile only because they sit in ktsu.DelegateTransform.Test, where the type is found first.

2. The README's "Complex Object Transformations" example needs an overload that doesn't exist

string description = DelegateTransform.With(person, p => $"{p.Name} is {p.Age} years old");

Only With<T>(T, Func<T, T>) exists (DelegateTransform.cs:50), so this gives CS0029: Cannot implicitly convert type 'string' to 'Person' and CS1662.

The fluent value.With(...).With(...) chaining described in CLAUDE.md doesn't compile either, because the methods aren't extension methods.

Suggested fix

  • Make the methods extension methods: input.With(x => …). This never names the type, so it avoids the namespace clash, and it makes the documented chaining work. Alternatively, rename the class, for example to Transform, so it no longer matches its namespace.
  • Add TResult With<T, TResult>(T input, Func<T, TResult> @delegate), with the same Ensure.NotNull check. If mapping is not intended, correct the README example instead.
  • Add a test project, or at least one test file, in a namespace outside ktsu.DelegateTransform (for example ktsu.Consumer) that compiles the README examples, so the clash can't come back.

Activity

  1. matt-edmondson commented on Sep 27, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    • Category: Bug
    • Priority: High. The library's only documented call form, DelegateTransform.With(...), fails to compile from any ktsu.* namespace, which covers every in-org consumer. The README mapping example and the chaining described in CLAUDE.md do not compile anywhere. The package's primary API is effectively unusable as documented.
    • Area / suggested assignee: DelegateTransform/DelegateTransform.cs (class/namespace name clash, missing With<T, TResult> overload), README, and test namespace coverage. Owner: @matt-edmondson
    • Duplicates / in progress: not a duplicate. No open PR in DelegateTransform.
    • Next step: decide between extension methods, which avoid naming the type and enable chaining, and renaming the class. Both change the public API, so this needs a version-bump decision. Add With<T, TResult> or fix the README example, and add a consumer-namespace test that compiles the README snippets.

    Generated by Claude Code

  2. matt-edmondson commented on Sep 28, 2026

    @matt-edmondson
    ContributorAuthor

    Decision (maintainer, 2026-09-28)

    • Make the methods extension methods, so callers write input.With(x => …). That avoids the namespace clash and makes the documented chaining work. The class is not being renamed.
    • Add TResult With<T, TResult>(T input, Func<T, TResult> @delegate), so the README mapping example compiles as written.
    • This is a public API change and ships as a major release, following the org-wide rule to take the correct fix and bump major.

    Next reader: implement both, and add a test file in a namespace outside ktsu.DelegateTransform (for example ktsu.Consumer) that compiles the README examples. Update the README and CLAUDE.md to the extension form, and release with [major].


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions