Skip to content

Commit

Permalink
Merge 09724ea into 7c21cd8
Browse files Browse the repository at this point in the history
  • Loading branch information
GintasS committed Jul 8, 2021
2 parents 7c21cd8 + 09724ea commit f5c663c
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions GitCommands/CommitTemplateItem.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Drawing;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using GitCommands.Utils;

namespace GitCommands
Expand Down Expand Up @@ -81,42 +79,7 @@ private static string SerializeCommitTemplates(CommitTemplateItem[]? items)
// do nothing
}

if (commitTemplateItem is null)
{
try
{
int p = serializedString.IndexOf(':');
int length = Convert.ToInt32(serializedString.Substring(0, p));

byte[] memoryData = Convert.FromBase64String(serializedString.Substring(p + 1));
using MemoryStream rs = new(memoryData, 0, length);
#pragma warning disable SYSLIB0011 // Type or member is obsolete
BinaryFormatter sf = new() { Binder = new MoveNamespaceDeserializationBinder() };
commitTemplateItem = (CommitTemplateItem[])sf.Deserialize(rs);
#pragma warning restore SYSLIB0011 // Type or member is obsolete

shouldBeUpdated = true;
}
catch
{
return null;
}
}

return commitTemplateItem;
}
}

public sealed class MoveNamespaceDeserializationBinder : SerializationBinder
{
private const string OldNamespace = "GitUI.CommandsDialogs.CommitDialog";
private const string NewNamespace = "GitCommands";

public override Type? BindToType(string assemblyName, string typeName)
{
typeName = typeName.Replace(OldNamespace, NewNamespace);

return Type.GetType($"{typeName}, {assemblyName}");
}
}
}

0 comments on commit f5c663c

Please sign in to comment.