-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Prashanth Govindarajan
committed
Apr 9, 2021
1 parent
629ad50
commit f3e6d94
Showing
10 changed files
with
119 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...System.Configuration.ConfigurationManager/src/System/Configuration/SettingsSerializeAs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ration.ConfigurationManager/tests/System/Configuration/BinaryFormatterDeprecationTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Configuration; | ||
using Microsoft.DotNet.RemoteExecutor; | ||
using Xunit; | ||
|
||
namespace System.ConfigurationTests | ||
{ | ||
public class BinaryFormatterDeprecationTests | ||
{ | ||
private static bool AreBinaryFormatterAndRemoteExecutorSupportedOnThisPlatform => PlatformDetection.IsBinaryFormatterSupported && RemoteExecutor.IsSupported; | ||
|
||
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "SettingsSerializeAs.Binary is deprecated only on Core")] | ||
[Fact] | ||
public void ThrowOnSettingsPropertyConstructorWithSettingsSerializeAsBinary() | ||
{ | ||
#pragma warning disable CS0618 // Type or member is obsolete | ||
Assert.Throws<NotSupportedException>(() => new SettingsProperty("Binary", typeof(byte[]), null, false,"AString", SettingsSerializeAs.Binary, new SettingsAttributeDictionary(), true, true)); | ||
#pragma warning restore CS0618 // Type or member is obsolete | ||
} | ||
|
||
[ConditionalFact(nameof(AreBinaryFormatterAndRemoteExecutorSupportedOnThisPlatform))] | ||
public void SerializeAndDeserializeWithSettingsSerializeAsBinary() | ||
{ | ||
RemoteInvokeOptions options = new RemoteInvokeOptions(); | ||
options.RuntimeConfigurationOptions.Add("System.Configuration.ConfigurationManager.EnableUnsafeBinaryFormatterInPropertyValueSerialization", bool.TrueString); | ||
RemoteExecutor.Invoke(() => | ||
{ | ||
#pragma warning disable CS0618 // Type or member is obsolete | ||
SettingsProperty property = new SettingsProperty("Binary", typeof(string), null, false, "AString", SettingsSerializeAs.Binary, new SettingsAttributeDictionary(), true, true); | ||
#pragma warning restore CS0618 // Type or member is obsolete | ||
SettingsPropertyValue value = new SettingsPropertyValue(property); | ||
value.PropertyValue = "AString"; // To force _changedSinceLastSerialized to true to allow for serialization in the next call | ||
object serializedValue = value.SerializedValue; | ||
Assert.NotNull(serializedValue); | ||
value.Deserialized = false; | ||
object deserializedValue = value.PropertyValue; | ||
Assert.Equal("AString", deserializedValue); | ||
}, options).Dispose(); | ||
} | ||
} | ||
} |