Skip to content

Move to CSharpAuthor 1.1.1007 and drop the workarounds - #21

Merged
ipjohnson merged 1 commit into
mainfrom
feature/csharpauthor-1007
Aug 8, 2026
Merged

Move to CSharpAuthor 1.1.1007 and drop the workarounds#21
ipjohnson merged 1 commit into
mainfrom
feature/csharpauthor-1007

Conversation

@ipjohnson

Copy link
Copy Markdown
Owner

Three types in SourceGenerator.Impl.Utilities existed only because CSharpAuthor could not express what the interception writer needed. 1.1.1007 can, so they go — 515 lines deleted, 170 added.

removed replaced by
ConstrainedTypeDefinition ClassDefinition.WhereStatement
AccessorMemberDefinition EventDefinition, PropertyDefinition.IndexParameters
TypeParameterDefinition CSharpAuthor.TypeParameterDefinition

Two related hacks go with them. The state class no longer smuggles its type parameters through the class nameAddGenericParameter declares them — which in turn means the hand-built new ConstructorDefinition($"DmState{index}") can go back to AddConstructor(), since the name no longer carries <T> for the constructor to inherit. State classes are also sealed now, which ComponentModifier could not say before.

The local TypeParameterDefinition tests are deleted rather than moved: they covered a dependency's behaviour, and it is tested where it lives.

private sealed class DmState0<T> : global::…InvocationState<T> where T : class, new()
{
    public DmState0(Work_Intercepted self, T arg0)

The snapshots move, and it is worth reading why

1.1.1007 fixes stray indentation before a closing parenthesis, which this generator has been emitting on every single-argument invocation:

-  …DependencyRegistry<…>.Add(ModuleDependencies        );
+  …DependencyRegistry<…>.Add(ModuleDependencies);
-  …DependencyRegistry<…>.ApplyServices(services            );
+  …DependencyRegistry<…>.ApplyServices(services);

That is not interception-specific — it is all generated output from this library, which is why eight module snapshots move. I checked every diff across all of them normalises to whitespace before a closing paren and nothing else, so no semantics changed.

The API snapshot also shows the whole 1006→1007 CSharpAuthor delta, because that source is compiled into the analyzer assembly. That includes sealed/record/init/file-scoped-namespace support which was already on their main before any of this work.

Verification

385 tests pass (400 minus the 15 deleted duplicates), 0 warnings, 86.9% coverage, verify-packages.sh clean. Generated output inspected directly for the generic state class, the event, and the multi-index indexer.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EgLfDy82CnQZiuU5j8byu9

Three types existed only because the library could not express what the
interception writer needed. It can now, so they go:

- ConstrainedTypeDefinition carried a where clause on a base type,
  because a class could not declare one. ClassDefinition.WhereStatement
  replaces it, and the type parameters move out of the class name into
  AddGenericParameter — so the state class no longer needs a
  hand-built ConstructorDefinition to avoid emitting `DmState0<T>(...)`
  as its constructor name.
- AccessorMemberDefinition wrote events and multi-index indexers.
  EventDefinition and PropertyDefinition.IndexParameters replace it.
- TypeParameterDefinition is now the library's own, with the value
  equality the local copy was missing. Its tests go with it: they
  covered a dependency's behaviour, which is tested where it lives.

State classes are sealed now, which ComponentModifier could not say
before.

The snapshots move for a reason worth reading: 1.1.1007 fixes stray
indentation before a closing parenthesis, so every single-argument
invocation this generator emits loses the spaces it used to carry —
`Add(ModuleDependencies        )` becomes `Add(ModuleDependencies)`.
Checked that every snapshot diff is whitespace before a closing paren
and nothing else.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EgLfDy82CnQZiuU5j8byu9
@ipjohnson
ipjohnson merged commit 19fe8c9 into main Aug 8, 2026
2 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.

1 participant