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]: Add FileAttributes.None #83125

Closed
meziantou opened this issue Mar 8, 2023 · 5 comments · Fixed by #89130
Closed

[API Proposal]: Add FileAttributes.None #83125

meziantou opened this issue Mar 8, 2023 · 5 comments · Fixed by #89130
Assignees
Labels
api-approved API was approved in API review, it can be implemented area-System.IO good first issue Issue should be easy to implement, good for first-time contributors help wanted [up-for-grabs] Good issue for external contributors
Milestone

Comments

@meziantou
Copy link
Contributor

Background and motivation

Similar to #79868, but for System.IO.FileAttributes.

One use-case for the 0 value is when enumerating files. 0 allows to not exclude files from enumeration based on their attributes.

new System.IO.EnumerationOptions()
{
    AttributesToSkip = 0,
}

API Proposal

namespace System.IO;

[System.Flags]
public enum FileAttributes
{
    None = 0,

    // Existing values:
    // ReadOnly
    // Hidden
    // ...

API Usage

Directory.EnumerateFiles("folder", "*", new System.IO.EnumerationOptions()
{
    AttributesToSkip = FileAttributes.None,
});

Could also be used in

if (!isSpecialDirectory && _options.AttributesToSkip != 0)

Alternative Designs

No response

Risks

No response

@meziantou meziantou added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Mar 8, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Mar 8, 2023
@ghost
Copy link

ghost commented Mar 8, 2023

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

Similar to #79868, but for System.IO.FileAttributes.

One use-case for the 0 value is when enumerating files. 0 allows to not exclude files from enumeration based on their attributes.

new System.IO.EnumerationOptions()
{
    AttributesToSkip = 0,
}

API Proposal

namespace System.IO;

[System.Flags]
public enum FileAttributes
{
    None = 0,

    // Existing values:
    // ReadOnly
    // Hidden
    // ...

API Usage

Directory.EnumerateFiles("folder", "*", new System.IO.EnumerationOptions()
{
    AttributesToSkip = FileAttributes.None,
});

Could also be used in

if (!isSpecialDirectory && _options.AttributesToSkip != 0)

Alternative Designs

No response

Risks

No response

Author: meziantou
Assignees: -
Labels:

api-suggestion, area-System.IO

Milestone: -

@Jozkee
Copy link
Member

Jozkee commented Mar 8, 2023

Directory.EnumerateFiles("folder", "*", new System.IO.EnumerationOptions()
{
    AttributesToSkip = FileAttributes.None,
});

Could this skip files without attributes?

@meziantou
Copy link
Contributor Author

meziantou commented Mar 8, 2023

Could this skip files without attributes?

The current implementation skips the check for specific attributes when it's set to 0. I'm not sure we want to change this behavior.

@adamsitnik adamsitnik added api-ready-for-review API is ready for review, it is NOT ready for implementation and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation untriaged New issue has not been triaged by the area owner labels May 19, 2023
@adamsitnik adamsitnik self-assigned this May 19, 2023
@adamsitnik
Copy link
Member

LGTM as proposed, I am going to present it for the API Review Board.

@terrajobst
Copy link
Member

terrajobst commented Jul 18, 2023

Video

  • Looks good as proposed
    • Users might be confused by None vs Normal but we believe it's Not A Big Deal™️.
namespace System.IO;

[System.Flags]
public enum FileAttributes
{
    None = 0,
    // Existing members omitted
}

@terrajobst terrajobst added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for review, it is NOT ready for implementation labels Jul 18, 2023
@adamsitnik adamsitnik removed their assignment Jul 18, 2023
@adamsitnik adamsitnik added good first issue Issue should be easy to implement, good for first-time contributors help wanted [up-for-grabs] Good issue for external contributors labels Jul 18, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 18, 2023
@adamsitnik adamsitnik added this to the 8.0.0 milestone Jul 31, 2023
@ghost ghost added in-pr There is an active PR which will close this issue when it is merged and removed in-pr There is an active PR which will close this issue when it is merged labels Aug 1, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 2, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Sep 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-System.IO good first issue Issue should be easy to implement, good for first-time contributors help wanted [up-for-grabs] Good issue for external contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants