Title slide to be used at the start of a Kathleen Dollard - CodeRapid module. @kathleendollard kathleendollard [email protected] Blog: http://blogs.msmvps.com/kathleen http://www.pluralsight.com/author/kathleen -dollard
Three Ways Roslyn Will Change Your Life •
•
•
•
•
•
•
•
•
•
•
•
• •
•
•
•
•
•
•
•
•
•
•
•
• Language History
Version CLR Date .NET Framework Visual Studio
C# 1.0 / VB 7 1.0 January 2002 .NET Framework 1.0 Visual Studio .NET 2002
C# 1.2 / VB 7.1 1.1 April 2003 .NET Framework 1.1 Visual Studio .NET 2003
C# 2.0 / VB 8 2.0 November 2005 .NET Framework 2.0 Visual Studio 2005
.NET Framework 2.0 2.0 Visual Studio 2008 C# 3.0 /VB 9 November 2007 .NET Framework 3.0 ] 2.0 SP1 Visual Studio 2010 .NET Framework 3.5
C# 4.0 / VB 10 4.0 April 2010 .NET Framework 4 Visual Studio 2010
Visual Studio 2012 C# 5.0 / VB 11 4.5 August 2012 .NET Framework 4.5 Visual Studio 2013
C# and VB Vnext VNext 2015?? VNext VNext
From www.Wikipedia.org
public void HelloWorld() { Console.WriteLine("Hello World"); } “Console”
System.Console Mine.Console
Compiler Pipeline Compiler Compiler API Pipeline Compiler Language Compiler API Service Pipeline •
•
•
•
•
•
•
•
•
•
•
•
• •
•
•
•
•
•
•
•
•
•
•
•
• • I was at her • talk yesterday • • • • • • • • • I was not at her • talk yesterday • Let’s build an analyzer with code fix!!! Analyzers and code fixes let you define rules for your projects, and define guidelines for libraries •
•
•
•
•
•
•
•
•
•
•
•
• •
•
•
•
•
•
•
•
•
•
•
•
• What have people already done with Roslyn? Quick look at OzCode, CodeConnect and ScriptCS .
.
.
. Didn’t you think more like... o Customer class implements INotifyPropertyChanged ◦ FirstName property (string) ◦ LastName property (string) ◦ Birthdate property (date) ◦ Id property (integer) Common Language Agnostic Mutable DOM
Language Agnostic Source Code Load GetSyntax SourceSource CodeCode RoslynDom Model Common Language Agnostic Mutable DOM
Load GetSyntax Language Agnostic Source Code SourceSource CodeCode RoslynDom Model
Roslyn Roslyn How do you think about this code?
namespace Foo { namespace Foo.Bar1 namespace Bar1 { { class FooBar{ } class FooBar{ } } } }
A. I think of them both as two nested namespaces
B. I think of them both as a single dotted namespace
C. I think of the first as nested namespaces and the second as a dotted namespace
D. I’m not a .NET programmer or I’m distracted by the shiny lights How do you think about this code?
public async Task
A. I think of this as a single set of code with something special in the middle (await)
B. I think of this as a block of code that runs before the delay, and a separate block after the delay
C. It depends on what I’m doing
D. I don’t know enough about async in .NET to answer Let’s dream my dream Window title using System; using System.ComponentModel;
namespace ExpansionFirstExample { public sealed class Customer : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged
[NotifyPropertyChanged] private string firstName; public class Customer : BizBase
private int id; public int Id “Real” code Window title debugging, using System; interacts with other using System.ComponentModel; code Happy Humans namespace ExpansionFirstExample { public sealed class Customer : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged
[NotifyPropertyChanged] private string firstName; public class Customer : BizBase
private int id; public int Id Window title using System; [NotifyPropertyChanged] using System.ComponentModel;
namespace ExpansionFirstExample { public class Customer : BizBase
public string FirstName { get; set; } private string firstName; public string FirstName { get { return firstName; } set { SetProperty(ref firstName, value); } }
public string LastName { get; set; } private string lastName; public string LastName { get { return lastName; } set { SetProperty(ref lastName, value); } }
public int Id { get; set; } private int id; public int Id Window title using System; [NotifyPropertyChanged] using System.ComponentModel;
namespace ExpansionFirstExample { public class Customer : BizBase
public string FirstName { get; set; } private string firstName; public string FirstName { get { return firstName; } set { SetProperty(ref firstName, value); } }
public string LastName { get; set; } private string lastName; public string LastName { get { return lastName; } set { SetProperty(ref lastName, value); } }
public int Id { get; set; } private int id; public int Id Window title
[NotifyPropertyChanged]
public class Customer : BizBase
public string FirstName { get; set; }
public string LastName { get; set; }
public int Id { get; set; } Change to right Change to left Window title changes left if possible affects right Else, custom source, alters [NotifyPropertyChanged] template, or cancels
public class Customer : BizBase
public string FirstName { get; set; } Change to Initial templates template Templates can be in proposed on requests scope a governance intelligent diff of of change hierarchy source (Ok, ambitious) public string LastName { get; set; }
public int Id { get; set; } My real dream is that you can realize your dream