This document summarizes key aspects of Windows 8 for .NET developers. It discusses the Metro style app architecture, which uses XAML for views and C#, C++, JavaScript, or VB for controllers and models. It also covers the .NET profile for Metro style apps, which is a subset of the full .NET Framework that removes APIs not applicable to these apps. The document provides details on namespaces, classes, and technologies included in this profile and how existing .NET code can be ported to it. It also discusses replaced technologies like WCF, XML, and threading APIs.
Nell’iperspazio con Rocket: il Framework Web di Rust!
Windows 8 für .net Entwickler
1. Windows 8 für .net Entwickler
Patric Boscolo
patbosc@microsoft.com
@patricsmsdn Student Technology Conference
2. Architecture
Metro style apps Desktop apps
XAML HTML / CSS
View
C C# JavaScript
Controller
Model
C++ VB (Chakra) HTML C C#
JavaScript C++ VB
WinRT APIs
System Services
Communication
Graphics & Media Devices & Printing
& Data
Internet .NET
Application Model Win32
Explorer / SL
Windows Core OS Services
Core
3.
4. Sub- and Superset
.NET Framework 4.5 Windows Phone 7
Silverlight 5
.NET Profile for Metro
style apps
5. Windows Managed
Mapped Types Interop Helpers
Runtime Types Types
Int32, String, IBuffer / Byte[]
Tuple, List<T>,
99% of Windows* Boolean, IAsync* / Task*
XDocument,
namespaces IEnumerable<T>, InputStream, Output
DataContract, etc.
IList<T>, Uri, etc. Stream,
6. Design Requirements
• Remove APIs not applicable to Metro style apps
– e.g. Console, ASP.NET
• Remove dangerous, obsolete, and legacy APIs
• Remove duplication (within .NET APIs and with WRT APIs)
– e.g. ArrayList (with List<T>) and XML DOM (with WR XML API)
• Remove APIs that are OS API wrappers
– e.g. EventLog, Performance Counters
• Remove badly designed APIs
– e.g. APIs that are confusing, don’t follow basic design guidelines, cause bad dependencies
7. Compatibility Requirements
• Running existing .NET applications as-is on the .NET profile for
Metro style apps is not an objective
• Porting existing C# and VB code to the profile should be easy
• Existing .NET developers should feel at home with this profile
• Code compiled to the profile must be able to execute on .NET
Framework 4.5
• Code compiled to the portable subset needs to be compatible
with this profile
8. * Refers to implementation assemblies, not reference assemblies. More on this later.
9. .NET for Metro style apps
WCF
XML MEF
HTTP Serialization
BCL
13. Removed, Replaced, and Changed
Existing Technology New Substitute
System.Windows Windows.UI.Xaml
System.Security.IsolatedStorage Windows.Storage.ApplicationData
System.Resources Windows.ApplicationModel.Resources
System.Net.Sockets Windows.Networking.Sockets
System.Net.WebClient Windows.Networking.BackgroundTransfer and
System.Net.HttpClient
14. Removed, Replaced, and Changed
Existing Technology Changes
Serialization • Use Data Contract for general serialization needs
• Use XML serialization for fine control of the XML
stream
Reflection • System.Type now represents a type reference
• System.Reflection.TypeInfo is the new System.Type
XML • XML Linq is the main XML parser
• Use XmlReader/Writer as a low level abstraction
Collections • Non generic collections gone
• New collection abstractions added:
IReadOnlyList<T>
Threading • Synchronization primitives mainly unchanged
• Thread control in Windows.Foundation.Threading
• Task.Run is the new high level way of doing
background processing
Async Model • !!!!
15. Porting Guide: Example Topic
Reflection
System.Type has become a type reference and only contains basic information. The majority of the reflection API's
are now on System.Reflection.TypeInfo. You can get a TypeInfo from a Type by using the GetTypeInfo() extension
method when you include a using statement for the System.Reflection namespace.
Existing .NET Code Replacement Code Notes
type.Assembly type.GetTypeInfo().Assembly
type.GetMethods(BindingFlags.DeclaredOnly type.GetTypeInfo().DeclaredMethods
)
type.GetMethod("MethodName", type.GetTypeInfo().GetDeclaredMethod("Met These samples are the same for Properties,
BindingFlags.DeclaredOnly) hodName") Events, and Fields.
type.GetMethod("MethodName") type.GetRuntimeMethod("MethodName") GetRuntimeMethod API in Beta.
type.GetMethods() type.GetRuntimeMethods() GetRuntimeMethods() API in Beta.
type.GetMethods(BindingFlags.Instance|Bindi type.GetRuntimeMethods().Where(m => GetRuntimeMethods() API in Beta.
ngFlags.Public) !m.IsStatic && m.IsPublic)
BindingFlags.NonPublic !member.IsPublic You can also use member.IsAssembly =>
internal or member.IsFamily => protected
for more flexibility
16. • .net 4.5 & Visual Studio 11
Tools Programming Models
Parallel C#/VB/F#
Debugger PLINQ Async Dataflow Async Parallel
C++
Stacks Agents Pattern
AMP
Task Parallel Library Library Library
Data Structures
Data Structures
Tasks
Watch
CPU GPU
Runtime
Concurrency
CLR ThreadPool ConcRT
Visualizer
CPU GPU Task Scheduler Task Scheduler DirectX
Threads
Resource Manager Resource Manager
Cores
Operating System Windows
Key: Tooling Managed Native New Updated
17. Async Implementation
• Task Representation as Feature in .net and Languages
– Produce and Consume Async Operations
• When you write a Async Method
– You Producing a Task<T> or Results Task<T>
• When you use Await
– You await Task<T> or Results Task<T>
18. Mental Model
• We all “know” sync methods are “cheap”
– Years of optimizations around sync methods
– Enables refactoring at will
public static void SimpleBody() {
Console.WriteLine("Hello, Async World!");
}
.method public hidebysig static void SimpleBody() cil managed
{
.maxstack 8
L_0000: ldstr "Hello, Async World!"
L_0005: call void [mscorlib]System.Console::WriteLine(string)
L_000a: ret
}
21. • More Information
• patbosc@microsoft.com
• Twitter: @patricsmsdn
• Blog: http://blogs.msdn.com/patricb
• Search for:
• ASYNC -> Stephen Toub
• .GC -> Pracheeti Nagarkar
• MPGO -> Mark Miller
• .net -> BCL Team Blog & Krzysztof Cwalina, Immo Landwerth and Joshua Goodman