Simplify source generator internals - #117
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
CSharpTypeReferenceintoTypeUsageand updates all call sites to constructTypeUsagedirectly. - 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TypeUsageWhy
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-restoredotnet format OpenApiWeaver.slnx --verify-no-changes --verbosity detailed --no-restoredotnet test OpenApiWeaver.slnx --configuration Release --no-build(153 passed)git diff --check