RSS
 

Debugging a Unit Test in VS2012 not stepping in

19 Sep

I ran into an issue the other day where I was trying to step into a method while debugging a unit test and the debugger just stepped over the method call.

The method was in a class library that the test was exercising. The problem was fixed by disabling Code Coverage. What I did was went Test->Test Settings-> and unticked the test settings that were current (that had code coverage enabled).

This has also been noted on Microsoft Connect so hopefully we will get some kind of patch soon.

 

Visual Studio: Track Active Item In Solution Explorer

14 Feb

I have been automatically tracking the current file in the solution explorer for quite a while. Most of the time this works well, every time I edit a file the solution explorer highlights the file I am editing. Sometimes it is a bit of a drag when you are jumping between multiple files and want to view the structure of the solution at a different location. (i.e. when the file you are editing is at the top of the solution and you want to look at some resource folder structure that is down near the bottom)
Anyway I have turned it off and am now using the keyboard shortcut Alt-Shift-L, this will highlight the current file in the solution explorer.

By the way…. Tools->Options>Projects and Soutions->Track Active Item in Solution Explorer is where you go to turn the automatic tracking feature on and off.

 
 

iOS – plist for playing audio in the background

08 Jan

To play audio while your app is running in the background add the following to your apps .plist

Required Background Modes screen shot

 
No Comments

Posted in Audio, iPhone

 

Missing Build Targets

21 Sep

Problem: The imported project “C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets” was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

Solution:

Copy the missing files over from another dev machine

or (what I did)

Install Team Explorer 2010 on the build machine

 
No Comments

Posted in MSBuild, TFS

 

NSString Format Specifiers

15 Jun

Handy list of format specifiers for NSString can be found here

 
 

WPF: ElementName bindings, or how my xaml started looking like Objective-C

18 May

(this post has nothing really to do with Objective-C except one little quirk, so if you’re looking for a link this is tenuous at best)

You know when you are binding from a xaml form to a property on the code-behind and you can find yourself doing all sorts of crazy bindings with FindAncestor to get to the property?

I find this a bit of a pain so what I usually do is give the xaml an x:Name attribute of self. Then I can do an ElementName binding like so:

<TextBox Text="{Binding ElementName=self, Path=PropertyInCodeBehindFile}"/>

I find it a nice simple way to get to those properties that are not related to the data context. I know it may be considered bad practice by some and we could have arguments about separation of concerns but I still like it :)

So what has this got to do with objective-C? Well in objective-C the “this” pointer is called “self”. If I name my forms as “this” it has the side effect that if you ever want to refer to it in the code-behind “this” refers to the class and you will end up with a “@this” as the element name. (this is how to reuse reserved words in c#)

 
No Comments

Posted in Binding, WPF, XAML

 

WPF: Binding to a static property of a static class

18 May

A have a static class, with a static property

public static class MyStaticClass {
   public static String Name {
      get { return "Hello"; }
   }
}

You can bind to it like so:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WpfApplication1"
        Title="MainWindow" Height="350" Width="525">

   <TextBlock Text="{Binding Source={x:Static Member=local:MyStaticClass.Name}}"/>

</Window>
 
No Comments

Posted in Binding, WPF, XAML

 

WPF: String.Format (just for text)

18 May

Something I use all the time is String.Format in xaml. Often the examples I see are for formatting dates or numerics, I usually just use it for formatting text. If you have one argument you can do it like this:

    <TextBlock
        Text="{Binding Path=Status, StringFormat=Your Status: {0}}" />

Which is a nice way to get a string like “Your Status: All Clear” after binding to an object with property Status=”All Clear”

Multiple arguments require something like the following

    <TextBlock>
        <TextBlock.Text>
           <MultiBinding
              StringFormat="{}{0} - {1}, {2}">
              <Binding
                 Path="Code" />
              <Binding
                 Path="GivenName" />
              <Binding
                 Path="FamilyName" />
           </MultiBinding>
        </TextBlock.Text>
    </TextBlock>

This will give you a string like “OBJ32 – John, Matthews” (if those were the properties Code, GivenName and FamilyName on whatever you bound the TextBox to).

 
No Comments

Posted in WPF, XAML

 

xCode 4: iPhone adHoc build in 7 Steps

02 May
  1. Select a device in the Schemes drop down (not the simulator)
  2. Choose the menu item Product->Archive.
  3. Open the Organiser (Command-Shift-2) if it is not already open.
  4. Highlight the built product and click Share…
  5. Choose your Identity for code signing, should match the one in your build settings.
  6. Save the .ipa file.
  7. Distribute.
 
 

Note To Self: Avoid working on unfinished projects

19 Apr

I have been doing a bit of moonlighting and finishing off other peoples projects. There are a couple of things that I have learnt from this (I’ll add to this from time to time):

  • The owner of the project very rarely tells you the real reason the original developer has moved on. A developer I know reckons 50% of the time it is because the guy paying the bills is a bit of an asshole. Another friend has stated that the other 50% of the time is that the original developer didn’t know what he (or she) was doing. Whatever the reason, I have never come across a project that was a joy to finish off for someone else when the original developer has left.

 

    • The code you are being asked to work on is probably crap. I would like to omit the ‘probably’ but admit there might be a case where it is not, I have not yet come across this case however. I have been reading a book by Kent Beck called Implementation Patterns. If developers followed such sage advice as this then finishing off a project would be no drama at all. What I usually find is a mess of classes, variable names, global variables, hacks and no real discernable patterns. It’s like the teenager who only ever tidies their room if friends are coming over. (I don’t know if these people ever tidy house, there is definitely no code review process) Also, I don’t know what it is about people that have been schooled in the C mentality but there is nothing wrong with naming variables. ‘c’ is not an appropriate representation.
     
    No Comments

    Posted in Code