sobota, 28 kwietnia 2012

Notatki o Windows 8 Consumer Preview - odc. 17

Jutro miną dwa miesiące od wydania Windows 8 Consumer Preview, a jednocześnie dzieli nas nieco ponad miesiąc od wydania Windows 8 Release Preview.

8329

Tyle tytułem wstępu, ale zostawmy już te terminy i przejdźmy do kolejnej porcji informacji o platformie “ósemki” w wersji Consumer Preview, a konkretnie do manifestu aplikacji oraz jej debugowania, wgrywania, analizy jakości kodu, testowania za pomocą testów jednostkowych, analizy wydajności.

W przypadku manifestu można dostrzec pewne zmiany w kontraktach, nazywanych coraz częściej deklaracjami - np. pojawiły się nowe, pewne zniknęły itp. - czy w atrybutach samego pakietu.

Przy debugowaniu dostajemy nieco więcej informacji o debugowaniu na zdalnej maszynie. Wgrywanie aplikacji dokonuje się automatycznie przy debugowaniu lub możemy dokonać tego sami (aczkolwiek też przy pomocy narzędzi związanych z debugowaniem). Przy wgrywaniu możemy wybrać dwie opcje - zdjęcie standardowej restrykcji na komunikację z adresem loopback oraz włączanie debugowania nie od razu, a dopiero po uruchomieniu aplikacji np. z ekranu start lub przez jakiś kontrakt. Możliwe jest również attachowanie do procesu aplikacji.

W analizie jakości kodu czy testowaniu nie widać zbytniej różnicy do wcześniejszego wydania. Dostajemy natomiast opis jak badać wydajność aplikacji napisanej w Java Script oraz w .NET/C++.

Packaging

Manifest designer

Capabilities

Declarations

  • Account Picture Provider - Registers the app as an account picture provider.
  • AutoPlay Content - Registers the app for content events, such as when a DVD is inserted.
  • AutoPlay Device - Registers the app for device events, such as when a web cam is attached.
  • Background Tasks - Enables the app to specify the class name of an inproc server DLL that runs application code in the background in response to external trigger events. When the event triggers, the Run method of the given class is invoked.
  • Cached File Updater - Registers the app as a cached file updater so that the app can update files that other Metro style apps access.
  • Camera Settings - Enables the app to provide custom control panels for web camera devices.
  • Certificates - Enables the app to install digital certificates, such as trusted root certificates. The certificates are used during secure connections to web services over SSL.
  • Contact Picker - Registers the app as a contact picker, which makes the app contacts available to other apps.
  • File Open Picker - Declares an app extensibility point of type windows.fileOpenPicker. If you set this declaration, users can choose and open the specified types of files.
  • File Save Picker - Declares an app extensibility point of type windows.fileSavePicker. If you set this declaration, users can choose the file name, extension, and storage location for the specified types of files.
  • File Type Associations - Registers File Type Associations (for example, .jpeg) on behalf of the app.
  • Game Explorer - Registers the app with the Windows Parental Control system using a Game Definition File (GDF). The GDF contains metadata that describes, for example, its rating in regional systems such as PEGI and ESRB.
  • Print Task Settings - Enables the app to replace the basic print settings.
  • Protocol - Registers URL protocols (for example, mailto) on behalf of the app.
  • Search - Enables the app to provide search capability.
  • Share Target - Registers the app as a share target, which allows the app to receive shareable content.
Content URIs - The URIs that your app can or can’t access.

Packaging

  • Package Name
  • Package Display Name
  • Logo
  • Publisher  - This must match the subject field of the certificate used to sign the package manifest
  • Certificate
  • Publisher Display Name - The name of the Publisher that appears on the certificate.
  • Package Family Name - A unique name that comprises the package name and a hash of the publisher string and that identifies the package on the system. The name is updated whenever the package name or publisher string changes.

Debugging and testing Windows Metro style apps

Running Windows Metro style apps on a remote machine

To debug on a remote device:

  • The remote device and the Visual machine must be connected over a network or connected directly through an Ethernet cable. Debugging over the internet is not supported.

  • The remote device must be running the remote debugging components.

  • You must be an administrator on the remote device to configure the firewall during installation. You must have user access to the remote device to run or connect to the remote debugger.

By default, the remote debugger uses Windows Authentication. You can also choose to run the remote debugger in No Authentication mode, but this mode is strongly discouraged.

To connect directly to a remote device, connect the two machines with a standard Ethernet cable. If the device does not have an Ethernet port, you can use a USB to Ethernet adapter to connect to the cable.

Visual Studio Windows 8 Consumer Preview Remote Debugger

Debugging is not supported on ARM devices in Visual Studio 11 Beta.

By default, the remote debugger is always running after you start it for the first time. It broadcasts its identity on the local sub-net of the network, which allows a Visual Studio machine on the same sub-net to know that the remote device is available as a remote debugging target. You can turn the remote debugger on and off and set various options, such as setting a timeout interval and setting permissions for access.

You control the remote debugger from the classic desktop on the remote device. When you install the remote debugger, a short-cut is placed on the desktop Start menu and a tile is placed on the Metro style Start screen. The Remote Debugging Monitor dialog box displays the current status and activity of the debugger and allows you to change debugger options. When the remote debugger is running, you can open the Remote Debugging Monitor and perform other tasks by using the remote debugger icon in the system tray.

You specify the remote device to connect to in the properties of the project. The procedure differs depending on the programming language. You can type the network name of the remote device, or you can select it from the Select Remote Debugging Connection dialog box. The Select Remote Debugger Connection dialog box displays the devices on the local network subnet and any device that is directly connected to the Visual Studio machine by an Ethernet cable.

Managed project properties for remote debugging

C++ project properties for remote debugging

Select Remote Debugger Connection dialog box

Deploying Windows Metro style apps from Visual Studio

Deployment is automatic when you debug your app from Visual Studio by using the Start Debugging option (Keyboard: F5) or the Start Without Debugging option (Keyboard: CTRL + F5). You can also deploy your app manually.

Manually deploying an app is a simple process:

  1. If you are deploying to a remote device, specify the name or IP address of the device in the property project page of the app's startup project.

  2. On the debugger Visual Studio toolbar, choose the deployment target from the drop-down list next to the Start Debugging button.

  3. On the Build menu, choose Deploy.

To deploy an app to a remote device:

  • A developer's license must be installed on the remote device.

  • The Visual Studio Remote Tools must be installed on the remote device and the Remote Debugging Monitor must be running.

    Deployment uses the remote debugger network channel to send the app files to the remote device.

Deployment options

You can set the following deployment options on the Debug property page of the startup project.

  • Allow Network Loopback
  • Do not launch, but debug my code when it starts (C# and VB) / Launch Application (JavaScript and C++) - to automatically start a debugging session when the app is launched.

Debugging Windows Metro style apps

How to start a debugging session (JS)

By default, Visual Studio immediately starts the app when you start debugging. You can also start a debug session but delay the start of your app. The app is launched in the debugger when it is launched from the Start menu or by an activation contract, or when it is started by another process or method.

You specify whether to delay the launch of your app in the Launch Application list on the Debugging property page of the app project. Choose one of these options:

  • Choose No to delay the launch of your app.

  • Choose Yes to launch the app immediately.

How to start a debugging session (.NET, C++)

To delay the launch of your app, you can:

  • For Visual C# and Visual Basic apps, select Do not launch, but debug my code when it starts on the Debugging property page.

  • For Visual C++ apps, choose Yes from the Launch Application list on the Debug property page.

Attach the debugger to a running app

To attach the debugger to a Metro style app, you must use the Debuggable Package Manager to set the app to run in debug mode. The Debuggable Package Manager is installed with the Visual Studio Remote Tools.

Attaching the debugger to an app is useful when you need to debug an already-installed app, such as an app that was installed from the Windows store. Attaching is required when you have the source files for the app, but you do not have a Visual Studio project for the app. For example, you might have a custom build system that does not use Visual Studio projects or solutions.

To attach to an app:

  1. Set the app to run in debug mode. This must be done when the app is not running.

  2. Start the app. You can start the app from the Start menu, an execution contract, or some other method.

  3. Attach the debugger to the running app.

Set the app to run in debug mode
  1. Install the Visual Studio Remote Tools on the device where the app is installed.

  2. On the Start menu, search for Debuggable Package Manager and then start it. A PowerShell window properly configured for the AppxDebug cmdlet appears.

  3. To enable debugging of an app, you must specify the PackageFullName identifier of the app. To view a list all apps that includes the PackageFullName, type Get-AppxPackage at the PowerShell prompt.

  4. At the PowerShell prompt, enter Enable-AppxDebug PackageFullName where PackageFullName is the PackageFullName identifier of the app.

Attach the debugger

JavaScript apps run in an instance of the wwahost.exe process. If other JavaScript apps are running when you attach to the app, you will need to know the numeric process id (PID) of the wwahost.exe that the app is running in.

Debugging Java Script apps

DOM Explorer

DOM Explorer

Attributes tab

JavaScript Console

JavaScript Console window

Interactive debugging & breaking mode

When a program that's running in the debugger encounters a breakpoint, the debugger temporarily suspends execution of the program.

How to inspect CSS rules

The Styles tab in DOM Explorer

How to view and edit the layout

Layout tab of DOM Explorer

How to view event listeners

The Events tab of DOM Explorer shows the events that are associated with a DOM element. Each top node represents an event that has active subscribers. The top node contains subnodes that represent the registered event listeners for the specific event. In addition to viewing the event listeners, you can use this tab to navigate to the location of the event listener in the JavaScript code.

The list on the Events tab is static, so if you add an event while the app is running, the new event won’t appear there. Event listeners for code elements that aren't DOM elements, such as xhr, don't appear on the Events tab.

Analyzing the performance of Windows Metro style apps

How to collect JavaScript performance data for Windows Metro style apps on a local machine

Stop Profiling

  • Start Performance Analysis  - to start your app and start profiling immediately
  • Stop profiling
  • Start Performance Analysis Paused - to start your app with profiling suspended

How to collect JavaScript performance data for Windows Metro apps on a device that does not have Visual Studio installed

Profiling with VSPerf.exe is useful when you want to test the performance on a variety of devices with different capabilities, such as processing speed, screen resolution, or abilities to process different kinds of input gestures.

With VSPerf.exe, you can profile an app that is started from the Start menu or by another process or procedure. You can focus your performance profiling on specific scenarios by pausing and resuming data collection. Once you have finished profiling, you copy a single file to your Visual Studio machine to analyze the data.

The following requirements are necessary to use VSPerf.exe on a remote device.

  • The app to be profiled must be deployed on the remote machine before you start profiling.

  • You must have administrator privileges on the remote device.

  • Visual Studio must be installed on a Windows 8 machine to analyze performance data collected from Metro style apps.

The remote profiling tool is installed with the Visual Studio Remote Tools, along with the remote debugging components.

Profiling is not supported on ARM devices in Visual Studio 11 Beta.

  • vsperf /listapps
  • vsperf /app:BouncingSquares
  • vsperf /package:54fb8cc2-1f58-4fe5-adb1-a246dd54ffa6_1.0.0.0_neutral__fsyyfg9a7tqy4

To profile JavaScript code, you must include the /js option in the command that starts the profiling session. You can not attach the profiler to the app to collect JavaScript performance data.

  • vsperf /app:{AppName} /file:{OutFile} /js
  • vsperf /package:{PackageFullName} /file:{OutFile} /js
  • vsperf /stop
  • vsperf /detach
  • vsperf /app:{AppName} /file:{OutFile} /js /pause
  • vsperf /package:{PackageFullName} /file:{OutFile} /js /pause
  • vsperf /pause
  • vsperf /resume

Analyzing JavaScript performance data in Metro Style apps

How to collect Visual C++, Visual C#, and Visual Basic performance data for Windows Metro style apps on a device that does not have Visual Studio installed

You can use VSPerf.exe to collect performance data for Visual C++, Visual C#, and Visual Basic from the following types of Metro style apps:

  • An app written using XAML and Visual C++, Visual C#, or Visual Basic.

  • An app written using HTML5 and JavaScript that contains components that are written in Visual C++, Visual C#, or Visual Basic.

vsperf /attach:{PID|ProcessName} /file:{OutFile} [/noclr]

Analyzing performance data for Visual C++ , Visual C#, Visual Basic, and code in Windows Metro style apps

Brak komentarzy: