Skip to content

Commit a820a51

Browse files
committed
added arg validation to debug bridge issue and bumped version
1 parent 943037e commit a820a51

File tree

6 files changed

+36
-13
lines changed

6 files changed

+36
-13
lines changed

Shared/AssemblyInfo.Version.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
using System.Runtime.CompilerServices;
33
using System.Runtime.InteropServices;
44

5-
[assembly: AssemblyVersion("3.4.3.0")]
5+
[assembly: AssemblyVersion("3.4.4.0")]

Squiggle.Bridge/BridgeHost.cs

+2
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ public void SendChatMessage(bool local, IPEndPoint target, Core.Chat.Transport.M
131131

132132
public void SendPresenceMessage(IPEndPoint target, byte[] message)
133133
{
134+
Validator.IsNotNull(target, "target");
135+
Validator.IsNotNull(message, "message");
134136
Send(target, new ForwardPresenceMessage() { BridgeEndPoint = externalEndPoint, Message = message});
135137
}
136138

Squiggle.Utilities/Net/Pipe/UnicastMessagePipe.cs

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ protected override NetMQSocket CreateListener()
2727

2828
public void Send(IPEndPoint target, byte[] message)
2929
{
30+
Validator.IsNotNull(target, "target");
31+
Validator.IsNotNull(message, "message");
3032
Send(target.Address.ToString(), target.Port, message);
3133
}
3234

Squiggle.Utilities/Serialization/SerializationHelper.cs

+13-12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.IO;
66
using ProtoBuf.Meta;
77
using System.Runtime.Serialization;
8+
using System.Diagnostics;
89

910
namespace Squiggle.Utilities.Serialization
1011
{
@@ -20,28 +21,28 @@ public static byte[] Serialize<T>(T item)
2021
var stream = new MemoryStream();
2122
ProtoBuf.Serializer.Serialize<T>(stream, item);
2223
return stream.ToArray();
23-
}
24-
25-
public static T Deserialize<T>(byte[] data)
26-
{
27-
if (data == null)
28-
throw new ArgumentNullException("data");
29-
30-
var stream = new MemoryStream(data);
31-
T item = ProtoBuf.Serializer.Deserialize<T>(stream);
32-
return item;
33-
}
24+
}
3425

3526
public static void Deserialize<T>(byte[] data, Action<T> onDeserialize, string entityName) where T:class
3627
{
3728
T obj = null;
3829
if (ExceptionMonster.EatTheException(() =>
3930
{
4031
obj = SerializationHelper.Deserialize<T>(data);
41-
}, "deserializing " + entityName))
32+
}, "deserializing " + entityName + " of type " + typeof(T).Name))
4233
{
4334
onDeserialize(obj);
4435
}
4536
}
37+
38+
static T Deserialize<T>(byte[] data)
39+
{
40+
if (data == null)
41+
throw new ArgumentNullException("data");
42+
43+
var stream = new MemoryStream(data);
44+
T item = ProtoBuf.Serializer.Deserialize<T>(stream);
45+
return item;
46+
}
4647
}
4748
}

Squiggle.Utilities/Squiggle.Utilities.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
<Compile Include="TimeExtensions.cs" />
107107
<Compile Include="Application\UserActivityMonitor.cs" />
108108
<Compile Include="Application\WinStartup.cs" />
109+
<Compile Include="Validator.cs" />
109110
</ItemGroup>
110111
<ItemGroup>
111112
<None Include="packages.config" />

Squiggle.Utilities/Validator.cs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace System
8+
{
9+
public static class Validator
10+
{
11+
public static void IsNotNull(object value, string name)
12+
{
13+
if (value == null)
14+
throw new ArgumentNullException(name);
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)