windows 8 für .net entwickler
DESCRIPTION
Actual Information about Windows 8 .TRANSCRIPT
Architecture
Windows Core OS Services
JavaScript(Chakra)
CC++
C#VB
Metro style apps
Communication & Data
Application Model
Devices & Printing
WinRT APIsGraphics &
Media
XAML HTML / CSS
HTMLJavaScri
pt
CC++
C#VB
Desktop apps
Win32
.NET / SL
Internet
Explorer
Syst
em
Serv
ices
Vie w
Mod
el
Contr
oll
er
Cor
e
Sub- and SupersetWindows Phone 7
Silverlight 5
.NET Framework 4.5
.NET Profile for Metro style apps
Windows Runtime
Types
Mapped Types
Interop Helpers
99% of Windows* namespaces
Int32, String, Boolean, IEnumerable<T>, IList<T>, Uri, etc.
IBuffer / Byte[] IAsync* / Task*InputStream, OutputStream,
Managed Types
Tuple, List<T>, XDocument, DataContract, etc.
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
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
* Refers to implementation assemblies, not reference assemblies. More on this later.
.NET for Metro style apps
BCL
HTTP
XML
Serialization
WCF
MEF
Main NamespacesSystemSystem.Collections*System.ComponentModelSystem.ComponentModel.Composition*System.Diagnostics*System.DynamicSystem.GlobalizationSystem.IOSystem.Linq*System.Net*System.ReflectionSystem.Runtime.InteropServices*System.Runtime.Serialization*System.ServiceModel*System.Text*System.ThreadingSystem.Threading.TasksSystem.Xml.*System.Xml.Linq
System Namespace* SimplicityActionAction<...>ActivatorArrayArraySegment<T>AsyncCallbackAttributeAttributeTargetsAttributeUsageAttributeBitConverterBooleanByteCharCLSCompliantAttributeConvertDateTimeDateTimeKindDateTimeOffsetDayOfWeekDecimalDelegateDoubleEnumEnvironmentEventArgsEventHandlerEventHandler<T>ExceptionFlagsAttributeFunc<...>GCGuid
IAsyncResultIComparable<T>ICustomFormatterIDisposableIEquatable<T>IFormatProviderIFormattableInt16Int32Int64IntPtrIObservable<T>IObserver<T>Lazy<T>MathMidpointRoundingMulticastDelegateNullableNullable<T>ObjectObsoleteAttributeParamArrayAttributePredicate<T>RandomRuntimeArgumentHandleRuntimeFieldHandleRuntimeMethodHandleRuntimeTypeHandleSByteSingleStringStringComparer
StringComparisonStringSplitOptionsThreadStaticAttributeTimeSpanTimeZoneInfoTupleTuple<...>TypeTypedReferenceUInt16UInt32UInt64UIntPtrUriUriBuilderUriComponentsUriFormatUriKindValueTypeVersionVoidWeakReferenceWeakReference<T>
* excluding exceptions
Removed, Replaced, and Changed
– System.Web– System.Data – System.Runtime.Remoting– System.Reflection.Emit– Private reflection– Application Domains
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
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 • !!!!
Removed, Replaced, and Changed
Porting Guide: Example TopicReflectionSystem.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().Assemblytype.GetMethods(BindingFlags.DeclaredOnly)
type.GetTypeInfo().DeclaredMethods
type.GetMethod("MethodName", BindingFlags.DeclaredOnly)
type.GetTypeInfo().GetDeclaredMethod("MethodName")
These samples are the same for Properties, 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|BindingFlags.Public)
type.GetRuntimeMethods().Where(m => !m.IsStatic && m.IsPublic)
GetRuntimeMethods() API in Beta.
BindingFlags.NonPublic !member.IsPublic You can also use member.IsAssembly => internal or member.IsFamily => protected for more flexibility
Look for more on the BCL team’s blog
• .net 4.5 & Visual Studio 11 Paralle
l Pattern LibraryTask Parallel Library
PLINQ
Managed
Native
Key:
WindowsOperating System
Runtime
Programming Models
CLR ThreadPool
Task Scheduler
Resource ManagerD
ata
Stru
cture
s Data
Str
uct
ure
s
Tools
Tooling
Parallel Debugger
Concurrency Visualizer
AsyncAgent
sLibrar
y
Stacks
Tasks
Watch
CPU
Threads
Cores
C#/VB/F#
AsyncDataflo
w C++AMP
DirectX
GPU
CPU GPU
ConcRT
Task Scheduler
Resource Manager
New Updated
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>
• We all “know” sync methods are “cheap”– Years of optimizations around sync methods– Enables refactoring at will
Mental Model
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 }
• Not so for asynchronous methodsMental Model, cont.
public static async Task SimpleBody() { Console.WriteLine("Hello, Async World!");}
.method public hidebysig static class [mscorlib]System.Threading.Tasks.Task SimpleBody() cil managed{ .custom instance void [mscorlib]System.Diagnostics.DebuggerStepThroughAttribute::.ctor() = ( 01 00 00 00 ) // Code size 32 (0x20) .maxstack 2 .locals init ([0] valuetype Program/'<SimpleBody>d__0' V_0) IL_0000: ldloca.s V_0 IL_0002: call valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::Create() IL_0007: stfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder Program/'<SimpleBody>d__0'::'<>t__builder' IL_000c: ldloca.s V_0 IL_000e: call instance void Program/'<SimpleBody>d__0'::MoveNext() IL_0013: ldloca.s V_0 IL_0015: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder Program/'<SimpleBody>d__0'::'<>t__builder' IL_001a: call instance class [mscorlib]System.Threading.Tasks.Task [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::get_Task() IL_001f: ret}
.method public hidebysig instance void MoveNext() cil managed{ // Code size 66 (0x42) .maxstack 2 .locals init ([0] bool '<>t__doFinallyBodies', [1] class [mscorlib]System.Exception '<>t__ex') .try { IL_0000: ldc.i4.1 IL_0001: stloc.0 IL_0002: ldarg.0 IL_0003: ldfld int32 Program/'<SimpleBody>d__0'::'<>1__state' IL_0008: ldc.i4.m1 IL_0009: bne.un.s IL_000d IL_000b: leave.s IL_0041 IL_000d: ldstr "Hello, Async World!" IL_0012: call void [mscorlib]System.Console::WriteLine(string) IL_0017: leave.s IL_002f } catch [mscorlib]System.Exception { IL_0019: stloc.1 IL_001a: ldarg.0 IL_001b: ldc.i4.m1 IL_001c: stfld int32 Program/'<SimpleBody>d__0'::'<>1__state' IL_0021: ldarg.0 IL_0022: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder Program/'<SimpleBody>d__0'::'<>t__builder' IL_0027: ldloc.1 IL_0028: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::SetException( class [mscorlib]System.Exception) IL_002d: leave.s IL_0041 } IL_002f: ldarg.0 IL_0030: ldc.i4.m1 IL_0031: stfld int32 Program/'<SimpleBody>d__0'::'<>1__state' IL_0036: ldarg.0 IL_0037: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder Program/'<SimpleBody>d__0'::'<>t__builder' IL_003c: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::SetResult() IL_0041: ret}
• Managed Profile Guided Optimization (for .net Applications)
• More Information
• [email protected]• 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