420 likes | 700 Views
What’s new in Visual Studio 2010 .Net Framework 4.0 and C#4.0. Ofir Aspis 1/2010 www.bna.co.il ofir@bna.co.il. Agenda. VS 2010 Targets High Level - IDE New Features VS 2010 As Editor and Platform Demo Editor features Extending the IDE Web MVC 2 and TDD Break
E N D
What’s new in Visual Studio 2010.Net Framework 4.0 and C#4.0 Ofir Aspis 1/2010 www.bna.co.il ofir@bna.co.il
Agenda • VS 2010 Targets • High Level - IDE New Features • VS 2010 As Editor and Platform • Demo • Editor features • Extending the IDE • Web MVC 2 and TDD • Break • What’s new in .Net Framework 4.0 and C# 4.0 • New Language Features • New Framework Application Blocks
Visual Studio 2010 Targets Complete Ultimate Premium Feature Set Professional Express Minimal Hobbyist Enterprise Audience
A New, Simplified SKU Structure VSTS Team Suite w/ MSDN Premium VS 2010 Ultimate w/ MSDN VSTS Development Ed. w/ MSDN Premium VSTS Database Ed. w/ MSDN Premium VS 2010 Premium w/ MSDN VSTS Architecture Ed. w/ MSDN Premium VSTS Test Ed. w/ MSDN Premium VS 2010 Professional w/ MSDN Visual Studio Professional w/ MSDN Premium Visual Studio Professional w/ MSDN Professional VS 2010 Professional Visual Studio Professional Visual Studio Standard
High-Level Features Visual Studio 2010 Professional Web Development Windows Development Silverlight Tooling Office Development Customizable IDE SharePoint Development Generate From Usage Cloud Development New WPF Editor Multi-Core Development
New features, the tip of the iceberg… Breakpoint Grouping Parallel Tasks Window New Look & Feel Extensible Test Runner Dynamic Data Tooling Generate From Usage Highlight References WPF-based Editor Breakpoint Labeling Click-Once Enhancements for Office Call Hierarchy Web Deploy Improved WPF Tooling Sharepoint Tooling Historical Debugging MVC Tooling Inline Call Tree Minidump Debugging Quick Search Concurrency Profiler JQuery Intellisense Breakpoint Import/Export Document Map Margin 64-bit Mixed-Mode Parallel Stacks Window HTML Snippets Improved Multi-Monitor web.config Transformation
The Two Faces of Visual Studio 2010 Visual Studio As An Editor Visual Studio As A Platform
… As An Editor An improved focus on… Writing code, Understanding code, Navigating code, Publishing code
… As A Platform New Extensible Editor allows editor to be easily extended to provide a rich and robust editing experience Online Visual Studio Gallery integrated directly into Visual Studio
… As A Platform Enabling the Visual Studio Ecosystem through: Online Templates Extensions and Extension Manager All Contributable by Community
The VS2010 Roadmap • Beta 2, October 19th, 2009 • RTM, March 22nd, 2010
What’s new in .Net4.0 and C# 4.0 • .Net Framework - A Brief Review • .Net Framework 4.0 Highlights • Managed Extensibility Framework (MEF) • Managed Languages • C# 4.0 New Features • Dynamic Language Runtime (DLR) • F#
The .NET Framework WPF Win Forms DLR ASP.NET WCF LINQ And more! Base Class Libraries The CLR JIT & NGEN Garbage Collector Security Model Exception Handling Loader & Binder
A Look Back… SP1 3.5 3.0 .NET 1.0 .NET 1.1 .NET 2.0 .NET 4 2002 2003 2005-08 2008 CTP CLR 1.0 CLR 1.1 CLR 2.0 CLR 4
Web Applications Client Applications Web Forms 4 AJAX 4 WPF 4 MEF Client/Server WCF 4
Managed Extensibility Framework • The Managed Extensibility Framework (MEF) is a new library in the .NET Framework that enables greater reuse of applications and components. • Using MEF, .NET applications can make the shift from being statically compiled to dynamically composed
Managed Languages Today Our managed languages are starting to share some very similar features: Functional Concise Declarative
Why Declarative Matters… What How Imperative Declarative
LINQ, The Power of Declarative IList<Person> FindParentsWithChildNamed(string childName) { var matches = new List<Person>(); foreach(var person in _people) { foreach(var child in person.Children) { if (child.Name.Equals(childName)) { matches.Add(person); break; } } } return matches; } Before
LINQ, The Power of Declarative IList<Person> FindParentsWithChildNamed(string childName) { var matches = from person in people from child in person.Children where child.Name.Equals(childName) select person; return matches.ToList(); } After
Parallel LINQ Parallel LINQ (PLINQ)enables developers to easily leveragemanycore with a minimal impactto existing LINQ programming model var q = from p in people where p.Name == queryInfo.Name && p.State == queryInfo.State && p.Year >= yearStart && p.Year <= yearEnd orderbyp.Year ascending select p; .AsParallel()
The Evolution of C# C# 4.0 Dynamic C# 3.0 LINQ C# 2.0 Generics C# 1.0 Managed Code
New C# 4.0 Features • Late-Binding Support • Named and Optional Parameters • Improved COM Interop • Covariance and Contravariance
Named and Optional Parameters • Consider this example: public void M(int x, int y = 5, int z = 7) { } • In this method, the parameters y and z are assigned default values. Calls to this method might look like this: M(1, 2, 3); // ordinary call of MM(1, 2); // omitting z – equivalent to M(1, 2, 7)M(1); // omitting both y and z – equivalent to M(1, 5, 7)M(1, z: 3); // passing z by nameM(x: 1, z: 3); // passing both x and z by nameM(z: 3, x: 1); // reversing the order of arguments
Type Equivalence Interop Assemblies translate between managed code and COM For each interface, struct, enum, delegate, and member, contains a managed equivalent with marshalling data
However Primary Interop Assemblies cause many pain points…
NO PIA • Compilers embed the portions of the interop assemblies that the add-ins actually use • Runtime ensuresthe embedded definitions of these types are considered equivalent
Why a “Dynamic Language Runtime”? Dynamically-Typed Ruby Python Statically-Typed VB C# Common Language Runtime
Why a “Dynamic Language Runtime”? Dynamically-Typed Ruby Python Statically-Typed VB Dynamic Language Runtime C# Common Language Runtime
.NET Dynamic Programming IronPython IronRuby C# VB.NET Others… Dynamic Language Runtime Expression Trees Dynamic Dispatch Call Site Caching PythonBinder RubyBinder ObjectBinder JScriptBinder COMBinder
Dynamically Typed Objects Calculator calc = GetCalculator(); int sum = calc.Add(10, 20); object calc = GetCalculator(); TypecalcType = calc.GetType(); object res = calcType.InvokeMember("Add", BindingFlags.InvokeMethod, null, newobject[] { 10, 20 }); int sum = Convert.ToInt32(res); ScriptObject calc = GetCalculator(); object res = calc.Invoke("Add", 10, 20); int sum = Convert.ToInt32(res); Statically typed to be dynamic dynamic calc = GetCalculator(); int sum = calc.Add(10, 20); Dynamic conversion Dynamic method invocation
F# in VS2010 • F# is .NET managed programming language combining functional programming and object-oriented programming. • It’s ideally suited for parallel, algorithmic, technical and explorative development • F# is a strongly-typed language like C#, but with a lightweight syntax often seen in a dynamic language like Python
F# Features • “Programming in The Small” with Tuples and functions • Simple, and more error-free asynchronous programming • Strong types for floating point code • Integrated with Visual Studio 2010
Syntax Sample let data = (1,2,3) let rotations (x, y, z) = [ (x, y, z); (z, x, y); (y, z, x) ] let derivative f x = let p1 = f (x - 0.05) let p2 = f (x + 0.05) (p2 - p1) / 0.1 let f x = 2.0*x*x - 6.0*x + 3.0 let df = derivative f System.Console.WriteLine("The derivative of f at x=4 is {0}", df 4.0)
Parallel and Asynchronous Programming with F# let http url = async { let req = WebRequest.Create(Uri url) let! resp = req.AsyncGetResponse() let stream = resp.GetResponseStream() let reader = new StreamReader(stream) let! contents = reader.AsyncReadToEnd() return contents } let sites = ["http://bing.com"; "http://microsoft.com"; "http://msdn.com"; "http://msnbc.com"] let htmlOfSites = Async.Parallel [for site in sites -> http(site)] |> Async.RunSynchronously
RESOURCES • Visual Studio 2010/.NET Framework 4.0 Training Kit • November Preview: http://tinyurl.com/5zf8y8 • Visual Studio Topic Area on Channel 9 • http://channel9.msdn.com/visualstudio • Includes videos from VS2010 and VSTS2010 weeks on Channel 9 • VS2010/NETFX4 Futures on MSDN • http://msdn.microsoft.com/en-us/vs2008/products/cc948977.aspx