SlideShare a Scribd company logo
.NET 2015: Будущее рядом
Андрей Акиньшин, JetBrains
.NEXT 2015 Moscow
1/53
2/53 Overview
3/53 Overview
4/53 Overview
5/53 Overview
6/53 Overview
7/53 Overview
8/53 Overview
9/53 Overview
10/53 Overview
11/53 Overview
12/53 Overview
13/53 Overview
14/53 Overview
15/53 Overview
16/53 Overview
17/53 Overview
18/53 Overview
.NET Platform Standard
19/53 .NET Platform Standard
.NET Platform Standard
Terms
.NET Platform Standard — a specific versioned set of
reference assemblies that all .NET Platforms must support as
defined in the CoreFX repo.
Principles
• Platform owners implement reference assemblies from a
particular .NET Platform Standard version.
• Platform owners may implement a subset of reference
assemblies from a particular .NET Platform Standard
version.
• Any change in a reference assembly’s API surface causes
the .NET Platform Standard to version.
• Lower versions are always compatible with higher
versions.
20/53 .NET Platform Standard
Relationship to Platforms
21/53 .NET Platform Standard
Mapping to platforms
22/53 .NET Platform Standard
Portable Profiles
23/53 .NET Platform Standard
NuGet
24/53 .NET Platform Standard
Contracts from CoreFX
...
25/53 .NET Platform Standard
C#7
26/53 C#7
Tuples (Background)
27/53 C#7
Tuples (Background)
public void Tally(IEnumerable<int> values, out int sum, out int count)
int s, c;
Tally(myValues, out s, out c);
Console.WriteLine($"Sum: {s}, count: {c}");
27/53 C#7
Tuples (Background)
public void Tally(IEnumerable<int> values, out int sum, out int count)
int s, c;
Tally(myValues, out s, out c);
Console.WriteLine($"Sum: {s}, count: {c}");
public Tuple<int, int> Tally(IEnumerable<int> values)
var t = Tally(myValues);
Console.WriteLine($"Sum: {t.Item1}, count: {t.Item2}")
27/53 C#7
Tuples (Background)
public void Tally(IEnumerable<int> values, out int sum, out int count)
int s, c;
Tally(myValues, out s, out c);
Console.WriteLine($"Sum: {s}, count: {c}");
public Tuple<int, int> Tally(IEnumerable<int> values)
var t = Tally(myValues);
Console.WriteLine($"Sum: {t.Item1}, count: {t.Item2}")
public struct TallyResult { public int Sum; public int Count; }
public TallyResult Tally(IEnumerable<int> values)
var t = Tally(myValues);
Console.WriteLine($"Sum: {t.Sum}, count: {t.Count}");
27/53 C#7
Tuples types
public (int sum, int count) Tally(IEnumerable<int> values)
var t = Tally(myValues);
Console.WriteLine($"Sum: {t.sum}, count: {t.count}");
28/53 C#7
Tuples types
public (int sum, int count) Tally(IEnumerable<int> values)
var t = Tally(myValues);
Console.WriteLine($"Sum: {t.sum}, count: {t.count}");
public async Task<(int sum, int count)>
TallyAsync(IEnumerable<int> values)
var t = await TallyAsync(myValues);
Console.WriteLine($"Sum: {t.sum}, count: {t.count}");
28/53 C#7
Tuple literals and deconstruction
var t = new (int sum, int count) { sum = 0, count = 0 };
29/53 C#7
Tuple literals and deconstruction
var t = new (int sum, int count) { sum = 0, count = 0 };
public (int sum, int count) Tally(IEnumerable<int> values)
{
var s = 0; var c = 0;
foreach (var value in values) { s += value; c++; }
return (s, c); // target typed to (int sum, int count)
}
29/53 C#7
Tuple literals and deconstruction
var t = new (int sum, int count) { sum = 0, count = 0 };
public (int sum, int count) Tally(IEnumerable<int> values)
{
var s = 0; var c = 0;
foreach (var value in values) { s += value; c++; }
return (s, c); // target typed to (int sum, int count)
}
public (int sum, int count) Tally(IEnumerable<int> values)
{
// infer tuple type from names and values
var res = (sum: 0, count: 0);
foreach (var value in values) { res.sum += value; res.count++; }
return res;
}
29/53 C#7
Tuple literals and deconstruction
var t = new (int sum, int count) { sum = 0, count = 0 };
public (int sum, int count) Tally(IEnumerable<int> values)
{
var s = 0; var c = 0;
foreach (var value in values) { s += value; c++; }
return (s, c); // target typed to (int sum, int count)
}
public (int sum, int count) Tally(IEnumerable<int> values)
{
// infer tuple type from names and values
var res = (sum: 0, count: 0);
foreach (var value in values) { res.sum += value; res.count++; }
return res;
}
(var sum, var count) = Tally(myValues); // deconstruct result
Console.WriteLine($"Sum: {sum}, count: {count}");
29/53 C#7
Tuples: проблемы
• Struct or class
• Mutability
• Tuples as fields
• Conversions
• . . .
Cм. также: roslyn#347
30/53 C#7
Pattern matching (Background)
// class Person(string Name);
class Person
{
public Person(string name) { this.Name = name; }
public string Name { get; }
}
// class Student(string Name, double Gpa) : Person(Name);
class Student : Person
{
public Student(string name, double gpa) : base(name)
{ this.Gpa = gpa; }
public double Gpa { get; }
}
// class Teacher(string Name, string Subject) : Person(Name);
class Teacher : Person
{
public Teacher(string name, string subject) : base(name)
{ this.Subject = subject; }
public string Subject { get; }
}
31/53 C#7
Pattern matching (Background)
static string PrintedForm(Person p)
{
Student s;
Teacher t;
if ((s = p as Student) != null && s.Gpa > 3.5)
{
return $"Honor Student {s.Name} ({s.Gpa})";
}
else if (s != null)
{
return $"Student {s.Name} ({s.Gpa})";
}
else if ((t = p as Teacher) != null)
{
return $"Teacher {t.Name} of {t.Subject}";
}
else
{
return $"Person {p.Name}";
}
}
32/53 C#7
Pattern matching (Background)
static void Main(string[] args)
{
Person[] oa = {
new Student("Einstein", 4.0),
new Student("Elvis", 3.0),
new Student("Poindexter", 3.2),
new Teacher("Feynmann", "Physics"),
new Person("Anders"),
};
foreach (var o in oa)
{
Console.WriteLine(PrintedForm(o));
}
Console.ReadKey();
}
33/53 C#7
Pattern matching: is
static string PrintedForm(Person p)
{
if (p is Student s && s.Gpa > 3.5)
{
return $"Honor Student {s.Name} ({s.Gpa})";
}
else if (p is Student s)
{
return $"Student {s.Name} ({s.Gpa})";
}
else if (p is Teacher t)
{
return $"Teacher {t.Name} of {t.Subject}";
}
else
{
return $"Person {p.Name}";
}
}
34/53 C#7
Pattern matching: switch
static string PrintedForm(Person p)
{
switch (p)
{
case Student s when s.Gpa > 3.5 :
return $"Honor Student {s.Name} ({s.Gpa})";
case Student s :
return $"Student {s.Name} ({s.Gpa})";
case Teacher t :
return $"Teacher {t.Name} of {t.Subject}";
default :
return $"Person {p.Name}";
}
}
35/53 C#7
Pattern matching: match
static string PrintedForm(Person p)
{
return p match (
case Student s when s.Gpa > 3.5 :
$"Honor Student {s.Name} ({s.Gpa})"
case Student s :
$"Student {s.Name} ({s.Gpa})"
case Teacher t :
$"Teacher {t.Name} of {t.Subject}"
case * :
$"Person {p.Name}"
);
}
36/53 C#7
Pattern matching: Exceptions
return p match (
case Student s when s.Gpa > 3.5 :
$"Honor Student {s.Name} ({s.Gpa})"
case Student s :
$"Student {s.Name} ({s.Gpa})"
case Teacher t :
$"Teacher {t.Name} of {t.Subject}"
case null :
throw new ArgumentNullException(nameof(p))
case * :
$"Person {p.Name}"
);
37/53 C#7
Pattern matching: members
return p match (
case Student s when s.Gpa > 3.5 :
$"Honor Student {s.Name} ({s.Gpa})"
case Student { Name is "Poindexter" } :
"A Nerd"
case Student s :
$"Student {s.Name} ({s.Gpa})"
case Teacher t :
$"Teacher {t.Name} of {t.Subject}"
case null :
throw new ArgumentNullException(nameof(p))
case * :
$"Person {p.Name}"
);
38/53 C#7
Pattern matching: =>
static string PrintedForm(Person p) => p match (
case Student s when s.Gpa > 3.5 :
$"Honor Student {s.Name} ({s.Gpa})"
case Student { Name is "Poindexter" } :
"A Nerd"
case Student s :
$"Student {s.Name} ({s.Gpa})"
case Teacher t :
$"Teacher {t.Name} of {t.Subject}"
case null :
throw new ArgumentNullException(nameof(p))
case * :
$"Person {p.Name}"
);
39/53 C#7
Readonly locals
readonly int foo = /* ... */ ;
readonly var foo = /* ... */ ;
val foo = /* ... */ ;
public void Bar(readonly int foo = 0)
public void Bar(readonly ref Matrix3D matrix)
40/53 C#7
Immutable Types
public immutable struct Tuple<T1, T2>
{
public Tuple(T1 item1, T2 item2)
{ Item1 = item1; Item2 = item2; }
public T1 Item1; // Implicitly readonly
public T2 Item2; // Implicitly readonly
}
41/53 C#7
Immutable Types
public immutable struct Tuple<T1, T2>
{
public Tuple(T1 item1, T2 item2)
{ Item1 = item1; Item2 = item2; }
public T1 Item1; // Implicitly readonly
public T2 Item2; // Implicitly readonly
}
public immutable struct ImmutableTuple<T1, T2>
(T1 item1, T2 item2)
where T1 : immutable
where T2 : immutable
{
public ImmutableTuple(T1 item1, T2 item2)
{ Item1 = item1; Item2 = item2; }
public T1 Item1;
public T2 Item2;
}
41/53 C#7
Nullability?!
42/53 C#7
Nullability?!
1 Добавляем в язык только ? и ! при
объявления и кастах
42/53 C#7
Nullability?!
1 Добавляем в язык только ? и ! при
объявления и кастах
2 NullReferenceException невозможен
42/53 C#7
Nullability?!
1 Добавляем в язык только ? и ! при
объявления и кастах
2 NullReferenceException невозможен
3 Процесс компиляции не меняется
42/53 C#7
Nullability?!
1 Добавляем в язык только ? и ! при
объявления и кастах
2 NullReferenceException невозможен
3 Процесс компиляции не меняется
4 Runtime ничего не знает про not-nullable
42/53 C#7
Nullability?!
1 Добавляем в язык только ? и ! при
объявления и кастах
2 NullReferenceException невозможен
3 Процесс компиляции не меняется
4 Runtime ничего не знает про not-nullable
5 Обратная совместимость
42/53 C#7
С#7: много разных идей
• Local functions
• Extensions properties
• AsyncEnumerable
• params IEnumerable
• digits separators
• binary literals
• ...
43/53 C#7
corefxlab
44/53 corefxlab
ILSub
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[ILSub(@"
.maxstack 2
.locals ([0] uint8& addr)
ldarg.0 // load the object
stloc.0 // convert the object pointer to a byref
ldloc.0 // load the object pointer as a byref
ldarg.1 // load the offset
add // add the offset
ldobj !!T // load a T value from the computed address
ret")]
public static T Get<T>(object obj, UIntPtr offset)
{
return default(T);
}
45/53 corefxlab
System.Buffers
public sealed class ManagedBufferPool<T> where T : struct
{
// 2MB taken as the default since the average HTTP page
// is 1.9MB per http://httparchive.org/interesting.php
public ManagedBufferPool(int maxBufferSizeInBytes = 2048000)
static ManagedBufferPool<byte> SharedByteBufferPool{get;}
T[] RentBuffer(int size, bool clearBuffer = false)
void EnlargeBuffer(ref T[] buffer, int newSize,
bool clearFreeSpace = false)
void ReturnBuffer(ref T[] buffer, bool clearBuffer = false)
}
46/53 corefxlab
System.Slices
public partial struct Span<T> : IEnumerable<T>, IEquatable<Span<T>>
{
readonly object _object;
readonly UIntPtr _offset;
public readonly int Length;
// ...
Span(T[] array, int start, int length)
unsafe Span(void* ptr, int length)
bool TryCopyTo(Span<T> dest)
Span<T> Slice(int start, int length)
}
// Extensions
static Span<T> Slice<T>(this T[] array, int start, int length)
static Span<char> Slice(this string str, int start, int length)
static Span<U> Cast<[Primitive]T, [Primitive]U>(this Span<T> slice)
static bool SequenceEqual<T>(this Span<T> first, Span<T> second)
// ...
47/53 corefxlab
System.Text.Utf8
public partial struct Utf8String :
IEnumerable<Utf8CodeUnit>,
IEquatable<Utf8String>,
IComparable<Utf8String>
{
private Span<byte> _buffer;
Utf8String(Span<byte> buffer)
Utf8String(byte[] utf8bytes, int index, int length)
Utf8String(string s)
Utf8CodeUnit this[int i]
Utf8String Substring(int index, int length)
Utf8String Trim()
byte[] CopyBytes()
// ...
}
48/53 corefxlab
MemCmp
/// <summary>
/// platform independent fast memory comparison
/// for x64 it is as fast as memcmp of msvcrt.dll,
/// for x86 it is up to two times faster!!
/// </summary>
internal static bool MemCmp<[Primitive]T>
(Span<T> first, Span<T> second)
where T : struct
{
unsafe
{
// ...
49/53 corefxlab
Array slicing syntax (roslyn#120)
int[] primes = new int[] { 2, 3, 5, 7, 9, 11, 13 };
int item = primes[1]; // Regular array access (value 3)
int[:] a = primes[0:3]; // A slice {2, 3, 5}
int[:] b = primes[1:2]; // A slice {3}
int[:] c = primes[:5]; // A slice {2, 3, 5, 7, 9}
int[:] d = primes[2:]; // A slice {5, 7, 9, 11, 13}
int[:] e = primes[:]; // A slice {2, 3, 5, 7, 9, 11, 13}
int[:] f = a[1:2]; // A slice {3}
int[:] g = primes[:]; // A slice {2, 3, 5, 7, 9, 11, 13}
int[:] h = primes; // A slice {2, 3, 5, 7, 9, 11, 13}
int[:] i = h[:]; // A slice {2, 3, 5, 7, 9, 11, 13}
50/53 corefxlab
И другие пространства имён
• System.Collections.Generic.MultiValueDictionary
• System.CommandLine
• System.Drawing.Graphics
• System.IO.FileSystem.Watcher.Polling
• System.Net.Libuv
• System.Numerics.Matrices
• System.Reflection.Metadata.Cil
• System.Text.Formatting.Globalization
• System.Text.Formatting
• System.Text.Http
• System.Text.Json
• System.Threading.Tasks.Channels
• System.Time
51/53 corefxlab
Будущее рядом!
52/53
Вопросы?
Андрей Акиньшин, JetBrains
http://aakinshin.net
https://github.com/AndreyAkinshin
https://twitter.com/andrey_akinshin
andrey.akinshin@gmail.com
53/53

More Related Content

What's hot

Advance features of C++
Advance features of C++Advance features of C++
Advance features of C++
vidyamittal
 
Network lab manual
Network lab manualNetwork lab manual
Network lab manual
Prabhu D
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semester
DOSONKA Group
 
C++11 smart pointer
C++11 smart pointerC++11 smart pointer
C++11 smart pointer
Lei Yu
 

What's hot (20)

Compiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersCompiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | Interpreters
 
Kirk Shoop, Reactive programming in C++
Kirk Shoop, Reactive programming in C++Kirk Shoop, Reactive programming in C++
Kirk Shoop, Reactive programming in C++
 
Compiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax DefinitionCompiler Construction | Lecture 2 | Declarative Syntax Definition
Compiler Construction | Lecture 2 | Declarative Syntax Definition
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
 
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
Lucio Floretta - TensorFlow and Deep Learning without a PhD - Codemotion Mila...
 
C++ L08-Classes Part1
C++ L08-Classes Part1C++ L08-Classes Part1
C++ L08-Classes Part1
 
Computer Programming- Lecture 4
Computer Programming- Lecture 4Computer Programming- Lecture 4
Computer Programming- Lecture 4
 
06.Loops
06.Loops06.Loops
06.Loops
 
Advance features of C++
Advance features of C++Advance features of C++
Advance features of C++
 
Advance C++notes
Advance C++notesAdvance C++notes
Advance C++notes
 
CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011
 
Network lab manual
Network lab manualNetwork lab manual
Network lab manual
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semester
 
Lecture 12: Classes and Files
Lecture 12: Classes and FilesLecture 12: Classes and Files
Lecture 12: Classes and Files
 
C++11 smart pointer
C++11 smart pointerC++11 smart pointer
C++11 smart pointer
 
Functional Programming You Already Know
Functional Programming You Already KnowFunctional Programming You Already Know
Functional Programming You Already Know
 
Constructor,destructors cpp
Constructor,destructors cppConstructor,destructors cpp
Constructor,destructors cpp
 
High performance web programming with C++14
High performance web programming with C++14High performance web programming with C++14
High performance web programming with C++14
 

Viewers also liked

Who would be the audience for your media
Who would be the audience for your mediaWho would be the audience for your media
Who would be the audience for your media
HollieSmith24
 
Company description plus
Company description plusCompany description plus
Company description plus
Aakash Sharma
 
Skrip majlis program genggam 5 a fasa 1 tahun 2014
Skrip majlis program genggam 5 a fasa 1 tahun 2014Skrip majlis program genggam 5 a fasa 1 tahun 2014
Skrip majlis program genggam 5 a fasa 1 tahun 2014
Anis Lisa Ahmad
 
Vaal Mental Health - Business Profile v 6
Vaal Mental Health - Business Profile v 6Vaal Mental Health - Business Profile v 6
Vaal Mental Health - Business Profile v 6
Johan (Sipho) Coetzee
 
Evaluation question 3
Evaluation question 3Evaluation question 3
Evaluation question 3
laura-illing
 
LEGO® Bricks and the Box
LEGO® Bricks and the BoxLEGO® Bricks and the Box
LEGO® Bricks and the Box
Teknobik
 
Fusf presentation to share 11.20
Fusf presentation to share 11.20Fusf presentation to share 11.20
Fusf presentation to share 11.20
fusfpresent
 
Cim d'àligues. Sessió de vol
Cim d'àligues. Sessió de volCim d'àligues. Sessió de vol
Cim d'àligues. Sessió de vol
primariachanel
 

Viewers also liked (20)

Luxembourg investment climate - Main tax features
Luxembourg investment climate - Main tax featuresLuxembourg investment climate - Main tax features
Luxembourg investment climate - Main tax features
 
Revolutionary 7-day Weight Loss Plan to Shed Pounds
Revolutionary 7-day Weight Loss Plan to Shed PoundsRevolutionary 7-day Weight Loss Plan to Shed Pounds
Revolutionary 7-day Weight Loss Plan to Shed Pounds
 
Who would be the audience for your media
Who would be the audience for your mediaWho would be the audience for your media
Who would be the audience for your media
 
Branding Short Story
Branding Short StoryBranding Short Story
Branding Short Story
 
Company description plus
Company description plusCompany description plus
Company description plus
 
Week5 lec3-bscs1
Week5 lec3-bscs1Week5 lec3-bscs1
Week5 lec3-bscs1
 
Xampp
XamppXampp
Xampp
 
Codema lettuce september 2013
Codema lettuce september 2013Codema lettuce september 2013
Codema lettuce september 2013
 
Skrip majlis program genggam 5 a fasa 1 tahun 2014
Skrip majlis program genggam 5 a fasa 1 tahun 2014Skrip majlis program genggam 5 a fasa 1 tahun 2014
Skrip majlis program genggam 5 a fasa 1 tahun 2014
 
Продолжаем говорить о микрооптимизациях .NET-приложений
Продолжаем говорить о микрооптимизациях .NET-приложенийПродолжаем говорить о микрооптимизациях .NET-приложений
Продолжаем говорить о микрооптимизациях .NET-приложений
 
Vaal Mental Health - Business Profile v 6
Vaal Mental Health - Business Profile v 6Vaal Mental Health - Business Profile v 6
Vaal Mental Health - Business Profile v 6
 
Taller técnicas efectivas de cobranza
Taller técnicas efectivas de cobranzaTaller técnicas efectivas de cobranza
Taller técnicas efectivas de cobranza
 
Evaluation question 3
Evaluation question 3Evaluation question 3
Evaluation question 3
 
President joyce banda meeting with british prime minister david cameron
President joyce banda meeting with british prime minister david cameronPresident joyce banda meeting with british prime minister david cameron
President joyce banda meeting with british prime minister david cameron
 
LEGO® Bricks and the Box
LEGO® Bricks and the BoxLEGO® Bricks and the Box
LEGO® Bricks and the Box
 
RP Singh
RP SinghRP Singh
RP Singh
 
Fusf presentation to share 11.20
Fusf presentation to share 11.20Fusf presentation to share 11.20
Fusf presentation to share 11.20
 
Cim d'àligues. Sessió de vol
Cim d'àligues. Sessió de volCim d'àligues. Sessió de vol
Cim d'àligues. Sessió de vol
 
Alta gastronomia Masia Notari 2014
Alta gastronomia Masia Notari 2014Alta gastronomia Masia Notari 2014
Alta gastronomia Masia Notari 2014
 
Public Private Partnership
Public Private Partnership Public Private Partnership
Public Private Partnership
 

Similar to .NET 2015: Будущее рядом

Csharp In Detail Part2
Csharp In Detail Part2Csharp In Detail Part2
Csharp In Detail Part2
Mohamed Krar
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2
Warui Maina
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
HamletDRC
 
If You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are WrongIf You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are Wrong
Mario Fusco
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
Woody Pewitt
 
F# Eye For The C# Guy - Seattle 2013
F# Eye For The C# Guy - Seattle 2013F# Eye For The C# Guy - Seattle 2013
F# Eye For The C# Guy - Seattle 2013
Phillip Trelford
 

Similar to .NET 2015: Будущее рядом (20)

Csharp4 generics
Csharp4 genericsCsharp4 generics
Csharp4 generics
 
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
 
Functional C++
Functional C++Functional C++
Functional C++
 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
 
Introduction à Dart
Introduction à DartIntroduction à Dart
Introduction à Dart
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
Csharp In Detail Part2
Csharp In Detail Part2Csharp In Detail Part2
Csharp In Detail Part2
 
2.overview of c++ ________lecture2
2.overview of c++  ________lecture22.overview of c++  ________lecture2
2.overview of c++ ________lecture2
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
 
If You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are WrongIf You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are Wrong
 
An imperative study of c
An imperative study of cAn imperative study of c
An imperative study of c
 
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic LabsTypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
 
Oop objects_classes
Oop objects_classesOop objects_classes
Oop objects_classes
 
Addressing Scenario
Addressing ScenarioAddressing Scenario
Addressing Scenario
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 
C++11 - STL Additions
C++11 - STL AdditionsC++11 - STL Additions
C++11 - STL Additions
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
 
F# Eye For The C# Guy - Seattle 2013
F# Eye For The C# Guy - Seattle 2013F# Eye For The C# Guy - Seattle 2013
F# Eye For The C# Guy - Seattle 2013
 
KotlinForJavaDevelopers-UJUG.pptx
KotlinForJavaDevelopers-UJUG.pptxKotlinForJavaDevelopers-UJUG.pptx
KotlinForJavaDevelopers-UJUG.pptx
 

More from Andrey Akinshin

More from Andrey Akinshin (20)

Поговорим про performance-тестирование
Поговорим про performance-тестированиеПоговорим про performance-тестирование
Поговорим про performance-тестирование
 
Сложности performance-тестирования
Сложности performance-тестированияСложности performance-тестирования
Сложности performance-тестирования
 
Сложности микробенчмаркинга
Сложности микробенчмаркингаСложности микробенчмаркинга
Сложности микробенчмаркинга
 
Поговорим про память
Поговорим про памятьПоговорим про память
Поговорим про память
 
Кроссплатформенный .NET и как там дела с Mono и CoreCLR
Кроссплатформенный .NET и как там дела с Mono и CoreCLRКроссплатформенный .NET и как там дела с Mono и CoreCLR
Кроссплатформенный .NET и как там дела с Mono и CoreCLR
 
Теория и практика .NET-бенчмаркинга (25.01.2017, Москва)
 Теория и практика .NET-бенчмаркинга (25.01.2017, Москва) Теория и практика .NET-бенчмаркинга (25.01.2017, Москва)
Теория и практика .NET-бенчмаркинга (25.01.2017, Москва)
 
Продолжаем говорить про арифметику
Продолжаем говорить про арифметикуПродолжаем говорить про арифметику
Продолжаем говорить про арифметику
 
Let’s talk about microbenchmarking
Let’s talk about microbenchmarkingLet’s talk about microbenchmarking
Let’s talk about microbenchmarking
 
Теория и практика .NET-бенчмаркинга (02.11.2016, Екатеринбург)
Теория и практика .NET-бенчмаркинга (02.11.2016, Екатеринбург)Теория и практика .NET-бенчмаркинга (02.11.2016, Екатеринбург)
Теория и практика .NET-бенчмаркинга (02.11.2016, Екатеринбург)
 
Поговорим про арифметику
Поговорим про арифметикуПоговорим про арифметику
Поговорим про арифметику
 
Подружили CLR и JVM в Project Rider
Подружили CLR и JVM в Project RiderПодружили CLR и JVM в Project Rider
Подружили CLR и JVM в Project Rider
 
Распространённые ошибки оценки производительности .NET-приложений
Распространённые ошибки оценки производительности .NET-приложенийРаспространённые ошибки оценки производительности .NET-приложений
Распространённые ошибки оценки производительности .NET-приложений
 
Поговорим о микрооптимизациях .NET-приложений
Поговорим о микрооптимизациях .NET-приложенийПоговорим о микрооптимизациях .NET-приложений
Поговорим о микрооптимизациях .NET-приложений
 
Практические приёмы оптимизации .NET-приложений
Практические приёмы оптимизации .NET-приложенийПрактические приёмы оптимизации .NET-приложений
Практические приёмы оптимизации .NET-приложений
 
Поговорим о различных версиях .NET
Поговорим о различных версиях .NETПоговорим о различных версиях .NET
Поговорим о различных версиях .NET
 
Низкоуровневые оптимизации .NET-приложений
Низкоуровневые оптимизации .NET-приложенийНизкоуровневые оптимизации .NET-приложений
Низкоуровневые оптимизации .NET-приложений
 
Основы работы с Git
Основы работы с GitОсновы работы с Git
Основы работы с Git
 
Сборка мусора в .NET
Сборка мусора в .NETСборка мусора в .NET
Сборка мусора в .NET
 
Об особенностях использования значимых типов в .NET
Об особенностях использования значимых типов в .NETОб особенностях использования значимых типов в .NET
Об особенностях использования значимых типов в .NET
 
Phd presentation
Phd presentationPhd presentation
Phd presentation
 

Recently uploaded

AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
Alluxio, Inc.
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
mbmh111980
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
Max Lee
 

Recently uploaded (20)

10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with StrimziStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdf
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
 
The Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionThe Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion Production
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data Migration
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 

.NET 2015: Будущее рядом

  • 1. .NET 2015: Будущее рядом Андрей Акиньшин, JetBrains .NEXT 2015 Moscow 1/53
  • 19. .NET Platform Standard 19/53 .NET Platform Standard
  • 20. .NET Platform Standard Terms .NET Platform Standard — a specific versioned set of reference assemblies that all .NET Platforms must support as defined in the CoreFX repo. Principles • Platform owners implement reference assemblies from a particular .NET Platform Standard version. • Platform owners may implement a subset of reference assemblies from a particular .NET Platform Standard version. • Any change in a reference assembly’s API surface causes the .NET Platform Standard to version. • Lower versions are always compatible with higher versions. 20/53 .NET Platform Standard
  • 21. Relationship to Platforms 21/53 .NET Platform Standard
  • 22. Mapping to platforms 22/53 .NET Platform Standard
  • 23. Portable Profiles 23/53 .NET Platform Standard
  • 25. Contracts from CoreFX ... 25/53 .NET Platform Standard
  • 28. Tuples (Background) public void Tally(IEnumerable<int> values, out int sum, out int count) int s, c; Tally(myValues, out s, out c); Console.WriteLine($"Sum: {s}, count: {c}"); 27/53 C#7
  • 29. Tuples (Background) public void Tally(IEnumerable<int> values, out int sum, out int count) int s, c; Tally(myValues, out s, out c); Console.WriteLine($"Sum: {s}, count: {c}"); public Tuple<int, int> Tally(IEnumerable<int> values) var t = Tally(myValues); Console.WriteLine($"Sum: {t.Item1}, count: {t.Item2}") 27/53 C#7
  • 30. Tuples (Background) public void Tally(IEnumerable<int> values, out int sum, out int count) int s, c; Tally(myValues, out s, out c); Console.WriteLine($"Sum: {s}, count: {c}"); public Tuple<int, int> Tally(IEnumerable<int> values) var t = Tally(myValues); Console.WriteLine($"Sum: {t.Item1}, count: {t.Item2}") public struct TallyResult { public int Sum; public int Count; } public TallyResult Tally(IEnumerable<int> values) var t = Tally(myValues); Console.WriteLine($"Sum: {t.Sum}, count: {t.Count}"); 27/53 C#7
  • 31. Tuples types public (int sum, int count) Tally(IEnumerable<int> values) var t = Tally(myValues); Console.WriteLine($"Sum: {t.sum}, count: {t.count}"); 28/53 C#7
  • 32. Tuples types public (int sum, int count) Tally(IEnumerable<int> values) var t = Tally(myValues); Console.WriteLine($"Sum: {t.sum}, count: {t.count}"); public async Task<(int sum, int count)> TallyAsync(IEnumerable<int> values) var t = await TallyAsync(myValues); Console.WriteLine($"Sum: {t.sum}, count: {t.count}"); 28/53 C#7
  • 33. Tuple literals and deconstruction var t = new (int sum, int count) { sum = 0, count = 0 }; 29/53 C#7
  • 34. Tuple literals and deconstruction var t = new (int sum, int count) { sum = 0, count = 0 }; public (int sum, int count) Tally(IEnumerable<int> values) { var s = 0; var c = 0; foreach (var value in values) { s += value; c++; } return (s, c); // target typed to (int sum, int count) } 29/53 C#7
  • 35. Tuple literals and deconstruction var t = new (int sum, int count) { sum = 0, count = 0 }; public (int sum, int count) Tally(IEnumerable<int> values) { var s = 0; var c = 0; foreach (var value in values) { s += value; c++; } return (s, c); // target typed to (int sum, int count) } public (int sum, int count) Tally(IEnumerable<int> values) { // infer tuple type from names and values var res = (sum: 0, count: 0); foreach (var value in values) { res.sum += value; res.count++; } return res; } 29/53 C#7
  • 36. Tuple literals and deconstruction var t = new (int sum, int count) { sum = 0, count = 0 }; public (int sum, int count) Tally(IEnumerable<int> values) { var s = 0; var c = 0; foreach (var value in values) { s += value; c++; } return (s, c); // target typed to (int sum, int count) } public (int sum, int count) Tally(IEnumerable<int> values) { // infer tuple type from names and values var res = (sum: 0, count: 0); foreach (var value in values) { res.sum += value; res.count++; } return res; } (var sum, var count) = Tally(myValues); // deconstruct result Console.WriteLine($"Sum: {sum}, count: {count}"); 29/53 C#7
  • 37. Tuples: проблемы • Struct or class • Mutability • Tuples as fields • Conversions • . . . Cм. также: roslyn#347 30/53 C#7
  • 38. Pattern matching (Background) // class Person(string Name); class Person { public Person(string name) { this.Name = name; } public string Name { get; } } // class Student(string Name, double Gpa) : Person(Name); class Student : Person { public Student(string name, double gpa) : base(name) { this.Gpa = gpa; } public double Gpa { get; } } // class Teacher(string Name, string Subject) : Person(Name); class Teacher : Person { public Teacher(string name, string subject) : base(name) { this.Subject = subject; } public string Subject { get; } } 31/53 C#7
  • 39. Pattern matching (Background) static string PrintedForm(Person p) { Student s; Teacher t; if ((s = p as Student) != null && s.Gpa > 3.5) { return $"Honor Student {s.Name} ({s.Gpa})"; } else if (s != null) { return $"Student {s.Name} ({s.Gpa})"; } else if ((t = p as Teacher) != null) { return $"Teacher {t.Name} of {t.Subject}"; } else { return $"Person {p.Name}"; } } 32/53 C#7
  • 40. Pattern matching (Background) static void Main(string[] args) { Person[] oa = { new Student("Einstein", 4.0), new Student("Elvis", 3.0), new Student("Poindexter", 3.2), new Teacher("Feynmann", "Physics"), new Person("Anders"), }; foreach (var o in oa) { Console.WriteLine(PrintedForm(o)); } Console.ReadKey(); } 33/53 C#7
  • 41. Pattern matching: is static string PrintedForm(Person p) { if (p is Student s && s.Gpa > 3.5) { return $"Honor Student {s.Name} ({s.Gpa})"; } else if (p is Student s) { return $"Student {s.Name} ({s.Gpa})"; } else if (p is Teacher t) { return $"Teacher {t.Name} of {t.Subject}"; } else { return $"Person {p.Name}"; } } 34/53 C#7
  • 42. Pattern matching: switch static string PrintedForm(Person p) { switch (p) { case Student s when s.Gpa > 3.5 : return $"Honor Student {s.Name} ({s.Gpa})"; case Student s : return $"Student {s.Name} ({s.Gpa})"; case Teacher t : return $"Teacher {t.Name} of {t.Subject}"; default : return $"Person {p.Name}"; } } 35/53 C#7
  • 43. Pattern matching: match static string PrintedForm(Person p) { return p match ( case Student s when s.Gpa > 3.5 : $"Honor Student {s.Name} ({s.Gpa})" case Student s : $"Student {s.Name} ({s.Gpa})" case Teacher t : $"Teacher {t.Name} of {t.Subject}" case * : $"Person {p.Name}" ); } 36/53 C#7
  • 44. Pattern matching: Exceptions return p match ( case Student s when s.Gpa > 3.5 : $"Honor Student {s.Name} ({s.Gpa})" case Student s : $"Student {s.Name} ({s.Gpa})" case Teacher t : $"Teacher {t.Name} of {t.Subject}" case null : throw new ArgumentNullException(nameof(p)) case * : $"Person {p.Name}" ); 37/53 C#7
  • 45. Pattern matching: members return p match ( case Student s when s.Gpa > 3.5 : $"Honor Student {s.Name} ({s.Gpa})" case Student { Name is "Poindexter" } : "A Nerd" case Student s : $"Student {s.Name} ({s.Gpa})" case Teacher t : $"Teacher {t.Name} of {t.Subject}" case null : throw new ArgumentNullException(nameof(p)) case * : $"Person {p.Name}" ); 38/53 C#7
  • 46. Pattern matching: => static string PrintedForm(Person p) => p match ( case Student s when s.Gpa > 3.5 : $"Honor Student {s.Name} ({s.Gpa})" case Student { Name is "Poindexter" } : "A Nerd" case Student s : $"Student {s.Name} ({s.Gpa})" case Teacher t : $"Teacher {t.Name} of {t.Subject}" case null : throw new ArgumentNullException(nameof(p)) case * : $"Person {p.Name}" ); 39/53 C#7
  • 47. Readonly locals readonly int foo = /* ... */ ; readonly var foo = /* ... */ ; val foo = /* ... */ ; public void Bar(readonly int foo = 0) public void Bar(readonly ref Matrix3D matrix) 40/53 C#7
  • 48. Immutable Types public immutable struct Tuple<T1, T2> { public Tuple(T1 item1, T2 item2) { Item1 = item1; Item2 = item2; } public T1 Item1; // Implicitly readonly public T2 Item2; // Implicitly readonly } 41/53 C#7
  • 49. Immutable Types public immutable struct Tuple<T1, T2> { public Tuple(T1 item1, T2 item2) { Item1 = item1; Item2 = item2; } public T1 Item1; // Implicitly readonly public T2 Item2; // Implicitly readonly } public immutable struct ImmutableTuple<T1, T2> (T1 item1, T2 item2) where T1 : immutable where T2 : immutable { public ImmutableTuple(T1 item1, T2 item2) { Item1 = item1; Item2 = item2; } public T1 Item1; public T2 Item2; } 41/53 C#7
  • 51. Nullability?! 1 Добавляем в язык только ? и ! при объявления и кастах 42/53 C#7
  • 52. Nullability?! 1 Добавляем в язык только ? и ! при объявления и кастах 2 NullReferenceException невозможен 42/53 C#7
  • 53. Nullability?! 1 Добавляем в язык только ? и ! при объявления и кастах 2 NullReferenceException невозможен 3 Процесс компиляции не меняется 42/53 C#7
  • 54. Nullability?! 1 Добавляем в язык только ? и ! при объявления и кастах 2 NullReferenceException невозможен 3 Процесс компиляции не меняется 4 Runtime ничего не знает про not-nullable 42/53 C#7
  • 55. Nullability?! 1 Добавляем в язык только ? и ! при объявления и кастах 2 NullReferenceException невозможен 3 Процесс компиляции не меняется 4 Runtime ничего не знает про not-nullable 5 Обратная совместимость 42/53 C#7
  • 56. С#7: много разных идей • Local functions • Extensions properties • AsyncEnumerable • params IEnumerable • digits separators • binary literals • ... 43/53 C#7
  • 58. ILSub [MethodImpl(MethodImplOptions.AggressiveInlining)] [ILSub(@" .maxstack 2 .locals ([0] uint8& addr) ldarg.0 // load the object stloc.0 // convert the object pointer to a byref ldloc.0 // load the object pointer as a byref ldarg.1 // load the offset add // add the offset ldobj !!T // load a T value from the computed address ret")] public static T Get<T>(object obj, UIntPtr offset) { return default(T); } 45/53 corefxlab
  • 59. System.Buffers public sealed class ManagedBufferPool<T> where T : struct { // 2MB taken as the default since the average HTTP page // is 1.9MB per http://httparchive.org/interesting.php public ManagedBufferPool(int maxBufferSizeInBytes = 2048000) static ManagedBufferPool<byte> SharedByteBufferPool{get;} T[] RentBuffer(int size, bool clearBuffer = false) void EnlargeBuffer(ref T[] buffer, int newSize, bool clearFreeSpace = false) void ReturnBuffer(ref T[] buffer, bool clearBuffer = false) } 46/53 corefxlab
  • 60. System.Slices public partial struct Span<T> : IEnumerable<T>, IEquatable<Span<T>> { readonly object _object; readonly UIntPtr _offset; public readonly int Length; // ... Span(T[] array, int start, int length) unsafe Span(void* ptr, int length) bool TryCopyTo(Span<T> dest) Span<T> Slice(int start, int length) } // Extensions static Span<T> Slice<T>(this T[] array, int start, int length) static Span<char> Slice(this string str, int start, int length) static Span<U> Cast<[Primitive]T, [Primitive]U>(this Span<T> slice) static bool SequenceEqual<T>(this Span<T> first, Span<T> second) // ... 47/53 corefxlab
  • 61. System.Text.Utf8 public partial struct Utf8String : IEnumerable<Utf8CodeUnit>, IEquatable<Utf8String>, IComparable<Utf8String> { private Span<byte> _buffer; Utf8String(Span<byte> buffer) Utf8String(byte[] utf8bytes, int index, int length) Utf8String(string s) Utf8CodeUnit this[int i] Utf8String Substring(int index, int length) Utf8String Trim() byte[] CopyBytes() // ... } 48/53 corefxlab
  • 62. MemCmp /// <summary> /// platform independent fast memory comparison /// for x64 it is as fast as memcmp of msvcrt.dll, /// for x86 it is up to two times faster!! /// </summary> internal static bool MemCmp<[Primitive]T> (Span<T> first, Span<T> second) where T : struct { unsafe { // ... 49/53 corefxlab
  • 63. Array slicing syntax (roslyn#120) int[] primes = new int[] { 2, 3, 5, 7, 9, 11, 13 }; int item = primes[1]; // Regular array access (value 3) int[:] a = primes[0:3]; // A slice {2, 3, 5} int[:] b = primes[1:2]; // A slice {3} int[:] c = primes[:5]; // A slice {2, 3, 5, 7, 9} int[:] d = primes[2:]; // A slice {5, 7, 9, 11, 13} int[:] e = primes[:]; // A slice {2, 3, 5, 7, 9, 11, 13} int[:] f = a[1:2]; // A slice {3} int[:] g = primes[:]; // A slice {2, 3, 5, 7, 9, 11, 13} int[:] h = primes; // A slice {2, 3, 5, 7, 9, 11, 13} int[:] i = h[:]; // A slice {2, 3, 5, 7, 9, 11, 13} 50/53 corefxlab
  • 64. И другие пространства имён • System.Collections.Generic.MultiValueDictionary • System.CommandLine • System.Drawing.Graphics • System.IO.FileSystem.Watcher.Polling • System.Net.Libuv • System.Numerics.Matrices • System.Reflection.Metadata.Cil • System.Text.Formatting.Globalization • System.Text.Formatting • System.Text.Http • System.Text.Json • System.Threading.Tasks.Channels • System.Time 51/53 corefxlab