Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Replace Contract.Requires with Debug.Assert #11600

Merged
merged 2 commits into from Sep 11, 2016

Conversation

benaadams
Copy link
Member

@benaadams benaadams commented Sep 11, 2016

See: #11596

@@ -535,7 +535,7 @@ private static void CheckBaseAddress(Uri baseAddress, string parameterName)

private void SetTimeout(CancellationTokenSource cancellationTokenSource)
{
Contract.Requires(cancellationTokenSource != null);
Debug.Assert(cancellationTokenSource != null);
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove the using imports for System.Diagnostics.Contracts in some of these files where Contract.Assert was the only use of contracts?

Copy link
Member Author

Choose a reason for hiding this comment

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

In my first pass I removed the using and project.json entries for them all; but it got a bit upset... As there were other uses.

Will make another pass.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we can't for all of them, as there are other uses of Contract still, like Contract.Ensure, Contract.End*, etc.

Copy link
Member Author

@benaadams benaadams Sep 11, 2016

Choose a reason for hiding this comment

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

Removed the usings

@stephentoub
Copy link
Member

A few comments, but otherwise LGTM. I admit I'm surprised to see the CI legs passing; I was expecting at least a few of the contracts would have been stale enough to cause a failure.

@benaadams benaadams force-pushed the contracts branch 2 times, most recently from f77b655 to fcd2f83 Compare September 11, 2016 19:07
@benaadams
Copy link
Member Author

Removed the usings; tried to remove the unneeded references but its quite tricky - might need an automated process.

@stephentoub
Copy link
Member

Thanks, Ben.

@@ -745,7 +745,7 @@ public override int Read([In, Out] Byte[] array, Int32 offset, Int32 count)
Task semaphoreLockTask, bool useApmPattern) {

// Same conditions validated with exceptions in ReadAsync:
// (These should be Contract.Requires(..) but that method had some issues in async methods; using Assert(..) for now.)
// (These should be Debug.Assert(..) but that method had some issues in async methods; using Assert(..) for now.)
Copy link
Member

Choose a reason for hiding this comment

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

This comment no longer makes sense. It can just be deleted.

@stephentoub
Copy link
Member

stephentoub commented Sep 11, 2016

Two remaining nits, otherwise LGTM. Thanks, @benaadams. Since CI is green, including with multiple outer loop runs, I'll merge and then fix the comments nits separately.

@stephentoub stephentoub merged commit 3c0e848 into dotnet:master Sep 11, 2016
@benaadams benaadams deleted the contracts branch September 11, 2016 23:13
@karelz karelz modified the milestone: 1.2.0 Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Replace Contract.Requires with Debug.Assert
* Remove unnessary Diagnostics.Contracts usings

Commit migrated from dotnet/corefx@3c0e848
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants