Skip to content

feat(SourceGenerator): Scaffold + [<ArguGenerate>] marker attribute#318

Merged
bartelink merged 5 commits into
fsprojects:masterfrom
dimension-zero:pr/30-source-generator-companion
Jun 8, 2026
Merged

feat(SourceGenerator): Scaffold + [<ArguGenerate>] marker attribute#318
bartelink merged 5 commits into
fsprojects:masterfrom
dimension-zero:pr/30-source-generator-companion

Conversation

@dimension-zero

Copy link
Copy Markdown
Contributor

feat(SourceGenerator): Scaffold + [] marker attribute

  • New project src/Argu.SourceGenerator (netstandard2.0): publishes the
    [] marker attribute. Today the marker is inert; a
    follow-up release will ship the actual generator that consumes it to
    emit a compile-time-built schema (bypassing Argu's reflection path).
    README.md documents the planned design and roadmap.
  • New sample samples/Argu.Samples.SourceGenerated: shows the opt-in
    shape. The sample currently runs through Argu's standard reflection
    path; once the generator lands, the same SampleArgs annotated with
    [] will use the generated factory automatically.
  • Argu.sln: register both new projects. The sample is nested under the
    existing 'samples' folder; the SourceGenerator library is a sibling
    of Argu.

Strictly additive. No change to the core Argu package's public surface,
behaviour, or dependency graph.


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

This PR scaffolds a new companion package (Argu.SourceGenerator) that introduces an [<ArguGenerate>] marker attribute to create an opt-in seam for a future compile-time schema generator, and adds a sample that demonstrates the intended usage pattern.

Changes:

  • Adds new src/Argu.SourceGenerator project (netstandard2.0) publishing the [<ArguGenerate>] marker attribute plus package README.
  • Adds new samples/Argu.Samples.SourceGenerated sample showing annotation and current reflection-based parsing flow.
  • Registers both projects in Argu.sln.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Argu.SourceGenerator/README.md Documents motivation, status, and roadmap for the planned generator.
src/Argu.SourceGenerator/AttributeMarkers.fs Introduces the [<ArguGenerate>] marker attribute type.
src/Argu.SourceGenerator/Argu.SourceGenerator.fsproj Adds the new packable library project and packaging configuration.
samples/Argu.Samples.SourceGenerated/Program.fs Adds a sample CLI template annotated with [<ArguGenerate>].
samples/Argu.Samples.SourceGenerated/Argu.Samples.SourceGenerated.fsproj Adds the new sample project referencing Argu + the marker package.
Argu.sln Includes the new library and sample in the solution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Argu.SourceGenerator/AttributeMarkers.fs
Comment thread src/Argu.SourceGenerator/Argu.SourceGenerator.fsproj
Comment thread src/Argu.SourceGenerator/Argu.SourceGenerator.fsproj
Comment thread src/Argu.SourceGenerator/Argu.SourceGenerator.fsproj Outdated
@dimension-zero dimension-zero force-pushed the pr/30-source-generator-companion branch from 69f7875 to 93f0a26 Compare June 1, 2026 07:07

@bartelink bartelink left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved in principle - ideally any forward looking statements like 'planned' get trimmed (see copilot comments) and we merge this just before the impl arrives.

(Main concern being not to merge something that nobody on the planet will end up using if anything changes)

@dimension-zero

Copy link
Copy Markdown
Contributor Author

@bartelink @nojaf — packaging hygiene cleanup pushed (ad7c6fc) to address Copilot's review:

  • AttributeMarkers.fs: removed the "(shipped separately)" wording that contradicted the <remarks> saying the generator is intentionally out of scope for this release.
  • Argu.SourceGenerator.fsproj:
    • Added <PackageReadmeFile>README.md</PackageReadmeFile> so NuGet clients render the README.
    • Added DotNet.ReproducibleBuilds PrivateAssets="All" to match the core Argu package and keep nupkg metadata consistent across the two packages.
    • Changed PackagePath="\""" on the README pack item to match the existing pattern in src/Argu/Argu.fsproj.

Pack succeeds with no warnings. CI green. Ready for review whenever convenient — this PR is just the marker scaffold; the generator itself is deliberately out of scope and there's no behaviour change to the core library.

Comment thread src/Argu.SourceGenerator/AttributeMarkers.fs Outdated
@dimension-zero

dimension-zero commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

@bartelink — doc comment reworked per your note (cc8b9b5):

  • <summary> is now in final form: states the purpose tersely (opts a template into compile-time schema generation → reflection-free ArgumentParser<'T>, which is what makes publish-AOT viable and removes the reflection startup cost), and calls out the key consideration a user must account for — the union and its Argu attributes have to be statically resolvable, since the generator reads the type at compile time. No "planned/future" wording.
  • <remarks> carries the caveat that the generator doesn't exist yet and that the marker can be applied now for a no-source-change benefit once it lands.
  • README intro reworded into plain English (now vs later).

I've kept this PR marker-only as before. On your "do the generator in one shot" offer — happy to, once you accept the marker first and bring the generator as its own PR so the scaffold isn't held up behind a much larger change. If you'd prefer them together, say so and I'll fold it in. Otherwise this is ready for merge whenever you're happy.

dimension-zero and others added 3 commits June 8, 2026 10:11
* New project src/Argu.SourceGenerator (netstandard2.0): publishes the
  [<ArguGenerate>] marker attribute. Today the marker is inert; a
  follow-up release will ship the actual generator that consumes it to
  emit a compile-time-built schema (bypassing Argu's reflection path).
  README.md documents the planned design and roadmap.
* New sample samples/Argu.Samples.SourceGenerated: shows the opt-in
  shape. The sample currently runs through Argu's standard reflection
  path; once the generator lands, the same SampleArgs annotated with
  [<ArguGenerate>] will use the generated factory automatically.
* Argu.sln: register both new projects. The sample is nested under the
  existing 'samples' folder; the SourceGenerator library is a sibling
  of Argu.

Strictly additive. No change to the core Argu package's public surface,
behaviour, or dependency graph.

# Conflicts:
#	Argu.slnx
- AttributeMarkers.fs: drop "(shipped separately)" wording, which was inconsistent with the <remarks> noting the generator is intentionally out of scope for this release.
- Argu.SourceGenerator.fsproj:
  - Set <PackageReadmeFile>README.md</PackageReadmeFile> so NuGet clients render the README as the package readme.
  - Add <PackageReference Include="DotNet.ReproducibleBuilds" PrivateAssets="All" /> to match the core Argu package and produce reproducible nupkg metadata.
  - Change PackagePath="\" to "" for the README pack item to match the existing pattern in src/Argu/Argu.fsproj.
Addresses review feedback on the AttributeMarkers.fs doc comment:
- <summary> now states the attribute's purpose in final form (no "planned"
  / "future" wording), terse, and calls out the key consideration a user
  must account for: the union and its Argu attributes must be statically
  resolvable, since the generator reads the type at compile time.
- <remarks> carries the caveat that the generator does not exist yet and
  that the marker can be applied now for a no-source-change benefit later.
- README intro reworded into plainer English describing what the package
  does now versus later.
@bartelink bartelink force-pushed the pr/30-source-generator-companion branch from cc8b9b5 to a6194f4 Compare June 8, 2026 09:12
@bartelink

Copy link
Copy Markdown
Member

(merging shortly)

@bartelink bartelink force-pushed the pr/30-source-generator-companion branch from c614188 to 30c1e6b Compare June 8, 2026 10:22
@bartelink

Copy link
Copy Markdown
Member

Thanks for the cleanups & follow-up!

@bartelink bartelink merged commit bc6376c into fsprojects:master Jun 8, 2026
4 checks passed
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.

3 participants