Skip to content

Simplify source generator internals - #117

Merged
shibayan merged 1 commit into
masterfrom
agent/simplify-source-generator-internals
Aug 14, 2026
Merged

Simplify source generator internals#117
shibayan merged 1 commit into
masterfrom
agent/simplify-source-generator-internals

Conversation

@shibayan

Copy link
Copy Markdown
Owner

Summary

  • collapse the private C# type representation into TypeUsage
  • remove redundant model state, accumulator state, and one-hop helpers
  • consolidate YAML extension detection without changing supported inputs

Why

Several internal values and forwarding methods duplicated information already owned by adjacent types. Keeping a single canonical representation reduces allocations and maintenance paths while preserving the generator's behavior.

Impact

There are no intended public API, generated-source, diagnostic, MSBuild, or package contract changes.

Validation

  • dotnet build OpenApiWeaver.slnx --configuration Release --no-restore
  • dotnet format OpenApiWeaver.slnx --verify-no-changes --verbosity detailed --no-restore
  • dotnet test OpenApiWeaver.slnx --configuration Release --no-build (153 passed)
  • git diff --check

@shibayan shibayan self-assigned this Aug 14, 2026
@shibayan shibayan added the enhancement New feature or request label Aug 14, 2026
@shibayan
shibayan marked this pull request as ready for review August 14, 2026 05:29
Copilot AI lite review requested due to automatic review settings August 14, 2026 05:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 refactors internal source-generator modeling to use a single canonical C# type representation (TypeUsage), removing redundant wrappers/state and simplifying a few helper paths while preserving generator behavior.

Changes:

  • Collapses CSharpTypeReference into TypeUsage and updates all call sites to construct TypeUsage directly.
  • Removes redundant internal state/one-hop helpers (e.g., tag accumulator group-name storage, enum number helper indirection).
  • Centralizes YAML extension detection into a single helper used by both document filtering and document reading.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/OpenApiWeaver/OpenApi/SchemaTypeResolver.cs Switches from TypeUsage.Create(...) to direct TypeUsage construction throughout schema type resolution.
src/OpenApiWeaver/OpenApi/SchemaEnumResolver.cs Removes redundant BuildNumberEnumMemberName passthrough and simplifies enum member naming switch.
src/OpenApiWeaver/Models/GenerationModels.cs Refactors TypeUsage to own all type-shape/nullability logic; simplifies computed properties using TypeUsage.
src/OpenApiWeaver/Models/CSharpTypeReference.cs Deletes the now-redundant internal type wrapper.
src/OpenApiWeaver/Generator/Transforming/ClientGenerator.Transformer.Tags.cs Simplifies tag-group accumulation by removing stored group name and using dictionary keys consistently.
src/OpenApiWeaver/Generator/Transforming/ClientGenerator.Transformer.Responses.cs Updates response type resolution to construct TypeUsage directly.
src/OpenApiWeaver/Generator/Transforming/ClientGenerator.Transformer.cs Removes redundant hasDirectionalSchemaProperties from the ClientModel constructor; computes serializer options type name as before.
src/OpenApiWeaver/Generator/ClientGenerator.DocumentReader.cs Consolidates YAML detection into IsYamlExtension(string extension) and reuses it consistently.
src/OpenApiWeaver/Generator/ClientGenerator.cs Minor cleanup to avoid default(ReadResult) initialization while preserving control flow.
src/OpenApiWeaver/CodeGeneration/JsonSerializerOptionsEmitter.cs Removes a redundant overload and avoids allocations by using static lambdas where appropriate.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@shibayan
shibayan merged commit 789be71 into master Aug 14, 2026
5 checks passed
@shibayan
shibayan deleted the agent/simplify-source-generator-internals branch August 14, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants