vs2012

27
Visual Studio 2012 and .NET 4.5 Andrei Marukovich [email protected] Twitt er: @amarukovich Blog: lunarfrog.com/ blog

Upload: bhaumik-shah

Post on 10-Nov-2014

17 views

Category:

Documents


1 download

TRANSCRIPT

Visual Studio 2012 and .NET 4.5

Andrei [email protected]

Twitter:

@amarukovich

Blog: lunarfrog.com/blog

2

Agenda

• Visual Studio 2012 improvements

• .NET Framework 4.5

• C# 5

3

Projects round-tripping

Visual Studio 2010 Visual Studio 2012

4

Round-tripping constrains

• Requires Visual Studio 2010 SP1

• Supports .NET 2.0 to 4.0, Silverlight 4 to 5

• Project categories• Round-trips seamlessly• Requires behavioral modifications to

round-trip• Does not round-trip• Deprecated projects

5

Demo

VS 2012 User Interface

6

Portable Class Libraries

• New project type

• Multi-platform targeting

7

.NET 4.5 Framework

• Pre-installed in Windows 8

• Windows XP is not supported

• .NET 4.5 is an in-place update for 4.0

.NET 2.0 .NET 4.0

.NET 3.0

.NET 3.5.NET 4.5

CLR 2.0 CLR 4.0

8

New in .NET 4.5

• Native .zip files support

ZipFile.CreateFromDirectory(@"C:\Example\", @"C:\Temp\example.zip");

ZipFile.ExtractToDirectory( @"C:\Temp\example.zip“, @"C:\Output\");

9

New in .NET 4.5

• ZipArchive class for fine control

var extractPath = @"c:\example\extract";

using (ZipArchive archive = ZipFile.OpenRead(@"c:\example\start.zip")) { foreach (ZipArchiveEntry entry in archive.Entries) { if (entry.FullName.EndsWith(".txt")) { entry.ExtractToFile(Path.Combine(extractPath, entry.FullName)); } } }

10

Performance optimizations

• Multicore Just-in-Time (JIT) compiler

static void Main(){ ProfileOptimization.SetProfileRoot(@"C:\Profiles\"); ProfileOptimization.StartProfile ("AppProfiles"); …}

• Enabled by default - ASP.NET 4.5, Silverlight 5

11

Native Image Generation

• Automatic Native Image Generation(NGen)

• Managed Profile Guided Optimization

12

Asynchrony

• New keywords in C# and VB• async• await

• Async methods in .NET framework

13

Synchronous call

private void ButtonClick(){ WebClient client = new WebClient(); var str = client.DownloadString("http://host/service"); ResultsBox.Text = str;}

Download Update

Thread

14

Async call

async private void ButtonClick(){ WebClient client = new WebClient(); var str = await client.DownloadStringTaskAsync("http://host/service"); ResultsBox.Text = str;}

Thread

Download string

15

Async call details

ButtonClick()

Download String

ButtonClick_Callback()

16

Demo

async and await

17

Limitations

• Cannot use await inside constructor

• Cannot use await inside catch and finally

• Cannot use await inside lock block

• Cannot use await inside Main method

18

New attributes in C# 5

• Caller information attributes• CallerMemberName• CallerFilePath• CallerLineNumber

19

Demo

Caller information attributes

20

Closures in C# 4public void PrintNumbers(){ var values = new List<int> { 1, 2, 3, 4, 5 }; var funcs = new List<Func<int>> ();

foreach(var v in values) funcs.Add( ()=> v);

foreach(var f in funcs) Console.WriteLine(f ());}

5 5 5 5 5

21

Closures in C# 4public void PrintNumbers(){ var values = new List<int> { 1, 2, 3, 4, 5 }; var funcs = new List<Func<int>> ();

foreach(var v in values) { var x = v; funcs.Add( ()=> x); } foreach(var f in funcs) Console.WriteLine(f ());}

1 2 3 4 5

22

Closures in C# 5public void PrintNumbers(){ var values = new List<int> { 1, 2, 3, 4, 5 }; var funcs = new List<Func<int>> ();

foreach(var v in values) funcs.Add( ()=> v);

foreach(var f in funcs) Console.WriteLine(f ());}

1 2 3 4 5

23

Desktop app development

.NETWinForm

s

.NET/XAML WPF

.NET/XAML

Silverlight

HTML/JSASP.NET

.NETWinForm

s

.NET/XAML WPF

.NET/XAML

Silverlight

HTML/JSASP.NET

HTML/JSWinRT

.NET/XAMLWinRT

C++/XAML/DX

Desktop HTML/BrowserWindows 8

Windows 7

Windows 8

24

Windows 8 app platform

WinRT APIs

IE 10 Engine

C++.NET

JavaScript C# / VB

HTML5 / CSS

DirectX XAML

Windows Kernel Services

25

Visual Studio 2012

Improved IDE

UI improvements

Better Intellisense

HTML5 templates

Portable libraries

Performance

Async

Multicore JIT

Optimized NGen

Technologies

Web API

EF 4.5

MEF 2.0

ASP .NET

WinRT

26

VisualStudio.com

Visual Studio Express

Windows 8

Web

Desktop

Free

Visual Studio

Ultimate

Premium

Professional

90-day trial

Thank you!

27

lunarfrog.com/blog

@amarukovich