Skip to content

feat: add builderConstructorMandatoryParameters option to enforce man… - #119

Merged
pmrogala merged 4 commits into
mainfrom
feature/8.8.0.0
Mar 6, 2026
Merged

feat: add builderConstructorMandatoryParameters option to enforce man…#119
pmrogala merged 4 commits into
mainfrom
feature/8.8.0.0

Conversation

@pmrogala

@pmrogala pmrogala commented Mar 6, 2026

Copy link
Copy Markdown
Owner

…datory constructor parameters in generated builders

…datory constructor parameters in generated builders

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

Adds a new builderConstructorMandatoryParameters configuration option to Buildenator, allowing generated builders to require the entity’s primary constructor parameters via a parameterized builder constructor, with supporting docs, diagnostics, and integration tests.

Changes:

  • Introduces builderConstructorMandatoryParameters in configuration/attributes and propagates it through generator configuration.
  • Updates constructor generation and suppresses the static factory property when mandatory parameters are enabled; adds BDN007 for mandatory+mocking incompatibility.
  • Adds integration test coverage plus README/CHANGELOG documentation for the new option.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/Buildenator.IntegrationTests/BuildersGeneratorMandatoryParametersTests.cs Adds integration tests asserting mandatory builder ctor args, override behavior via With..., collections, and suppression of static factory property.
Tests/Buildenator.IntegrationTests/Buildenator.IntegrationTests.csproj References the SourceWithoutAssemblyInfo project to compile/run the new scenario.
Tests/Buildenator.IntegrationTests.SourceWithoutAssemblyInfo/EntityWithMandatoryConstructorParametersBuilder.cs Defines a builder annotated with builderConstructorMandatoryParameters: true for integration testing.
Tests/Buildenator.IntegrationTests.SharedEntities/EntityWithMandatoryConstructorParameters.cs Adds an entity with a required constructor for the new feature scenario.
README.md Documents the new option, its behavior, and provides an advanced usage example.
CHANGELOG.md Adds a release note entry for builderConstructorMandatoryParameters and BDN007.
Buildenator/MakeBuilderAttributeInternal.cs Extends internal attribute model to carry BuilderConstructorMandatoryParameters.
Buildenator/Generators/ConstructorsGenerator.cs Implements generation of parameterized builder constructors when the option is enabled.
Buildenator/Generators/BuilderSourceStringGenerator.cs Wires the option into constructor generation, suppresses static factory property, and emits BDN007 when combined with mocking configuration.
Buildenator/Diagnostics/BuildenatorDiagnosticDescriptors.cs Adds diagnostic descriptor BDN007.
Buildenator/Configuration/Contract/IBuilderProperties.cs Adds BuilderConstructorMandatoryParameters to builder configuration contract.
Buildenator/Configuration/BuilderProperties.cs Propagates the new option through global/local configuration and exposes it via IBuilderProperties.
Buildenator/AnalyzerReleases.Unshipped.md Registers BDN007 as a new shipped/unshipped analyzer diagnostic.
Buildenator.Abstraction/MakeBuilderAttribute.cs Extends public attribute API with builderConstructorMandatoryParameters.
Buildenator.Abstraction/BuildenatorConfigurationAttribute.cs Extends global configuration attribute API with builderConstructorMandatoryParameters.

}

var settableProperties = entity.AllUniqueSettablePropertiesAndParameters
.Where(p => constructorToBuild?.ContainsParameter(p.SymbolName) != true)

This comment was marked as resolved.

Comment thread Buildenator/Generators/ConstructorsGenerator.cs
pmrogala added 2 commits March 6, 2026 23:35
…andatory constructor parameters

fix: update changelog and README for new diagnostic errors BDN007 and BDN008
refactor: modify EntityWithMandatoryConstructorParameters to include tags and update related tests
…andatoryParameters in generated constructors
@pmrogala
pmrogala merged commit ca6b291 into main Mar 6, 2026
1 check passed
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.

2 participants