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

Added missing contracts in Directory class. #251

Merged
merged 1 commit into from
Oct 5, 2015
Merged

Added missing contracts in Directory class. #251

merged 1 commit into from
Oct 5, 2015

Conversation

fedotovalex
Copy link
Contributor

This fixes #249.

Adds contracts for:

  • Directory.GetFileSystemEntries(string, string, SearchOption)
  • Directory.GetFiles(string, string, SearchOption)
  • Directory.GetDirectories(string, string, SearchOption)

Contract.Requires(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);
Contract.Ensures(Contract.Result<string[]>() != null);
Contract.Ensures(Contract.ForAll(Contract.Result<string[]>(), file => file != null));
Contract.EnsuresOnThrow<System.IO.IOException>(true, @"path is a file name.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this message is correct? It seems slightly misleading to me because it doesn't tell what the error type is...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, that's what MSDN says, although honestly I just copied and pasted this part without much thinking. Looking closer, I'm not sure if there is much value in adding EnsuresOnThrow in this form.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah.. This stuff looked weird for me as well, but then I've searched thought this repo and found that this is a canonical way to express possible exceptions.

My point was more about the message that is absolutely unclear, but because the official documentation is saying that, I'm not sure what we can do. I would prefer to have more clear message but have no idea what this message should looks like.

@SergeyTeplyakov
Copy link
Contributor

Everything is looks good for me...

@yaakov-h
Copy link
Contributor

Oh thanks! 😄 I was going to attempt this myself, but got stuck fighting a Git-vs-Line-Endings war.

SergeyTeplyakov added a commit that referenced this pull request Oct 5, 2015
Added missing contracts in Directory class.
@SergeyTeplyakov SergeyTeplyakov merged commit b2021fb into microsoft:master Oct 5, 2015
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.

No Contracts for Directory.GetFiles(String, String, SearchOption)
3 participants