w w w . l a m b d a 3 . c o m . b r
O futuro do C#
Giovanni Bassi
• Programador
• MVP
• Não gerente
• Trouxe a Scrum.org, PSM e PSD pro Brasil
• blog.lambda3.com.br, podcast.lambda3.com.br,
dotnetarchitects.net
• @giovannibassi
• Escalador e ciclista
podcast.lambda3.com.br
0 – Eventos
1 – Docker
2 – .NET Core RC2
3 – Git
4 – Estudo
5 – Open Source
6 – Xamarin
7 – Node.js
8 – Democracia organizacional
9 – O programador poliglota
...
Toda semana em:
stackoverflow.com/insights/survey/2017#most-popular-technologies
stackoverflow.com/insights/survey/2017#most-loved-dreaded-and-wanted
F#
10,000’s
Tens of thousands
VB
100,000’s
Hundreds of thousands
C#
1,000,000’s
Millions
F#
10,000’s
Tens of thousands
VB
100,000’s
Hundreds of thousands
C#
1,000,000’s
Millions
Demos!
var tuple = (f1: x.f1, f2: x?.f2);
var tuple = (x.f1, x?.f2);
https://github.com/dotnet/csharplang/blob/master/proposals/csharp-7.1/infer-tuple-names.md
static (int, int) Tally(int[] values) => default;
https://github.com/dotnet/csharplang/blob/master/proposals/target-typed-default.md
static async Task Main()
{
// await ...
}
https://github.com/dotnet/csharplang/blob/master/proposals/async-main.md
IAsyncEnumerable<Person> people = database.GetPeopleAsync();
foreach await (var p in people) { … }
using await (IAsyncDisposable resource = await store.GetRecordAsync(…)) { … }
extension Enrollee extends Person
{
// static field
static Dictionary<Person, Professor> enrollees = new Dictionary<Person, Professor>();
// instance method
public void Enroll(Professor supervisor) { enrollees[this] = supervisor; }
// instance property
public Professor Supervisor => enrollees.TryGetValue(this, out var supervisor) ? supervisor : null;
// static property
public static ICollection<Person> Students => enrollees.Keys;
// instance constructor
public Person(string name, Professor supervisor) : this(name) { this.Enroll(supervisor); }
}
class Person : IEquatable<Person>
{
public string First { get; }
public string Last { get; }
public Person(string First, string Last) => (this.First, this.Last) = (First, Last);
public void Deconstruct(out string First, out string Last)
=> (First, Last) = (this.First, this.Last);
public bool Equals(Person other)
=> other != null && First == other.First && Last == other.Last;
public override bool Equals(object obj) => obj is Person other ? Equals(other) : false;
public override int GetHashCode() => GreatHashFunction(First, Last);
…
}
class Person(string First, string Last);
O Futuro do C#: C#8

O Futuro do C#: C#8

  • 1.
    w w w. l a m b d a 3 . c o m . b r O futuro do C#
  • 2.
    Giovanni Bassi • Programador •MVP • Não gerente • Trouxe a Scrum.org, PSM e PSD pro Brasil • blog.lambda3.com.br, podcast.lambda3.com.br, dotnetarchitects.net • @giovannibassi • Escalador e ciclista
  • 4.
    podcast.lambda3.com.br 0 – Eventos 1– Docker 2 – .NET Core RC2 3 – Git 4 – Estudo 5 – Open Source 6 – Xamarin 7 – Node.js 8 – Democracia organizacional 9 – O programador poliglota ... Toda semana em:
  • 5.
  • 6.
  • 7.
    F# 10,000’s Tens of thousands VB 100,000’s Hundredsof thousands C# 1,000,000’s Millions
  • 8.
    F# 10,000’s Tens of thousands VB 100,000’s Hundredsof thousands C# 1,000,000’s Millions
  • 9.
  • 10.
    var tuple =(f1: x.f1, f2: x?.f2); var tuple = (x.f1, x?.f2); https://github.com/dotnet/csharplang/blob/master/proposals/csharp-7.1/infer-tuple-names.md
  • 11.
    static (int, int)Tally(int[] values) => default; https://github.com/dotnet/csharplang/blob/master/proposals/target-typed-default.md
  • 12.
    static async TaskMain() { // await ... } https://github.com/dotnet/csharplang/blob/master/proposals/async-main.md
  • 13.
    IAsyncEnumerable<Person> people =database.GetPeopleAsync(); foreach await (var p in people) { … } using await (IAsyncDisposable resource = await store.GetRecordAsync(…)) { … }
  • 14.
    extension Enrollee extendsPerson { // static field static Dictionary<Person, Professor> enrollees = new Dictionary<Person, Professor>(); // instance method public void Enroll(Professor supervisor) { enrollees[this] = supervisor; } // instance property public Professor Supervisor => enrollees.TryGetValue(this, out var supervisor) ? supervisor : null; // static property public static ICollection<Person> Students => enrollees.Keys; // instance constructor public Person(string name, Professor supervisor) : this(name) { this.Enroll(supervisor); } }
  • 15.
    class Person :IEquatable<Person> { public string First { get; } public string Last { get; } public Person(string First, string Last) => (this.First, this.Last) = (First, Last); public void Deconstruct(out string First, out string Last) => (First, Last) = (this.First, this.Last); public bool Equals(Person other) => other != null && First == other.First && Last == other.Last; public override bool Equals(object obj) => obj is Person other ? Equals(other) : false; public override int GetHashCode() => GreatHashFunction(First, Last); … } class Person(string First, string Last);