invalidate state when directory is created (dotnet/corefx#40677)
authorTomas Weinfurt <tweinfurt@yahoo.com>
Thu, 19 Sep 2019 17:38:41 +0000 (10:38 -0700)
committerGitHub <noreply@github.com>
Thu, 19 Sep 2019 17:38:41 +0000 (10:38 -0700)
Commit migrated from https://github.com/dotnet/corefx/commit/a3bf1eaff8819262e9308a94a59277df95fed6b7

src/libraries/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs
src/libraries/System.IO.FileSystem/tests/DirectoryInfo/Create.cs

index 69e0eb1..d9de6da 100644 (file)
@@ -92,7 +92,11 @@ namespace System.IO
             throw new ArgumentException(SR.Format(SR.Argument_InvalidSubPath, path, FullPath), nameof(path));
         }
 
-        public void Create() => FileSystem.CreateDirectory(FullPath);
+        public void Create()
+        {
+            FileSystem.CreateDirectory(FullPath);
+            Invalidate();
+        }
 
         // Returns an array of Files in the DirectoryInfo specified by path
         public FileInfo[] GetFiles() => GetFiles("*", enumerationOptions: EnumerationOptions.Compatible);
index a32615f..3eef2db 100644 (file)
@@ -74,5 +74,14 @@ namespace System.IO.Tests
             DirectoryInfo testInfo = new DirectoryInfo(testDir + extension + trailing);
             Assert.Equal(trailing, testInfo.Extension);
         }
+
+        [Fact]
+        public void CreateDirectoryWithAttributes()
+        {
+            string testDir = Path.Combine(GetTestFilePath(), "CreateDirectoryWithAttributes");
+            DirectoryInfo testInfo = new DirectoryInfo(testDir);
+            testInfo.Create();
+            testInfo.Attributes = FileAttributes.Directory | FileAttributes.Normal;
+        }
     }
 }