Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The GetFiles overload with a predicate doesn't work properly #981

Closed
thomaslevesque opened this issue Jun 10, 2016 · 2 comments
Closed

The GetFiles overload with a predicate doesn't work properly #981

thomaslevesque opened this issue Jun 10, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@thomaslevesque
Copy link
Contributor

What You Are Seeing?

The GetFiles overload with a predicate doesn't pass the file to the predicate, but its parent folder.

What is Expected?

The predicate should receive the file, as specified in the documentation:

predicate
Type: Func<IFileSystemInfo,​ bool>
The predicate used to filter files based on file system information.

What version of Cake are you using?

Version 0.11.0+Branch.main.Sha.f67efd089db717c4e67bf0e32a9003cd90f67620

Are you running on a 32 or 64 bit system?

64bit

What environment are you running on? Windows? Linux? Mac?

Windows 8.1

Are you running on a CI Server? If so, which one?

No

@thomaslevesque
Copy link
Contributor Author

Looking at the code, it seems to be a documentation issue rather than a bug... GlobbingAliases.GetFiles accepts a Func<IFileSystemInfo, bool> and passes it to IGlobber.Match, but IGlobber.Match actually accepts a Func<IDirectory, bool>. Because of contravariance, a Func<IFileSystemInfo, bool> is a valid Func<IDirectory, bool>, but the signature of GetFiles seems to imply that the predicate will receive either files or directories, when it will actually receive only directories.

Looking at the doc, my understanding was that the predicate was a filter applied to the items found during the scan; but actually it's a filter on which directories will be scanned. The doc should be updated to make that clear.

(for my use case, what I really needed was Linq's Where method, but when I saw an overload of GetFiles with a predicate, I tried to use it instead)

@patriksvensson
Copy link
Member

@thomaslevesque Great catch! We should get this fixed ASAP.

@patriksvensson patriksvensson added this to the v0.14.0 milestone Jun 10, 2016
@gep13 gep13 modified the milestones: v0.14.0, v0.15.0 Jun 28, 2016
@patriksvensson patriksvensson self-assigned this Jul 20, 2016
@gep13 gep13 added the Bug label Jul 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants