Awesome, Free Software: Core FTP

I had to do some testing for a project that uploads its payload via SFTP. I wanted to setup a basic, no-frills SFTP server that could accept my files. I did a quick Google search and found Core FTP Server–a free download. After about 2 minutes of configuration, I had my SFTP server up & running; it was fantastic.

I also see that they have a free mini sftp server that’s available. It’s a no-install, one-user, one-directory SFTP server, and IT WORKS AWESOMELY! This might be my new favorite way to securely transfer files between sites!

Core FTP Server

XmlSerializer and Namespaces

Need to share some data with another system/program/thing? XML files are a great, easy way to do it! Typically, my process for creating or consuming XML files will be to generate a class from an XML schema definition (XSD) and then serialize to and deserialize from XML as needed.

Usually, you don’t need to do anything above and beyond this, but from time to time you might need to do some additional manipulation with the XML namespaces and associated prefixes. The XmlSerializer class gives you a lot of flexibility to do this, and it’s really easy! Here are some different things you can do along with the output produced.

Here’s my no-frills Person class that I’ll be serializing to XML in the examples that follow:

[XmlType(Namespace = "http://adamprescott/sample")]
public class Person
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public DateTime? DateOfBirth { get; set; }
}

By default, the serializer will include the XML namespace on each element.

var p = new Person
    {
        LastName = "Sample",
        FirstName = "James Q.",
        DateOfBirth = new DateTime(1970, 1, 1),
    };
var serializer = new XmlSerializer(typeof(Person));
serializer.Serialize(Console.Out, p);
<?xml version="1.0"?>
<Person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <FirstName xmlns="http://adamprescott/sample">James Q.</FirstName>
  <LastName xmlns="http://adamprescott/sample">Sample</LastName>
  <DateOfBirth xmlns="http://adamprescott/sample">1970-01-01T00:00:00</DateOfBirth>
</Person>

Whoa-day! That’s pretty busy. You can clean it up a lot just by declaring the default namespace when you instantiate your XmlSerializer.

var p = new Person
    {
        LastName = "Sample",
        FirstName = "James Q.",
        DateOfBirth = new DateTime(1970, 1, 1),
    };
var serializer = new XmlSerializer(typeof(Person), "http://adamprescott/sample");
serializer.Serialize(Console.Out, p);
<?xml version="1.0"?>
<Person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://adamprescott/sample">
  <FirstName>James Q.</FirstName>
  <LastName>Sample</LastName>
  <DateOfBirth>1970-01-01T00:00:00</DateOfBirth>
</Person>

That’s a little nicer, but what if I don’t want those XMLSchema namespaces? That’s easy, too!

var p = new Person
    {
        LastName = "Sample",
        FirstName = "James Q.",
        DateOfBirth = new DateTime(1970, 1, 1),
    };
var serializer = new XmlSerializer(typeof(Person), "http://adamprescott/sample");
var namespaces = new XmlSerializerNamespaces();
namespaces.Add(string.Empty, "http://adamprescott/sample");
serializer.Serialize(Console.Out, p, namespaces);
<?xml version="1.0"?>
<Person xmlns="http://adamprescott/sample">
  <FirstName>James Q.</FirstName>
  <LastName>Sample</LastName>
  <DateOfBirth>1970-01-01T00:00:00</DateOfBirth>
</Person>

Note that I made the prefixes all string.Empty. If I were to specify a prefix, it would be included in the serialized XML.

var p = new Person
    {
        LastName = "Sample",
        FirstName = "James Q.",
        DateOfBirth = new DateTime(1970, 1, 1),
    };
var serializer = new XmlSerializer(typeof(Person));
var namespaces = new XmlSerializerNamespaces();
namespaces.Add("ap", "http://adamprescott/sample");
serializer.Serialize(Console.Out, p, namespaces);
<?xml version="1.0"?>
<Person xmlns:ap="http://adamprescott/sample">
  <ap:FirstName>James Q.</ap:FirstName>
  <ap:LastName>Sample</ap:LastName>
  <ap:DateOfBirth>1970-01-01T00:00:00</ap:DateOfBirth>
</Person>

Move Shelvesets Between Branches in TFS

At my company, we do a lot of concurrent development between a number of branches. It’s not uncommon for a change made in one branch to be needed in another branch. TFS Power Tools includes functionality to help you quickly and easily migrate a shelveset from one branch into another.

The usage is simple, too. Go to the command-line and type the following (make sure you run it from a directory mapped to a workspace):

tfpt unshelve "My Shelveset" /migrate /source:$/SourceBranch /target:$/TargetBranch

When you run the command, it will load the changes stored in the shelveset into the specified target branch. Super!

AVG Free Edition

If anybody asks me for recommendations on an anti-virus solution, I always point them to AVG. I’ve used it for years and love it. It has a great UI, does a good job detecting and cleaning viruses, and they have a free edition to-boot! The only drawback to the free edition is that it’s so hard to find the download!

If you try to find it by browsing through http://www.avg.com, it’s near impossible to find. So, the easiest way to find it is to remember this URL: free.avg.com.

If you do happen to download and/or install the not-free version, it will prompt you to convert to the free version when you go to uninstall. So that’s another way to get it.

Bright Future for WP7

Microsoft has come out with a list of new features that will be coming with the Mango update later this year. I gotta say, I’m really excited. I’m happy with the phone exactly how it is now, but it’s getting so much better. You can find feature/update lists all over the internet, or you can browse the What’s next | Windows Phone 7 page at Microsoft.

These are the features that I’m most excited about:

  • IE9
  • Voice turn-by-turn navigation
  • Bing Vision
  • Local Scout
  • Better integration with Twitter & support for Facebook chat
  • Improved multitasking (alt+tab-like behavior)

The only feature that I was really missing from the BlackBerry Curve that I had with Sprint is the Sprint Navigation app. It was nice to always have a GPS in my pocket. WP7 has Bing maps with directions, but it’s not the best for figuring out where to go while driving since you need to scroll through and read the steps. So I’m definitely happy to see that voice-guided turn-by-turn directions are coming. I’m also looking forward to trying out Bing Vision.

Also, the check out PC Magazine’s 2011 Readers’ Choice Awards for mobile phones here. The Samsung Focus on AT&T (my phone) had a sparking 9.1 rating. I agree with it–I love this phone!

Goodbye .net Reflector, Hello ILSpy

I love[d] RedGate’s .net Reflector and used it all the time. It made me sad to see that they decided to eliminate the free version. The price isn’t terrible at $35, but it’s enough to make me explore other options before putting in a purchase request at work. I talked to some colleagues, did some quick Google research, and was pleasantly surprised to find a wonderful substitute called ILSpy.

ILSpy does exactly what .net Reflector did for me. I can explore objects, methods, and properties in assemblies, and it’ll decompile to show implementation details. ILSpy (or something similar, like .net Reflector) is a must-have tool for debugging and troubleshooting. I definitely recommend you check it out!

More info here.