Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Remove contracts from the startup path - #1254

Merged
jkotas merged 1 commit into
dotnet:masterfrom
MichalStrehovsky:contracts
May 8, 2016
Merged

jkotas merged 1 commit into
dotnet:masterfrom
MichalStrehovsky:contracts

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

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.

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);

@jkotas jkotas May 8, 2016 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jkotas

jkotas commented May 8, 2016

Copy link
Copy Markdown
Member

LGTM

@jkotas
jkotas merged commit 11167c5 into dotnet:master May 8, 2016
@MichalStrehovsky
MichalStrehovsky deleted the contracts branch May 8, 2016 18:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants