Fix for DebugAssertException detection during testing + VIntUtils length assertions - #1400
Merged
Merged
Conversation
…tion type from the Microsoft.NET.Test.Sdk that has been added there since 16.6.0 so catch blocks don't swallow it.
… VInt lengths, not requiring maximum lengths, which are in fact allowed for sources that don't change position on read.
4 tasks done
paulirwin
approved these changes
Jul 4, 2026
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.
Fix for
DebugAssertExceptiondetection during testing +VIntUtilslength assertionsDescription
While reviewing #1373, I discovered that the length checking was incorrectly requiring the length to be at least the max length allowed. I fixed it on the #1373 branch and then decided it was better off as its own PR, but when I cherry picked onto
master, I discovered that #1360 already had a fix, but #1373 hadn't been rebased againstmaster. Still, this provides more robust checking to ensure that the length is at least as long as it should be to hold the value. This is entirely implemented inDebugbuilds and is entirely removed from the compile inReleasebuilds.This also revealed that the
DebugAssertExceptionhad changed inMicrosoft.NET.Test.Sdk16.6.0 when testing, which replaces the CLRDebugAssertExceptiontype. As such, our exception handling was not treatingDebug.Assert()exceptions correctly according to how Java does. This updates theLuceneTestFrameworkInitializerto correctly set that exception type soDebug.Assert()exceptions are caught when Lucene swallows them and ignored when Lucene ignores them.This also adds a
TestDebugAssertExceptionTypeString()test to detect if theMicrosoft.NET.Test.Sdkcan no longer be found at its current location to help catch any changes to it in the future. However, do note that this test only works inDebugbuilds.