Tag Archives: Visual Studio

How to fix 403 errors when managing Azure SQL Database from Visual Studio

I had some interesting challenges last week in managing Azure SQL Database from inside of Visual Studio 2013.  Check out how I fixed this problem on Kloud’s official blog here:

http://blog.kloud.com.au/2014/09/08/how-to-fix-403-errors-when-managing-azure-sql-database-from-visual-studio/

Tagged , ,

What Happens When You Delete a User from Visual Studio Online

As of May 7 2014, Visual Studio Online has shifted to a paid model where all user accounts over the basic 5 user limit must hold a paid license in order to access and use the service.

So, what happens when you remove a user’s account from Visual Studio Online? Let’s take a look.

No, really, it’s OK

Firstly, just a word of reassurance here – your data consistency will remain even after you’ve removed the user’s account.  It might seem obvious but it is comforting to know that you’ll still have the history associated with the account.

Work Items

Your Product Backlog Items (PBIs) and other Work Items will continue to work as expected – even if the user created or updated the Work Item or has it assigned to them at the time their account is removed.

Audit trail entries that were created by this user through their activities on individual Work Items will retain full fidelity so you can trace actions by the user at any future point.

Source Control

Both Git and TFS source control repositories will behave as expected and the user’s change history of files will remain intact.

Are they really locked out?

Yes. Visual Studio Online via the web, Visual Studio and source control will not allow a deleted account to have access.  Even Git with it’s alternative credentials returns an authentication failure when trying to perform any action.

Any edge cases?

Not that we’ve seen.  Here’s some advice on things to do before you remove an account (granted some of these might not make any sense depending on how stale the account is and what it’s purpose is).

  1. Be aware there is an initial soft limit of 50 user accounts per subscription.  You can raise a support ticket to get this increased.
  2. Make sure you have alternate project administrators if the account you are deleting has previously been the only project administrator.
  3. Make sure any outstanding check-ins are either shelved or checked-in.

It’s early days for Visual Studio Online as a paid SaaS solution – it will be interesting to see how it continues to evolve now that it’s generating a revenue stream for Microsoft.

Tagged , , , ,

Debug iOS App from Visual Studio with Xamarin extension using the iPhone Simulator.

This is a really quick and easy tip for those starting out doing iOS development with Xamarin (and specifically with the Visual Studio extensions). If you don’t have access to an iOS device and want to debug on the Simulator that ships with Xcode make sure you do the following:

Set the “Platform” to “iPhoneSimulator” for the project.

1. Select the Solutions Configuration menu (allows you typically to choose Debug or Release) and is next to the “Start” debug button.
2. In the Configuration Manager for your iOS App select “Platform” and change to “iPhoneSimulator” (highlighted below).
3. Save the changes and you should now be able to debug.

Selecting iPhoneSimulator

I scratched my head on this for a while ;).

BTW, did I say how cool it is that you can develop Android and iOS apps from right inside Visual Studio? You still need a Mac and Xcode for iOS but Android is there for the taking (you can even edit the axml layout files directly inside Visual Studio!)

Tagged , , , ,

TFS As A Service (TFSPreview.com) – Connect to and Query Using C#

Having worked with every version of Team Foundation Server (TFS) since its inception I was keen to see what API support “TFSPreview.com” has. The good news is that (at time of blogging) the API accessibility is all there, is free and aligns with the on-premise API and client object model.

I’ve always felt the strongly-typed client object model and library is a strength of the TFS offering over many of its competitors and the classes that compose it provide some good extensibility possibilities – I’ve been on a project where all “Requirements” work item types from an MSF Agile project were exported via the API to a Word document and formatted for presentation to the customer (and we could re-run it any time!)

This past week has seen the RTM availability for a bunch of Microsoft products including Visual Studio and Team Foundation Server 2012, which means that an RTM set of the TFS Client Object Model assemblies are now available. After grabbing them I fired up Visual Studio, added in the correct references and was able to connect to our TFS Preview instance and perform some query magic.

Here’s an (incomplete) sample of how easy it is!


// Add the namespaces.  Make sure it's version 11.0.0.0!
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client; 

// some time later in your code...
// this code assumes the user who owns the current thread has previously authorised against the server
using (TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("https://yourinstance.tfspreview.com/defaultcollection"), new TfsClientCredentials()))
{
     var workItemService = tpc.GetService<WorkItemStore>();

     var queryString = "Select [State], [Title] From WorkItems Where [System.TeamProject] = @TeamProject and [Work Item Type] = @Type and [Assigned to] = @Me";

     var variables = new Dictionary()
                         {
                             {"Type","Task"},
                             {"TeamProject", "YOURPROJECT"}
                         };

     var query = new Query(workItemService, queryString, variables);
     WorkItemCollection results = query.RunQuery();
}

So the above is just a simple and incomplete example – but it will connect and return results for you. The TFS extensibility options are pretty wide and varied as can be seen on MSDN! I’ll post more stuff up here over time as I work through my planned use of this server (a custom team board in our office… too big perhaps, but hey…).

If you don’t have a TFSPreview account I’d recommend getting one and having a play – Microsoft has said the platform will be free through until the end of 2012 so I’d say there’s no better way to try it out than that. They are also shipping updates for the platform every 3 weeks which will be ahead of the on-premise version which will get quarterly updates (based on the TFSPreview updates). Get in and get informed.

Tagged , , , , , , , ,

Doing the Shimmy Fake (VS11 Beta Unit Test Isolation).

I’m sure many of you have read of or heard about the Moles Power Tool that shipped as an add-on to the original Visual Studio 2010 release back in 2009. There was certainly a lot of speculation about which way this Microsoft Research project would go.

The great news is that with the impending Visual Studio “11” release it appears the Moles Power Tool is now baked into the Microsoft.QualityTools namespace.

I first read about this on the MSDN ALM blog which I’d recommend you go and have a look at. My first thought was that the new Shim Fake is essentially what a Mole was previously. In writing up a few simple test cases my hunch was confirmed (see the tooltip reads “Sets the mole of…”:

fakemole

(I expect this will change before the RTM release though!)

So what can you do with a Shim? A Shim allows you to redirect calls to a method to a delegate you control which means you can control flow in tests that might otherwise have been blocked. Where I’ve used this heavily previously was with SharePoint 2010 classes and with the System.Configuration namespace.

You need to do a bit of work to create the baseline for a Fake – firstly the assemblies must be referenced in your Unit Test project in Visual Studio – right click on the assembly under “References” and choose “Add Fake Assembly”:

The Add Fakes Assembly context menu item.

Visual Studio will add some XML files that define the Fake and a new reference will appear that represents the Fakes:

Solution Explorer with Fakes.

A Simple Example

The easiest way to show how this all works in your favour is with a simple example. Firstly let’s assume we have a simple helper class that utilises System.IO.File. In the past we would have had to resort to 3rd party products to redirect any calls to System.IO.File so that we can test the code around the call. Here’s our File helper class definition:


public class FileWriter
{
     public void AppendContentsToFile(string filePath, string conentToAppend)
     {
         try
         {
             System.IO.File.AppendAllText(filePath, conentToAppend);
         }
         catch (Exception ex)
         {
             // log and throw.
         }
     }
}

And now let’s see how we use a Shim to allow us to test the FileWriter AppendContentsToFile method. The important elements to note are: using the Fakes namespace so that you can create a ShimContext which is needed to use a Shim. You’ll also notice that the Shim has a different class name and that the method combines the name and type of each parameter. If you don’t use a ShimContext your test will fail, but helpfully the test runner will actually provide a code sample of what needs doing in order to fix the test.

By using an anonymous delegate we provide a redirection of the call to a method we write and control. This quickly becomes a powerful way to isolate just your code from underlying Framework methods.


using Microsoft.QualityTools.Testing.Fakes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using UnitTestingDemoApp;

namespace UnitTestProject1
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestFileWriterAppendContents()
        {
            using (ShimsContext.Create())
            {
                var writer = new FileWriter();

                System.IO.Fakes.ShimFile.AppendAllTextStringString = (file, contents) =>; AppendStringToFile(file, contents);

                writer.AppendContentsToFile(&quot;C:\\some\\path\\afile.text&quot;, &quot;somecontents&quot;);
            }
        }

        private void AppendStringToFile(string filePath, string textToAppend)
        {
            // perform some logic, maybe throw exceptions.
        }
    }
}

This is a simple example of how Shims can be used – right now beyond MSDN there isn’t a lot of detail about but if you read up on Moles you will quickly get the idea.

And the Shimmy Fake? Well, I tip my hat to Australian kids entertainers the Wiggles and their Shimmy Shake from 2008…

Tagged , , , , ,