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

[API Proposal]: FileSystemGlobbing FilePatternMatch.Index #65371

Open
CheloXL opened this issue Feb 15, 2022 · 2 comments
Open

[API Proposal]: FileSystemGlobbing FilePatternMatch.Index #65371

CheloXL opened this issue Feb 15, 2022 · 2 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.IO
Milestone

Comments

@CheloXL
Copy link

CheloXL commented Feb 15, 2022

Background and motivation

I need to know which include pattern actually matches the FilePatternMatch returned matcher.Execute.

I'm proposing to add an additional property, Index, to the FilePatternMatch, that would be the index where that pattern was added.

With this information, I'm able to know the original pattern.

API Proposal

namespace Microsoft.Extensions.FileSystemGlobbing
{
    public struct FilePatternMatch : IEquatable<FilePatternMatch>
    {
        ...
        public int Index { get; }
        ...
    }
}

API Usage

var result = matcher.Execute(...);
foreach (var match in result.Files)
{
    Console.WriteLine(match.Index);
}

Alternative Designs

Another option could be to simply add a Pattern property, that would hold the original pattern. Not sure which one is best, since FilePatternMatch is a struct (in memory terms).

Risks

This is not a breaking change (it only extends the api), nor I'm aware of any performance regressions this could cause.

@CheloXL CheloXL added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Feb 15, 2022
@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.IO untriaged New issue has not been triaged by the area owner labels Feb 15, 2022
@ghost
Copy link

ghost commented Feb 15, 2022

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

Issue Details

Background and motivation

I need to know which include pattern actually matches the FilePatternMatch returned matcher.Execute.

I'm proposing to add an additional property, Index, to the FilePatternMatch, that would be the index where that pattern was added.

With this information, I'm able to know the original pattern.

API Proposal

namespace Microsoft.Extensions.FileSystemGlobbing
{
    public struct FilePatternMatch : IEquatable<FilePatternMatch>
    {
        ...
        public int Index { get; }
        ...
    }
}

API Usage

var result = matcher.Execute(...);
foreach (var match in result.Files)
{
    Console.WriteLine(match.Index);
}

Alternative Designs

Another option could be to simply add a Pattern property, that would hold the original pattern. Not sure which one is best, since FilePatternMatch is a struct (in memory terms).

Risks

This is not a breaking change (it only extends the api), nor I'm aware of any performance regressions this could cause.

Author: CheloXL
Assignees: -
Labels:

api-suggestion, area-System.IO, untriaged

Milestone: -

@jozkee
Copy link
Member

jozkee commented Mar 8, 2022

An Index wouldn't be very useful as Matcher doesn't expose the include patterns. Including the Pattern in FilePatternMatch makes more sense to me.
There's an open request for improving Globbing in .NET (#21362), I think this proposal should be considered as part of that effort.

@jozkee jozkee removed the untriaged New issue has not been triaged by the area owner label Mar 8, 2022
@jozkee jozkee added this to the Future milestone Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.IO
Projects
None yet
Development

No branches or pull requests

2 participants