public void SerializeDeserialize() { InvalidProjectFileException e = new InvalidProjectFileException( "projectFile", 1, 2, 3, 4, "message", "errorSubcategory", "errorCode", "helpKeyword"); using (MemoryStream memstr = new MemoryStream()) { BinaryFormatter frm = new BinaryFormatter(); frm.Serialize(memstr, e); memstr.Position = 0; InvalidProjectFileException e2 = (InvalidProjectFileException)frm.Deserialize(memstr); Assert.Equal(e.ColumnNumber, e2.ColumnNumber); Assert.Equal(e.EndColumnNumber, e2.EndColumnNumber); Assert.Equal(e.EndLineNumber, e2.EndLineNumber); Assert.Equal(e.ErrorCode, e2.ErrorCode); Assert.Equal(e.ErrorSubcategory, e2.ErrorSubcategory); Assert.Equal(e.HasBeenLogged, e2.HasBeenLogged); Assert.Equal(e.HelpKeyword, e2.HelpKeyword); Assert.Equal(e.LineNumber, e2.LineNumber); Assert.Equal(e.Message, e2.Message); Assert.Equal(e.ProjectFile, e2.ProjectFile); } }
/// <summary> /// Creates an instance of this exception using the specified error message and inner invalid project file exception. /// This is used in order to wrap and exception rather than rethrow it verbatim, which would reset the callstack. /// The assumption is that all the metadata for the outer exception comes from the inner exception, eg., they have the same error code. /// </summary> internal InvalidProjectFileException(string message, InvalidProjectFileException innerException) : this(innerException.ProjectFile, innerException.LineNumber, innerException.ColumnNumber, innerException.EndLineNumber, innerException.EndColumnNumber, message, innerException.ErrorSubcategory, innerException.ErrorCode, innerException.HelpKeyword) { }
/// <summary> /// Creates an instance of this exception using the specified error message and inner invalid project file exception. /// This is used in order to wrap and exception rather than rethrow it verbatim, which would reset the callstack. /// The assumption is that all the metadata for the outer exception comes from the inner exception, eg., they have the same error code. /// </summary> internal InvalidProjectFileException(string message, InvalidProjectFileException innerException) : this(innerException.ProjectFile, innerException.LineNumber, innerException.ColumnNumber, innerException.EndLineNumber, innerException.EndColumnNumber, message, innerException.ErrorSubcategory, innerException.ErrorCode, innerException.HelpKeyword) { }