Skip to content

feat(AutoGenerateColumn): add Required property - #8643

Merged
ArgoZhang merged 5 commits into
mainfrom
feat-AutoGenerateColumn-Required
Oct 31, 2026
Merged

ArgoZhang merged 5 commits into
mainfrom
feat-AutoGenerateColumn-Required

Conversation

@Tony-ST0754

@Tony-ST0754 Tony-ST0754 commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator
  • 在AutoGenerateColumn开启Required、IsRequiredWhenAdd、IsRequiredWhenEdit属性支持
  • 同时保持原始默认值为null,保证原业务逻辑不变

Link issues

fixes #8642

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Support configuring required-field behavior for automatically generated columns while preserving existing default behavior.

New Features:

  • Add public Required, IsRequiredWhenAdd, and IsRequiredWhenEdit options to AutoGenerateColumnAttribute.

Enhancements:

  • Preserve nullable interface defaults so unset values continue to fall back to existing required-field behavior.

Tests:

  • Add unit coverage for unset, explicitly enabled, explicitly disabled, and reset required-state options.

feat:开启Required、IsRequiredWhenAdd、IsRequiredWhenEdit属性支持
@bb-auto

bb-auto Bot commented Oct 29, 2026

Copy link
Copy Markdown

Thanks for your PR, @Tony-ST0754. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@bb-auto
bb-auto Bot requested a review from ArgoZhang October 29, 2026 07:37
@bb-auto bb-auto Bot added the enhancement New feature or request label Oct 29, 2026
@bb-auto bb-auto Bot added this to the v11.0.0 milestone Oct 29, 2026
@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (6c90354) to head (8fcc736).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #8643   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          776       776           
  Lines        35234     35243    +9     
=========================================
+ Hits         35234     35243    +9     
Flag Coverage Δ
BB 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sourcery-ai

sourcery-ai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds Required, IsRequiredWhenAdd, and IsRequiredWhenEdit support to AutoGenerateColumnAttribute using nullable backing fields to preserve unset-vs-explicit-false semantics and fallback behavior, with unit tests covering all state transitions.

File-Level Changes

Change Details Files
Expose required-field configuration on AutoGenerateColumnAttribute while preserving nullable interface semantics and fallback behavior.
  • Add public Required, IsRequiredWhenAdd, and IsRequiredWhenEdit properties with XML documentation.
  • Back each setting with nullable storage so omitted values remain null through IEditorItem/ITableColumn interfaces, while public getters default to false.
  • Allow explicit false and interface-assigned null to remain distinguishable from an unset value for downstream fallback resolution.
src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs
Add unit coverage for default, explicit, and reset states of the new required settings.
  • Verify public properties default to false while interface views remain null when unset.
  • Verify attribute assignment and interface assignment propagate values correctly.
  • Verify explicit false values and resetting through nullable interfaces are handled correctly.
test/UnitTest/Attributes/AutoGenerateClassTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#8642 Expose Required, IsRequiredWhenAdd, and IsRequiredWhenEdit as configurable AutoGenerateColumnAttribute properties while preserving nullable values through the IEditorItem and ITableColumn interfaces. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Tony-ST0754 Tony-ST0754 changed the title feat(AutoGenerateColumn):Enable Required Support feat(AutoGenerateColumn):add Required Support Oct 29, 2026

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs" line_range="90-95" />
<code_context>

-    bool? ITableColumn.IsRequiredWhenAdd { get; set; }
+    /// <summary>
+    /// <para lang="zh">获得/设置 当前列是否必填。默认值为 null,使用 <see cref="RequiredAttribute"/> 或 <see cref="IsRequiredWhenAdd"/>、<see cref="IsRequiredWhenEdit"/> 值</para>
+    /// <para lang="en">Gets or sets whether the current column is required. Default is null, using the <see cref="RequiredAttribute"/> or the <see cref="IsRequiredWhenAdd"/>, <see cref="IsRequiredWhenEdit"/> values</para>
+    /// </summary>
+    public bool Required
+    {
+        get => _required ?? false;
+        set => _required = value;
+    }
</code_context>
<issue_to_address>
**Unset settings appear false**

When a caller reads an unset setting through the public attribute property, the public property getters convert an unset backing value to `false`, so callers reading the attribute directly see the same value for unset and explicitly disabled settings, contrary to the documented null default.

Update the public-property documentation to say that its getter returns false when unset and that the interface view preserves null.

Also at `src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs:108-114`, `src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs:127-131`.
</issue_to_address>

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@ArgoZhang ArgoZhang changed the title feat(AutoGenerateColumn):add Required Support feat(AutoGenerateColumn): add Required property Oct 30, 2026
@ArgoZhang
ArgoZhang merged commit bcdb2b7 into main Oct 31, 2026
7 checks passed
@ArgoZhang
ArgoZhang deleted the feat-AutoGenerateColumn-Required branch October 31, 2026 00:09
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.

feat(AutoGenerateColumn): add Required Support

2 participants