Let codegen use the code generator rather than a copy of one - #155
Conversation
[patch] Dependabot moved ktsu.Semantics.Paths to 4.0.0 and left ktsu.Semantics.Strings at 3.2.1. Paths 4.0.0 depends on Strings >= 4.0.0, so central package management now pins a version below what the graph requires and every project referencing either fails to restore with NU1605: "Detected package downgrade". main does not build. Raising the pin to match is the whole fix. It is unrelated to the change after it and would have been its own pull request, except that nothing in this repository builds until it lands. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0165XQS7s11ssp36AEY8tvCF
[minor] KtsuTools.CodeGen carried its own IAstNode, five node types, a hand-written YAML reader and a C# and a Python emitter - 456 lines, every one of which ktsu.Coder already had, along with C++, JavaScript, a round trip back to YAML, a node-graph editor and a test suite. Two implementations of one idea, and the smaller one was the one nobody was improving. So the module now references that package and keeps what a command-line front end is actually for: finding the file, choosing the generator, and putting the result somewhere. It gains C++ and JavaScript, and it gains every node Coder can read rather than only a function declaration - the YAML shape a caller already wrote is the shape Coder's own reader expects, so a document that worked still works. The tests follow the same split. They no longer check what a generator emits, because that package checks its own across four languages far more thoroughly than a copy here did; what is left to test is that a document reaches a generator, that the right one is chosen, and that a document describing nothing is reported rather than thrown out of a command. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0165XQS7s11ssp36AEY8tvCF
[patch] SonarCloud reported new issues on the rewritten file, and reproducing its analyzers locally found one of them in code this change touches: S2325, "make GenerateAsync a static method". It is the same complaint CA1822 makes, which the method already carries a suppression for, and the answer is the same: CodeGenService is a singleton injected into CodeGenCommand's constructor, so a static method would leave the command holding a dependency it takes and never uses. The suppression now names both rules, and the reason moves into the documentation where a reader will find it rather than sitting above the pragma. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0165XQS7s11ssp36AEY8tvCF
|
Acting on the SonarCloud comment above — with one gap worth naming, since I could not close it from here. This repository has no dotnet build KtsuTools.CodeGen/KtsuTools.CodeGen.csproj \
-p:CustomAfterMicrosoftCommonProps=/path/to/sonar-local.propsThat found one issue in the files this PR changes:
It is the same complaint Four of the five I cannot see. The analyzer package ships some rules disabled that a project's quality profile enables, and sonarcloud.io is not reachable from this environment, so there is no way from here to tell whether the remaining four are in Worth noting separately: the analyzers report a good number of pre-existing findings across Generated by Claude Code |
|
|
Correcting my previous comment: S2325 was not one of the five. The re-analysis after b69b8cc still reports 5 new issues, unchanged. So either that rule was never among them and my local run simply enables rules this project's quality profile does not, or the scanner does not count a The suppression stands on its own merits: So the position is: all five remain unidentified from this environment, not four. Everything is green and the gate passes, so nothing is blocked — but the dashboard is the only place those five can actually be read. Generated by Claude Code |



KtsuTools.CodeGen/CodeGenService.cswas 456 lines, and about 400 of them were a second, smallerktsu.Coder:IAstNode,FunctionDeclaration,ParameterNode,VariableDeclaration,ReturnStatementILanguageGenerator,CSharpGenerator,PythonGeneratorYamlDeserializer, and a serializer backTwo implementations of one idea, and the smaller one was the one nobody was improving. The module is
net10.0and the package isnet10.0;net9.0, so there was never a targeting reason for it.What this does
Replaces the body with a package reference and keeps what a command-line front end is actually for: finding the file, choosing the generator, putting the result somewhere.
CodeGenService.GenerateAsynckeeps its signature, soCodeGenCommandis untouched.Two things get better as a side effect.
codegen --lang cppand--lang javascriptnow exist. And the command reads any node Coder can read rather than only afunctionDeclaration— a whole source file, a namespace, a class — because the reader is no longer a parser for one shape.No format break. Coder's reader expects the same keys the hand-written one did (
functionDeclaration→name,returnType,parameters,body), so a document that worked still works. There is a test that reads one.Tests
They follow the same split. They no longer assert what a generator emits — that package tests its own across four languages far more thoroughly than a copy here did. What is left to test is the part this module still owns: that a document reaches a generator, that the right one is chosen, that a document describing nothing is reported rather than thrown out of a command, and one end-to-end run producing C++ from a file.
The other commit
maindoes not currently build. Dependabot movedktsu.Semantics.Pathsto 4.0.0 in #153 and leftktsu.Semantics.Stringsat 3.2.1; Paths 4.0.0 depends on Strings >= 4.0.0, so central package management pins below what the graph requires and restore fails withNU1605: Detected package downgrade. Raising the pin is the whole fix. It is unrelated to the change beside it and would have been its own pull request, except nothing here builds until it lands — so it is the first commit, and each commit builds on its own.Testing
dotnet buildclean, 0 warnings. 64/64 tests pass.🤖 Generated with Claude Code
https://claude.ai/code/session_0165XQS7s11ssp36AEY8tvCF
Generated by Claude Code