Skip to content

Commit b4317d9

Browse files
committed
Bugfix for #553 #544
1 parent 303e49f commit b4317d9

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

src/InstagramApiSharp/Classes/Models/Challenge/ChallengeRequireVerifyMethod.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Newtonsoft.Json;
1111
namespace InstagramApiSharp.Classes
1212
{
13+
[System.Serializable]
1314
public class InstaChallengeRequireVerifyMethod
1415
{
1516
[JsonProperty("step_name")]
@@ -28,6 +29,7 @@ public class InstaChallengeRequireVerifyMethod
2829
public bool SubmitPhoneRequired => StepName == "submit_phone";
2930
}
3031

32+
[System.Serializable]
3133
public class InstaChallengeRequireStepData
3234
{
3335
[JsonProperty("choice")]

src/InstagramApiSharp/Classes/Models/Challenge/InstaChallengeLoginInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace InstagramApiSharp.Classes
1313
{
14+
[System.Serializable]
1415
public class InstaChallengeLoginInfo
1516
{
1617
[JsonProperty("url")]

src/InstagramApiSharp/Classes/ResponseWrappers/Login/TwoFactorLoginInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace InstagramApiSharp.Classes
44
{
5+
[System.Serializable]
56
public class InstaTwoFactorLoginInfo
67
{
78
[JsonProperty("obfuscated_phone_number")]

src/InstagramApiSharp/Classes/ResponseWrappers/Other/PhoneVerificationSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace InstagramApiSharp.Classes
1313
{
14+
[System.Serializable]
1415
public class InstaPhoneVerificationSettings
1516
{
1617
[JsonProperty("max_sms_count")] public string MaxSmsCount { get; set; }

src/InstagramApiSharp/Helpers/SerializationHelper.cs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
using Newtonsoft.Json;
22
using System.IO;
33
using System.Runtime.Serialization;
4-
using System.Text;
5-
#if !WINDOWS_UWP
4+
using InstagramApiSharp.Classes;
5+
using System;
6+
#if NETFRAMEWORK || NETSTANDARD
67
using System.Runtime.Serialization.Formatters.Binary;
8+
#else
9+
using System.Text;
710
#endif
811
namespace InstagramApiSharp.Helpers
912
{
@@ -12,8 +15,11 @@ internal class SerializationHelper
1215
public static Stream SerializeToStream(object o)
1316
{
1417
var stream = new MemoryStream();
15-
#if !WINDOWS_UWP
16-
IFormatter formatter = new BinaryFormatter();
18+
#if NETFRAMEWORK || NETSTANDARD
19+
IFormatter formatter = new BinaryFormatter
20+
{
21+
Binder = new BinaryFormatterSerializationBinder()
22+
};
1723
formatter.Serialize(stream, o);
1824
stream.Position = 0;
1925
#else
@@ -26,8 +32,11 @@ public static Stream SerializeToStream(object o)
2632

2733
public static T DeserializeFromStream<T>(Stream stream)
2834
{
29-
#if !WINDOWS_UWP
30-
IFormatter formatter = new BinaryFormatter();
35+
#if NETFRAMEWORK || NETSTANDARD
36+
IFormatter formatter = new BinaryFormatter
37+
{
38+
Binder = new BinaryFormatterSerializationBinder()
39+
};
3140
stream.Seek(0, SeekOrigin.Begin);
3241
return (T)formatter.Deserialize(stream);
3342
#else
@@ -45,4 +54,15 @@ public static T DeserializeFromString<T>(string json)
4554
return JsonConvert.DeserializeObject<T>(json);
4655
}
4756
}
57+
#if NETFRAMEWORK || NETSTANDARD
58+
class BinaryFormatterSerializationBinder : SerializationBinder
59+
{
60+
public override Type BindToType(string assemblyName, string typeName)
61+
{
62+
if (typeName.Equals(typeof(StateData).FullName))
63+
return typeof(StateData);
64+
return null;
65+
}
66+
}
67+
#endif
4868
}

0 commit comments

Comments
 (0)