.NET Reflector 9.3 release notes
Published 22 November 2017
22nd November, 2017
Features
Beta support for the following C# 7.0 features:
Tuples
class TestValueTuples { public (int Key, string Value)[] TestArray; public IEnumerator<(int Key, string Value)> TestInnerType; public (int Key, string Value) TestField; public (int Key, string Value) TestProperty { get; set; } public (int Key, string Value) TestMethod() { throw new NotImplementedException(); } public Func<(int Key, string Value)> TestFunc; public event EventHandler<(int Key, string Value)> TestEvent; public (int Q, int W) Method1((int Key, string Value) arg) { Console.WriteLine(TestField.Value); Console.WriteLine(TestProperty.Value); Console.WriteLine(TestMethod().Value); Console.WriteLine(arg.Value); Console.WriteLine(TestInnerType.Current.Value); Console.WriteLine(TestArray[0].Value); Console.WriteLine(TestFunc().Value); Console.WriteLine(TestFunc.Invoke().Value); TestEvent += (sender, tuple) => { Console.WriteLine(tuple.Value); }; return (8, 16); } }
Out variables
int TestMethod1(Dictionary<string, int> arg, string key) { if (!arg.TryGetValue(key, out var result)) result = 0; return result; }
Pattern Matching
int TestMethod1<T>(IEnumerable<T> arg) { switch (arg) { case IList<T> tmp: return 1; case IEnumerable<int> tmp when tmp.Any(): return tmp.First(); case Queue<T> tmp: return 2; case Stack<T> tmp: return 3; } return 4; } int TestMethod2<T>(IEnumerable<T> arg) { if(arg is List<T> list) return list.Count; return 0; }
Deconstruction
class TestDeconstructors { private int a, b, c; public void Deconstruct(out int a, out int b, out int c) { a = this.a; b = this.b; c = this.c; } public void Method1(TestDeconstructors other) { (a, b, c) = other; } }
Discards
int TestMethod1<T>(IEnumerable<T> arg) { switch (arg) { case IList<T> _: return 1; case IEnumerable<int> tmp when tmp.Any(): return tmp.First(); case Queue<T> _: return 2; case Stack<int> tmp: return tmp.Peek(); } return 4; } int TestMethod2<TKey, TResult>(Dictionary<TKey, TResult> arg) { return arg.TryGetValue(default(TKey), out _) ? 1 : 0; }
Literals
int num = 1_000_000;
Throw Expressions
public static void Method1(IEnumerable<int> asd) { var tmp = (asd as IList<int>) ?? throw new ArgumentNullException(nameof(asd)); }
Fixes
RP-4058 - (VsPackage): on F12 Jump, find proper declaration based on metadata line