Posts

Xamarin .xib Tree Hierarchy Cleanup

Image
Another annoyance with Xamarin Studio is when adding a new iPhone View Controller and the csproj's hierarchy is different than what you'd expect (or what is used in the mobile-samples ). So I whipped up another Python script to save me some time & appease my obsessiveness. Let's add a new iPhone View Controller simply called "MainMenu"... Notice how the tree hierarchy has the .designer.cs file nested underneath the controller .cs file -- and the .xib file is completely independent. Now let's run xamarin_tree_clean.py available at  https://gist.github.com/xeb/5907008 And when we head back over to Xamarin Studio, it will automatically reload the project file & our tree hierarchy will be clean again.

Switch Xamarin Studio to Xcode5 for iOS 7.0 Development (and back)

Image
I enjoy using Xamarin .  I also want to play with the Xcode5 Developer Preview . But sometimes I want to switch back & forth between Xcode5 and Xcode4.  Why?  Because of this: That's the message you'll get in Xamarin if you use Xcode5-DP.  So I hacked out a quick Python script to help me switch back & forth in my project. It's simple enough to just be worthy of a Gist.  See: xamarin_switch.py at https://gist.github.com/xeb/5890019 . Use it within the directory of the solution & csproj that you are working with.  Then just run the script & specify which verison of Xcode you want.  (Either a 4 or a 5 or "xcode4" or "xcode5"). Example: Again thats.... xamarin_switch.py xcode4 To go to Xcode4 + iOS 5.1/6.0/etc. and xamarin_switch.py xcode5 To go to Xcode5-DP + iOS 7.0 This did three things: Changed the SDK Location of Xamarin Studio Changed the first CSPROJ file to the correct iOS Build version Launched Xam...

Unconventional Technical Leadership

I just finished reading David Byttow's Effective Technical Leadership post.  There are some unsaid ideas that he did not present that I wanted to share.  But first... Why listen to me?  I'm a Lead Software Engineer at a large video game developer ( google me ).  I've stopped posting to this blog since joining the company as a Software Engineer in 2010.  But in 2 years, I've been promoted 3 times and now lead a team that develops a massive amount of live operation.  I will get called at 3am if something breaks.  Or is too slow.  There is no one above me that has more technical knowledge of the systems I work on.  Once its escalated to me -- I have to fix it.  If something happens 1-in-a-million times in our codebase, it may happen 100 times a day. It is not easy  keeping people productive, effective & reliable in a medium sized team.  Below are some random bits of advice I can offer after spending a decade creating la...

Applying WebInvoke without an Attribute

Haven't posted in a long time but thought I'd post this bit of WCF extensibility I was working on at home. There is nothing on the Internet about how to do this & I felt I should figure something out. Scenario: You have legacy WCF services that you want to switch to a WebHttpBinding w/ JSON but don't want to update 1,337 service contracts to include a WebInvoke attribute, UriTemplates and Request/Response Body Types In this scenario I'll be assuming use of IIS and Windows Process Activation Services to host your service. The WebInvokeAttribute implements IOperationBehavior. So what we need to do is somewhere in the WCF stack apply this operation behavior programmatically to our Endpoint's Contract.Operations. Let's start from the bottom up & take a look at an extension method that does this. /// <summary> /// Automatically applies the Web Invoke behavior to all operations in the collection /// </summary> /// <param name="operatio...

MapReduce in C# using Task Parallel Library

Back in August I starting playing with a C# implementation of Google's MapReduce algorithm. The implementation was based on something Stephan Brenner did, although I completely refactored it. Today I added a little bit of logic to split up the actual execution of Map & Reduce in this implementation using the Task Parallel Library in .NET 4.0. Check out the source code for MapReduce in C# on GitHub. Below is an excerpt from the Tests on how to implement the library. Counting Words in Files public static List<KeyValuePair<string, int>> Map(FileInfo document, string text) { var items = text.Split('\n', ' ', '.', ',','\r'); return items.Select(item => new KeyValuePair<string, int>(item, 1)).ToList(); } public static List<int> Reduce(string word, List<int> wordCounts) { if (wordCounts == null) return null; var result = new List<int> { 0 }; foreach (var value in wordC...

Require comment / message on all SVN commits for Visual SVN Server

(I've been posting a lot the last few days!) Something that drives me nuts is not having a comment or message when looking at SVN history. It's impossible to know what went on. Even a bad comment is better than no comment. SVN hooks are a great way to solve this. If we make a pre-commit.bat file that checks the commit data for a comment, returns an error code of 1 if it wasn't found (with some text) or returns 0 if the comment is there. Check out the pre-commit hook that I found online (thanks, Anuj Gakhar!) or check out the hook below. @echo off setlocal rem Subversion sends through the path to the repository and transaction id set REPOS=%1 set TXN=%2 rem check for an empty log message svnlook log %REPOS% -t %TXN% | findstr . > nul if %errorlevel% gtr 0 (goto err) else exit 0 :err echo. 1>&2 echo A log message or comment is required to commit 1>&2 exit 1 This works perfectly except for 1 downfall -- you have to distribute it in every freaking reposito...

Using ref Keyword with Reference Types in C#

One of our developers was using the ref keyword in a method that needed to replace the value of a property of the method's parameter. In other words... public class Person { public int ID { get; set; } public string Name { get; set; } public string Email { get; set; } } public static class ReferenceExample { public static void Main() { var person = new Person { Name = "Mark", Email = "none@none.com", }; Save(ref person); Console.WriteLine(person.ID); Console.ReadLine(); } public static void Save(ref Person person) { person.ID = 1; // Pretend this saves to a database or something } } The thinking is correct. Person needs to be passed by reference. So why not use the ref keyword, right? Well...Person is already a reference type . So if we are just replacing properties, we don't need the ref keyword. Removing it changes nothing with our code. T...