This repository was archived by the owner on Nov 13, 2026. It is now read-only.
Repository navigation
Remove contracts from the startup path - #1254
Merged
Merged
Conversation
Seems like the reason for using `Contract.Assert` instead of `Debug.Assert` in the startup path was that `Debug.Assert` won't work because it's not low level enough (needs `String.Empty` to work). `Contract.Assert` is still problematic when the condition is not met. The right solution is to actually define a lower level Assert.
| { | ||
| Contract.Assert(count >= 0); | ||
| Contract.Assert(bytes != null); | ||
| Debug.Assert(count >= 0); |
Member
There was a problem hiding this comment.
I guess this used Contract.Assert because of the regular System.Private.CoreLib\src\System\Text\UTF8Encoding.cs that this was derived from used it. Changing it to Debug.Assert sounds good.
Member
|
LGTM |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Seems like the reason for using
Contract.Assertinstead ofDebug.Assertin the startup path was thatDebug.Assertwon't workbecause it's not low level enough (needs
String.Emptyto work).Contract.Assertis still problematic when the condition is not met.The right solution is to actually define a lower level Assert.