From 5f13fa0343276ff7dfb376eddc24f82561db36a9 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Tue, 29 Dec 2015 20:11:39 +0000 Subject: [PATCH] Fix serialization of custom exceptions. --- OpenRA.Game/FieldLoader.cs | 9 +++++++++ OpenRA.Mods.Common/Commands/DevCommands.cs | 1 + OpenRA.Utility/Program.cs | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/OpenRA.Game/FieldLoader.cs b/OpenRA.Game/FieldLoader.cs index 61ea993c39..7bd075e9f8 100644 --- a/OpenRA.Game/FieldLoader.cs +++ b/OpenRA.Game/FieldLoader.cs @@ -16,6 +16,7 @@ using System.Drawing.Imaging; using System.Globalization; using System.Linq; using System.Reflection; +using System.Runtime.Serialization; using System.Text.RegularExpressions; using OpenRA.Graphics; using OpenRA.Primitives; @@ -24,6 +25,7 @@ namespace OpenRA { public static class FieldLoader { + [Serializable] public class MissingFieldsException : YamlException { public readonly string[] Missing; @@ -42,6 +44,13 @@ namespace OpenRA Header = missing.Length > 1 ? header : headerSingle ?? header; Missing = missing; } + + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + base.GetObjectData(info, context); + info.AddValue("Missing", Missing); + info.AddValue("Header", Header); + } } public static Func InvalidValueAction = (s, t, f) => diff --git a/OpenRA.Mods.Common/Commands/DevCommands.cs b/OpenRA.Mods.Common/Commands/DevCommands.cs index dff76295e9..7e2e4bad79 100644 --- a/OpenRA.Mods.Common/Commands/DevCommands.cs +++ b/OpenRA.Mods.Common/Commands/DevCommands.cs @@ -125,6 +125,7 @@ namespace OpenRA.Mods.Common.Commands world.IssueOrder(new Order(command, world.LocalPlayer.PlayerActor, false)); } + [Serializable] class DevException : Exception { } } } diff --git a/OpenRA.Utility/Program.cs b/OpenRA.Utility/Program.cs index 9c9cf976ab..82304cdeff 100644 --- a/OpenRA.Utility/Program.cs +++ b/OpenRA.Utility/Program.cs @@ -11,9 +11,11 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; namespace OpenRA.Utility { + [Serializable] public class NoSuchCommandException : Exception { public readonly string Command; @@ -22,6 +24,12 @@ namespace OpenRA.Utility { Command = command; } + + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + base.GetObjectData(info, context); + info.AddValue("Command", Command); + } } class Program