This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Tracks exception which was thrown after instantiation of the tracker. | |
/// </summary> | |
/// <remarks> | |
/// It can be used to get the exception in finally block of try-catch-finally. | |
/// </remarks> | |
/// <example> | |
/// <code> | |
/// var tracker = new ExceptionTracker(); | |
/// try |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class EnumerableExtensions | |
{ | |
/// <summary> | |
/// Handles the exception and returns either new one (can be same as received) or <c>null</c> - which means exception is handled and should not be | |
/// thrown. Enumerations ends in any case. | |
/// </summary> | |
public static IEnumerable<T> Catching<T, TMoveNextException>( | |
this IEnumerable<T> seq, | |
Func<TMoveNextException, Exception?> catchOnMoveNext) | |
where TMoveNextException : Exception |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Diagnostics; | |
using System.Runtime.ExceptionServices; | |
namespace Helpers; | |
public static class ExceptionHelper | |
{ | |
private const string ActivityIdKey = "ActivityId"; | |
private static readonly object Sync = new(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ArrayExtensions | |
{ | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static ref T At<T>(this T[] array, int index) | |
{ | |
ref T tableRef = ref MemoryMarshal.GetArrayDataReference(array); | |
return ref Unsafe.Add(ref tableRef, (nint)index); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ref struct IndexSet | |
{ | |
public static int SizeInBytes(uint maxIndex) | |
{ | |
var indicesCount = maxIndex + 1; | |
var (size, additionalBits) = ((int)(indicesCount >> 3), indicesCount & 0b111); | |
if (additionalBits > 0) | |
{ | |
size++; | |
} |