Conversation
…le async selector tests Agent-Logs-Url: https://github.com/RFBCodeWorks/MvvmControls/sessions/01c5df53-6a81-4a3d-bf93-34fcf7448be7 Co-authored-by: RFBomb <20431767+RFBomb@users.noreply.github.com>
…le async RefreshableSelector tests Agent-Logs-Url: https://github.com/RFBCodeWorks/MvvmControls/sessions/01c5df53-6a81-4a3d-bf93-34fcf7448be7 Co-authored-by: RFBomb <20431767+RFBomb@users.noreply.github.com>
|
Copilot completely missed the mark on this request. Reworking the test class to demonstrate the following:
|
Tests a complex interaction between selectors that are refreshing in response to each other's collection and selection changes, to ensure that the refreshes are happening in the correct sequence and that the correct number of refreshes are being triggered for each selector. Also ensures that the 'EnsureInitializedAsync' method correctly waits for the last active refresh to complete.
Copilot fixes for failing unit tests to solve the Sequence test for a complex interaction
|
@copilot : After the review, update the initial PR comment to reflect changes and the overview. |
… flow using Func<Task<TList>> constructor Agent-Logs-Url: https://github.com/RFBCodeWorks/MvvmControls/sessions/7e938384-6e06-4bc7-aec9-abb8f7cd3f3c Co-authored-by: RFBomb <20431767+RFBomb@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR exposes EnsureInitialized / EnsureInitializedAsync on IRefreshableItemSource and refines RefreshableSelector async refresh/initialization behavior, alongside new/updated tests covering refresh sequencing and “don’t cancel in-flight refresh on repeated calls” semantics.
Changes:
- Add
EnsureInitialized(TimeSpan?)andEnsureInitializedAsync(CancellationToken)toIRefreshableItemSource. - Update
RefreshableSelectorasync refresh/initialization waiting logic to track the latest execution task and avoid canceling an in-flight refresh due to repeatedRefreshAsynccalls. - Adjust selector/ItemSource change-notification ordering and add a new test suite for refresh sequencing.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/MvvmControlsTests/Mvvm.Tests/RefreshableSelectorTests.cs | Updates async refresh test to verify repeated calls do not cancel the running refresh. |
| tests/MvvmControlsTests/Mvvm.Tests/RefreshableSelectorSequenceTests.cs | Adds multi-selector sequence tests validating chained refresh behavior and initialization waiting. |
| tests/MvvmControlsTests/CSharp9_MissingComponents.cs | Removes a NETFRAMEWORK NotNullAttribute shim from the test project. |
| tests/.Playlists/RefreshableSelectorTests.playlist | Adds a playlist including the new sequence tests. |
| src/Mvvm.Controls/Mvvm/RefreshableSelector.cs | Introduces helpers to await the latest async command execution task; adjusts command options and refresh flow. |
| src/Mvvm.Controls/Mvvm/Primitives/SelectorDefinition.cs | Adds a collection-change flag to avoid resetting selection when selecting during collection change. |
| src/Mvvm.Controls/Mvvm/Primitives/ItemSource.cs | Reorders _onCollectionChanged callback vs. OnItemsChanged() invocation. |
| src/Mvvm.Controls/Mvvm/IRefreshableItemSource.cs | Exposes EnsureInitialized / EnsureInitializedAsync on the interface. |
| src/Mvvm.Controls/Mvvm/ExtensionMethods.cs | Adds [NotNull]/[DoesNotReturn] annotations and a new null-check helper. |
| src/Mvvm.Controls/CSharp9_MissingComponents.cs | Adds NETFRAMEWORK shims for NotNullAttribute and DoesNotReturnAttribute. |
| RFBCodeWorks.Mvvm.sln | Adds AGENTS.md to solution items. |
| AGENTS.md | Updates solution/component documentation and Roslyn 5.x wording. |
Comments suppressed due to low confidence (2)
tests/MvvmControlsTests/CSharp9_MissingComponents.cs:10
NotNullAttributewas removed for .NET Framework builds, but the test project still uses[NotNull](e.g., intests/MvvmControlsTests/XAssert.cs). This will fail to compile fornet48unlessNotNullAttributeis available via a referenced assembly/package. Consider reintroducing a localSystem.Diagnostics.CodeAnalysis.NotNullAttributedefinition under#if NETFRAMEWORK(or adding the appropriate package reference) so thenet48target continues to build.
using System.ComponentModel;
#if !NET5_0_OR_GREATER
namespace ClassLibrary
{
src/Mvvm.Controls/Mvvm/Primitives/SelectorDefinition.cs:183
- This
ArgumentOutOfRangeExceptioncall is using the(string paramName, string message)overload, but the arguments are passed in reverse order. As written, the long text becomesparamNameand the message becomes"SelectedIndex", which is misleading for callers and debuggers. Swap the arguments (and ideally includevalueasactualValue).
{
throw new ArgumentOutOfRangeException($"SelectedIndex property was set to a value outside the valid range (expected value between -1 and number of items in the collection ( currently: {Items.Count} )", nameof(SelectedIndex));
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reworked in e143fa4. The test class now has a single method,
Updated. See the revised PR description below. Changes
|
…om/RFBCodeWorks/MvvmControls into copilot/add-test-case-mvvmcontrols
@Copilot was adding this file, when this file was not the goal of the PR and is the pathways are tested via other tests. Deleted (for the 2nd or 3rd time).
RFBomb
left a comment
There was a problem hiding this comment.
- Deleted nuget.exe as its not supposed to be included in the lib.
- Deleted the file Copilot kept adding with unit tests because it misunderstood initial instructions.
- All unit tests are passing as of this review, so I'm merging in.
Overview:
The goal for this PR was to ensure that background tasks during viewmodel initialization can safely perform complex interactions with the RefreshableSelectors.
EnsureInitializedandEnsureInitializedAsyncexisted onRefreshableSelectorbut were not part ofIRefreshableItemSource, making them inaccessible through the interface.Changes
IRefreshableItemSourcevoid EnsureInitialized(TimeSpan? maxWaitTime = null)Task EnsureInitializedAsync(CancellationToken token)RefreshableSelectorSequenceTests(new)Demonstrates a ViewModel-style flow using the
Func<Task<TList>>(non-cancellable async) constructor. Constructor parameters are exposed as class-level properties configured in[TestInitialize]: