Skip to content

Conversation

bigbes
Copy link
Collaborator

@bigbes bigbes commented Aug 27, 2025

Add infrastructure to generate optional wrapper types for custom types that
implement MessagePack extension methods (MarshalMsgpack/UnmarshalMsgpack).

Changes:

  • New CLI tool (cmd/gentypes) to generate code for specific types.
  • Support for MessagePack extension format with configurable extension codes.
  • Compatibility with existing option package patterns.
  • Updated linter exclusions for generator code paths.
  • Added import allow lists for new dependencies.

Example usage:
go run cmd/gentypes -ext-code 1 -package ./path/to/package TypeName

Closes #TNTP-3734.

@bigbes bigbes requested a review from Copilot August 27, 2025 10:05
Copilot

This comment was marked as outdated.

@bigbes bigbes marked this pull request as ready for review August 27, 2025 10:12
@bigbes bigbes force-pushed the bigbes/tntp-3734-optional-types-generator branch from 49069c5 to 441f593 Compare August 27, 2025 10:56
@coveralls
Copy link

coveralls commented Aug 27, 2025

Coverage Status

coverage: 91.616%. remained the same
when pulling 22ee789 on bigbes/tntp-3734-optional-types-generator
into 7a7e26c on master.

@bigbes bigbes requested a review from Copilot August 27, 2025 10:59
Copilot

This comment was marked as outdated.

@bigbes bigbes force-pushed the bigbes/tntp-3734-optional-types-generator branch 2 times, most recently from 024b79e to e3d62f7 Compare August 27, 2025 14:11
@bigbes bigbes changed the title generation: adding support for user types generator: add optional type generator for user-defined MessagePack types Aug 27, 2025
@oleg-jukovec
Copy link
Collaborator

The commit message ideally should be short (<52 chars), so you need to update it:

generator: add optional type generator for user-defined MessagePack types

->

generator: add generator for user-defined types

Copy link
Collaborator

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the patch.

To be honest, it is unclear how to use this now and why it is needed.

Please add a description in the README.md for this generator and how to use it at this PR.

@bigbes bigbes force-pushed the bigbes/tntp-3734-optional-types-generator branch 2 times, most recently from 876c6af to a3418aa Compare August 28, 2025 19:48
@@ -0,0 +1,37 @@
package extractor
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, test a public API only.

Suggested change
package extractor
package extractor_test

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@bigbes bigbes force-pushed the bigbes/tntp-3734-optional-types-generator branch 4 times, most recently from 59ad5c5 to dff22cb Compare September 1, 2025 09:54
Copy link

@Copilot Copilot AI left a comment

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 adds infrastructure for generating optional wrapper types for custom types that implement MessagePack extension methods. It introduces a new CLI tool to generate code for specific types with configurable MessagePack extension codes and maintains compatibility with existing option package patterns.

  • Adds cmd/gentypes CLI tool for generating optional types with MessagePack extension support
  • Implements code generation templates for both optional types and their corresponding tests
  • Creates test infrastructure including the FullMsgpackExtType example with complete MessagePack serialization

Reviewed Changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
go.mod Updates dependencies to support the new code generation tool
cmd/gentypes/generator.go Main CLI application for generating optional types
cmd/gentypes/generator/extension.go Core code generation logic and template execution
cmd/gentypes/generator/type_gen.go.tpl Template for generating optional type implementations
cmd/gentypes/generator/type_gen_test.go.tpl Template for generating comprehensive test suites
cmd/gentypes/extractor/*.go Package analysis and AST extraction utilities
cmd/gentypes/test/*.go Example implementation and generated test files
README.md Documentation for the new gentype utility
.golangci.yml Updated linter configuration for generator code paths

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@bigbes bigbes force-pushed the bigbes/tntp-3734-optional-types-generator branch from dff22cb to f19150d Compare September 1, 2025 11:16
Copy link
Contributor

@patapenka-alexey patapenka-alexey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like all dots in the right places.

Add infrastructure to generate optional wrapper types for custom types that
implement MessagePack extension methods (MarshalMsgpack/UnmarshalMsgpack).

Changes:
* New CLI tool (cmd/gentypes) to generate code for specific types.
* Support for MessagePack extension format with configurable extension codes.
* Compatibility with existing option package patterns.
* Updated linter exclusions for generator code paths.
* Added import allow lists for new dependencies.

Example usage:
  go run cmd/gentypes -ext-code 1 -package ./path/to/package TypeName

Closes #TNTP-3734.
@bigbes bigbes force-pushed the bigbes/tntp-3734-optional-types-generator branch from f19150d to 22ee789 Compare September 2, 2025 09:52
@bigbes bigbes merged commit 93a7028 into master Sep 2, 2025
14 checks passed
@bigbes bigbes deleted the bigbes/tntp-3734-optional-types-generator branch September 2, 2025 09:55
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.

4 participants