#MSFT it is cool again – review from Build 2019

 

At Microsoft Build 2019 conference, Microsoft has announced a ton of new features and tool releases with a focus on innovation using AI and mixed reality with the intelligent cloud and the intelligent edge. In his opening keynote, Microsoft CEO Satya Nadella outlined the company’s vision and developer opportunity across Microsoft Azure, Microsoft Dynamics 365 and IoT Platform, Microsoft 365, and Microsoft Gaming.

“As computing becomes embedded in every aspect of our lives, the choices developers make will define the world we live in,” said Satya Nadella, CEO, Microsoft.

“Microsoft is committed to providing developers with trusted tools and platforms spanning every layer of the modern technology stack to build magical experiences that create new opportunity for everyone.”

Watch it live here!

Developer productivity in Microsoft 365 platform Increase

Microsoft Graph data connect

Microsoft Graphs are now powered with data connectivity, a service that combines analytics data from the Microsoft Graph with customers’ business data. Microsoft Graph data connect will provide Office 365 data and Microsoft Azure resources to users via a toolset. The migration pipelines are deployed and managed through Azure Data Factory. Microsoft Graph data connect can be used to create new apps shared within enterprises or externally in the Microsoft Azure Marketplace.

It is generally available as a feature in Workplace Analytics and also as a standalone SKU for ISVs. More information here.

Microsoft Search

Microsoft Search works as a unified search experience across all Microsoft apps-  Office, Outlook, SharePoint, OneDrive, Bing and Windows. It applies AI technology from Bing and deep personalized insights surfaced by the Microsoft Graph to personalized searches. Other features included in Microsoft Search are:

  • Search box displacement
  • Zero query typing and key-phrase suggestion feature
  • Query history feature, and personal search query history
  • Administrator access to the history of popular searches for their organizations, but not to search history for individual users
  • Files/people/site/bookmark suggestions

Microsoft Search will begin publicly rolling out to all Microsoft 365 and Office 365 commercial subscriptions worldwide at the end of May. Read more on MS Search here.

Fluid Framework

As the name suggests Microsoft’s newly launched Fluid framework allows seamless editing and collaboration between different applications. Essentially, it is a web-based platform and componentized document model that allows users to, for example, edit a document in an application like Word and then share a table from that document in Microsoft Teams (or even a third-party application) with real-time syncing.

Microsoft says Fluid can translate text, fetch content, suggest edits, perform compliance checks, and more. The company will launch the software developer kit and the first experiences powered by the Fluid Framework later this year on Microsoft Word, Teams, and Outlook.
Read more about Fluid framework here.

Microsoft Edge new features

Microsoft Build 2019 paved way for a bundle of new features to Microsoft’s flagship web browser, Microsoft Edge. New features include:

  • Internet Explorer mode: This mode integrates Internet Explorer directly into the new Microsoft Edge via a new tab. This allows businesses to run legacy Internet Explorer-based apps in a modern browser.
  • Privacy Tools: Additional privacy controls which allow customers to choose from 3 levels of privacy in Microsoft Edge—Unrestricted, Balanced, and Strict. These options limit third parties to track users across the web.  “Unrestricted” allows all third-party trackers to work on the browser. “Balanced” prevents third-party trackers from sites the user has not visited before. And “Strict” blocks all third-party trackers.
  • Collections: Collections allows users to collect, organize, share and export content more efficiently and with Office integration.

Microsoft is also migrating Edge over to Chromium. This will make Edge easier to develop for by third parties.

For more details, visit Microsoft’s developer blog.

New toolkit enhancements in Microsoft 365 Platform

Windows Terminal

Windows Terminal is Microsoft’s new application for Windows command-line users. Top features include:

  • User interface with emoji-rich fonts and graphics-processing-unit-accelerated text rendering
  • Multiple tab support and theming and customization features
  • Powerful command-line user experience for users of PowerShell, Cmd, Windows Subsystem forLinux (WSL) and all forms of command-line application

Windows Terminal will arrive in mid-June and will be delivered via the Microsoft Store in Windows 10. Read more here.

React Native for Windows

Microsoft announced a new open-source project for React Native developers at Microsoft Build 2019. Developers who prefer to use the React/web ecosystem to write user-experience components can now leverage those skills and components on Windows by using ” React Native for Windows” implementation.

React for Windows is under the MIT License and will allow developers to target any Windows 10 device, including PCs, tablets, Xbox, mixed reality devices and more. The project is being developed on GitHub and is available for developers to test. More mature releases will follow soon.

Windows Subsystem for Linux 2

Microsoft rolled out a new architecture for Windows Subsystem for Linux: WSL 2 at the MSBuild 2019. Microsoft will also be shipping a fully open-source Linux kernel with Windows specially tuned for WSL 2. New features include massive file system performance increases (twice as much speed for file-system heavy operations, such as Node Package Manager install). WSL also supports running Linux Docker containers.

The next generation of WSL arrives for Insiders in mid-June. More information here.

New releases in multiple Developer Tools

.NET 5 arrives in 2020

.NET 5 is the next major version of the .NET Platform which will be available in 2020. .NET 5 will have all .NET Core features as well as more additions:

  • One Base Class Library containing APIs for building any type of application
  • More choice on runtime experiences
  • Java interoperability will be available on all platforms.
  • Objective-C and Swift interoperability will be supported on multiple operating systems
  • .NET 5 will provide both Just-in-Time (JIT) and Ahead-of-Time (AOT) compilation models to support multiple compute and device scenarios.
  • .NET 5 also will offer one unified toolchain supported by new SDK project types as well as a flexible deployment model (side-by-side and self-contained EXEs)

Detailed information here.

ML.NET 1.0

ML.NET is Microsoft’s open-source and cross-platform framework that runs on Windows, Linux, and macOS and makes machine learning accessible for .NET developers. Its new version, ML.NET 1.0, was released at the Microsoft Build Conference 2019 yesterday. Some new features in this release are:

  • Automated Machine Learning Preview: Transforms input data by selecting the best performing ML algorithm with the right settings. AutoML support in ML.NET is in preview and currently supports Regression and Classification ML tasks.
  • ML.NET Model Builder Preview: Model Builder is a simple UI tool for developers which uses AutoML to build ML models. It also generates model training and model consumption code for the best performing model.
  • ML.NET CLI Preview: ML.NET CLI is a dotnet tool which generates ML.NET Models using AutoML and ML.NET. The ML.NET CLI quickly iterates through a dataset for a specific ML Task and produces the best model.

Visual Studio IntelliCode, Microsoft’s tool for AI-assisted coding

Visual Studio IntelliCode, Microsoft’s AI-assisted coding is now generally available. It is essentially an enhanced IntelliSense, Microsoft’s extremely popular code completion tool. Intellicode is trained by using the code of thousands of open-source projects from GitHub that have at least 100 stars.

It is available for C# and XAML for Visual Studio and JavaJavaScript, TypeScript, and Python for Visual Studio Code. IntelliCode also is included by default in Visual Studio 2019, starting in version 16.1 Preview 2. Additional capabilities, such as custom models, remain in public preview.

Visual Studio 2019 version 16.1 Preview 2

Visual Studio 2019 version 16.1 Preview 2 release includes IntelliCode and the GitHub extensions by default. It also brings out of preview the Time Travel Debugging feature introduced with version 16.0. Also includes multiple performances and productivity improvements for .NET and C++ developers.

Gaming and Mixed Reality

Minecraft AR game for mobile devices

At the end of Microsoft’s Build 2019 keynote yesterday, Microsoft teased a new Minecraft game in augmented reality, running on a phone. The teaser notes that more information will be coming on May 17th, the 10-year anniversary of Minecraft.

HoloLens 2 Development Edition and unreal engine support

The HoloLens 2 Development Edition includes a HoloLens 2 device, $500 in Azure credits and three-months free trials of Unity Pro and Unity PiXYZ Plugin for CAD data, starting at $3,500 or as low as $99 per month.

The HoloLens 2 Development Edition will be available for preorder soon and will ship later this year. Unreal Engine support for streaming and native platform integration will be available for HoloLens 2 by the end of May.

Intelligent Edge and IoT

Azure IoT Central new features

Microsoft Build 2019 also featured new additions to Azure IoT Central, an IoT software-as-a-service solution.

  • Better rules processing and customs rules with services like Azure Functions or Azure Stream Analytics
  • Multiple dashboards and data visualization options for different types of users
  • Inbound and outbound data connectors, so that operators can integrate with   systems
  • Ability to add custom branding and operator resources to an IoT Central application with new white labeling options

New Azure IoT Central features are available for customer trials.

IoT Plug and Play

IoT Plug and Play is a new, open modeling language to connect IoT devices to the cloud seamlessly without developers having to write a single line of embedded code. IoT Plug and Play also enable device manufacturers to build smarter IoT devices that just work with the cloud. Cloud developers will be able to find IoT Plug and Play enabled devices in Microsoft’s Azure IoT Device Catalog. The first device partners include Compal, Kyocera, and STMicroelectronics, among others.

Azure Maps Mobility Service

Azure Maps Mobility Service is a new API which provides real-time public transit information, including nearby stops, routes and trip intelligence. This API also will provide transit services to help with city planning, logistics, and transportation.

Azure Maps Mobility Service will be in public preview in June. Read more about Azure Maps Mobility Service here.

KEDA: Kubernetes-based event-driven autoscaling

Microsoft and Red Hat collaborated to create KEDA, which is an open-sourced project that supports the deployment of serverless, event-driven containers on Kubernetes. It can be used in any Kubernetes environment — in any public/private cloud or on-premises such as Azure Kubernetes Service (AKS) and Red Hat OpenShift.

KEDA has support for built-in triggers to respond to events happening in other services or components. This allows the container to consume events directly from the source, instead of routing through HTTP. KEDA also presents a new hosting option for Azure Functions that can be deployed as a container in Kubernetes clusters.

Securing elections and political campaigns

ElectionGuard SDK and Microsoft 365 for Campaigns

ElectionGuard, is a free open-source software development kit (SDK) as an extension of Microsoft’s Defending Democracy Program to enable end-to-end verifiability and improved risk-limiting audit capabilities for elections in voting systems. Microsoft365 for Campaigns provides security capabilities of Microsoft 365 Business to political parties and individual candidates. More details here.

Summary of Microsoft Connect 2015

I try to put together most of the Microsoft technology announcements from Connect 2015, some of the news where updated at 30 November with RTM releases of .NET 4.6.1, NET Core and VS 2015 Update 1 .

Brian post some of them also here – http://blogs.msdn.com/b/bharry/archive/2015/11/30/vs-2015-update-1-and-tfs-2015-update-1-are-available.aspx 

.NET Team – http://blogs.msdn.com/b/dotnet/archive/2015/12/01/the-week-in-net-12-1-2015.aspx 

below…

  • Visual Studio Code beta release, Added extensibility support, open source project
  • .NET Core 5 RC and ASP.NET 5 RC with Go-Live license, can start using it in production – now is RTM (update DEC.)
  • Visual Studio Online is now Visual Studio Team Services, agile team collaboration and DevOps
  • Visual Studio Dev Essentials, priority forum support, Pluralsight, Wintellect,, Xamarin, (Azure early 2016)
  • Visual Studio cloud subscriptions
    • Monthly subscriptions include the VS Pro or Enterprise IDE, access to VSTS
    • Annual subscriptions includes technical support incidents, Azure credits, etc
  • Visual Studio Marketplace, central place to find, acquire, install extensions for all editions of Visual Studio
  • VS 2015 Update 1 and TFS 2015 Update 1, will both happen on November 30th.
  • Xamarin 4 support. end-to-end solution to build, test, monitor native mobile apps with VS2015 Update 1
  • iOS Build with MacinCloud on VSTS, currently in preview at $30/month per agent with no limits on build hours

other Announcements

Read all the details here:

There are also more than 70 on-demand videos with additional details on: connect2015

Microsoft Unity DI Container it is Open Source

   After few months , when was announced that  Prism over to new owners. The Pattern And Practices Team spend some of time and effort into identifying  needs and vision around Unity and owners that would invest in the project and support the community.

 

Going Forward

Be sure to read the official announcement from the new team and follow their work on the new GitHub repo. Let them know what you’d like to see in future releases of Unity and help them continue to grow the community

Fork it and lets begin to improve what we need , like I wrote before in another blog about DI   – https://dumians.wordpress.com/2013/10/02/dependency-containers-and-thread-safe-how-to/.

“Update All” NuGet Packages in Visual Studio 2015 it is back

   For few days was the Visual Studio 2015 % TFS 2015, .Net 4.6.1 released, what’s new you can find here – https://www.visualstudio.com/en-us/news/vs2015-update1-vs.aspx 

and one of the many feature updates that comes with is the updated NuGet Interface in Visual Studio, that allows now also NuGet Multiple Package Update.

Till now was also possible in NuGet command console with – Update-Package command on Solution Level.

image

Leaks Analysis with the Memory Usage Tool in Visual Studio 2015

Memory Usage tool in the Diagnostics Tool window

In Visual Studio 2015 CTP 6 was introduced the new debugger-integrated diagnostics tools, including the Memory Usage tool. For the first time, you could investigate memory growth on the managed heap without leaving everyone’s favorite tool, the debugger. Based on your feedback, we’ve been refining the experience for Visual Studio 2015 RC. This Post how to use the Memory Usage tool while debugging to find and fix a common source of leaks in .NET code: event handlers.

The Test app

For this walkthrough, I’ll be using the WPF version our sample app, PhotoFilter. You can find it in the PhotoFilter.WPF folder inside the solution (zip file).image

PhotoFilter loads all the images in your Pictures library, and displays them in a list. Double-click any image to open an ImagePage view in a new window. While the MainWindow list displays smaller thumbnails, the ImagePage view shows a scaled version of the full image. PhotoFilter offers two ways to view this larger image: either change the selection in MainWindow to update the image displayed in the open ImagePage window, or close the ImagePage window and open a new one by double-clicking again in the Main Window’s list.

It is a leak anyway?

There are only a handful of ways to leak memory in the managed, garbage-collected environment of the .NET CLR. One of the more common scenarios is when the garbage collector refuses to clean-up an object, even though we are certain it’s beyond its useful life. This is generally an indication that some object somewhere is holding a reference to the should-be-dead object. Sometimes these references are very subtle, or not apparent in our own code. Using the Memory Usage tool, we can not only discover the leaks, but also track down the references that are keeping the zombies alive.

Find the leak

I start debugging to run the application, exercising the code paths while watching the Memory graph. The graph displays process memory using a metric called Private Bytes. You can find more on Private Bytes in one of my earlier blog posts on the Memory Usage tool. An app’s managed heap is part of the process memory, so increases in the heap will also cause increases in the Private Bytes.

image

Repeatedly opening and closing new ImagePage windows shows a disturbing trend on the graph. Each time I open the ImagePage window, the memory climbs. The first jump, at point A, I expect to happen. Each time my application opens the ImagePage, the bitmap being displayed is fully decoded into memory. Point B is where I get concerned. At that point, I closed the ImagePage window, and opened and closed three new ones for the next pictures in the list. After closing the first ImagePage, I expect the next garbage collection to clean up the ImagePage and all the memory it used. Instead, what I see is a stepped pattern of memory always showing a net increase. Each new ImagePage adds to the overall process memory. Closing them doesn’t result in the memory being cleaned up. These are signs of a leak.

Finding the source

I only exercised the code paths for these two views. So, I can be pretty sure that this leak behavior is somehow related to the ImagePage objects. One option, something we’re all pretty familiar with, is digging around the code seeing if anything looks “suspicious” or “smells”. With VS2015, instead of hunting and smelling, we can use the Memory Usage tool.

I’ll do that by taking snapshots before and after the interesting parts, and then investigating the diff to better understand what’s keeping the zombie objects alive.

The Memory Usage tab

In the Diagnostic Tools window, I’ll switch to the Memory Usage tab. Once there, a simple toolbar shows me all the basic interactions.

image

Note: “Take Snapshot” temporarily pauses the process if it’s running, and walks the managed heap. This finds all the objects that are still live and not eligible for clean up by the garbage collector. Once a snapshot completes, an overview of its key stats appears in the table below the toolbar.

Getting back to my investigation, I start debugging. Then I wait for the app to start and for the memory graph to stabilize. For many applications, you’ll want to interact with it first to ensure you’ve eliminated any initialization costs before considering the memory usage stabilized. This app is very simple, so I won’t worry about additional initialization costs for my current investigation.

image

Once the graph has settled, I take the first snapshot, which will serve as the baseline for comparison. Because I first noticed the issue by opening and closing the ImagePage view a few times, for my investigation I’ll follow the same steps. This time, however, I’ll open and close it a total of ten times. This should help amplify any “spikes” in the data.

Before taking the second snapshot, I first want to get my app into a break state. Unlike snapshots taken while the app is running, snapshots taken while broken have a super-power: you can inspect the values of the individual instances of objects live on the heap. This super-power is only available while you’re still in the same break state that the snapshot was taken in. Once you continue, or take another step, instance inspection won’t be available on that snapshot again.

But, how do I know where to set my breakpoint? No need! Once I’ve completed my repro steps, I can just press the Break All button on the Debug toolbar.

image

Now that we’re in a break state, I’ll go ahead and take the second snapshot. Once it’s finished, I’ll keep the process paused. Notice the gray arrow to the left of the second snapshot in the table below? That indicates that the object inspection super-power is available for that snapshot as long as I don’t continue, step, or stop debugging.

image

Snapshot overview table

Let’s take a look at what each snapshot shows us in the overview. From left-to-right:

  • The snapshot’s sequential number. Numbers are reset each debugging session.
  • The process running time when the snapshot was taken.
  • The count of the live objects on the managed heap. In parenthesis is the diff of the count from the preceding snapshot.
  • The size of the live objects on the managed heap, also followed by a diff in parenthesis.

Each blue metric in the table is a link that launches the Heap View for the snapshot. Heap View will be the focus of most of your memory investigations. I’ll start with the live object count diff. By clicking the object count diff link (gold arrow in above image), Heap View opens in diff mode, sorted by the “Count Diff” column. By default, the diff mode compares the chosen snapshot to the one immediately preceding it. If you have more than two snapshots, you can use the “Compare to” dropdown to customize which snapshot to compare against.

image

There’s quite a bit of data in the Heap View. Depending on your knowledge of the .NET framework, the types at the top of the table may look completely unfamiliar. Don’t let that discourage you! A very simple strategy let’s you start with the types you know best: the types you wrote in just your code. I’ll show you how.

In the top-right corner of the Heap View, there’s a search box. I can quickly narrow down the types in the table by searching for my app’s module name ‘PhotoFilter’.

image

And there it is, right at the top of the Types table: PhotoFilter.WPF.ImagePage. A total of 10 instances are still alive, despite the fact that the windows hosting the views are long closed. Now, I’ve confirmed the leak, and know one of the players. Unfortunately, I still don’t know why these ImagePage objects are zombies.

Instances, instances

When hovering over the entry for PhotoFilter.WPF.ImagePage in the table, you’ll see an icon appear. This is the Instances view icon. I click it, and navigate to a new view that shows data on the individual instances of ImagePage.

image

Because this snapshot is super-power enabled, I can inspect each instance, with full DataTip support for complex values.

image

Inspecting each ImagePage, I confirm that these are the views of the images I clicked on. These should have been cleaned up by the garbage collector, but some object somewhere is holding a reference to each instance. By selecting an instance in the top pane, the Paths to Root will open in the bottom pane. This view shows a bottom-up hierarchy of what objects are holding references that prevent garbage collection. Here, in the Instances view, the tree will auto-expand to show the primary roots. Following these paths usually reveals the culprit. For ImagePage, it’s also worth noting that each instance has the exact same type hierarchy in its Paths to Root. So, for my investigation, a single code fix might be all I need.

image

Right below PhotoFilter.WPF.ImagePage is a suspicious entry: SelectionChangedEventHandler. Event handler subscription is a well-known cause of leaking objects in .NET. Continuing up the tree, I can see that the event handler belongs to a ListView. My app only has one ListView, on the MainWindow. I know the major players are the ImagePage, a SelectionChangedEventhandler, and the ListView that owns it. At this point, it’s a good idea to take a look at the code. I’ll begin with my own code, the ImagePage code-behind.

Right away, in the ImagePage constructor, I see all the major players come together.

image

A reference to a ListView is passed to the ImagePage constructor (line 51), and the new instance of ImagePage subscribes to the SelectionChanged event of that ListView (line 56). Looking at the subscribed event handler, _parentList_SelectionChanged, this code implements the feature that updates an open ImagePage view when the selection changes in the ListView on the MainWindow.

An object that subscribes to an event of a longer-lived object needs to explicitly unsubscribe from that event at some point, or else the shorter-lived object will never really die. For PhotoFilter, I decided to override the Window.OnClosed handler, and unsubscribe from the SelectionChangedEventHandler there (line 73).

image

Now, when I close an ImagePage window, it unsubscribes itself from the ListView.SelectionChanged event. If that event handler was the only reference rooting the object, they should now be cleaned up by the garbage collector.

image

It’s always a good to verify a fix, so I’ll rerun the experiment to make sure memory is getting cleaned up by the garbage collector as expected. Looking at the graph, after restarting the app and opening and closing ImagePage 10 times, this now appears to be exactly what’s happening. Before the fix, process memory was around 350MB. After the fix, it’s now less than 100MB. Problem solved!

Code Quality improvements with MSbuild & Team Build – SonarQube integration

Technical debt is the set of problems in a development effort that make forward progress on customer value inefficient.  Technical debt saps productivity by making code hard to understand, fragile, difficult to validate, and creates unplanned work that blocks progress. Technical debt is insidious.  It starts small and grows over time through rushed changes, lack of context and lack of discipline. Organizations often find that more than 50% of their capacity is sapped by technical debt.

image

SonarQube is an open source platform that is the de facto solution for understanding and managing technical debt.

Customers have been telling us and SonarSource, the company behind SonarQube, that the SonarQube analysis of .Net apps and integration with Microsoft build technologies needs to be considerably improved.

Over the past few months we have been collaborating with our friends from SonarSource and are pleased to make available a set of integration components that allow you to configure a Team Foundation Server (TFS) Build to connect to a SonarQube server and send the following data, which is gathered during a build under the governance of quality profiles and gates defined on the SonarQube server.

  • results of .Net and JavaScript code analysis
  • code clone analysis
  • code coverage data from tests
  • metrics for .Net and JavaScript

We have initially targeted TFS 2013 and above, so customers can try out these bits immediately with code and build definitions that they already have. We have tried using the above bits with builds in Visual Studio Online (VSO), using an on-premises build agent, but we have uncovered a bug around the discovery of code coverage data which we are working on resolving. When this is fixed we’ll send out an update on this blog. We are also working on integration with the next generation of build in VSO and TFS.

In addition, SonarSource have produced a set of .Net rules, written using the new Roslyn-based code analysis framework, and published them in two forms: a nuget package and a VSIX. With this set of rules, the analysis that is done as part of build can also be done live inside Visual Studio 2015, exploiting the new Visual Studio 2015 code analysis experience

The source code for the above has been made available at https://github.com/SonarSource, specifically:

We are also grateful to our ever-supportive ALM Rangers who have, in parallel, written a SonarQube Installation Guide, which explains how to set up a production ready SonarQube installation to be used in conjunction with Team Foundation Server 2013 to analyse .Net apps. This includes reference to the new integration components mentioned above.

imageimage

This is only the start of our collaboration. We have lots of exciting ideas on our backlog, so watch this space.

As always, we’d appreciate your feedback on how you find the experience and ideas about how it could be improved to help you and your teams deliver higher quality and easier to maintain software more efficiently.

If you have any technical issues then please make your way over to http://stackoverflow.com, tagging your questions with sonarqube, and optionally tfs, c#, .net etc. For the current list of sonarqube questions seehttp://stackoverflow.com/questions/tagged/sonarqube.

Smart Unit Testing With Visual Studio 2015

Smart Testing (former pex & moles ) has a new name now – IntelliTest and explores your .NET code to generate test data and a suite of unit tests. For every statement in the code, a test input is generated that will execute that statement. A case analysis is performed for every conditional branch in the code. For example, if statements, assertions, and all operations that can throw exceptions are analyzed. This analysis is used to generate test data for a parameterized unit test for each of your methods, creating unit tests with maximum code coverage. Then you bring your domain knowledge to improve these unit tests.

When you run IntelliTest, you can easily see which tests are failing and add any necessary code to fix them. You can select which of the generated tests to save into a test project to provide a regression suite. As you change your code, rerun IntelliTest to keep the generated tests in sync with your code changes.

Get started with IntelliTest

You must use Visual Studio Enterprise. Sad smile

Explore: Use IntelliTest to explore your code paths and generate test data
  1. Open your solution in Visual Studio. Then open the class file that has methods you want to test.
  2. Right-click in a method in your code and choose Run IntelliTest to generate unit tests for all the code paths in your method.

    Right-click in your method to generate unit tests

    A parameterized unit test is generated for this method. The test data is created to exercise the code paths in the method. IntelliTest runs your code many times with different inputs. Each run is represented in the table showing the input test data and the resulting output or exception.

    Exploration Results window is displayed with tests

    To generate unit tests for all the public methods in a class, simply right-click in the class rather than a specific method. Then choose Run IntelliTest. Use the drop-down list in the Exploration Results window to display the unit tests and the input data for each method in the class.

    Select the test results to view from the list

    For tests that pass, check that the reported results in the result column match your expectations for your code. For tests that fail, fix your code and add exception handling if necessary. Then rerun IntelliTest to see if your fixes generated more test data from different code paths.

Persist: Save test data and unit tests as a regression suite
  • Select the data rows that you want to save with the parameterized unit test into a test project.

    Select tests; right-click and choose Save

    You can view the test project and the parameterized unit test that has been created with a PexMethod attribute. (The individual unit tests, corresponding to each of the rows, are saved in the .g.cs file in the test project.) The unit tests are created using the Visual Studio test framework, so you can run them and view the results from Test Explorer just as you would for any unit tests that you created manually.

    Open class file in test method to view unit test

    Any necessary references are also added to the test project.

    If the method code changes, rerun IntelliTest to keep the unit tests in sync with the changes.

Assist: Use IntelliTest to find issues in your code
  1. If you have more complex code, IntelliTest can help you discover any issues for unit testing. For example, if you have a method that has an interface as a parameter and there is more than one class that implements that interface. After you run IntelliTest, warnings are displayed for this issue. View the warnings to decide what you want to do.

    Right-click method and choose Smart Unit Tests

     

  2. After you investigate the code and understand what you want to test, you can fix a warning to choose which classes to use to test the interface.

    Right-click the warning and choose Fix

    This choice is added into the PexAssemblyInfo.cs file.

    [assembly: PexUseType(typeof(Camera))]

     

  3. Now you can rerun IntelliTest to generate a parameterized unit test and test data just using the class that you fixed.

    Rerun Smart Unit Tests to generate the test data

Q & A

Q: Can you use IntelliTest for unmanaged code?

A: No, IntelliTest only works with managed code, because it analyzes the code by instrumenting the MSIL instructions.

Q: When does a generated test pass or fail?

A: It passes like any other unit test if no exceptions occur. It fails if any assertion fails, or if the code under test throws an unhandled exception.

If you have a test that can pass if certain exceptions are thrown, you can set one of the following attributes based on your requirements at the test method, test class or assembly level:

  • PexAllowedExceptionAttribute
  • PexAllowedExceptionFromTypeAttribute
  • PexAllowedExceptionFromTypeUnderTestAttribute
  • PexAllowedExceptionFromAssemblyAttribute

Q: Can I add assumptions to the parameterized unit test?

A: Yes, use assumptions to specify which test data is not required for the unit test for a specific method. Use the PexAssume class to add assumptions. For example, you can add an assumption that the lengths variable is not null like this.

PexAssume.IsNotNull(lengths);

If you add an assumption and rerun IntelliTest, the test data that is no longer relevant will be removed.

Q: Can I add assertions to the parameterized unit test?

A: Yes, IntelliTest will check that what you are asserting in your statement is in fact correct when it runs the unit tests. Use the PexAssert class to add assertions. For example, you can add an assertion that two variables are equal.

PexAssert.AreEqual(a, b);

If you add an assertion and rerun IntelliTest, it will check that your assertion is valid and the test fails if it is not.

Q: What testing frameworks does IntelliTest support?

A: Currently only mstest is supported.

Q: Can I learn more about how the tests are generated?

A: Yes, read this blog post about the model and process.

New Features for TFS @ Visual Studio Online and free Ebook from TFS Rangers Team

Visual Studio Online (VSO) 24×7 for Teams Available  and it  explore as we evolve, innovate, and continuously fine-tune the processes . The recent Managing agile open-source software projects with Microsoft Visual Studio Online eBook is already dated, thanks to the cool features that are released as part of the regular service updates.

Here are top features are noted today, while working on the setup of the VSO Extensibility Ecosystem, App Sample and Guidance project, which will be covered in more detail in one of the upcoming posts.

  1. After creating a new team project, you can fast-track to your Kanban board to get organised, or to your source control system to manage your code.
    image
  2. Your backlog visually indicates which work items are managed by your or another team. For example, 10516-10528 are owned by another team and cannot be reordered on the ALM team board.
    image
    If we show the area path, this becomes even more evident.
    image
  3. The Value Area allows us to define a business of architecture (runway) value for each work item, as used by the Scaled Agile Framework (SAFe).
  4. We can opt in the Epic backlog level and stop decorating some of our Features with an Epic tag to simulate an Epic.
  5. Board columns can be customised, allowing us to introduce our favourite “in flight” analogy for active projects.
    image
  6. Definition of Done (DoD) can be specified for each column and instead of searching for the DoD in a document or work item, you simply click image.
  7. Part of the customisation is the ability to split columns into Doing and Done.

image

Release Management and DevOps with TFS 2013 and future – FAQ

The Subject of Operations (DevOps) it is meanwhile an Hot aspect in the ALM of any application from the point of view of Delivery, Quality, Costs and Reliability. That is the first part of an series regarding this topic.

I will use  a dummy MVC Web Application that’s basically the Visual Studio 2013 template plus a small modification to the web.config so that we can demo the workflow but The same Flow can be , sure with depending complexity with any kind of Application (Native, Multiplatform, Managed or hybrid combinations).

The example I have is to show a message on the home page from a setting in the web.config. This setting then varies based on the environment (dev, prod, etc) the application is running on, and this will be the variable that will be changed by web.config transformations and Release Manager.

Although I’m using an AppSettings key, you can use it for other settings and connection strings as well. The same rules apply.

I made the following modifications:

Index.cshtml

HomeController.cs

Web.config

The application should show  the msg from the web.config settings as per below (running from Visual Studio);

Setting up web.config transforms

I’ll not go into too much detail on how to setup web.config transforms and what the transformation syntax is for them, as they’ve been very well explained on MSDN.

The strategy that I used here was to structure my transformations so that:

  1. The original web.config file has the settings needed for the developer to run in debug mode in Visual Studio
  2. I added a new configuration (Release) that will have the proper web.config transformations to put tokens in the key/values that I need to be changed later by Release Management:

The same transformed config using Release configuration will be used by Release Management (RM) to deploy to all the environments in the release path.RM will then substitute the “__EnvLabel__” token with the appropriate value for each target deployment environment.

TFS Build

You can use any template for the build, including the RM template to trigger a release directly from the build.

The trick here is to force the web config transformation to happen during build, so you end up with a web.config that has the tokens RM is expecting. By default, web config transformations only happen during deployment.

In order for you to add this behaviour, you can add the following arguments to MSBuild:

/p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false

Also, make sure that you’re building the correct configuration that has the transforms to add the token (in our example is Any CPU and Release):

Once the build finishes, the output should look like this (noticed the web.config transformed to include the token):

Release Path setup

Now, we have to take that config and replace the tokens with the proper values according to the target environment. In this example, I’m going to use an Agent-based setup. I’ll update this later to also include an Agent-less deployment using PowerShell Desired State Configuration (DSC).

First we configure Release Manager Server, Release Management Client and a deployment agent on the target server. You can find more detailed information on setting up those parts here: Install Release Management Server and Client, Install Deployment Agents..

I used the same target server to simulate both DEV and PROD IIS environments, by using two different ports:

Then I configured a server in RM to point to that box:

Next I configured the two environments, DEV and PROD:

Next step is to configure a release path where we have a DEV -> PROD deployment flow:

The setup above is, of course, overly simplistic for demo purposes. What you should have in mind is that you can configure who can approve (individuals or groups), who can validate and whether those steps are automated or not. In my example, I don’t need approvals for DEV, but need one for PROD. When the deployment workflow is initiated, DEV will be deployed automatically while PROD will wait for an approval before proceeding.

Next step is to configure the components to be deployed, in this case our web application:

I chose to use the “builds with application” option, since I’m going to use the build definition that will be defined in the release path.

Next, I’ll setup the deployment tool. In my case, XCopy, but you can use MS Deploy or other tool as appropriate:

The secret of the web.config token replacement happens here on the Configuration Variables. We specify that the replacement happens “Before Installation”, so that the config file is updated before being copied to the target server. We also specify the wildcard to tell RM what files we want RM to look for tokens: in this case *.config.

Next we define the release template. In this example:

  • You can see the DEV -> PROD workflow
  • Servers in the deployment (I only have one in this example, but you might have multiple most likely)
  • Components: the application being deployed (you might have to manually add it by right-clicking Components
  • I included optional steps to backup current site, and to rollback in case deployment fails (more of a best practice, but they’re not necessary)

Notice that the “EnvLabel” token we specified before gets a value here, depending on the environment, along with the other variables like target and backup folders:

Deploying

Let’s get some action going!

We initiate the release manually, choosing the template we configured previously, PROD as the last stage and selecting the last build as the one to deploy:

After a while we should see the following results:

Notice that the deployment to DEV was completed, but deployment to PROD is waiting for approval.

DEV has been successfully deployed:

While PROD has not yet:

The reason is that we’re waiting for approval. Let’s go ahead and open the approval window using the RM web client:

Clicking on the “Approve” for the selected release, we get the following dialog:

If we want to approve, but delay the deployment for later (off-hours deployment), we can click on the “Deferred Deployment” and select a day/time for when the deployment will execute:

After approval is given, the workflow resumes and finishes deploying to PROD:

There you have it!

Visual Studio 2015 Product Lineup available with Versions and changes

The Marketing Team of VS has announcing the editions of Visual Studio 2015 that will be available when we release the final product this summer.

Focus is to improve upon the power and productivity of Visual Studio, making it easier to use, no matter what platform you’re on, no matter what app you’re building and make it easier for you to choose which edition of Visual Studio is the right one for you.

More value will deliver bringing Visual Studio Premium and Visual Studio Ultimate into one single offering called Visual Studio Enterprise with MSDN. It includes all the high value features you’re already familiar with in Visual Studio Ultimate, along with new innovation that’s coming with the 2015 release. So, in addition to Visual Studio Community and Visual Studio Professional with MSDN, our new Visual Studio Enterprise with MSDN rounds out the three primary Visual Studio 2015 offerings.

Visual Studio 2015 Product Offerings

The Visual Studio Professional, Team Foundation Server, Team Foundation Server Express, Visual Studio Express and MSDN Platforms will be continued to offer as a part of the complete Visual Studio 2015 and MSDN portfolio.

Getting Visual Studio 2015

Customers who have an active subscription for Visual Studio Premium with MSDN or Visual Studio Ultimate with MSDN will automatically get upgraded to Visual Studio Enterprise with MSDN. And the pricing of Visual Studio Enterprise with MSDN will be significantly less than the current price of Visual Studio Ultimate with MSDN. Check out the Visual Studio 2015 Product Editions for detailed feature and pricing information, including the current promotions ,so you can get the most value out of Visual Studio today.

Also if you haven’t tried it yet, download Visual Studio 2015 CTP 6 to test out the new features and send feedback through the usual channels (UserVoice, Send-a-Smile, or Connect).

Here is an Feature comparison between the VS 2013 Versions

https://www.visualstudio.com/en-us/products/compare-visual-studio-products-vs.aspx