Skip to content

Instantly share code, notes, and snippets.

Ahson Khan ahsonkhan

Block or report user

Report or block ahsonkhan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Scenario1_expected.json
// 1b) Expected output:
{"Email":"james@example.com","Active":true,"CreatedDate":"2013-01-20T00:00:00.0000000Z","Roles":["User","Admin"]}
// 2c) Expected output:
{
"Email": "james@example.com",
"Active": true,
"CreatedDate": "2013-01-20T00:00:00Z",
"Roles": [
@ahsonkhan
ahsonkhan / Class_Utf8JsonWriter.md
Created Apr 17, 2019
Utf8JsonWriter Re-design based on usability and reliability feedback
View Class_Utf8JsonWriter.md

Motivation - Usability and Reliability:

  • The current writer is a ref struct, which requires passing by ref.
  • The use of array pool could result in reliability concerns if misused.
  • Async writes and state passing could be problematic.
  • No IBufferWriter implementation built in.

Goals:

  • Continue to support IBufferWriter (i.e. PipeWriter) directly
  • Keep ability for user to control buffering with ability to avoid data copies.
@ahsonkhan
ahsonkhan / CallStack-StackOverflow.txt
Created Feb 27, 2019
ApiCompat write diff stack overflow for uap
View CallStack-StackOverflow.txt
[External Code]
> Microsoft.Cci.Extensions.dll!Microsoft.Cci.Writers.CSharp.CSDeclarationWriter.WriteEnumValue(Microsoft.Cci.IMetadataConstant constant, Microsoft.Cci.ITypeReference constantType) Line 67 C#
Microsoft.Cci.Extensions.dll!Microsoft.Cci.Writers.CSharp.CSDeclarationWriter.WriteMetadataConstant(Microsoft.Cci.IMetadataConstant constant, Microsoft.Cci.ITypeReference constantType) Line 258 C#
Microsoft.Cci.Extensions.dll!Microsoft.Cci.Writers.CSharp.CSDeclarationWriter.WriteEnumValue(Microsoft.Cci.IMetadataConstant constant, Microsoft.Cci.ITypeReference constantType) Line 123 C#
Microsoft.Cci.Extensions.dll!Microsoft.Cci.Writers.CSharp.CSDeclarationWriter.WriteMetadataConstant(Microsoft.Cci.IMetadataConstant constant, Microsoft.Cci.ITypeReference constantType) Line 258 C#
Microsoft.Cci.Extensions.dll!Microsoft.Cci.Writers.CSharp.CSDeclarationWriter.WriteEnumValue(Microsoft.Cci.IMetadataConstant constant, Microsoft.Cci.ITypeReference constantType) Line 123 C#
Microsoft.Cci.Extensions.dll!M
@ahsonkhan
ahsonkhan / ref-api-diff.md
Last active Feb 22, 2019
Difference in reference assemblies between .NET Core 3.0 master and .NET Core 3.0 UpdateRefs branch
View ref-api-diff.md
@ahsonkhan
ahsonkhan / ArrayBufferWriter.ArrayPool.cs
Created Jan 29, 2019
Sample implementation of ArrayBufferWriter, a class that implements IBufferWriter<byte> backed by ArrayPool<byte>.Shared.
View ArrayBufferWriter.ArrayPool.cs
public class ArrayBufferWriter : IBufferWriter<byte>, IDisposable
{
private byte[] _rentedBuffer;
private int _written;
private long _committed;
private const int MinimumBufferSize = 256;
public ArrayBufferWriter(int initialCapacity = MinimumBufferSize)
{
@ahsonkhan
ahsonkhan / ArrayBufferWriter.cs
Created Jan 28, 2019
Sample implementation of ArrayBufferWriter, a class that implements IBufferWriter<byte>
View ArrayBufferWriter.cs
namespace System.Buffers
{
public class ArrayBufferWriter : IBufferWriter<byte>, IDisposable
{
private byte[] _rentedBuffer;
private int _written;
private long _committed;
private const int MinimumBufferSize = 256;
@ahsonkhan
ahsonkhan / JsonReaderPerf-report-github.md
Last active May 12, 2018
JsonLab and Json.NET JsonReader Performance Comparison Results for various JSON strings (UTF-8 and UTF-16)
View JsonReaderPerf-report-github.md
BenchmarkDotNet=v0.10.14.534-nightly, OS=Windows 10.0.16299.371 (1709/FallCreatorsUpdate/Redstone3)
Intel Xeon CPU E5-1620 v2 3.70GHz, 1 CPU, 8 logical and 4 physical cores
Frequency=3604598 Hz, Resolution=277.4234 ns, Timer=TSC
.NET Core SDK=2.1.300-rtm-008823
  [Host]     : .NET Core 2.1.0-rtm-26508-02 (CoreCLR 4.6.26508.04, CoreFX 4.6.26508.03), 64bit RyuJIT
  Job-JIQQBR : .NET Core 2.1.0-rtm-26508-02 (CoreCLR 4.6.26508.04, CoreFX 4.6.26508.03), 64bit RyuJIT

InvocationCount=1024  TargetCount=5  WarmupCount=3  
@ahsonkhan
ahsonkhan / IntParserUnrolled.md
Last active Jun 24, 2017
Loop unrolled int 32 parser
View IntParserUnrolled.md
public static bool TryParseInt32(ReadOnlySpan<byte> text, out int value, out int bytesConsumed)
{
    int textLength = text.Length;
    if (textLength < 1) goto FalseExit;

    int sign = 1;
    int index = default;
    int num = text[index];
@ahsonkhan
ahsonkhan / System.Text.Primitives.md
Last active Jun 19, 2017
System.Text.Primitives API Review
View System.Text.Primitives.md
namespace System.Buffers.Text {
    public static class Base64 {
        public static int ComputeDecodedLength(ReadOnlySpan<byte> source);
        public static int ComputeEncodedLength(int sourceLength);
        public static TransformationStatus Decode(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesConsumed, out int bytesWritten);
        public static TransformationStatus DecodeInPlace(Span<byte> buffer, out int bytesConsumed, out int bytesWritten);
        public static TransformationStatus Encode(ReadOnlySpan<byte> source, Span<byte> destination, out int bytesConsumed, out int bytesWritten);
        public static TransformationStatus EncodeInPlace(Span<byte> buffer, int sourceLength, out int bytesWritten);
    }
@ahsonkhan
ahsonkhan / job-testLinux-16-console.txt
Created May 9, 2017
job-testLinux-16-console.txt
View job-testLinux-16-console.txt
Started by user Ahson Khan
Building in workspace C:\Program Files (x86)\Jenkins\workspace\testLinux
> git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git.exe config remote.origin.url https://github.com/dotnet/dotnet-ci # timeout=10
Fetching upstream changes from https://github.com/dotnet/dotnet-ci
> git.exe --version # timeout=10
> git.exe fetch --tags --progress https://github.com/dotnet/dotnet-ci +refs/heads/*:refs/remotes/origin/* # timeout=30
> git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
> git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
You can’t perform that action at this time.