Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions csharp/Platform.Exceptions/Ensure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ namespace Platform.Exceptions
{
/// <summary>
/// <para>Contains two extensible classes instances that can be supplemented with static helper methods by using the extension mechanism. These methods ensure the contract compliance.</para>
/// <para>Содержит два экземпляра расширяемых класса, которые можно дополнять статическими вспомогательными методами путём использования механизма расширений. Эти методы занимаются гарантированием соответствия контракту.</para>
/// </summary>
public static class Ensure
{
/// <summary>
/// <para>Gets an instance of the extension root class that contains helper methods to guarantee compliance with the contract.</para>
/// <para>Возвращает экземпляр класса корня-расширения, который содержит вспомогательные методы для гарантирования соответствия контракту.</para>
/// </summary>
public static readonly EnsureAlwaysExtensionRoot Always = new EnsureAlwaysExtensionRoot();

/// <summary>
/// <para>Gets an instance of the extension root class that contains helper methods to guarantee compliance with the contract, but are executed only during debugging.</para>
/// <para>Возвращает экземпляр класса корня-расширения, который содержит вспомогательные методы для гарантирования соответствия контракту, но выполняются только во время отладки.</para>
/// </summary>
public static readonly EnsureOnDebugExtensionRoot OnDebug = new EnsureOnDebugExtensionRoot();
}
Expand Down
145 changes: 66 additions & 79 deletions csharp/Platform.Exceptions/EnsureExtensions.cs

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions csharp/Platform.Exceptions/ExceptionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,30 @@ namespace Platform.Exceptions
{
/// <summary>
/// <para>Provides a set of extension methods for <see cref="Exception"/> objects.</para>
/// <para>Предоставляет набор методов расширения для объектов <see cref="Exception"/>.</para>
/// </summary>
public static class ExceptionExtensions
{
/// <summary>
/// <para>Represents the separator used within the process of generating a representation string (<see cref="ToStringWithAllInnerExceptions(Exception)"/>) to separate different inner exceptions from each other. This field is constant.</para>
/// <para>Представляет разделитель, используемый внутри процесса формирования строки-представления (<see cref="ToStringWithAllInnerExceptions(Exception)"/>) для разделения различных внутренних исключений друг от друга. Это поле является константой.</para>
/// </summary>
public static readonly string ExceptionContentsSeparator = "---";

/// <summary>
/// <para>Represents a string returned from <see cref="ToStringWithAllInnerExceptions(Exception)"/> in the event of an unsuccessful attempt to format an exception. This field is a constant.</para>
/// <para>Представляет строку выдаваемую из <see cref="ToStringWithAllInnerExceptions(Exception)"/> в случае неудачной попытки форматирования исключения. Это поле является константой.</para>
/// </summary>
public static readonly string ExceptionStringBuildingFailed = "Unable to format exception.";

/// <summary>
/// <para>Ignores the exception, notifying the <see cref = "IgnoredExceptions" /> class about it.</para>
/// <para>Игнорирует исключение, уведомляя об этом класс <see cref="IgnoredExceptions"/>.</para>
/// </summary>
/// <param name="exception"><para></para><para></para></param>
public static void Ignore(this Exception exception) => IgnoredExceptions.RaiseExceptionIgnoredEvent(exception);

/// <summary>
/// <para>Returns a string that represents the specified exception with all its inner exceptions.</para>
/// <para>Возвращает строку, которая представляет указанное исключение со всеми его внутренними исключениями.</para>
/// </summary>
/// <param name="exception"><para>The exception that will be represented as a string.</para><para>Исключение, которое будет представленно в виде строки.</para></param>
/// <returns><para>A string that represents the specified exception with all its inner exceptions.</para><para>Cтроку, которая представляет указанное исключение со всеми его внутренними исключениями.</para></returns>
/// <param name="exception"><para>The exception that will be represented as a string.</para></param>
/// <returns><para>A string that represents the specified exception with all its inner exceptions.</para></returns>
public static string ToStringWithAllInnerExceptions(this Exception exception)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ namespace Platform.Exceptions.ExtensionRoots
{
/// <summary>
/// <para>Represents the extension root class for Ensure.Always.</para>
/// <para>Представляет класс корень-расширения для Ensure.Always.</para>
/// </summary>
public class EnsureAlwaysExtensionRoot
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ namespace Platform.Exceptions.ExtensionRoots
{
/// <summary>
/// <para>Represents the extension root class for Ensure.OnDebug.</para>
/// <para>Представляет класс корень-расширения для Ensure.OnDebug.</para>
/// </summary>
public class EnsureOnDebugExtensionRoot
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ namespace Platform.Exceptions.ExtensionRoots
{
/// <summary>
/// <para>Represents the extension root class for Throw.A.</para>
/// <para>Представляет класс корень-расширения для Throw.A.</para>
/// </summary>
public class ThrowExtensionRoot
{
Expand Down
10 changes: 2 additions & 8 deletions csharp/Platform.Exceptions/IgnoredExceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,33 @@
namespace Platform.Exceptions
{
/// <summary>
/// <para>Сontains a mechanism for notifying about the occurrence of ignored exceptions, as well as a mechanism for their collection.</para>
/// <para>Содержит механизм уведомления о возникновении игнорируемых исключений, а так же механизм их сбора.</para>
/// <para>Contains a mechanism for notifying about the occurrence of ignored exceptions, as well as a mechanism for their collection.</para>
/// </summary>
public static class IgnoredExceptions
{
private static readonly ConcurrentBag<Exception> _exceptionsBag = new ConcurrentBag<Exception>();

/// <summary>
/// <para>An event that is raised every time an exception has been ignored.</para>
/// <para>Событие, которое генерируется каждый раз, когда исключение было проигнорировано.</para>
/// </summary>
public static event EventHandler<Exception> ExceptionIgnored = OnExceptionIgnored;

/// <summary>
/// <para>Gets an immutable collection with all collected exceptions that were ignored.</para>
/// <para>Возвращает неизменяемую коллекцию со всеми собранными исключениями которые были проигнорированы.</para>
/// </summary>
public static IReadOnlyCollection<Exception> CollectedExceptions => _exceptionsBag;

/// <summary>
/// <para>Gets or sets a value that determines whether to collect ignored exceptions into CollectedExceptions.</para>
/// <para>Возвращает или устанавливает значение, определяющие нужно ли собирать игнорируемые исключения в CollectedExceptions.</para>
/// </summary>
public static bool CollectExceptions { get; set; }

/// <summary>
/// <para>Raises an exception ignored event.</para>
/// <para>Генерирует событие игнорирования исключения.</para>
/// </summary>
/// <param name="exception"><para>The ignored exception.</para><para>Игнорируемое исключение.</para></param>
/// <param name="exception"><para>The ignored exception.</para></param>
/// <remarks>
/// <para>It is recommended to call this method in cases where you have a catch block, but you do not do anything with exception in it.</para>
/// <para>Рекомендуется вызывать этот метод в тех случаях, когда у вас есть catch блок, но вы ничего не делаете в нём с исключением.</para>
/// </remarks>
public static void RaiseExceptionIgnoredEvent(Exception exception) => ExceptionIgnored.Invoke(null, exception);
private static void OnExceptionIgnored(object sender, Exception exception)
Expand Down
2 changes: 0 additions & 2 deletions csharp/Platform.Exceptions/Throw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ namespace Platform.Exceptions
{
/// <summary>
/// <para>Contains an instance of an extensible class that can be supplemented with static helper methods by using the extension mechanism. These methods throw exceptions.</para>
/// <para>Содержит экземпляр расширяемого класса, который можно дополнять статическими вспомогательными методами путём использования механизма расширений. Эти методы занимаются выбрасыванием исключений.</para>
/// </summary>
public static class Throw
{
/// <summary>
/// <para>Gets an instance of the extension root class that contains helper methods for throwing exceptions.</para>
/// <para>Возвращает экземпляр класса корня-расширения, который содержит вспомогательные методы для выбрасывания исключений.</para>
/// </summary>
public static readonly ThrowExtensionRoot A = new ThrowExtensionRoot();
}
Expand Down
21 changes: 8 additions & 13 deletions csharp/Platform.Exceptions/ThrowExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,38 @@ namespace Platform.Exceptions
{
/// <summary>
/// <para>Provides a set of extension methods for <see cref="ThrowExtensionRoot"/> objects.</para>
/// <para>Предоставляет набор методов расширения для объектов <see cref="ThrowExtensionRoot"/>.</para>
/// </summary>
public static class ThrowExtensions
{
/// <summary>
/// <para>Throws a new <see cref="System.NotSupportedException"/>.</para>
/// <para>Выбрасывает новое <see cref="System.NotSupportedException"/>.</para>
/// </summary>
/// <param name="root"><para>The extension root to which this method is bound.</para><para>Корень-расширения, к которому привязан этот метод.</para></param>
/// <param name="root"><para>The extension root to which this method is bound.</para></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void NotSupportedException(this ThrowExtensionRoot root) => throw new NotSupportedException();

/// <summary>
/// <para>Throws a new <see cref="System.NotSupportedException"/>, while returning a value of <typeparamref name="TReturn"/> type.</para>
/// <para>Выбрасывает новое <see cref="System.NotSupportedException"/>, вовращая при этом значение типа <typeparamref name="TReturn"/>.</para>
/// </summary>
/// <typeparam name="TReturn"><para>The type of returned value.</para><para>Тип возвращаемого значения.</para></typeparam>
/// <param name="root"><para>The extension root to which this method is bound.</para><para>Корень-расширения, к которому привязан этот метод.</para></param>
/// <returns><para>A value of <typeparamref name="TReturn"/> type.</para><para>Значение типа <typeparamref name="TReturn"/>.</para></returns>
/// <typeparam name="TReturn"><para>The type of returned value.</para></typeparam>
/// <param name="root"><para>The extension root to which this method is bound.</para></param>
/// <returns><para>A value of <typeparamref name="TReturn"/> type.</para></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TReturn NotSupportedExceptionAndReturn<TReturn>(this ThrowExtensionRoot root) => throw new NotSupportedException();

/// <summary>
/// <para>Throws a new <see cref="System.NotImplementedException"/>.</para>
/// <para>Выбрасывает новое <see cref="System.NotImplementedException"/>.</para>
/// </summary>
/// <param name="root"><para>The extension root to which this method is bound.</para><para>Корень-расширения, к которому привязан этот метод.</para></param>
/// <param name="root"><para>The extension root to which this method is bound.</para></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void NotImplementedException(this ThrowExtensionRoot root) => throw new NotImplementedException();

/// <summary>
/// <para>Throws a new <see cref="System.NotImplementedException"/>, while returning a value of <typeparamref name="TReturn"/> type.</para>
/// <para>Выбрасывает новое <see cref="System.NotImplementedException"/>, вовращая при этом значение типа <typeparamref name="TReturn"/>.</para>
/// </summary>
/// <typeparam name="TReturn"><para>The type of returned value.</para><para>Тип возвращаемого значения.</para></typeparam>
/// <param name="root"><para>The extension root to which this method is bound.</para><para>Корень-расширения, к которому привязан этот метод.</para></param>
/// <returns><para>A value of <typeparamref name="TReturn"/> type.</para><para>Значение типа <typeparamref name="TReturn"/>.</para></returns>
/// <typeparam name="TReturn"><para>The type of returned value.</para></typeparam>
/// <param name="root"><para>The extension root to which this method is bound.</para></param>
/// <returns><para>A value of <typeparamref name="TReturn"/> type.</para></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TReturn NotImplementedExceptionAndReturn<TReturn>(this ThrowExtensionRoot root) => throw new NotImplementedException();
}
Expand Down
Loading