Fix SlicingArgumentDefaultValue within ListSizeAttribute #9369
Fix SlicingArgumentDefaultValue within ListSizeAttribute #9369glen-84 merged 10 commits intoChilliCream:mainfrom
SlicingArgumentDefaultValue within ListSizeAttribute #9369Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes ListSizeAttribute so SlicingArgumentDefaultValue can be set via attribute syntax without triggering CS0655, and ensures the value is forwarded into the applied @listSize directive so static cost analysis can use it. It also adds/updates tests and snapshots to validate default-value inference and precedence rules.
Changes:
- Update
ListSizeAttributeto supportSlicingArgumentDefaultValueas an attribute argument and pass it through duringOnConfigure. - Add tests verifying (1) inference from paging
DefaultPageSizeand (2)ListSizeAttributeprecedence over paging defaults. - Add/refresh snapshots for the new/updated test cases.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/CostAnalysis/src/CostAnalysis/Types/ListSizeAttribute.cs | Makes SlicingArgumentDefaultValue usable in attributes and forwards it into ListSizeDirective. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/StaticQueryAnalysisTests.cs | Adds a new static query analysis test case for slicing default value behavior. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/SlicingArgumentsTests.cs | Adds schema snapshot tests for inferred default and precedence behavior. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/DescriptorExtensionTests.cs | Extends assertions to include slicingArgumentDefaultValue when applying ListSize via descriptor extension. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/AttributeTests.cs | Extends assertions to include SlicingArgumentDefaultValue when applying ListSize via attribute. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/snapshots/StaticQueryAnalysisTests.Execute_ListQuery_ReturnsExpectedResult_9.md | New snapshot for the added static query analysis scenario. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/snapshots/SlicingArgumentsTests.SlicingArgumentDefaultValue_Inferred_From_DefaultPageSize.graphql | New schema snapshot validating inference from DefaultPageSize. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/snapshots/SlicingArgumentsTests.SlicingArgumentDefaultValue_ListSizeAttribute_HasPrecedenceOver_DefaultPageSize.graphql | New schema snapshot validating attribute precedence over paging defaults. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/HotChocolate/CostAnalysis/src/CostAnalysis/Types/ListSizeAttribute.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Updates the CostAnalysis ListSizeAttribute so SlicingArgumentDefaultValue can be set via attribute named arguments (fixing CS0655) and is respected during directive configuration, with additional tests and snapshots to validate behavior and precedence vs paging defaults.
Changes:
- Switched
ListSizeAttribute.SlicingArgumentDefaultValueto a non-nullableintwith an internal unset sentinel, and passed the value through inOnConfigure. - Expanded unit test coverage for
@listSizedefault slicing argument behavior and precedence over paging defaults. - Added/updated snapshot artifacts for static query analysis and schema snapshots.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/CostAnalysis/src/CostAnalysis/Types/ListSizeAttribute.cs | Implements unset sentinel + validates non-negative inputs; forwards SlicingArgumentDefaultValue into ListSizeDirective. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/StaticQueryAnalysisTests.cs | Adds a theory data case covering slicingArgumentDefaultValue in @listSize. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/SlicingArgumentsTests.cs | Adds schema snapshot tests for inferred/default slicing argument default values and precedence rules. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/DescriptorExtensionTests.cs | Ensures descriptor extension ListSize(...) applies slicingArgumentDefaultValue correctly. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/AttributeTests.cs | Verifies attribute-driven directive values including default slicing argument value and null behavior when omitted. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/snapshots/StaticQueryAnalysisTests.Execute_ListQuery_ReturnsExpectedResult_9.md | Snapshot for new static analysis test case (index 9). |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/snapshots/SlicingArgumentsTests.SlicingArgumentDefaultValue_Inferred_From_DefaultPageSize.graphql | Schema snapshot validating inferred slicingArgumentDefaultValue from paging default. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/snapshots/SlicingArgumentsTests.SlicingArgumentDefaultValue_ListSizeAttribute_HasPrecedenceOver_DefaultPageSize.graphql | Schema snapshot validating attribute-provided default takes precedence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/HotChocolate/CostAnalysis/src/CostAnalysis/Types/ListSizeAttribute.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR addresses an attribute-usage compiler error around ListSizeAttribute.SlicingArgumentDefaultValue and ensures the value is correctly propagated into the configured @listSize directive during schema configuration, with additional regression tests/snapshots in the CostAnalysis test suite.
Changes:
- Update
ListSizeAttributeto supportSlicingArgumentDefaultValueas an attribute argument and pass it through duringOnConfigure. - Add/extend unit tests and snapshots covering precedence/inference of slicing-argument defaults (including paging defaults).
- Extend existing directive application tests to validate
slicingArgumentDefaultValueis present in the directive value.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/CostAnalysis/src/CostAnalysis/Types/ListSizeAttribute.cs | Adjusts attribute properties and forwards slicingArgumentDefaultValue into ListSizeDirective during configuration. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/StaticQueryAnalysisTests.cs | Adds a new list-size scenario to the static query analysis theory data. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/snapshots/StaticQueryAnalysisTests.Execute_ListQuery_ReturnsExpectedResult_9.md | Snapshot for the new static analysis scenario including slicingArgumentDefaultValue. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/SlicingArgumentsTests.cs | Adds schema snapshot tests for inferred vs explicit slicing-argument defaults. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/snapshots/SlicingArgumentsTests.SlicingArgumentDefaultValue_Inferred_From_DefaultPageSize.graphql | Snapshot asserting inference of slicingArgumentDefaultValue from paging defaults. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/snapshots/SlicingArgumentsTests.SlicingArgumentDefaultValue_ListSizeAttribute_HasPrecedenceOver_DefaultPageSize.graphql | Snapshot asserting attribute-provided default takes precedence over paging default. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/DescriptorExtensionTests.cs | Extends descriptor extension test to assert SlicingArgumentDefaultValue is applied to the directive. |
| src/HotChocolate/CostAnalysis/test/CostAnalysis.Tests/AttributeTests.cs | Extends attribute tests to assert SlicingArgumentDefaultValue is applied and null when not specified. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/HotChocolate/CostAnalysis/src/CostAnalysis/Types/ListSizeAttribute.cs
Show resolved
Hide resolved
src/HotChocolate/CostAnalysis/src/CostAnalysis/Types/ListSizeAttribute.cs
Show resolved
Hide resolved
src/HotChocolate/CostAnalysis/src/CostAnalysis/Types/ListSizeAttribute.cs
Show resolved
Hide resolved
|
@N-Olbert Thanks! |
ListSize(SlicingArgumentDefaultValue = Custom_Value)].SlicingArgumentDefaultValuewithinOnConfigure.