Evan J Palmer's Blog

A blog about learning (code, improv, film and, anything else).

Month: January, 2013

Accessing .Net’s Opensource Code Via ReSharper in Visual Studio

Trying to think of something to do with open source...

TLDR: Alt+` and select “Sources From Symbol File”.

I love working with other programmers. Especially other programmers who know more than me (not particularly hard to find).

I would love to do a project or part of a programming XP or paired – it hasn’t happened yet, but who knows. The career is still young… kinda…

Anyway, the great thing about working with other people is you can learn so much from them. For example, something that might seem incredibly obvious to them, might not have occurred to you. Or they might have a few tricks up their sleeve that wouldn’t come up in conversation, or that they might not even realise aren’t common knowledge.

Obviously, the opposite is also true and sometimes you can impart some of your wisdom on to someone else!

At work the other day, this exact thing happened. Here’s the context.

I was making an optional parameter for a method. I wanted the default value to the empty string.

This works:

public void DoSomething(string aString = “”)

but this

public void DoSomething(string aString = String.Empty)

does not.

Why?

Well the compiler is telling me the default value needs to be a constant. Surely String.Empty is a constant, right?

Thinking this was an interesting little tidbit I’d stumbled across, I posed this question to my mate (let’s call him “Adam”) who didn’t know why it would be a problem off the top of his head. We joked that it’s probably something only Skeet would know (which is actually a really nerdy joke in hindsight). Then Adam suggested we look at the source code implementation for String.Empty.

On his keyboard he hits Alt+` and selects “Sources From Symbol File”.

We can now view the implementation of String.Empty and see it’s static readonly in oppose to a const  a compile time constant. The difference being that a const is an unchanging value that we know won’t change and are able to drop those zeros and ones into the compiled output. A readonly can be set in a constructor or to something like DateTime.Now. Here’s an excellent explanation.

Now, I knew the framework was opensource, but had no idea it was so easily accessed via ReSharper and Visual Studio. This is an awesome feature that I will be using a lot more of in the future, and I believe will make me a better programmer.

Adam thought this was common knowledge and would never have mentioned it, if it hadn’t come up randomly.

Long live smart guys!

So, this idea of learning by simply working with other humans-beings  is a great one, and I imagine it holds true for all professions, or disciplines, not just software development.

As an aside, this reminds me of a recent-ish post by Old Faithful (Aka Scott Hanselman) who encourages us to look under the hood more often:

http://www.hanselman.com/blog/TheInternetIsNotABlackBoxLookInside.aspx

Getting a large Voice Memo off your iPhone without iTunes

TLDR: Message it to yourself, then email the message.

IHLOT:

My friends and I were messing around with some amateur film stuff over the weekend.

We didn’t have a decent mirophone (my cool new NTG3 hasn’t arrived yet), and the on board microphone on my camera is basically poop.

We decided to record the audio on the iPhone and see how that turned out (much better than the on board microphone, if you’re interested).

Anywho, so I’ve got about 10 minutes worth of dialogue sitting on my phone. I connect it to my machine and try to find the file in windows explorer, like I would a photo. Unfortunately Windows is unable to read what I assume is some kind of propriety File System format by Apple.

I don’t worry  – instead I just try to email to myself, but get an error message saying “Memo is too long. Would you like to select a shorter version of this message?” I don’t want to crop it (I want all the dialogue, of course).

I grooaaan when I realise I have to use iTunes. I don’t have iTunes installed (with Spotify/Downcast and my contacts synced to the cloud I don’t need it) so I install the clunky piece of crap and tell it I tell it to sync my memo’s. In response it tells me to do that it’d have to delete everything on my phone. This is less than Ideal.

Pop quiz, hot shot. What do you do, what do you do?

Well as I said in the TLDR, I messaged it to myself and from the message I got (when it eventually came through) I emailed it to myself, with no size restriction.

So yeah, I couldn’t find these instructions online – I hope this finds someone well.

Kind of a bugger because I was hoping to use my iPhone as a kind of field recorder for future film stuff.

I wonder if there’s a better app out there… ???

*IHLOT – I Have Lots Of Time…. what’s the opposite of TLDR?