using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Security.Cryptography;
public static partial class JsonExtensions
public static void ReadAndAssert(this ref Utf8JsonReader reader)
throw new JsonException();
var inputFileName = "Question73284540In.txt";
var outputFileName = "Question73284540Out.txt";
File.WriteAllText(inputFileName, "this is some text");
await using (var stream = new FileStream(inputFileName, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 4096, useAsync: true))
await SaveAsync(stream, outputFileName, default(CancellationToken));
async Task SaveAsync(Stream stream, string path, CancellationToken ct)
var sha512 = SHA512.Create();
var fileName = Path.GetFileName(path);
var destinationPath = Path.Combine("/tmp", fileName);
var destinationPath = path;
await using (var fileStream = File.Create(path))
await using (var cryptoStream = new CryptoStream(fileStream, sha512, CryptoStreamMode.Write))
await stream.CopyToAsync(cryptoStream, ct);
if (sha512?.Hash is { } computedHash)
Console.WriteLine(Convert.ToBase64String(computedHash));
Console.WriteLine("err");
public static async Task Main(string[] args)
Console.WriteLine("Environment version: {0} ({1})", System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription , GetNetCoreVersion());
Console.WriteLine("{0} version: {1}", typeof(JsonSerializer).Assembly.GetName().Name, typeof(JsonSerializer).Assembly.FullName);
await new Program().Test();
Console.WriteLine("Failed with unhandled exception: ");
public static string GetNetCoreVersion()
var assembly = typeof(System.Runtime.GCSettings).GetTypeInfo().Assembly;
var assemblyPath = assembly.Location.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
int netCoreAppIndex = Array.IndexOf(assemblyPath, "Microsoft.NETCore.App");
if (netCoreAppIndex > 0 && netCoreAppIndex < assemblyPath.Length - 2)
return assemblyPath[netCoreAppIndex + 1];