Skip to content

Instantly share code, notes, and snippets.

View werwolfby's full-sized avatar

Alexander Puzynia werwolfby

  • Service Titan
  • Seattle, USA
View GitHub Profile
@werwolfby
werwolfby / TaskEx.cs
Last active May 30, 2024 08:29
When All with results
public static class TaskEx
{
public static async Task<(T1, T2)> WhenAll<T1, T2>(Task<T1> task1, Task<T2> task2)
{
await Task.WhenAll(task1, task2);
return (task1.GetAwaiter().GetResult(), task2.GetAwaiter().GetResult());
}
public static async Task<(T1, T2, T3)> WhenAll<T1, T2, T3>(Task<T1> task1, Task<T2> task2, Task<T3> task3)
{
@werwolfby
werwolfby / CustomJsonSerializerOptions.cs
Last active June 27, 2024 17:24
Custom JsonConverter that could fallback to default one
public static class CustomJsonSerializerOptions
{
public static readonly JsonSerializerOptions Options = new() {
PropertyNamingPolicy = new SnakeCaseJsonNamingPolicy(),
PropertyNameCaseInsensitive = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
Converters = {
new JsonStringEnumConverter (new SnakeCaseJsonNamingPolicy()),
// Other converters
}