CodeGenHelpers
CodeGenHelpers copied to clipboard
Example from readme doesn't work
I've just found this project and decided to try it out by copying the example provided in the readme. On doing so I found some issues, although since I'm not familiar with the project it may be my fault.
- The
ClassBuilder.AddConstructormethod returns aConstructorBuilderwhich doesn't contain anAddPropertymethod.
This requires using theClassproperty to go back to theClassBuilder.
Alternatively, maybeConstructorBuildercould add theAddPropertymethod so the example just works. It seems other builders follow this pattern (e.g.:ClassBuilder.AddNamespaceImport). - The
ClassConstructor.AddPropertymethod doesn't have an overload that takes the type of the property.
This requires using thePropertyBuilder.SetTypemethod. However, specifying the type of the property is required so I feel like it would be better to add a parameter[^1] to theAddPropertymethod which would make the example work. - The generated output doesn't include the accessibility modifiers since they weren't specified.
I suggest adding the accessibility modifiers to the example or modifying the output in the readme to match the generated output. - The generated output always adds the namespace in the
SomeOtherTypeparameter and property, but the output in the readme doesn't include it.
If this is intentional, I think the output in the readme should be modified to match the generated output. - The generated output declares the properties in reverse order, unlike what's being shown in the readme.
Should the property order be respected or is this intentional?
I'm willing to make a PR with the changes needed to fix this issue, let me know what would be the preferred way to resolve it.
[^1]: It can be a new overload to preserve binary compatibility, not sure how important that is for this project.