Top Banner
Building and testing Windows 8 Metro Style Applications using C+ +,C# and JavaScript Radu Vunvulea [email protected] http://vunvulearadu.blogspot.com
34

Radu vunvulea building and testing windows 8 metro style applications using c++,c# and java script

Dec 25, 2014

Download

Technology

Radu Vunvulea

In this session you will discover how you can develop applications that use components written in different programming language (C++, C# and JavaScript). A brief introduction in WinRT Components and testing tools will also be presented.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

Building and testing Windows 8 Metro Style Applications using C++,C# and JavaScript

Radu [email protected]

http://vunvulearadu.blogspot.com

Page 2: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

{“name” : “Radu Vunvulea,“company” : “iQuest”,“userType” : “enthusiastic”“technologies” : [ “.NET”, “JS”, “Azure”, “Web”, “Mobile”, “SL” ],“w8experience” : [ “2 LoB App”, “1 Travel App”],“blog” : “vunvulearadu.blogspot.com”,“email” : ”[email protected]”,“socialMedia” :

{“twitter” : “@RaduVunvulea”,

“fb” : “radu.vunvulea”}

}

Who am I?

Page 3: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• WinRT• Windows 8 Architecture I• WinMD• Windows 8 Architecture II• Windows 8 Profiles• Mixing Components• Extensibilities points • Unit tests• Windows 8 App Package

Agenda

Page 4: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

•WinRT•WinMD• Chakra• Windows Kernel Service• Windows Runtime API• CLR, CRT, WinJS

Page 5: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

•WinRT•WinMD• Chakra• Windows Kernel Service• Windows Runtime API• CLR, CRT, WinJS

Page 6: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• WinRT – Windows Runtime• Allow us to build app that use Windows functionalities• We can use any kind of language (managed or not)

• C#• C++• JavaScript• Visual Basic

• Language projection for any kind of language• Expose Windows functionalities • Native for any supported language

What exactly is WinRT

Page 7: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• WinRT – Windows Runtime• Allow us to build app that use Windows functionalities• We can use any kind of language (managed or not)

• C#• C++• JavaScript• Visual Basic

• Language projection for any kind of language• Expose Windows functionalities • Native for any supported language

What exactly is WinRT

Page 8: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• We don’t need to use COM and Win32 anymore – for “Metro Apps”

• Easy access to Windows features• Object lifetime management • Same API on different languages• A lot of things are supported by default, we don’t need to

write code for that:• Image capture• IO access• Geolocation• Contracts• Networking• … and so on

Why WinRT is good

Page 9: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• We don’t need to use COM anymore• Easy access to Windows features• Object lifetime management • Same API on different languages• A lot of things are supported by default, we don’t need to

write code for that:• Image capture• IO access• Geolocation• Contracts• Networking• … and so on

Why WinRT is good

Page 10: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• WinMD – Windows Metadata• Describe what a WinRT component can do• Separate file, not included in the WinRT file• Compatible metadata - .NET ECMA-355 (not IDL)

• This is the secret which make it possible a WinRT object to be consumed by - native C++ - managed C# - JavaScript using Chakra JS Engine

What about WinMD

Page 11: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

Windows 8 and WinRT architecture

Page 12: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

Windows 8 and WinRT Architecture

Page 13: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• Only one CLR for all application (desktop and “Metro Apps”)• Different instances for desktop and “Metro Apps”• Only one IL for all applications (desktop and “Metro Apps”)• Only one MSIL for all applications• The same .NET Framework 4.5 is used for all applications,

but it used different profiles• .NET Client Profile – desktop• .NET Metro Profile – “Metro Apps”

• Framework contains rules that define what parts are available for each profile

Windows 8 and WinRT Architecture

Page 14: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

Windows 8 Profiles

.NET

Silverlight

Windows Phone

Windows 8 Apps

.NET

Page 15: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• JavaScript with HTML 5 and CSS+ Well Known+ IndexdDB+ Dynamic language- WinRT not fully available

• C# with XAML+ Full access to WinRT + some custom libraries+ async/await, async calls supported at language level+ Component written for SL or WP7 can be reused+ Well known- XAML can be a hell sometimes

• C+++ Very fast+ DirectX (games)

What should I use?

Page 16: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

How to mix different components

C# C++

Java Script

Page 17: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

How to mix different components

C# C++

Java Script

It is not possible

Page 18: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• .WinMD describes all the public API exposed by the component

• For JavaScript, the system will manage the class instances• We don’t need to configure the project that will generate

the shared component

• Be aware that you cannot have/use• XAML controllers in a Java Script app• Java Script components in a XAML/C# project

• Even if we have a WebView, we don’t have full access

• We can have a C# component that use XAML and use it in a C++ application that use DirectX

How to mix different components

Page 19: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• Our class that will be exposed have to:• Be sealed • Be public• No virtual• The class should not be empty• The class should not be abstract• All the input and output of collection types need to be

interfaces (IList)• Interfaces are not supported in this moment to be

exposed• Windows.Foundation.Metadata.DefaultOverload– for overloading

How to create reusable C# components

Page 20: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• Asynchronous calls are supported• An asynchronous call need to return an

IAsyncOperationTReturn>• We can obtain it calling “AsAsyncOperation()” method.

• A Task<T> is automatically converted into Promise• Don’t forget to named your method accordingly • Any method that’s take longer than 50ms

How to create reusable C# components

Page 21: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

Demo

Page 22: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• It is an important feature for LoB applications

• Dynamic components loading (reflection)• JS loaded and compiled at runtime

• MEF (Managed Extensibility Framework)• Prims

What about extensibility…

Page 23: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• It is an important feature for LoB applications

• Dynamic components loading (reflection)• JS loaded and compiled at runtime

• MEF (Managed Extensibility Framework)• Prims

• Non-official response• Wait, have patience, in 6-9 months we may have

something for you

What about extensibility…

Page 24: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

Demo

Page 25: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• For code written in C/C++, C# and Visual Basic we have build in support for unit tests

Unit tests

Page 26: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• For code written in C/C++, C# and Visual Basic we have build in support for unit tests

• What about Java Script? • Should we write unit tests for it? • Can I run unit tests from Visual Studio 2012? • Can I integrate Java Script unit tests to the build

machine?

Unit tests

Page 27: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• For code written in C/C++, C# and Visual Basic we have build in support for unit tests

• What about Java Script? • Should we write unit tests for it? YES• Can I run unit tests from Visual Studio 2012? YES• Can I integrate Java Script unit tests to the build

machine? YES

• There are a lot of frameworks and plugins for this:• Chutzpah Test Adapter for Visual Studio 2012• QUnit

Unit tests

Page 28: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

Demo

Page 29: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• A package contains all the files that are required by our application to run

• An update of our app represent a new version of package that contains all the files (not the delta)

• Each package is sign by the author using a unique key• A package can be created using

• Visual Studio• MakeAppX.exe (command line)

Windows 8 App Package

Page 30: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• Every package contains a Package Manifest

• Package Manifest:• Package identity

(package name, version, publisher, processor architecture, resource ID)

• Package propertiesinformation about package

• Capabilitiesa list of application capabilities

• Extensionsused to communicate with system and other application

• Visual elementsdefault tile, logo images, background color, and splash screen

Windows 8 App Package

Page 31: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

• Each package contains a Power Shell script• A normal user can install a package only from Marketplace• Using a developer account any package can be installed on

a computer (even the packages that are not signed)

• Corporate devices – Windows 8 Enterprise• Windows 8 App packages that can be pushed from the

corporate network without the need to publish the application on the Marketplace.

Windows 8 App Package

Page 32: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

Demo

Page 33: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script
Page 34: Radu vunvulea  building and testing windows 8 metro style applications using c++,c# and java script

THE END

Radu [email protected]

http://vunvulearadu.blogspot.com