Skip to content

Expand Nuke.* transition shims to full public API coverage via source generator #69

@ChrisonSimtian

Description

@ChrisonSimtian

Follow-up to #47 / PR that ships the Nuke.Common MVP shim.

Current state

src/Shims/Nuke.Common/ ships a hand-written shim covering the entry-point surface: NukeBuild, INukeBuild, [Parameter], [Secret], [Solution], [GitRepository]. That's enough for a class Build : NukeBuild { ... } declaration to compile against the shim.

Gap

Hand-written shims don't scale. Fallout.Common alone has 158 public types. Add Fallout.Build, Fallout.Components, Fallout.Tooling, ProjectModel, SolutionModel, Utilities (and sub-packages) — easily 500+ public types across all shim packages. Each needs:

C# construct Shim mechanism
Class Public subclass with constructors mirrored
Sealed class Wrapper with member-by-member delegation
Interface Sub-interface
Abstract class Public subclass (stays abstract)
Enum Cannot be subclassed — needs a using = alias documentation, or skip
Delegate Cannot be implicitly converted across types — skip
Static helper class Static wrapper with method-by-method delegation
Attribute Subclass with constructor pass-through
Generic class/method Pass through type parameters / constraints

Design

A Roslyn source generator referenced from each shim project. The generator:

  1. Reads [assembly: ShimAllPublicTypesFrom("Fallout.Common")] marker (or similar).
  2. Finds the canonical referenced assembly in the compilation's references.
  3. Walks every public type via INamespaceSymbol/INamedTypeSymbol.
  4. For each, emits source for the appropriate shim mechanism above into a generated .cs file in the shim project.
  5. Skips types it can't bridge (enums, delegates) — logs them and emits build warnings so we know what consumers are still locked out of.

Out of scope (deliberately)

  • Bridging delegates — fallout-migrate handles that
  • Bridging enums — fallout-migrate handles that

Why hand-written shipped first

  • Source generator is non-trivial (~500 LOC of generator code + tests)
  • A hand-written MVP gave Chris's other Fallout-consuming project something to test today
  • Architecture (subclass-based) is the same in both — only the generation method differs

Done when

  • Generator produces shims for every public class/interface/struct/attribute/static-helper-method in the marker's target assembly
  • All 15 Fallout.* canonical packages have matching shim projects (Nuke.Common, Nuke.Build, Nuke.Components, etc.)
  • tests/Nuke.Common.Shim.Tests/SampleConsumerBuild.cs expanded to exercise the full surface a typical consumer touches and still compiles
  • Release pipeline pushes shim nupkgs to GitHub Packages alongside the Fallout.* push to nuget.org

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions