Välkommen till Sommarkollo 2007 2006. VISUAL STUDIO 2008.
-
Upload
esmond-newman -
Category
Documents
-
view
214 -
download
0
Transcript of Välkommen till Sommarkollo 2007 2006. VISUAL STUDIO 2008.
Välkommen till Sommarkollo 2007
2006
VISUAL STUDIO 2008
Agenda
Target vista & .NET 3.0 Handle Data Microsoft Office New Web Experience ALM
Wanna’ see a movie?
Friday the 6’th 15.00 Kista Centrum 100 seats for free
Visual Studio ”Orcas”
JScript IntelliSense
WPF and WCFvisual designers
“My” support for.NET Framework 3.0 VSTS support for
device development
VSTO for 2007 Office system
Language-integratedquery (LINQ)
Windows Vistadebugging & profiling
MFC forWindows Vista
Office Ribboncontrols
Load TestModeler
Full AJAX support
Diagnostics supportfor WCF applications
Test-driven profiling
Tools for DB ProsSupport fordistributed teams
VB, XAML,andXML Refactoring
Framework Multitargeting
Choose which Framework version to target when building an application .NET Framework 2.0 (Whidbey) .NET Framework 3.0 (Vista) .NET Framework 3.5 (Orcas)
VS IDE only shows feature appropriate for your selected target version Toolbox, Add New Item, Add Reference, Add
Web Reference, Intellisense, etc
Framework Multitargeting
Framework Multitargeting
Whidbey Vista Orcas
time
Version = Assembly references + compilersNo new CLR runtime
Framework Multitargeting
Framework 2.0 – no framework 3.0 required
Raw Vista Box – no Framework 3.5 Enhanced scenarios – LINQ, AJAX, full
framework 3.5 Easy upgrade for current VS2005
Developers Not available in Express SKUs
Multi-targeting Scenarios
Target vista & .NET 3.0
Target Vista – C++
Prepare for UAC – User Account Control Embed manifest through
property in project Leverage new controls
Task Dialog Command Link Split Button Network Address Sys Link
Use Aero style and appearance in your applications http://msdn.microsoft.com/msdnmag/issues/
07/06/Cpp/
Visual Designer for WPF creates a seamless designer/developer workflow with Expression Blend
XAML-based editing directly in the IDE Changes reflected in the designer in realtime
Control extensibility Project templates, debugger & deployment
support Side-by-side support for Winforms
ElementHost in Toolbox ClickOnce deployment support for WPF apps
Windows Presentation Foundation
Autohost for the hosting of WCF services WSDL test client allows message injection
(beta 2) Hosting Wizard eases migration of
services New WCF Project templates include both
the Autohost and Test Client into an out-of-the-box F5 experience
Simple item template for adding WCF services to an existing Project
Windows Communication &Windows Workflow Foundation
Windows Communication &Windows Workflow Foundation Activities to consume WCF services
Function similarly to the InvokeWebService activity available today
Hosting extensions to expose WF workflows as WCF services Messaging activities (send, receive) A workflow hosting environment to handle
instantiation and message routing
Mobile Development
Works side-by-side with Visual Studio 2005 In-box support for Windows Mobile 5.0
SDKs Unit Testing Integration with Visual Studio
Team System Security Aware IDE Device Emulator 3.0
Create unit tests for Create unit tests for device applications device applications using the VSTS Unit using the VSTS Unit Test infrastructureTest infrastructure
Ability to target Ability to target multiple multiple
versions of versions of the .NET the .NET Compact Compact
Framework Framework runtimeruntime
Device Security Device Security Manager makes it easy Manager makes it easy to deal with complex to deal with complex
device security device security settingssettings
Better Better understand understand
current device current device security security settingssettings
Easy to change the Easy to change the device into a specific device into a specific
security setting to test security setting to test application under application under different security different security
profilesprofiles
Device emulator Device emulator offers the ability to offers the ability to
emulate new emulate new hardware hardware
peripheralsperipherals
Device emulator Device emulator emulating Windows emulating Windows Embedded CE 6.0 Embedded CE 6.0 operating systemoperating system
Emulating a low battery scenario. This feature is Emulating a low battery scenario. This feature is very helpful for device developers to see how very helpful for device developers to see how their application will behave in a low battery their application will behave in a low battery
scenario on a real devicescenario on a real device
Core Language Enhancements
Extension Methods
namespace MyStuff{ public static class Extensions { public static string Concatenate(this IEnumerable<string> strings, string separator) {…} }}
using MyStuff;
string[] names = new string[] { "Axel", "Mia", "Niels" };string s = names.Concatenate(", ");
Extensionmethod
Brings extensions into scope
obj.Foo(x, y)
XXX.Foo(obj, x, y)
IntelliSense!
Object Initializerspublic class Point{ private int x, y;
public int X { get { return x; } set { x = value; } } public int Y { get { return y; } set { y = value; } }}
Point a = new Point { X = 0, Y = 1 };
Point a = new Point();a.X = 0;a.Y = 1;
Field or property assignments
Collection Initializers
List<int> numbers = new List<int> { 1, 10, 100 };
Must implement IEnumerable
List<int> numbers = new List<int>();numbers.Add(1);numbers.Add(10);numbers.Add(100);
Must have public Add method
Dictionary<int, string> spellings = new Dictionary<int, string> { { 0, "Zero" }, { 1, "One" }, { 2, "Two" }, { 3, "Three" } };
Add can take more than one
parameter
IEnumerable<Contact> phoneListQuery = from c in customers where c.State == "WA" select new Contact { Name = c.Name, Phone = c.Phone };
Anonymous Types
public class Contact{ public string Name; public string Phone;}
+
var phoneListQuery = from c in customers where c.State == "WA" select new { Name = c.Name, Phone = c.Phone };
Anonymous Types class XXX{ public string Name; public string Phone;}
IEnumerable<XXX>
foreach (var entry in phoneListQuery) { Console.WriteLine(entry.Name); Console.WriteLine(entry.Phone);}
XXX
Expression TreesCode as Data
Predicate<Customer> test = c => c.State == "WA";
Predicate<Customer> test = new Predicate<Customer>(XXX);
private static bool XXX(Customer c) { return c.State == "WA";}
public delegate bool Predicate<T>(T item);
Expression TreesCode as Data
Expression<Predicate<Customer>> test = c => c.State == "WA";
public delegate bool Predicate<T>(T item);
ParameterExpression c = Expression.Parameter(typeof(Customer), "c");Expression expr = Expression.Equal( Expression.Property(c, typeof(Customer).GetProperty("State")), Expression.Constant("WA") );Expression<Predicate<Customer>> test = Expression.Lambda<Predicate<Customer>>(expr, c);
Automatic properties
public class Product{ public string Name; public decimal Price;}
Automatic properties
public class Product{ string name; decimal price;
public string Name { get { return name; } set { name = value; } }
public decimal Price { get { return price; } set { price = value; } }}
Automatic properties
public class Product{ public string Name { get; set; } public decimal Price { get; set; }}
private string □;
public string Name { get { return □; } set { □ = value; }}
Must have both get and set
C# 3.0 Language Innovations
var contacts = from c in customers where c.State == "WA" select new { c.Name, c.Phone };
var contacts = customers .Where(c => c.State == "WA") .Select(c => new { c.Name, c.Phone });
Extension methods
Lambda expressions
Query expressions
Object initializers
Anonymous types
Local variable type inference
Handle Data
Problem:Data != Objects
The LINQ Project
Objects
<book> <title/> <author/> <year/> <price/></book>
XML
.NET Language Integrated Query
C# 3.0 VB 9.0 Others…
Relational
LINQ toObjects
LINQ toSQL
LINQ toXML
LINQ toEntities
LINQ toDataSets
LINQ Operators
Restriction Where
Projection Select, SelectMany
Ordering OrderBy, ThenBy
Grouping GroupBy
Joins Join, GroupJoin
Quantifiers Any, All
Partitioning Take, Skip, TakeWhile, SkipWhile
Sets Distinct, Union, Intersect, Except
Elements First, Last, Single, ElementAt
Aggregation Count, Sum, Min, Max, Average
Conversion ToArray, ToList, ToDictionary
Casting OfType<T>, Cast<T>
SqlConnection c = new SqlConnection(…); c.Open(); SqlCommand cmd = new SqlCommand( @"SELECT c.Name, c.Phone
FROM Customers c WHERE c.City = @p0"
); cmd.Parameters.AddWithValue("@po", "London"); DataReader dr = c.Execute(cmd); while (dr.Read()) { string name = dr.GetString(0); string phone = dr.GetString(1); DateTime date = dr.GetDateTime(2); } dr.Close();
Data Access In APIs Today
Queries in quotes
Arguments loosely bound
Results loosely typed
Compiler cannot help
catch mistakes
Data Access with LINQ
public class Customer { public int Id; public string Name; public string City; public string Phone; }
----------------------------
GridView1.DataSource = from customer in db.Customers where customer.City == "London" select customer;
GridView1.DataBind();
Classes describe data
Query is natural part
of the language
The compiler provides
IntelliSense and type-checking
LINQ Architecture
ObjectsObjects
<book> <title/> <author/> <price/></book>
XMLXMLRelationalRelational
LINQ enabled data sourcesLINQ enabled data sources
LINQ LINQ To ObjectsTo Objects
LINQ LINQ To XMLTo XML
LINQ enabled ADO.NETLINQ enabled ADO.NET
VBVB Others…Others…
LINQ LINQ To EntitiesTo Entities
LINQ LINQ To SQLTo SQL
LINQ LINQ To DatasetsTo Datasets
.Net Language Integrated Query (LINQ).Net Language Integrated Query (LINQ)
C#C#
LINQ Basics
Query Operators can be used against any .NET collection (IEnumerable<T>) Built-in examples: Select, Where, GroupBy, Join,
etc. Extensibility model supports adding/replacing
them
Query Expressions can operate on information sources and apply query operators against them to return IEnumerable<T> sequences
Searching/Sorting an Array
string [] cities = { “Auckland”, “Oslo”, “Sydney”, “Seattle”, “Paris”, “Los Angeles” };
IEnumerable<string> places = from city in cities where city.Length > 5
orderby city descending select city;
GridView1.DataSource = places;GridView1.DataBind();
Array implements
IEnumerable<T>
LINQ Query Expression using Query Operators
IEnumerable<string>sequence result can
be used w/ databinding
Projections
Sometimes you want to modify or transform the data you return from a query
LINQ enables powerful “data shaping” scenarios using projections
Can optionally be used in conjunction with new “anonymous type” compiler support
Projections w/ Anonymous Types
List<City> cities = CityUtilityHelper.GetCities();
var places = from city in cities where city.DistanceFromSeattle > 1000 select new { City = city.Name, Country = city.Country, DistanceInKm = city.DistanceFromSeattle * 1.61 };
GridView1.DataSource = places; GridView1.DataBind();
Anonymous type used to custom shape data
results and apply miles->kilometer conversion
Projections w/ Anonymous Types
<asp:GridView ID="GridView1" AutoGenerateColumns="false" runat="server"> <Columns> <asp:BoundField HeaderText="Country" DataField="Country" /> <asp:BoundField HeaderText="City" DataField=“City" /> <asp:BoundField HeaderText="Dist (KM)" DataField="DistanceInKm" /> </Columns></asp:GridView>
LINQ for SQL
Maps .NET classes to relational SQL data Translates LINQ queries to SQL execution Supports change tracking for insert,
update, delete operations Built on top of ADO.NET and integrates
with connection-pooling and transactions
LINQ for SQL Basics
public partial class Product { public int ProductID; public string ProductName; public Nullable<int> SupplierID; public Nullable<int> CategoryID;}
public class NorthwindDataContext : DataContext { public Table<Product> Products;}
NorthwindDataContext db = new NorthwindDataContext();
DataList1.DataSource = from product in db.Products where product.UnitsInStock > 0 select product;
DataList1.DataBind();
PK/FX Relationships in DatabaseProducts Table Suppliers Table
Categories Table
Foreign Key Relationshipsto the Suppliers and Categories Tables
Associations in the O-R Designer
Code Associations in Model public partial class Product { public int ProductID; public string ProductName; public Nullable<int> SupplierID; public Nullable<int> CategoryID;
public Supplier Supplier; public Category Category; }
public partial class Supplier { public int SupplierID; public string CompanyName; public EntitySet<Product> Products; }
public partial class Category { public int CategoryID; public EntitySet<Product> Products; }
Programming XML today…
XmlDocument doc = new XmlDocument();XmlElement contacts = doc.CreateElement("contacts");foreach (Customer c in customers) if (c.Country == "USA") { XmlElement e = doc.CreateElement("contact"); XmlElement name = doc.CreateElement("name"); name.InnerText = c.CompanyName; e.AppendChild(name); XmlElement phone = doc.CreateElement("phone"); phone.InnerText = c.Phone; e.AppendChild(phone); contacts.AppendChild(e); }doc.AppendChild(contacts); <contacts>
<contact> <name>Great Lakes Food</name> <phone>(503) 555-7123</phone> </contact> …</contacts>
Imperative model
Document centric
No integrated queries
Memory intensive
LINQ to XML
XElement contacts = new XElement("contacts", from c in customers where c.Country == "USA" select new XElement("contact", new XElement("name", c.CompanyName), new XElement("phone", c.Phone) ));
Declarative model
Element-centric
Integrated queries
Smaller and faster
ADO.NET vNext
Data as Objects The Entity Data Model (EDM), which allows developers
to model data at a higher level of abstraction Client-views/mapping engine to map to and from
store schemas Full query support over EDM schemas using Entity
SQL and LINQ Open provider model that allows other stores to plug
into the ADO.NET Entity Framework Data Integration to core languages
Language-Integrated Query (LINQ) LINQ to Entities: formulate queries using LINQ against
your EDM schemas LINQ to DataSet: the DataSet with full query
capabilities LINQ queries can go against one or more DataTable
objects
ADO.NET Entity Framework (1/2) "Client Views" map existing relational schema to a
rich conceptual entity model Conceptual entity model exposes concepts that make
sense to your application Different apps may have different views of the same
data Application and storage schemas may evolve
independently Exposed as an "Entity Client" ADO.NET Data
Provider Common, familiar ADO.NET Programming pattern
Compatible with existing applications/tools Canonical Entity SQL “eSQL” used to query Conceptual
Model Supports 3rd party ADO.NET Data Providers
ADO.NET Entity Framework (2/2) Entities presented as CLR Objects
Work with higher level "ObjectContext" Tracks object identity, changes
Query through Entity SQL or LINQ queries Entity Data Model Designer
Integrated into the Orcas IDE Create entities from scratch or generate
EDM models from an existing database Easily consume existing EDM models
Sync Services for ADO.NET
Simplifying the Client “Golden Nugget” Application works against a local data cache and
periodically synchronizes with the server Experience unchanged on lost connectivity
“Want local caching, but can’t spend time getting the basics right” All the heavy lifting handled by the Framework
“Want to leverage/extend your my ADO.NET knowledge”
“Want to build real world N tier Application” Sync via services with pluggable proxy/service Server Data Components can use any ADO.net Provider
Application supports Occasionally Connected Scenarios
Sync Component Architecture
Data FormsData Forms
SyncAgentSyncAgent
Data AccessData Access
Work against local database
Sync keeps the local and remote stores in sync
Can push changes directly or via services
SyncTableSyncTableSyncAdaptercommandsSyncAdaptercommands
SyncAdapterSyncAdapter
ServerSyncProviderServerSyncProvider
DBCommandDBCommand
SQL Server SQL Server CompactCompact
Edition 3.5Edition 3.5
TransportTransport
ServiceServiceServiceServiceProxyProxy
ClientClientSyncProviderSyncProvider
SyncGroupSyncGroup Server DBServer DB
Guidance for LINQ to Relational Data LINQ to SQL
Emphasis on rapid application development Direct mapping to Microsoft SQL Server family of
databases Available in Orcas
LINQ to Entities Focus on enterprise-grade data scenarios Flexible mapping to relational data Access to Microsoft SQL Server family and
other databases through ADO.NET provider model
Available in first half of 2008 CTP’s and Betas on top of Orcas releases through 2007
Microsoft Office
Visual Studio Tools for Office - “Orcas” Strategic platform infrastructure based on .NET
3.0 & Managed Add-In Foundation (MAF) Highly-streamlined developer experience
New designers: ribbon, custom task pane, Outlook form region
ClickOnce deployment and security Document-level solutions
Word, Excel, InfoPath: 2003 onwards Managed controls on the document surface Doc-level Actions Pane ServerDocument – manipulate documents without
automating Office Word content control support
Visual Studio Tools for Office - “Orcas” Application-level add-Ins
Application domain isolation Remote updateability All 2007 Office system apps App-level custom task pane Ribbon customization Support for legacy “Shared Add-ins”
Workflow without VS2008 Create workflow in Visual Studio
2005 Author the feature definition file
Add GUID Add title Add description Add manifest location
Author workflow template definition file Add GUID Add name Add description
Compile the workflow files into a .NET assembly
Sign the assembly Add key file
Design the actual workflow, add code etc. (This is the “real” developer task)
Install assembly into the Global Assembly Cache
Extract public key token Add key token to workflow
template definition file Deploy feature definition file to
SharePoint file system Deploy workflow definition file to
SharePoint file system Reset Internet Information
Services Press F5 Attach to WPW3.exe process Associate workflow with
document library
Workflow with VS2008
Create workflow in Visual Studio Tools for Office “Orcas”
Design the actual workflow, add code etc. (This is the “real” developer task)
Press F5
New Web Experience
“Orcas” Web Tools Objectives Address top customer issues in VS 2005 Reduce cost and increase effectiveness
of Web UI design Enabling developers & designers to
program "AJAX-style" interactive web user interfaces
Programming model and design experience around language/data access (LINQ)
Best tool for the Vista platform (WCF, IIS7)
Design Surface
WYSIWYG layout CSS editing experience
CSS Properties Window Direct Style Application Style Management Tool Windows WYSIWYG Positioning Support
Split View Nested Master Pages Support
Design Surface
Enabling AJAX for DevelopersGoals Enable highly interactive AJAX Web apps Retain the ease of the ASP.NET model Powerful tools for AJAX client
development Key Features Jscript IntelliSense and Editor Support Jscript Debugging Support
JScript Editor Support
Intellisense experience for JScript Better Jscript language IntelliSense
Type inferencing, Script library includes
IntelliSense against ASP.NET AJAX class model IntelliSense against Web service proxies
ASMX and WCF Services ASP.NET Services (e.g. Membership, Roles, Profile)
Rich editor support Syntax validation (squiggles) Formatting and colorization
JScript Debugging
IE Developer Improvements Switch to enable script debugging HTTP trace in developer toolbar
Visual Studio improvements Move Script Explorer to
Solution Explorer Breakpoints in ASPX map to
rendered HTML Filter properties, methods, events
in watch window
XML IDE support and Tools
XSLT Debugger Enables Input Data Breakpoints allowing
the user to break the execution of the style-sheet whenever a certain node in input document is hit.
IDE Improves the experience a user has when
working with an XML Schema in textual and graphical mode at the same time
ALM
Visual Studio Team System
New scenarios Improved Development Productivity
Code metrics, ‘hotpathing’, base-lining Load Testing Enhancements
Improved load modeling, reporting, graphing Continuous Integration
Build Queuing, Queue Management, Drop Management
Version Control Enhancements Lower adoption blockers
TFS Deployment & Administration Migration Toolkit
Metric: Class Coupling# of Dependencies Between Types
GUI
Business Logic
Transaction
Customer Account
Metric: Class Inheritance# of Base Types
Component
Control
Label
ListBox
ListControl
LinkLabelComboBox
Metric: Lines of Code# of Executing Lines of Code
123
4
5
static class Program{
#region Application Entry Point/// <summary>/// The main entry point for the application./// </summary>[STAThread]static void Main(string[] args){
Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Workflow(args);
}#endregion
#region Static Methods/// <summary> Primary workflow for the application. </summary>/// <param name="args"> Command line arguments. </param>private static void Workflow(string[] cmdargs){
// Collect the list of command line argumentsList<string> args = new List<string>(cmdargs);
// Show usage syntax if the user so asksif (UseArg(args, "/?")) { ShowAbout(); return; }
Metric: Cyclomatic Complexity# of Branches
12
3
45
6,7
89
10
11
bool ParseCommandLine(string[] args){
if (args.Length == 0) ShowHelp(); return;for (int i = 0; i < args.Length; i++)
switch (args[i]){
case "/?" :ShowHelp();return false;
case "/input" :if (args.Length > i && File.Exists(args[i + 1]))
InputFile = args[i++];break;
case "/c" :Colapse = true;break;
}return true;
}
Metric: Maintainability Index
Overall indication of complexity byaggregation of several factors [Carnegie 1]
Lines of Code Cyclomatic Complexity Computational Complexity [Halstead 1]
Used on the Windows Code Base
[Halstead 1] Halstead, Maurice H. Elements of Software Science, Operating, and Programming Systems Series Volume 7. New York, NY: Elsevier, 1977.
Maintainability Index = 171 - 5.2 * log2(Halstead Volume) - 0.23 * (Cyclomatic Complexity) - 16.2 * log2(Lines of Code)
[Carnegie 1] Carnegie Mellon University, Software Engineering Institute, Maintainability Index Technique for Measuring Program Maintainability, http://www.sei.cmu.edu/str/descriptions/mitmpm.html
Resources
Web http://ajax.asp.net http://msdn.microsoft.com/vcsharp/
default.aspx Blogs
http://blogs.msdn.com/msbuild http://blogs.msdn.com/vbteam http://blogs.msdn.com/adonet http://blogs.msdn.com/johanl http://blogs.msdn.com/pahlberg