Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2017-05-30 13:52:03 +0300
committerMarek Safar <marek.safar@gmail.com>2017-05-30 13:52:03 +0300
commite49886bd091487abfbf5de934a451c5a8fe7f4c5 (patch)
tree9be1edce4158baf348d542e25fb8418285b06346 /src/System.IO.FileSystem
parenta50d8c81151fb97996da2fcafd2a97c7f3c8938c (diff)
Revert "Scale back [Serializable] CoreFX types (#19742)"
This reverts commit 6dd451f51451a7d0ceea6104b51bd17005e9a0e6.
Diffstat (limited to 'src/System.IO.FileSystem')
-rw-r--r--src/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs1
-rw-r--r--src/System.IO.FileSystem/src/System/IO/FileInfo.cs1
-rw-r--r--src/System.IO.FileSystem/src/System/IO/FileSystemInfo.cs1
-rw-r--r--src/System.IO.FileSystem/tests/DirectoryInfo/Serialization.cs22
-rw-r--r--src/System.IO.FileSystem/tests/FileInfo/Serialization.cs22
-rw-r--r--src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj1
6 files changed, 48 insertions, 0 deletions
diff --git a/src/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs b/src/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs
index 03c7311565..4b4a274997 100644
--- a/src/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs
+++ b/src/System.IO.FileSystem/src/System/IO/DirectoryInfo.cs
@@ -10,6 +10,7 @@ using System.Runtime.Serialization;
namespace System.IO
{
+ [Serializable]
public sealed partial class DirectoryInfo : FileSystemInfo
{
[System.Security.SecuritySafeCritical]
diff --git a/src/System.IO.FileSystem/src/System/IO/FileInfo.cs b/src/System.IO.FileSystem/src/System/IO/FileInfo.cs
index 8ff606c857..e13fcfe9f5 100644
--- a/src/System.IO.FileSystem/src/System/IO/FileInfo.cs
+++ b/src/System.IO.FileSystem/src/System/IO/FileInfo.cs
@@ -15,6 +15,7 @@ namespace System.IO
{
// Class for creating FileStream objects, and some basic file management
// routines such as Delete, etc.
+ [Serializable]
public sealed partial class FileInfo : FileSystemInfo
{
private String _name;
diff --git a/src/System.IO.FileSystem/src/System/IO/FileSystemInfo.cs b/src/System.IO.FileSystem/src/System/IO/FileSystemInfo.cs
index 31a8432b74..5002a4c828 100644
--- a/src/System.IO.FileSystem/src/System/IO/FileSystemInfo.cs
+++ b/src/System.IO.FileSystem/src/System/IO/FileSystemInfo.cs
@@ -13,6 +13,7 @@ using System.Runtime.Versioning;
namespace System.IO
{
+ [Serializable]
public abstract partial class FileSystemInfo : MarshalByRefObject, ISerializable
{
protected String FullPath; // fully qualified path of the file or directory
diff --git a/src/System.IO.FileSystem/tests/DirectoryInfo/Serialization.cs b/src/System.IO.FileSystem/tests/DirectoryInfo/Serialization.cs
new file mode 100644
index 0000000000..0395821da3
--- /dev/null
+++ b/src/System.IO.FileSystem/tests/DirectoryInfo/Serialization.cs
@@ -0,0 +1,22 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.Serialization.Formatters.Tests;
+using Xunit;
+
+namespace System.IO.Tests
+{
+ public partial class DirectoryInfo_Serialization : FileSystemTest
+ {
+ [Fact]
+ public void SerializeDeserialize_Roundtrip()
+ {
+ var orig = new DirectoryInfo("SomePath");
+ DirectoryInfo cloned = BinaryFormatterHelpers.Clone(orig);
+ Assert.Equal(orig.Name, cloned.Name);
+ Assert.Equal(orig.FullName, cloned.FullName);
+ Assert.Equal(orig.ToString(), cloned.ToString());
+ }
+ }
+}
diff --git a/src/System.IO.FileSystem/tests/FileInfo/Serialization.cs b/src/System.IO.FileSystem/tests/FileInfo/Serialization.cs
new file mode 100644
index 0000000000..275c88ddcd
--- /dev/null
+++ b/src/System.IO.FileSystem/tests/FileInfo/Serialization.cs
@@ -0,0 +1,22 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.Serialization.Formatters.Tests;
+using Xunit;
+
+namespace System.IO.Tests
+{
+ public class FileInfo_Serialization : FileSystemTest
+ {
+ [Fact]
+ public void SerializeDeserialize_Roundtrip()
+ {
+ var orig = new DirectoryInfo("SomePath");
+ DirectoryInfo cloned = BinaryFormatterHelpers.Clone(orig);
+ Assert.Equal(orig.Name, cloned.Name);
+ Assert.Equal(orig.FullName, cloned.FullName);
+ Assert.Equal(orig.ToString(), cloned.ToString());
+ }
+ }
+}
diff --git a/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj b/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
index 02cbadaf0d..7e346d3068 100644
--- a/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
+++ b/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
@@ -18,6 +18,7 @@
<Compile Include="FileInfo\Replace.cs" />
<Compile Include="FileStream\Handle.cs" />
<Compile Include="Directory\GetLogicalDrives.cs" />
+ <Compile Include="DirectoryInfo\Serialization.cs" />
<Compile Include="FileStream\EndRead.cs" />
<Compile Include="FileStream\EndWrite.cs" />
<Compile Include="FileStream\LockUnlock.cs" />