From 0fbc50d52e5b4c49f442fb0f53b184cbbf60004d Mon Sep 17 00:00:00 2001 From: Sergei Pavlov Date: Thu, 4 Jan 2024 20:44:26 -0800 Subject: [PATCH] Get rid of `Xtensive.Core.AggregateException` type --- .../Indexing/ForeignKeyInfoTest.cs | 1 + .../Indexing/PrimaryIndexInfoTest.cs | 1 - .../Indexing/SecondaryIndexInfoTest.cs | 1 - .../Indexing/StorageInfoTest.cs | 1 - .../Core/Exceptions/AggregateException.cs | 165 ------------------ 5 files changed, 1 insertion(+), 168 deletions(-) delete mode 100644 Orm/Xtensive.Orm/Core/Exceptions/AggregateException.cs diff --git a/Orm/Xtensive.Orm.Tests/Indexing/ForeignKeyInfoTest.cs b/Orm/Xtensive.Orm.Tests/Indexing/ForeignKeyInfoTest.cs index 89b023b30e..7e48cd77c6 100644 --- a/Orm/Xtensive.Orm.Tests/Indexing/ForeignKeyInfoTest.cs +++ b/Orm/Xtensive.Orm.Tests/Indexing/ForeignKeyInfoTest.cs @@ -4,6 +4,7 @@ // Created by: Ivan Galkin // Created: 2009.03.23 +using System; using Xtensive.Core; using Xtensive.Orm; using Xtensive.Orm.Upgrade.Model; diff --git a/Orm/Xtensive.Orm.Tests/Indexing/PrimaryIndexInfoTest.cs b/Orm/Xtensive.Orm.Tests/Indexing/PrimaryIndexInfoTest.cs index 7e1901b962..cd82df5ef0 100644 --- a/Orm/Xtensive.Orm.Tests/Indexing/PrimaryIndexInfoTest.cs +++ b/Orm/Xtensive.Orm.Tests/Indexing/PrimaryIndexInfoTest.cs @@ -11,7 +11,6 @@ using Xtensive.Core; using Xtensive.Orm.Tests; using Xtensive.Orm.Upgrade.Model; -using AggregateException = Xtensive.Core.AggregateException; namespace Xtensive.Orm.Tests.Indexing { diff --git a/Orm/Xtensive.Orm.Tests/Indexing/SecondaryIndexInfoTest.cs b/Orm/Xtensive.Orm.Tests/Indexing/SecondaryIndexInfoTest.cs index adf2089c20..30028754f4 100644 --- a/Orm/Xtensive.Orm.Tests/Indexing/SecondaryIndexInfoTest.cs +++ b/Orm/Xtensive.Orm.Tests/Indexing/SecondaryIndexInfoTest.cs @@ -10,7 +10,6 @@ using Xtensive.Core; using Xtensive.Orm.Tests; using Xtensive.Orm.Upgrade.Model; -using AggregateException = Xtensive.Core.AggregateException; namespace Xtensive.Orm.Tests.Indexing { diff --git a/Orm/Xtensive.Orm.Tests/Indexing/StorageInfoTest.cs b/Orm/Xtensive.Orm.Tests/Indexing/StorageInfoTest.cs index 40c59b0805..4fb69efd34 100644 --- a/Orm/Xtensive.Orm.Tests/Indexing/StorageInfoTest.cs +++ b/Orm/Xtensive.Orm.Tests/Indexing/StorageInfoTest.cs @@ -10,7 +10,6 @@ using Xtensive.Orm.Tests; using Xtensive.Modelling.Actions; using Xtensive.Orm.Upgrade.Model; -using AggregateException = Xtensive.Core.AggregateException; namespace Xtensive.Orm.Tests.Indexing { diff --git a/Orm/Xtensive.Orm/Core/Exceptions/AggregateException.cs b/Orm/Xtensive.Orm/Core/Exceptions/AggregateException.cs deleted file mode 100644 index 928e627457..0000000000 --- a/Orm/Xtensive.Orm/Core/Exceptions/AggregateException.cs +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright (C) 2003-2010 Xtensive LLC. -// All rights reserved. -// For conditions of distribution and use, see license. -// Created by: Alex Yakunin -// Created: 2008.07.03 - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Runtime.Serialization; -using System.Security; -using System.Text; -using System.Linq; - -namespace Xtensive.Core -{ - /// - /// Aggregates a set of caught exceptions. - /// - [Serializable] - public class AggregateException : Exception - { - private Exception[] exceptions; - - /// - /// Gets the list of caught exceptions. - /// - public IReadOnlyList Exceptions - { - [DebuggerStepThrough] - get { return exceptions; } - } - - /// - /// Gets the "flat" list with all aggregated exceptions. - /// If other s were aggregated, - /// their inner exceptions are included instead of them. - /// - /// Flat list of aggregated exceptions. - public List GetFlatExceptions() - { - var result = new List(); - - foreach (var exception in exceptions) { - var ae = exception as AggregateException; - if (ae!=null) - result.AddRange(ae.GetFlatExceptions()); - else - result.Add(exception); - } - - return result; - } - - /// - public override string ToString() - { - StringBuilder sb = new StringBuilder(64); - sb.Append(base.ToString()); - sb.AppendFormat("\r\n{0}:", Strings.OriginalExceptions); - int i = 1; - foreach (Exception exception in exceptions) - sb.AppendFormat("\r\n{0}: {1}", i++, exception); - return sb.ToString(); - } - - #region Private \ internal methods - - private void SetExceptions(Exception[] exceptions) - { - this.exceptions = exceptions; - } - - private void SetExceptions(Exception exception) - { - exceptions = new Exception[] { exception }; - } - - #endregion - - - // Constructors - - /// - /// Initializes a new instance of this type. - /// - public AggregateException() - : base(Strings.ExASetOfExceptionsIsCaught) - { - } - - /// - /// Initializes a new instance of this type. - /// - /// Text of message. - public AggregateException(string text) - : base(text) - { - } - - /// - /// Initializes a new instance of this type. - /// - /// Text of message. - /// Inner exception. - public AggregateException(string message, Exception innerException) - : base(message, innerException) - { - SetExceptions(innerException); - } - - /// - /// Initializes a new instance of this type. - /// - /// Inner exceptions. - public AggregateException(Exception[] exceptions) - : base(Strings.ExASetOfExceptionsIsCaught, exceptions.First()) - { - SetExceptions(exceptions); - } - - /// - /// Initializes a new instance of this type. - /// - /// Text of message. - /// Inner exceptions. - public AggregateException(string message, Exception[] exceptions) - : base(message, exceptions.First()) - { - SetExceptions(exceptions); - } - - - // Serialization - - /// - /// Deserializes instance of this type. - /// - /// - /// -#if NET8_0_OR_GREATER - [Obsolete(DiagnosticId = "SYSLIB0051")] -#endif - protected AggregateException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - exceptions = (Exception[]) info.GetValue("Exceptions", typeof (Exception[])); - } - - /// - /// Serializes instance of this type. - /// - /// - /// - [SecurityCritical] -#if NET8_0_OR_GREATER - [Obsolete(DiagnosticId = "SYSLIB0051")] -#endif - public override void GetObjectData(SerializationInfo info, StreamingContext context) - { - base.GetObjectData(info, context); - info.AddValue("Exceptions", exceptions); - } - } -} \ No newline at end of file