Posts

Showing posts from February, 2017

Infer Generics, Implicit new and Significant whitespace

Image
Good afternoon! I made some suggestions on the Visual Studio section of the Uservoice site. Let's go through them in the order of controversy ;-) Implicit new My first suggestion is for a quality of life feature that I originally ran across in the Boo programming language : When referring to a class identifier, presume instantiation: throw ArgumentException(); // read as `throw new ArgumentException()` since there's no `ArgumentException` method in scope, but there is a class var banana = Fruit( "Banana" ); // read as `new Fruit("Banana")` since there's no `Fruit(string)` method in scope, but there is a class https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/18043915-implicit-new Infer Generics My section suggestion identifies a common pattern in my daily life - I've been working with a lot of sequences (lists and dictionaries) in my Web, WebJob, hybrid web app and Bot projects. To make the C# language mo

Exploring your code with NDepend 2017.1.0 Professional Edition

Image
I just got my hands on a license to NDepend 2017 (thanks patrick!). After installing it and opening an arbitrary solution I was working on at the office, it struck me how great it is to have someone - or a tool - to discuss complexity with! Not wanting to attach a NDepend project to my solution (since I share this solution with my colleagues who is not evaluating this tool yet), I opened the stand-alone Visual NDepend from the NDepend menubar Analyzing my solution, the tool highlighted that one of my methods were overly large and complex - a method that evaluated certain column headers in an Excel document against a set of known terms in order to understand its structure. Just by highlighting this complexity nudged me to take a step back and look at our overall solution to see if this particular logic belonged there, or if this entire project, in fact, could be seen as just an extraction process, handling the interpretation elsewhere. THIS is something I appreciate from this tool

Microsoft Bot Framework and the IScorable interface

Using the IScorable interface and hook your implementation into the AutoFac dependency injection container supplied by the Microsoft Bot Framework team, you can create multiple separate global chat logic handlers: BOT: Hi and Welcome! Human: Do you like candy? -> CandyResponseHandler BOT: I certainly do! Licorice is my favourite! Human: How are you feeling today? -> FeelingResponseHandler BOT: Never better! I just had some licorice a little while ago! Let's create the candy response handler together before we move on: public class CandyResponseHandler : IScorable { private readonly IDialogStack _stack; public CandyResponseHandler(IDialogStack stack) { SetField.NotNull(out _stack, nameof(stack), stack); } public async Task PrepareAsync(IActivity item, CancellationToken token) { var message = item?.AsMessageActivity(); var messageText = message?.Text; if (String.IsNullOrWhiteSpace(messageText))