Skip to content

[TypeGen]: clear stale manifests when generation becomes empty - #23

Open
RejectKid wants to merge 1 commit into
MistyKuu:masterfrom
RejectKid:fix-empty-typegen-manifest
Open

RejectKid wants to merge 1 commit into
MistyKuu:masterfrom
RejectKid:fix-empty-typegen-manifest

Conversation

@RejectKid

Copy link
Copy Markdown
Contributor

Summary

Removing the final [GenerateTypes] attribute or fluent .WithGeneratedTypes(...) registration leaves the previous on-disk manifest in obj. The MSBuild task replays that manifest, so deleted TypeScript/Zod files return on subsequent builds.

Successful generation passes now emit a valid zero-file manifest even when there are no discovered models or the requested emitters produce no files. This allows both the live-write path and the existing MSBuild task to sweep previously generated files using the current directory marker and banner ownership rules. Handwritten files remain untouched. Empty results caused by compilation errors or fatal generator/configurator diagnostics do not trigger cleanup.

Document the cleanup behavior, a one-time rebuild after upgrading, and the existing IDE/file-I/O and shared-output-directory limitations. The MSBuild cleanup implementations do not need changes: they already process zero-file manifests.

Affected package(s)

ZibStack.NET.TypeGen and its configuration documentation.

Type of change

  • Bug fix
  • Generator / generated-code behavior change

How was this verified?

286 passed, 0 failed, 0 skipped in the full TypeGen Release suite.

$env:MSBUILDDISABLENODEREUSE = '1'
$env:DOTNET_CLI_USE_MSBUILD_SERVER = '0'
dotnet test packages/ZibStack.NET.TypeGen/tests/ZibStack.NET.TypeGen.Tests/ZibStack.NET.TypeGen.Tests.csproj -c Release

Four new package-level regressions pack the actual generator and abstractions, install them into isolated consumer projects, and preserve obj across successive builds. The removal cases failed against the original code before the fix.

Coverage includes attribute and fluent removal, the empty-emitter case, partial removal while other types remain, output-directory renames, deleted output staying deleted, handwritten file preservation, stable output timestamps, and compiler/configurator/generic-type/Zod-validation failure paths. MSBuild-only consumers disable analyzer-side writes; the live-write consumer verifies cleanup occurs before MSBuild's sweep.

Local test execution used a shortened process-scoped Windows PATH so the existing TypeScript/Zod tests could resolve npx. The Release build has existing nullable and xUnit analyzer warnings; no new warnings were introduced. git diff --check passes.

Checklist

  • Branched from latest upstream master, focused on a single change
  • Tests added or updated, including actual package/MSBuild integration
  • Docs updated under docs/src/content/docs/
  • Build is clean — no new warnings
  • Commit subjects use the [Package]: … prefix

This branch has not been deployed

No deployments
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