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.
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Radu vunvulea building and testing windows 8 metro style applications using c++,c# and java script
1. Building and testing Windows 8
Metro Style Applications using
C++,C# and JavaScript
Radu Vunvulea
vunvulear@gmail.com
http://vunvulearadu.blogspot.com
3. Agenda
• WinRT
• Windows 8 Architecture I
• WinMD
• Windows 8 Architecture II
• Windows 8 Profiles
• Mixing Components
• Extensibilities points
• Unit tests
• Windows 8 App Package
6. What exactly is WinRT
• 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
7. What exactly is WinRT
• 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
8. Why WinRT is good
• 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
9. Why WinRT is good
• 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
10. What about WinMD
• 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
13. Windows 8 and WinRT Architecture
• 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
15. What should I use?
• 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)
16. How to mix different components
C# C++
Java Script
17. How to mix different components
C# C++
It is not possible
Java Script
18. How to mix different components
• .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
19. How to create reusable C# components
• 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
20. How to create reusable C# components
• 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
22. What about extensibility…
• It is an important feature for LoB applications
• Dynamic components loading (reflection)
• JS loaded and compiled at runtime
• MEF (Managed Extensibility Framework)
• Prims
23. What about extensibility…
• 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
25. Unit tests
• For code written in C/C++, C# and Visual Basic we have build in
support for unit tests
26. Unit tests
• 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?
27. Unit tests
• 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
29. Windows 8 App Package
• 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)
30. Windows 8 App Package
• Every package contains a Package Manifest
• Package Manifest:
• Package identity
(package name, version, publisher, processor architecture, resource ID)
• Package properties
information about package
• Capabilities
a list of application capabilities
• Extensions
used to communicate with system and other application
• Visual elements
default tile, logo images, background color, and splash screen
31. Windows 8 App Package
• 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.