For quite a long time I tried to study Roslyn , but like all of us, I ran into a single problem: there was absolutely no time for that. How is this question usually solved? We go to a lot of resources and look for reports and articles on the topic of interest to us and how we repeat the author’s movements as a template, which shows how to use it. What do we encounter when looking for descriptions of the topics proposed on the CLR ium ? We do not find anything . Ie, of course, Google gives out something on the requests of “Roslyn”, “Roslyn samples”, but nevertheless these are chewed examples a thousand times, and, moreover, ancient as mammoths by the standards of release of new CTP versions. This is important because the availability of information implies the development of a particular infrastructure. And the coolest but not the only article on Roslyn at the moment is this: Roslyn to automatically translate C # code into 1C code This is where ideas came up to tell the CLR ium about Roslyn , RyuJIT , CoreFx , the sharing of objects between processes and other issues that are difficult to find answers on the Internet. So, the main topics that we are ready to cover on the Roslyn report:
We will not do the introductory : on the Internet, all the reports are introductory and you have seen them
We will analyze from simple to complex how the existing rules are arranged in the supply of Roslyn ( C # 6 features ). But consider not a list, as they do at conferences, but their source code
As soon as we review them, we will review the existing metrics on Roslyn. How they are written, how code metrics are built .
Next, we will write not just "count the number of letters" a "in all the words of the source code, we will write support for tuples for C #:
public (int, int) ReturnCoords() { return (0, 0); } var (x, y) = ReturnCoords();
And make Nemerle match operator.
match (i) { | 1 => Console.WriteLine(1) | 2 => Console.WriteLine(2) | x => Console.WriteLine(x) } match (i) { | x when (x < 0) => WriteLine("negative") | x when (x > 36) => WriteLine("more than 36") | x when (x % 2 == 0)=> WriteLine($"valid even number $x") | x => WriteLine($"valid odd number $x") } match (obj) { | iDisp is IDisposable => iDisp.Dispose() | _ => (); }
These are very complex examples that you can’t easily write for the evening and this is what you want to find on the Internet, but you can’t.