Fix TryGet returning false for empty subranges with exclusive parent boundaries#3
Merged
blaze6950 merged 3 commits intofeature/implement-data-related-logic-for-rangesfrom Feb 3, 2026
Conversation
…rt parents Co-authored-by: blaze6950 <32897401+blaze6950@users.noreply.github.com>
…stead of empty RangeData Co-authored-by: blaze6950 <32897401+blaze6950@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Address feedback on data logic implementation for ranges
Fix TryGet returning false for empty subranges with exclusive parent boundaries
Feb 3, 2026
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where TryGet(Range subRange, ...) incorrectly returned false for empty subranges when the parent range had exclusive boundaries. The issue occurred because negative indices (from boundary adjustments) were rejected before empty-range logic could execute.
Changes:
- Reordered validation logic to check for empty ranges (
count <= 0) before validating index bounds - Added clarifying comment explaining the ordering requirement
- Added three test cases covering empty subranges at exclusive boundaries
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Intervals.NET.Data/RangeData.cs | Moved empty-range check before negative-index guard to properly handle empty subranges at exclusive boundaries |
| tests/Intervals.NET.Data.Tests/RangeDataTests.cs | Added three test cases verifying empty subranges return true with empty data when at exclusive parent boundaries |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
blaze6950
added a commit
that referenced
this pull request
Feb 3, 2026
* Feature: Implement data-related logic for RangeData and update range factory methods for consistency - Introduced RangeData abstraction to couple logical ranges with data sequences and domains. - Updated RangeFactory methods to remove type parameters for cleaner usage. - Added TryCreate method for Range with validation and error messaging. - Enhanced Distance method in domain interfaces to ensure accurate step calculations. - Revised tests to reflect changes in range factory methods and ensure correctness. - Updated project metadata and CI/CD configurations for new data module. * Feature: Add validation method for RangeData to ensure data sequence matches expected logical elements * Feature: Add overview and implementation details for RangeData in README.md * Feature: Add unit tests for RangeData extensions to validate adjacency and data integrity * Feature: Add unit tests for RangeData extensions to validate equality, slicing, and domain interactions * Feature: Add benchmarks for RangeData and RangeDataExtensions to evaluate performance and memory usage * Feature: Integrate Codecov coverage reporting into CI workflows for all projects * Feature: Enhance RangeData logic for sub-range and point access with validation and improved error handling - Refine RangeData indexer to validate sub-range finiteness and containment, throwing specific exceptions for invalid cases - Update TryGet methods to ensure points and sub-ranges are within bounds before accessing data - Align index calculations with range inclusivity for accurate data mapping - Improve XML documentation for IRangeDomain to clarify complexity of Distance implementations - Update benchmarks and tests for readonly domain fields and minor cleanup - Clarify package description and README section for RangeData usage and validation * Feature: Update Microsoft.NET.Test.Sdk to version 17.11.1 in test project dependencies * Feature: Update Microsoft.NET.Test.Sdk to version 17.11.1 in test project dependencies * Feature: Update test execution paths and remove Codecov upload from Domain.Abstractions workflow * Feature: Update test paths in CI configuration and enhance documentation for TryCreate method * Feature: Update CI configuration to use test paths for dependency restoration, building, and testing * Feature: Correct test path in CI configuration for Intervals.NET.Data.Tests * Feature: Update CI configuration to use test path for dependency restoration and building * Feature: Optimize null-check for domain parameter to avoid boxing in RangeData * Feature: Enhance test coverage for RangeData and DateTime domains with edge case scenarios * chore: get rid of redundant md files * Feature: Update range comments and improve test method naming for clarity * Feature: Refine distance calculation and improve exception messages in RangeData * Feature: Improve range validation logic to handle overflow and enhance error messaging * Feature: Enhance range validation to correctly handle infinity bounds and improve exception messaging * Feature: Update range documentation for clarity and improve validation logic in TrimEnd method * Feature: Enhance TrimStart and TrimEnd methods to support inclusive/exclusive boundaries and improve documentation * Feature: Update documentation for RangeData methods to clarify return values and equality semantics * Feature: Clarify documentation for range span calculation and return type details * Feature: Update test data in IsTouching method to clarify range element counts * Feature: Update test data in IsBeforeAndAdjacentTo method to clarify element counts for ranges * Feature: Refine documentation and logic in RangeData extensions for clarity and consistency * Feature: Enhance documentation for domain interfaces and implementations to clarify performance characteristics and equality semantics * Feature: Update README to enhance structure and clarity of RangeData documentation * Fix TryGet returning false for empty subranges with exclusive parent boundaries (#3) * Initial plan * Add test case demonstrating bug with empty subranges in exclusive-start parents Co-authored-by: blaze6950 <32897401+blaze6950@users.noreply.github.com> * Fix bug where empty subranges with negative indices returned false instead of empty RangeData Co-authored-by: blaze6950 <32897401+blaze6950@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: blaze6950 <32897401+blaze6950@users.noreply.github.com> --------- Co-authored-by: Mykyta Zotov <mykyta.zotov@ihsmarkit.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TryGet(Range subRange, ...)incorrectly returnedfalsefor empty-but-contained subranges when the parent range had exclusive boundaries. Example: parent(10,20]with subrange(10,10]returnedfalseinstead of an emptyRangeData.Root Cause
After adjusting indices for boundary inclusiveness,
endIndexcould become negative for empty ranges. The negative-index guard rejected these before the empty-range check (count <= 0) could execute.Changes
count <= 0before validating index bounds💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.