TWC9: NuPack, WebMatrix Beta 2, MVC View Engines Reviewed

This week on Channel 9, Dan and Clint discuss the week's top developer news, including:
Picks of the week!
Pick of the week! Thanks for the shout-out as always...
BTW, the Watch links for the picks of the weeks are backward (Clint's watch link points at Dan's, Dan's at Clint's)
I love that extensionmethod.net thing. Wonderful!
Also, Dan's rage with the whole string/stream thing is so recognizable. It drives me crazy every single time.
Epic Dan-rant from minute 16:
"But then I try to create... a God-damn stream - but that's an abstract class... so then I need to find... a StreamWriter...but."
Truer words were never spoken... And I love the way it ends with a "but", that but is what every developer feels like a grunt coming from your soul every time you try to convince yourself that correct encapsulation and abstraction layers and architecture comes before productivity and ease-of-use.
Or wait... No it doesn't! Cover the 90% use-cases first and the 10% use-cases later. In the case of symmetric encryption the 90% use-cases are with a string-in string-out. An extension method for this need to be in String - and this needs to happen now as a critical reboot-all-servers update to .NET 4.0! Heck I'll even implement the solution right here and now:
/// <summary> /// Critical extension methods to make encryption and decryption easy. /// </summary> public static class CriticalStringExtensions { /// <summary> /// Gets a Stream containing the bytes from the given string. /// </summary> /// <param name="source">String object.</param> /// <param name="encoding">Encoding to use. Uses UTF8 as default.</param> /// <returns></returns> public static Stream AsStream(this string source, Encoding encoding = null) { if (encoding == null) encoding = Encoding.UTF8; if (source.Length > 0) return new MemoryStream(encoding.GetBytes(source)); else return new MemoryStream(0); } /// <summary> /// Gets a string from the bytes in a stream. /// </summary> /// <param name="source">String object.</param> /// <param name="stream">Stream to read from.</param> /// <param name="encoding">Encoding to use. Uses UTF8 as default.</param> public static string AsString(this Stream stream, Encoding encoding = null) { if (encoding == null) encoding = Encoding.UTF8; using (var reader = new StreamReader(stream, encoding)) { return reader.ReadToEnd(); } } }
are you still forced to submit your internal application to the winphone marketplace in order to get them on devices?
phone7 looks really hot but it is (or atleast was) waaay to complicated to get your code onto an actual device... paying 99 bucks to simply deploy your own app to your own phone? come on dudes..
we'd really love to make an app for internal use at my company, but having to submit it to the marketplace where its visible for everyone is an absolute showstopper both in terms of added work to get it approved for the marketplace, and cost to develop and deploy
@DLNA
DLNA is a protocol but as far as i understand you have to buy a licence from the DLNA group to make an app that uses it. As far as i know there is no special hardware involved, its just an peer2peer network protocol that TVs and other stuff (such as win7) can support
Another great show, and thanks for the good word guys!
@hansol:Not bad; could extend it a little though
public static class CriticalStringExtensions { public static Stream AsStream(this string source, Encoding encoding = null) { var result = Stream.Null; if (source != null && source.Length != 0) result = new MemoryStream((encoding ?? Encoding.UTF8).GetBytes(source)); return result; } public static string AsString(this Stream stream, Encoding encoding = null) { if (stream == null) return string.Empty; using (var reader = new StreamReader(stream, encoding ?? Encoding.UTF8)) return reader.ReadToEnd(); } }
A slightly different take. Not necessarily better.If contracts (with static checks!) are available then one should probably use Contract.Requires(source != null); and likewise Contract.Requires(stream != null).
@exoteric: Agreed! I love the succint syntax of the ?? operator, but the Contract.Requires stuff, that's attributes from a feature that's not in production yet, right? Or am I not up to speed here...
@gduncan411: thanks for the heads up, don't tell dan or it will be the last time he'll give me the keys to the car!
@hansol: Code Contracts is a .NET 4.0 feature and so is production ready. Static analysis tools for Code Contracts is a commercial feature of some Visual Studio versions (I forget which). Some Code Contracts features are exposed as attributes, e.g. [Pure]; the above is of course not. I didn't check for how Stream.Null is implemented but it's probably a no-op singleton (I hope).