diff --git a/src/libraries/System.IO.FileSystem.Primitives/tests/FileAttributesTests.cs b/src/libraries/System.IO.FileSystem.Primitives/tests/FileAttributesTests.cs index 1820a548e3f11..2612a9dcd3dd0 100644 --- a/src/libraries/System.IO.FileSystem.Primitives/tests/FileAttributesTests.cs +++ b/src/libraries/System.IO.FileSystem.Primitives/tests/FileAttributesTests.cs @@ -11,6 +11,7 @@ public static class FileAttributesTests [Fact] public static void ValueTest() { + Assert.Equal(0x0000, (int)FileAttributes.None); Assert.Equal(0x0001, (int)FileAttributes.ReadOnly); Assert.Equal(0x0002, (int)FileAttributes.Hidden); Assert.Equal(0x0004, (int)FileAttributes.System); diff --git a/src/libraries/System.IO.FileSystem/tests/File/GetSetAttributes_SafeFileHandle.cs b/src/libraries/System.IO.FileSystem/tests/File/GetSetAttributes_SafeFileHandle.cs index f6b72510d2e0d..2ab6eabc3d441 100644 --- a/src/libraries/System.IO.FileSystem/tests/File/GetSetAttributes_SafeFileHandle.cs +++ b/src/libraries/System.IO.FileSystem/tests/File/GetSetAttributes_SafeFileHandle.cs @@ -22,7 +22,7 @@ protected override FileAttributes GetAttributes(string path) using SafeFileHandle fileHandle = OpenFileHandle(path, FileAccess.Read); return File.GetAttributes(fileHandle); } - + protected override void SetAttributes(string path, FileAttributes attributes) { using SafeFileHandle fileHandle = OpenFileHandle(path, FileAccess.ReadWrite); @@ -33,7 +33,7 @@ protected override void SetAttributes(string path, FileAttributes attributes) public void NullArgumentValidation() { Assert.Throws("fileHandle", static () => File.GetAttributes(default(SafeFileHandle)!)); - Assert.Throws("fileHandle", static () => File.SetAttributes(default(SafeFileHandle)!, (FileAttributes)0)); + Assert.Throws("fileHandle", static () => File.SetAttributes(default(SafeFileHandle)!, FileAttributes.None)); } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs index a13ed274b7e64..3076be747961a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Enumeration/FileSystemEnumerator.Unix.cs @@ -129,7 +129,7 @@ public bool MoveNext() } } - if (!isSpecialDirectory && _options.AttributesToSkip != 0) + if (!isSpecialDirectory && _options.AttributesToSkip != FileAttributes.None) { // entry.IsHidden and entry.IsReadOnly will hit the disk if the caches had not been // initialized yet and we could not soft-retrieve the attributes in Initialize diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileAttributes.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileAttributes.cs index 9c31d04b3e778..e8c25ea9445ec 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileAttributes.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileAttributes.cs @@ -6,6 +6,7 @@ namespace System.IO [Flags] public enum FileAttributes { + None = 0x0000, ReadOnly = 0x0001, Hidden = 0x0002, System = 0x0004, diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 93aae0a85eb3b..03b8b7f4a55ed 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -9746,6 +9746,7 @@ public enum FileAccess [System.FlagsAttribute] public enum FileAttributes { + None = 0, ReadOnly = 1, Hidden = 2, System = 4, diff --git a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/EnumConverterTests.cs b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/EnumConverterTests.cs index 38db85aaf8b53..ff06d27d43759 100644 --- a/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/EnumConverterTests.cs +++ b/src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/EnumConverterTests.cs @@ -186,8 +186,8 @@ public void ConvertFileAttributes(bool useGenericVariant) options); Assert.Equal(@"""directory, compressed, integrity_stream""", json); - json = JsonSerializer.Serialize(FileAttributes.Compressed & FileAttributes.Device, options); - Assert.Equal(@"0", json); + json = JsonSerializer.Serialize((FileAttributes)(-1), options); + Assert.Equal(@"-1", json); json = JsonSerializer.Serialize(FileAttributes.Directory & FileAttributes.Compressed | FileAttributes.IntegrityStream, options); Assert.Equal(@"""integrity_stream""", json);