Simplify requirements loading with LoadResult#155
Conversation
Agent-Logs-Url: https://github.com/demaconsulting/ReqStream/sessions/7db48b15-2002-4c56-ac2f-4559c14ffb27 Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Agent-Logs-Url: https://github.com/demaconsulting/ReqStream/sessions/035569b8-8e18-4f57-adaf-42037ea4d1dd Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot When creating new contexts for capturing output, make sure they're disposed before trying to read the log file to prevent file-in-use errors on Windows. |
Agent-Logs-Url: https://github.com/demaconsulting/ReqStream/sessions/9285552e-9737-4603-a993-d5ac66266661 Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Fixed in b896f98. All three |
There was a problem hiding this comment.
Pull request overview
This PR unifies requirements parsing/linting behind a single Requirements.Load() API that returns a LoadResult object, and updates call sites/tests/docs to use the new result-centric pattern.
Changes:
- Replaced tuple-based load results (and removed
Requirements.Read) with aLoadResulttype returned fromRequirements.Load(). - Centralized lint issue reporting via
LoadResult.ReportIssues(Context)and updated CLI flow accordingly. - Updated and expanded unit tests to validate
LoadResultbehavior and new calling patterns; refreshed modeling design documentation.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| test/DemaConsulting.ReqStream.Tests/Tracing/TraceMatrixTests.cs | Migrates Requirements.Read usage to Requirements.Load(...).Requirements in trace matrix tests. |
| test/DemaConsulting.ReqStream.Tests/Tracing/TraceMatrixReadTests.cs | Updates trace matrix read tests to the new Load API. |
| test/DemaConsulting.ReqStream.Tests/Tracing/TraceMatrixExportTests.cs | Updates trace matrix export tests to the new Load API. |
| test/DemaConsulting.ReqStream.Tests/Modeling/RequirementsReadTests.cs | Renames/repurposes parsing tests to use LoadResult instead of exception-based Read. |
| test/DemaConsulting.ReqStream.Tests/Modeling/RequirementsLoadTests.cs | Updates existing load tests and adds new tests for LoadResult.HasErrors and ReportIssues. |
| test/DemaConsulting.ReqStream.Tests/Modeling/RequirementsLoaderTests.cs | Refactors lint helper logic to rely on LoadResult.HasErrors / Issues. |
| test/DemaConsulting.ReqStream.Tests/Modeling/RequirementsExportTests.cs | Migrates export tests from Read to Load. |
| src/DemaConsulting.ReqStream/Program.cs | Replaces repetitive issue-foreach loops with result.ReportIssues(context) and uses result.Issues. |
| src/DemaConsulting.ReqStream/Modeling/RequirementsLoader.cs | Changes loader return type to LoadResult and constructs it based on whether errors exist. |
| src/DemaConsulting.ReqStream/Modeling/Requirements.cs | Removes Read API and makes Load return LoadResult. |
| src/DemaConsulting.ReqStream/Modeling/LoadResult.cs | Introduces LoadResult type with Requirements, Issues, HasErrors, and ReportIssues. |
| docs/design/modeling/requirements.md | Documents the unified Load API and new LoadResult type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
test/DemaConsulting.ReqStream.Tests/Modeling/RequirementsLoadParsingTests.cs
Show resolved
Hide resolved
test/DemaConsulting.ReqStream.Tests/Tracing/TraceMatrixTests.cs
Outdated
Show resolved
Hide resolved
test/DemaConsulting.ReqStream.Tests/Tracing/TraceMatrixReadTests.cs
Outdated
Show resolved
Hide resolved
test/DemaConsulting.ReqStream.Tests/Tracing/TraceMatrixExportTests.cs
Outdated
Show resolved
Hide resolved
test/DemaConsulting.ReqStream.Tests/Modeling/RequirementsExportTests.cs
Outdated
Show resolved
Hide resolved
test/DemaConsulting.ReqStream.Tests/Modeling/RequirementsReadTests.cs
Outdated
Show resolved
Hide resolved
|
@copilot The build failed with: |
…equirements_Load_ Agent-Logs-Url: https://github.com/demaconsulting/ReqStream/sessions/7d550c5c-0261-442a-a7ff-fd11e563af47 Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
... Fixed in b532796. The |
|
@copilot apply changes based on the comments in this thread |
…assertions Agent-Logs-Url: https://github.com/demaconsulting/ReqStream/sessions/2e37d776-d945-4af1-9b9c-ed02af111503 Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Done in 6d721ce. Applied all the review comments:
|
Pull Request
Description
Replaces the dual
Read/LoadAPI and tuple return type with a singleRequirements.Load()that returns aLoadResultsealed class. The result encapsulates the nullable requirements tree, all lint issues, and knows how to route them to the context output — eliminating the repetitive foreach-over-issues pattern at every call site.LoadResult(new)Requirements? Requirements— null when any error-level issue is presentIReadOnlyList<LintIssue> Issuesbool HasErrorsReportIssues(Context context)— routes warnings tocontext.WriteLineand errors tocontext.WriteErrorAPI simplification
Requirements.Read()removed;Requirements.Load()now returnsLoadResultRequirementsLoader.Loadreturn type updated from tuple toLoadResultCall-site before/after
Tests
Requirements.Read()usages in tests converted toLoad()+ null/HasErrorschecks; test methods renamed fromRequirements_Read_*toRequirements_Load_*RequirementsReadTests.csrenamed toRequirementsLoadParsingTests.csto match the class nameRequirements.Load(reqPath).Requirements!usages replaced with a safeloadResult+Assert.IsNotNullpattern acrossTraceMatrixTests.cs,TraceMatrixReadTests.cs,TraceMatrixExportTests.cs, andRequirementsExportTests.csissue.ToString().Contains(...)assertions inRequirementsLoadParsingTests.csreplaced withissue.Description.Contains(...)for message text andissue.Location.Contains(...)for file pathsLoadResult.ReportIssuesandHasErrors, usingContextto verify routingReportIssuestests use block-scopedusingto disposeContextbefore reading log files, preventing file-in-use errors on WindowsRequirements traceability
docs/reqstream/modeling/requirements.yamlanddocs/reqstream/ots/mstest.yamlupdated to reference the renamedRequirements_Load_*test method namesDocs
docs/design/modeling/requirements.mdupdated to documentLoadResultand the simplified single-method API; both call-site references corrected toresult.ReportIssues(context)Type of Change
Related Issues
Pre-Submission Checklist
Before submitting this pull request, ensure you have completed the following:
Build and Test
dotnet build --configuration Releasedotnet test --configuration Releasedotnet run --project src/DemaConsulting.ReqStream --configuration Release --framework net10.0--no-build -- --validateCode Quality
dotnet format --verify-no-changesQuality Checks
Please run the following checks before submitting:
cspell "**/*.{md,cs}"markdownlint "**/*.md"yamllint .Testing
Documentation
Additional Notes
Requirements.Read()is a breaking removal — callers outside this repo that depended on it must migrate toRequirements.Load()and checkresult.Requirements/result.HasErrors.LoadResultis implemented as asealed class(not a C#record) since value-semantics andwith-expressions are not needed for this type.