Skip to content

Instantly share code, notes, and snippets.

@safern
Created May 3, 2019 01:07
Show Gist options
  • Save safern/9bef6285587b7333e1c7e810dc4cf983 to your computer and use it in GitHub Desktop.
Save safern/9bef6285587b7333e1c7e810dc4cf983 to your computer and use it in GitHub Desktop.
This samples the input and output of GenAPI after adding nullability support

INPUT

namespace tmp
{
    public class Program
    {
        public delegate string? SampleEventHandler(object? sender, string e);
        public event SampleEventHandler? Event;
        public string?[] A1()
        {
            throw null!;
        }

        public string?[][]? A2()
        {
            return null;
        }

        public string?[][]?[]? A3()
        {
            return null;
        }

        public Dictionary<string?, string>? Foo()
        {
            return null;
        }

        public (string? item1, string item2)? Foo2()
        {
            return ("hello", "world");
        }

        public Dictionary<Dictionary<string?, string?>?, string>? Foo3()
        {
            return null!;
        }

        public ValueTuple<string?, string>? Foo4()
        {
            return null;
        }

        public Dictionary<int, KeyValuePair<int?, string?>?>? Foo5()
        {
            return null;
        }

        public void Foo6(string? a, int? b)
        {
            return;
        }

        public ValueTuple<ValueTuple<string, int>, Dictionary<int, int>> Foo7()
        {
            throw null!;
        }

        public bool Foo8<T>(T value) where T : class ?
        {
            return false;
        }

        public T Foo9<T>(T value) where T : IEnumerable<string?>
        {
            return default!;
        }

        public System.Collections.Generic.Dictionary<(String key0, int value0), (int? item1, (int key2, string? item2), string?)> Foo9()
        {
            throw null!;
        }

        public HashSet<dynamic> Foo10()
        {
            throw null!;
        }

        public dynamic Foo11()
        {
            throw null!;
        }

        public string? Prop1 { get; set; }
    }

    public class C<TKey> : HashSet<string?>, IEnumerable<string?> where TKey : Attribute?
    {
        IEnumerator<string?> IEnumerable<string?>.GetEnumerator()
        {
            throw new NotImplementedException();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            throw new NotImplementedException();
        }
    }

    public class D<TKey> : IEnumerator<string?>, IFoo<IDictionary<int, string?>?>
    {
        int IFoo<IDictionary<int, string?>?>.this[IDictionary<int, string?>? key] { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

        string? IEnumerator<string?>.Current => throw new NotImplementedException();

        object IEnumerator.Current => throw new NotImplementedException();

        void IDisposable.Dispose()
        {
            throw new NotImplementedException();
        }

        bool IEnumerator.MoveNext()
        {
            throw new NotImplementedException();
        }

        void IEnumerator.Reset()
        {
            throw new NotImplementedException();
        }
    }

    public interface IFoo<T>
    {
        int this[T key] { get; set; }
    }
}

OUTPUT

namespace tmp
{
    public partial class C<TKey> : System.Collections.Generic.HashSet<string?>, System.Collections.Generic.IEnumerable<string?>, System.Collections.IEnumerable where TKey : System.Attribute?
    {
        public C() { }
        System.Collections.Generic.IEnumerator<string?> System.Collections.Generic.IEnumerable<string?>.GetEnumerator() { throw null; }
        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
    }
    public partial class D<TKey> : System.Collections.Generic.IEnumerator<string?>, System.Collections.IEnumerator, System.IDisposable, tmp.IFoo<System.Collections.Generic.IDictionary<int, string?>?>
    {
        public D() { }
        string? System.Collections.Generic.IEnumerator<string?>.Current { get { throw null; } }
        object System.Collections.IEnumerator.Current { get { throw null; } }
        int tmp.IFoo<System.Collections.Generic.IDictionary<int, string?>?>.this[System.Collections.Generic.IDictionary<int, string?>? key] { get { throw null; } set { } }
        bool System.Collections.IEnumerator.MoveNext() { throw null; }
        void System.Collections.IEnumerator.Reset() { }
        void System.IDisposable.Dispose() { }
    }
    public partial interface IFoo<T>
    {
        int this[T key] { get; set; }
    }
    public partial class Program
    {
        public Program() { }
        public string? Prop1 { get { throw null; } set { } }
        public event tmp.Program.SampleEventHandler? Event { add { } remove { } }
        public string?[] A1() { throw null; }
        public string?[][]? A2() { throw null; }
        public string?[][]?[]? A3() { throw null; }
        public System.Collections.Generic.Dictionary<string?, string>? Foo() { throw null; }
        public System.Collections.Generic.HashSet<dynamic> Foo10() { throw null; }
        public dynamic Foo11() { throw null; }
        public (string? item1, string item2)? Foo2() { throw null; }
        public System.Collections.Generic.Dictionary<System.Collections.Generic.Dictionary<string?, string?>?, string>? Foo3() { throw null; }
        public (string?, string)? Foo4() { throw null; }
        public System.Collections.Generic.Dictionary<int, System.Collections.Generic.KeyValuePair<int?, string?>?>? Foo5() { throw null; }
        public void Foo6(string? a, int? b) { }
        public ((string, int), System.Collections.Generic.Dictionary<int, int>) Foo7() { throw null; }
        public bool Foo8<T>(T value) where T : class? { throw null; }
        public System.Collections.Generic.Dictionary<(string key0, int value0), (int? item1, (int key2, string? item2), string?)> Foo9() { throw null; }
        public T Foo9<T>(T value) where T : System.Collections.Generic.IEnumerable<string?> { throw null; }
        public delegate string? SampleEventHandler(object? sender, string e);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment