Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Wednesday, August 06, 2014

Reactive Extensions for mere mortals (and using them to merge Window Closing KeyEvents and MouseClicks events)

Loek van den Ouweland - Use Reactive Extensions to merge KeyEvents and MouseClicks to close a window

After reading this post, you’ve learned how to convert MouseClick  and KeyDown events into observable collections. You’ll see how you can even make these collections more convenient by merging them into one stream that tells your window to close with or without saving data.

Before we begin

How would you do this with events? Easy. Create a KeyDown event and ButtonClick events.

  • VirtualKey.Enter -> Close(true)
  • VirtualKey.Escape -> Close(false)
  • ButtonOK.Click -> Close(true)
  • ButtonCancel.Click -> Close(false)



I thought this a cool example of how Reactive Extensions is shown to be useful and usable by mere mortals. As they say in RX land, "Life is but a stream [of data]"

Wednesday, July 30, 2014

Using the OpenXML SDK Productivity Tool to "decompile" Office documents (Turn *X files into the C# OpenXML SDK code that would generate them)

Ode To Code - Easily Generate Microsoft Office Files From C#


These days, Office files are no longer in a proprietary binary format, and are we can create the files directly without using COM automation. A .docx Word file, for example, is a collection of XML documents zipped into a single file. The official name of the format is Open XML.

There is an SDK to help with reading and writing OpenXML, and a Productivity Tool that can generate C# code for a given file. All you need to do is load a document, presentation, or workbook into the tool and press the “Reflect Code” button.


The downside to this tool is that even a simple document will generate 4,000 lines of code. Another downside is that the generated code assumes it will write directly to the file system, however it is easy to pass in an abstract Stream object instead.

So while this code isn’t perfect, the code does produce valid document and..."

I've been blogging about the OpenXML SDK for years now, but I think this is the first time I've seen this part of it, this utility. And like he says, 4K LoC is like, well, allot, it does look like an awesome way to learn the low level OpenXML SDK ins and outs.


Related Past Post XRef:
Open Sesame - Open XML SDK is now open source

Using OpenXML to load an Excel Worksheet into a DataTable (or just how different OpenXML is from the old Excel API we're used too)

Using OpenXML SDK to generate Word documents via templates (and without Word being installed)
Checking for Microsoft Word DocX/DocM Revisions/Track Changes without using Word... (via OpenXML SDK, LINQ to XML or XML DOM)
LINQ to XlsX... Using VB.Net, LINQ, the OpenXML SDK and a little C# helper, to query an Excel XlsX
Using native OpenXML to create an XlsX (Which provides an example of why I highlight tools that make OpenXML easier...)
Generating Xlsx's on the Server? You're using OpenXML, right? With help from the PowerTools for OpenXML?

Official boat-load, as in supertanker, sized OpenXML content list (Insert "One OpenXML content list to rule them all" here)
So how do I get from here to OpenXML? Got a map for you, an Open XML SDK Blog Map…
Where to go to scratch your OpenXML dev info itch…
"Open XML Explained" Free eBook (PDF)
The Noob's Guide to Open XML Dev (If you know how to spell OpenXML but that's about it, this is your Getting Started guide...)

Reusing the PowerShell PowerTools for Open XML in your C# or VB.Net world
PowerShell, OpenXML, WMI and the PowerTools for OpenXML = Doc generation for our inner geek
Because it’s a PowerShell kind of day… PowerTools for Open XML V1.1 Released
OpenXML PowerTools updated – Cell your Excel via PowerShell
Powering into OpenXML with PowerShell

Open XML SDK 2.0 for Microsoft Office Released – Automate Office documents without Office

Open XML 2.0 Code Snippets for VS2010 (and VS2008 too)
Open XML Format SDK 2.0 Code Snippets for Visual Studio 2008 – 52 C#/VB Code Snippets to help ease your Open XML coding
Open XML File Format Code Snippets for Visual Studio 2005 (Office 2007 NOT required)

Open XML SDK v1 Released

OpenXML Viewer 1.0 Released – Open source DocX to HTML conversion, with IE, Firefox and Opera (and/or command line) support

Tuesday, June 03, 2014

Not your usual Succinctly book... "Neural Networks using C# Succinctly" (reg-ware)

James D. McCaffrey - Neural Networks using C# Succinctly

I wrote a new book titled “Neural Networks using C# Succinctly”. It was published this week. There are many existing books on neural networks but no good ones (in my opinion) that focus on how to create neural networks from a software developer’s point of view. My book is free and you can download a PDF version from here:


I’ve written books before but for “Neural Networks using C# Succinctly” the process was a bit different. I was sitting at my desk one day when I got an unsolicited phone call. Normally I never answer such calls but on this particular day, I did. The call was a young woman named Hilary Bowling who worked for a company called Syncfusion. Hilary asked me if I’d be interested in writing a book about neural networks.

Hilary told me that Syncfusion published relatively short (roughly 100 page) e-books and made them available for free. I was skeptical — I figured there’d have to be a catch of some sort. But in fact, Syncfusion does publish free e-books for software developers. The only minor catch is that you have to register and end up on Syncfusion’s mailing list, but Syncfusion doesn’t take advantage of this (I signed up to see what would happen).

Anyway, it took me a few months to write “Neural Networks using C# Succinctly” (writing a book is much more time-consuming than you might expect) and now it’s available from the Syncfusion Web site...

Syncfusion - Neural Networks using C# Succinctly


Neural networks are an exciting field of software development used to calculate outputs from input data. While the idea seems simple enough, the implications of such networks are staggering—think optical character recognition, speech recognition, and regression analysis. With Neural Networks Using C# Succinctly by James McCaffrey, you'll learn how to create your own neural network to solve classification problems, or problems where the outcomes can only be one of several values. Learn about encoding and normalizing data, activation functions and how to choose the right one, and ultimately how to train a neural network to find weights and bias values that provide accurate predictions.

Table of Contents

  1. Neural Networks
  2. Perceptrons
  3. Feed-Forward
  4. Back-Propagation
  5. Training

How can you go wrong with 128 free('ish) pages on C# Neural Networks!



Related Past Post XRef:
"Visual Studio 2013 Succinctly" free [reg-ware] now available from... you guessed it, Syncfusion
"Windows Phone 8 Succinctly - The practical approach to Windows Phone 8 development" eBook (Reg-ware)
Succinctly eBook of the Day: "Twitter Bootstrap Succinctly" [Reg-ware]
Need some help up the WPF learning curve? "WPF Succinctly" from Syncfusion is now available (and free :)
TypeScript Succinctly - Free [Name/email-ware] eBook
Getting sharp with F# with the free "F# Succinctly" eBook [reg-ware]
Syncfusion helps shed a little succinct light on LightSwitch with "LightSwitch Succinctly" (Reg-ware)
"JavaScript Succinctly" - Another free (reg-ware) eBook from Syncfusion
Get into sync with HTTP with the new free (reg-ware) Syncfusion Succinctly eBook, "HTTP Succinctly"
Spelunk the technical details of the PDF format with "PDF Succinctly" from Syncfusion (Free/reg-ware PDF/Mobi ebook)
"Git Succinctly" Free/reg-ware PDF/Mobi ebook)
jQuery Succinctly - Free eBook (reg-ware, PDF and/or Mobi)


Visual Studio "14" CTP 1 Now Available

Somasegar’s blog - Visual Studio "14" CTP

Today, we are making available a first community technology preview of the next version of Visual Studio, codenamed Visual Studio “14”.  This early build is focused on enabling feedback and testing from the Visual Studio community.  Visual Studio "14" will most likely be available sometime in 2015, with a more complete preview release and final naming available later this year.  Given that this is a very early build, please install in a test environment with no earlier versions of Visual Studio installed.

You can read about the new features and known issues in this first Visual Studio “14” CTP, and also download today.

Over the last 3 months, we've announced many exciting technologies that will be important parts of Visual Studio "14" - including the "Roslyn" .NET compiler platform, ASP.NET vNext and Apache Cordova tooling.  The Visual Studio "14" CTP 1 includes these tools, as well as many additional improvements across Visual Studio, including an early look at some new C++ 11 support that will be part of Visual Studio "14".

C# and VB with the .NET Compiler Platform ("Roslyn")

In Visual Studio "14", the C# and VB compilers and IDE support are fully built on the .NET Compiler Platform ("Roslyn").  This open-source compiler as a service now sits behind dozens of developer experiences in Visual Studio "14", powering build, IntelliSense, refactoring, CodeLens, debugging and many more features developers use every day.  In most places the experiences are unchanged, but there have also been many small improvements across the entire development experience as part of the new compiler platform.

In the Visual Studio "14" preview C# refactoring support has been completely revamped including two new core refactorings: Inline Temporary Variable and Introduce Explaining Variable. Additionally, refactoring support for Visual Basic has been added for the first time.


Visual Studio "14" also supports APIs that come from NuGet with their own analyzers, squiggling issues in your code as you type and offering you automatic fixes, all powered by the .NET Compiler Platform.

You can read more about the new C# and VB developer experiences on the C# blog and the Visual Basic blog.



You can read more about ASP.NET vNext in the Visual Studio "14" CTP on the .NET Web Development and Tools blog.

C++ 11/14

We've continued to push forward on the standards conformance of the Visual C++ compiler....


You can read more about the C++ improvements in the Visual Studio "14" CTP on the C++ blog.


This early preview of Visual Studio "14" is an opportunity to gather feedback on the next version of Visual Studio and .NET.  For developers picking up the CTP, I encourage you to share your feedback on the Connect website, or through Send-a-Smile in the Visual Studio IDE.

Visual Studio "14" CTP release notes

Visual Studio "14" CTP Version 14.0.21730.1.DP release notes

This article lists the release notes for the Microsoft Visual Studio "14" Community Technology Previews (CTPs).

Visual Studio "14" CTPs are previews for the next major release of Visual Studio. These Visual Studio CTPs are intended to promote continuous feedback between early adopters and the Visual Studio development team. We would love to receive your input on the new product functionality and the improved experiences. Your feedback will help shape the future of Visual Studio, and together we will improve the developer experience.

The following download link will always point you to the latest CTP:
Download the latest Visual Studio "14" CTP package now


  • CTPs are English only.
  • CTPs are unsupported and are intended to be used for testing, trial, and feedback purposes only.
  • CTPs have not been subject to final validation. They are not meant to be run on production workstations or servers, or used to create production code. Installing a CTP on a production server will put the server in an unsupported state.
  • Although these CTPs are intended to be installed side-by-side with earlier versions of Visual Studio, complete compatibility on every CTP is not guaranteed. For this early Visual Studio "14" CTP, we recommend that you install the product in a VM, a VHD, or on a fresh computer, because there are known side-by-side compatibility issues with Visual Studio 2013.

The goal of this CTP is to collect your feedback. To report a bug, please use Connect. You can also share your ideas and suggestions on UserVoice. Your quick thoughts can be shared by using Send-a-Smile through the Visual Studio IDE.

New Features



Known issues


Installing Visual Studio "14" CTP side-by-side with Visual Studio 2013

There are known issues when you install Visual Studio "14" CTP 14.0.21730.1 DP on the same computer as Visual Studio 2013. While we expect that an uninstallation of Visual Studio "14" and then a repair of Visual Studio 2013 should fix these issues, our safest recommendation is to install Visual Studio "14" in a VM, a VHD, a fresh computer, or another non-production test-only computer that does not have Visual Studio 2013 on it. All of these Visual Studio side-by-side issues are expected to be fixed soon.

There is an installation block in this Visual Studio "14" CTP that will prevent installation on a computer where an earlier version of Visual Studio is already installed. To disable the block that will put the computer in an un-recommended state, add the value "BlockerOverride" to the registry:


Note the Known Issues! But Yeah! New VS!  :)

Monday, May 19, 2014

What is 14 sessions, 21 hours and free? The Exam Prep Sessions from TechEd North America 2014...

Speaking of content to catch on the Channel 9 Windows Phone App...

Born to Learn - Now Available On Demand: Exam Prep Sessions from TechEd NA 2014

Whether you attended TechEd North America 2014 or not, all the Exam Prep sessions are available for you to watch anytime, thanks to our friends at Channel 9. Catch them all here.

For ease of reference, here's the list of Exam Prep sessions in the order they were presented during TechEd NA. Enjoy!


14 sessions, 21 hours'ish, all free...


Wednesday, April 16, 2014

Droning on with Tasks, Rx and some TPL

The Brain Dump - Tasks and awaits and Rx! (And Drones!) Oh My!

A few people I work with are tinkering with an off-the-shelf drone in our spare time and so we are writing a C# library to control it.

The way it works is you send UDP commands to the drone and you receive a stream of status & navigation UDP packets from it. So everything is asynchronous by default. You don’t send a command and get back an “I got it!” response. You have to send a command and then monitor the status for a change reflecting your desired state,

For example, to start flying, you must repeatedly send the “take off” packet every few milliseconds until you see the “is flying” flag set in the status packets. Lets see what that would look like.

We want the SendCommand method to be asynchronous and totally decoupled from the UI. So the send process looks like this.



Broken down, each function is simple enough to understand and debug. This simplicity only comes from the power of Rx, the TPL and the async/await functionality. Imagine what the code would look like before when all the timers and .NET events and state would have to be managed directly.

Mostly I just liked his title... :P

Well that and there are some tips in this post that will come in handy, right about, well, now...

Wednesday, April 09, 2014

Roslyn gets Mono - Mono and Roslyn

Last week, Microsoft open sourced Roslyn, the .NET Compiler Platform for C# and VB.

Roslyn is an effort to create a new generation of compilers written in managed code. In addition to the standard batch compiler, it contains a compiler API that can be used by all kinds of tools that want to understand and manipulate C# source code.


Roslyn on Mono

At BUILD, we showed Roslyn running on Mono. If you want to run your own copy of Roslyn today, you need to use both a fresh version of Mono, and apply a handful of patches to Roslyn [2].


Adopting Roslyn: Mono SDK

Our goal is to keep track of Roslyn as it is being developed, and when it is officially released, to bundle Roslyn's compilers with Mono [6].

But in addition, this will provide an up-to-date and compliant Visual Basic.NET compiler to Unix platforms.

Our plans currently are to keep both compilers around, and we will implement the various C# 6.0 features into Mono's C# compiler.


Mono Project and Roslyn

Our goal is to contribute fixes to the Roslyn team to make sure that Roslyn works great on Unix systems, and hopefully to provide bug reports and bug fixes as time goes by.

We are very excited about the release of Roslyn, it is an amazing piece of technology and one of the most sophisticated compiler designs available. A great place to learn great C# idioms and best practices [5], and a great foundation for great tooling for C# and VB.

Thanks to everyone at Microsoft that made this possible, and thanks to everyone on the Roslyn team for starting, contributing and delivering such an ambitious project.


VB.Net on Linux? Awesome. Xamarin really is exciting to watch. I love those guys (and it's not just the free booze from their Build talking either... well.. much... ;)

Monday, March 24, 2014

Image Resizer for Windows Explorer (Right-Click... Resize Picture...)

Windows Enterprise Desktop - Image Resizer: Free, Handy Windows Explorer Shell Extension

For those not already familiar with the terminology, the software tool “Image Resizer for Windows” is what’s called an Explorer Shell Extension (aka ShellEx). When you install it on a Windows PC, it adds to Explorer’s capabilities. Thus, if you can puzzle your way into the screen capture to the left (which I resized using the very tool I’m writing about at the moment), you’ll see that an entry in the right-click Explorer menu called “Resize pictures” has been added to call put this utility to work. Selecting that menu entry produces the Image Resizer window that appears beneath the menu snippet, and shows that you can pick any of a number of default resizings (small, medium, large, or mobile). You can also create you own custom resizings as well (as I typically do for my blog posts, which are limited to 500 pixels in width, maximum).

For anybody who must work with images or screen captures on a regular basis, Image Resizer for Windows is a great add-in for their software toolbox. It’s a CodePlex project so it’s Open Source, free, and safe for general and widespread use. There’s even a server version that’s based on ASP.NET available through And for those whose memories go back far enough, yes indeed, this is a faithful replacement for the old Windows XP PowerToy also named Image Resizer. It’s pretty popular, too: according to the CodePlex home page for the tool, it’s been downloaded over 1.4 million times.


Image Resizer for Windows

Image Resizer for Windows is a utility that lets you resize one or more selected image files directly from Windows Explorer by right-clicking. I created it so that modern Windows users could regain the joy they left behind with Microsoft's Image Resizer Powertoy for Windows XP.
Feedback & Support
If you need help installing or using the tool, use the Discussions tab to ask your question.
If you find a bug or think of a feature, use the Issue Tracker tab to submit your request.


While it's been a couple years since this was updated/released, it's still a great tool for anyone doing "stuff" with images/pictures. Best part is the source is available... :)


Related Past Post XRef:
Easy image resizing for the digital camera happy - Image Resizer Powertoy clone for Vista & Windows 7 (32 & 64 bit)
Image Resizer PowerToy for XP and Vista - Easy Resizing of Images, Pictures, Digital Photos, etc via Windows Explorer

Wednesday, March 05, 2014

"Location Intelligence for Windows Store" the free eBook...

Ricky's Bing Maps Blog - Free eBook: Location Intelligence for Windows Store


I am happy to announce the release of my  book “Location Intelligence for Windows Store Apps”. This is available as a free eBook. Yes I said “free”, as in “Free beer”.

Location Intelligence has been one of the fastest growing industries in recent years and continues to grow at an exponential rate. Seventy to eighty percent of all business data has some sort of geospatial context. Many companies want to make use of this data however most of them do not know where to start. Many of these same companies are planning to create Windows Store apps.

In this book we will dive into the world of location intelligence and the different options for creating location aware applications in Windows 8.1. The first half of the book focuses on the inner workings of Window Store Apps and the various location related tools available such as sensors and the Bing Maps SDK. The second half of the book focuses on creating several useful location intelligent apps. All code samples are provided in JavaScript, C# and Visual Basic.

Table of Contents

  • Chapter 1: Getting Started
  • Chapter 2: The Sensor and Location Platform
  • Chapter 3: Bing Maps JavaScript API
  • Chapter 4: Bing Maps Native API
  • Chapter 5: Bing Maps REST Services
  • Chapter 6: Bing Spatial Data Services
  • Chapter 7: Working with Spatial Data
  • Chapter 8: Drawing on the Map
  • Chapter 9: Creating an Augmented Reality App
  • Chapter 10: Creating a Templatable Compass Control
  • Chapter 11: Cross Platform Development

... [Click through for the download links]

At 421 pages this is not your slim eBook... :)


From the PDF;

Location Intelligence has been one of the fastest growing industries in recent years and continues to grow at an exponential rate. Seventy to eighty percent of all business data has some sort of geospatial context. Many companies want to make use of this data however most of them do not know where to start. Many of these same companies are planning to create applications targeting Windows 8. You may well be reading this book for this very reason.

With Windows 8 you have the ability to create applications that reach across many platforms such as desktops, laptops and tablet devices. A Windows Store app is a new type of application that runs on Windows 8 devices. Unlike traditional desktop apps, a Windows Store app has a single, chrome-less window that fills the entire screen by default, so there are no distractions. In addition to this, these apps can support different layouts and views to create a fluid experience across different screen sizes and orientations. Several different types of input sources are supported, including touch, pen, mouse, and keyboard input. It’s also possible for apps to communicate with each other by sharing content in a standard way. Instead of icons, Window Store apps uses live tiles which can be used to display useful, at-a-glance data to the user, without the need for the user to open up the app. Windows Store apps can be written in several different languages including JavaScript, C#, Visual Basic, C++ and C. Apps are distributed through the Windows Store in Windows 8 and gives you the ability to make your app available to millions of people around the world.

In this book we will dive into the world of location intelligence and the different options for creating location aware applications in Windows 8. The first half of the book focuses on learning what tools are available for creating location aware Window Store applications. The second half of the book uses a more hands on approach by demonstrating how to develop complete end-to-end location aware solutions.

Who this book is for?
This book is aimed at developers who are being introduced to creating location based Windows Store apps using both Web (HTML, CSS3, JavaScript) and Managed (C#, Visual Basic) programming languages. Previous knowledge on creating location based application is not required or needed and all topics are explained from the ground up. This will including the use of Bing Maps and sensors such as the accelerometer, compass, gyro, and location services. It will be assumed that you have a working knowledge of one of these programming languages; JavaScript, C# or Visual Basic. Experience creating Windows Store applications will help but is not required.

Chapter Overview
In the first half of this book each chapter builds on top of the previous such that by the time you reach the end chapter 7 you will have gained a good working knowledge on how to use all the tools available for creating location aware Windows Store app. The chapters in the second half of the book are independent of each other. Each of these chapters show how to create a complete end to end application. If you wish to skip between these chapters, you can do so without missing out on any content that might be required


A Windows 8.1 C# Code Snip Sheet, Vol 1...

msplebanon - "W8.1 C# Cheat Sheet Vol.1" by Moalla Ilani

After a long experience with new developer students, I have seen some are thirsty for very basic codes to startup their first apps. Some spend hours on search engines to find the codes they need from open source websites, and from professional point of view, being familiar with search engines is a great talent to have, while other fresh students are still not familiar and may give up from first time.

So cheers this is a safe place to start, this cheat sheet is full of very basic and useful C# windows 8 codes that will help you run your first apps, and you will always stay in need for it whatever professional you are. Of course I may miss some codes you may be waiting for, please feel free to tell me about in order to add them. So before beginning, I recommend everyone to save this cheat sheet on their desktop, in a notepad.txt file, and continue on adding some useful codes to it for future daily use, so that you save time and be more productive.


Nice little collection of Windows 8.1 code snips...

Today's Shiny... C# Pad, web based C# REPL environment

Sunny Ahuwanya's Blog - Introducing C# Pad

I’m excited to present C# Pad, an interactive web based C# REPL.

Have you ever wanted to quickly evaluate an expression or test some code, like say try out different DateTime string formats or test a method or clear up some confusion (like what’s the difference between Uri.EscapeDataString and Uri.EscapeUriString or what new Random().Next(0) returns), or decode some string in Base64 or some other format?

C# Pad lets you easily do all those things and a whole lot more.

Interactive REPL

Do you see the embedded code pad below? Go ahead and hit the Go button.


That’s because C# Pad is a REPL. Objects in previous submissions are visible and accessible from the current one.
( Did you also notice the cool code completion? :) )

You don’t need to call Console.WriteLine to display results. Simply type the variable name (without a semicolon) in the last line of a code submission and the string representation of the variable’s value will be displayed. 
For example, type greeting in the same code pad and hit Go to see its value.


You can use C# Pad to write complex code, define classes and methods and evaluate all kinds of expressions ranging from simple mathematical expressions like 60 * 60 * 24 or Math.Sin((30 * Math.PI)/ 180) to LINQ expressions.


C# Everywhere

You can embed interactive code pads in your blog, website or any site you can edit, just like I have in this blog post. You can even select a theme that matches your site.
Yes, this means you can now create a C# playground anywhere. Simply visit, compose the code you’d like to embed, click the embed button and follow the instructions. 


You can also load and save Github Gists.
To load a Gist, open or simply

As examples, the links below open up Gists in C# Pad. ( Did you know The Octocat codes in C#? )


Numerical Analysis

The awesome Math.Net Numerics library is bundled with C# Pad, which makes working on complex math and statistics problems a breeze.


C# Pad is the first and only (as of this writing) web based interactive C# REPL, with code completion, diagnostics, themes, embeddability, timing information, Gist support and more features to come.

I hope you find C# Pad useful and delightful. Drop me a line or use the help link on the site to provide feedback on feature suggestions, bug reports and other kinds of feedback


C# Pad





Now that's pretty damn cool... Editing code is a little bit of a pain, as code seems to be highlighted often (so keying replaces the highlighted block), and tab doesn't selected the intellisense like hints, but this is still some awesome coding... :)

Friday, February 28, 2014

Dan's @ it again with @XamarinAppDev and - Announcing and @XamarinAppDev

Some of you may have noticed that I silently launched a new link blog and Twitter account on Monday. Today I'm formally announcing both: Say hello to and @XamarinAppDev!


I've been working on a very large native cross platform application for a client that runs on iOS, Android, Windows Phone, and Windows Store, leveraging the Xamarin tools. A natural extension of that process has been searching for news and content about what is going on in the Xamarin developer community.

So following in the footsteps of and @WindowsAppDev, my hope is that the new site and and Twitter feed will be a valuable resource for the Xamarin community.


So you've heard my total and complete Build WAG (Wild Ass Guess) is? That on Day One they announce MS's is buying Xamarin. We'll see... (okay, maybe it will be Day Two... or not at all... lol)

Wednesday, February 26, 2014

? for C#? (aka C# might be getting a object hierarchy Safe Navigation Operator)

Jerry Nixon @ Work - At last, C# is getting “?.”, sometimes called the Safe Navigation Operator

Visual Studio (and many other Microsoft Products) uses as a feedback mechanism for users to suggest and vote on product features. One of the most popular features, with 3,752 votes, a new “?.” operator for the C# language, sometimes called the Safe Navigation Operator.

The news

Rejoice. Yesterday, Tuesday, February 25, 2014, on the Visual Studio User Voice, Mads Torgersen, the C# Language PM, responded on behalf of the Visual Studio Project Team. He said, “We are seriously considering this feature for C# and VB, and will be prototyping it in the coming months.” ...


What is it? Here’s the scenario

Consider getting the grandchild of a parent object like this:

var g1 = parent.child.child.child;

Okay, so, this is some poor coding because the value of child could be null....


How the new operator works

Consider getting the grandchild of a parent object like this:

var g1 = parent?.child?.child?.child;
if (g1 != null) // TODO

Wow! ...



Mad’s Visual Studio User Voice comment continued with a little more explanation of the operator’s implementation. He said, “If the type of e.x (etc) is a non-nullable value type S, then the type of e?.x is S?. Otherwise the type of e?.x is the same as that of e.×. If we can’t tell whether the type is a non-nullable value type (because it is a type parameter without sufficient constraints) we’ll probably give a compile-time error.” This comment, and the idea that a method call or indexer can be to the right of the operator are just candy.


This operator would be pretty awesome and safe me a great deal of code... Wonder if we'll hear more about this at Build? Here's to hoping...

Friday, February 21, 2014

Need a little help cleaning up your code? CodeMaid will help with that developer dirty work... - CodeMaid extension for visual studio

Till now I’m a resharper fan boy and I still love using it. It is a great productivity tool. But it is not free for commercial use. So lots of my friends tell we want something open source or free which provide some kind of productivity over normal visual studio things and recently I came across CodeMaid extension of visual studio. It is a great plugin.

What is CodeMaid?

CodeMaid is an open source Visual Studio extension to cleanup, dig through and simplify our C#, C++, F#, VB, XAML, XML, ASP, HTML, CSS, LESS, JavaScript and TypeScript coding.


An open source visual studio extension to cleanup, dig through and simplify our C#, C++, F#, VB, XAML, XML, ASP, HTML, CSS, LESS, JavaScript and TypeScript coding


Code Digging
Visualize and navigate through the contents of your C# and C++ files from a tree view hierarchy. Quickly switch between different sorting methods to get a better overview. Drag and drop to reorganize the code. See McCabe complexity scores and informative tooltips.

Reorganize the layout of members in a C# file to follow Microsoft’s StyleCop convention, or your own preferences.

Recursively collapse nodes or the entire tree in the solution explorer window.

Enable, modify or disable many of the aspects of how CodeMaid does its work.

Format comments to wrap at a specified column and arrange XML major and minor tags on separate lines.

View the overall progress of a build within Visual Studio, or in the Windows taskbar, both with a green/red status indication.

Switch between related files, such as cpp and header files or xaml and code-behind.

Join two adjacent lines, or a highlighted section of code onto a single line.

Find the current file in the solution explorer window.

and More!
Toggle read-only state, close read-only files, etc.

Download (Visual Studio Gallery) Go Straight to the Source

I dig the number of languages supported (and that it's OSS :) This is SO likely to see a Coding4Fun blog post in the near future... :)

Thursday, February 20, 2014

"Biggy: SQLite for Documents and .NET"

wekeroad - Hello Biggy


A File-based Document Store for .NET

I've been using NeDB (a file-based document store for Node) for a few projects and I utterly love it. Such a simple idea, so fast, so elegant and many times just what I need! I had assumed that such a thing must be around for .NET because there are about 100 different kinds of lists in C#... someone must have made one with a persistent backing store!

But I looked around and couldn't find it, so I made it (as I'll need this in the coming months).

The idea is basically this: I want to use LINQ, I like Dynamics, and I like speed. So that's it, and here's Biggy:


Reading and Writing

So, by now you should be wondering why this is useful. The simple answer is that if you have a high-read application (like a blog, CMS, etc) then something like Biggy could speed things up.

Whenever you instantiate a new BiggyList it tries to read it's data from disk - this is good, and it's bad. It's good because from that point on whenever you try to query your data (using LINQ) it's an in-memory operation and you can't get much faster than that.

It's bad because this means you probably want to have a single DB instance around for the life of your app. This might be easy for some, might be repulsive to others. I'm used to doing this kind of thing with Node (all modules in Node are cached which means you always hit the same module instance).

For a blog engine, this might be a very fun thing to have - no database installs, superfast, easy to use. For a Twitter clone... not so much.


robconery / biggy

Biggy: SQLite for Documents and .NET

This is just a goofy idea at this point, inspired by NeDB which is basically the same thing, but with Node.

I like the idea of SQLite (a file-based relational data-store), but wouldn't it be fun to have this kind of thing for a Document database too? One nice thing about C# (among many) is the built-in LINQ stuff, another nice thing is that C# has Dynamics now too. Biggy is simply an implementation of ICollection with a JSON backing store. I added a few helpy things in there (like events and a few other things) and this might be completely dumb but I like the idea.


What It's Good For

The only disk activity occurs when you call "Save()" and when you instantiate the List itself - everything else happens in memory. This makes Biggy incredibly fast but it also means we're doing file management - which can be tricky.

This is one place that I hope I can get a PR for - I'm dropping the entire contents to disk on every save and YES if you try this will millions of records it will probably cause you some problems. But with 100 or so, it shouldn't be that big of a problem.

That makes Biggy compelling for high-read situations, such as a blog, product catalog, etc. At least that's what I've used NeDB for and it works great.


In the Tasks project (a Console app) there are simple loops that write 1000 records to disk at once (in a batch) as well as a simple read. You can see the results for yourself... they are OK.

Writing 1000 records in a batch takes about 30ms (give or take), writing in a loop takes about 4 seconds (!), but reading records out is too small to record :):):).

There's a lot to do to make this a bit more functional, but for now it does what I envisioned.

Wanna Help?


Now that's an interesting project to play with... hum... and it looks like of fun too. [i.e. queued for a future Coding4Fun blog post ;]

Tuesday, February 18, 2014

101 [+ 7] C# LINQ samples, one project...

Visual Studio Gallery - MSDN 108 C# LINQ Samples Consolidated with Single Project


All MSDN LINQ 101 Samples and few more samples consolidated to Single project and given required comments for each topic...


Targeted Audience:

1. .NET Architects

2. .NET Application Designers

3. .NET Application Developers


1. .Net technologies.

2. Basic understanding of design patterns.

3. Basic understanding of OOPS.


All MSDN LINQ 101 Samples and few more samples consolidated to Single project and given required comments for each topic.

1. Open Solution.

2. Right click on the project and select Manage NuGet.

3. Select missing packages and Add

4. Run the application

Topics Covered:

1. Restriction Operators

2. Projection Operators

3. Partitioning Operators

4. Ordering Operators

5. Grouping Operators

6. Set Operators

7. Conversion Operators

8. Element Operators

9. Generation Operators

10. Quantifiers

11. Aggregate Operators

12. Custom Sequence  Operators

13. Query Execution  Operators

14. Join  Operators

15. Miscellaneous Operators

Sometimes it's just easier to have it local. And if you're using a cool code indexer like Sando (and) then finding that right snip is even easier...

BTW, here's the original/source, 101 LINQ Samples.


Related Past Post XRef:
An oldie but a goodie, 101 LINQ Samples (C# and VB)

Monday, February 17, 2014

Bing your IDE to this new C# Code Search VS Extension (from Bing)

The Visual Studio Blog - Introducing Bing Code Search for C#

Imagine wanting to read a file line by line, and process those lines. Today, we’d most likely load up a web browser, visit our favorite search engine, and start crafting a well-designed set of keywords that helps the search engine understand the problem we’re trying to solve.

In the ideal case, we’d find high quality official documentation with examples, or a highly voted-on topic from one of the major forums or crowd sourced Q&A web sites. We would then scan through the options, try to figure out what’s relevant to us and do some copy/paste magic.

We wanted this to be become more accessible and make finding relevant code samples for the given tasks you’re trying to complete far easier.

Making it better

We wanted to make that experience better for you. To that end, Visual Studio, Bing and Microsoft Research have teamed up to deliver a DevLabs experience that takes code search to the next level.

When you find yourself looking for a code-sample that you could leverage for a task, you can trigger the new Bing Code Search experience directly from IntelliSense.


Behind the scenes, that query is securely beamed up to Bing along with contextual pieces that help us hone in on the fuller meaning of that query. We use meta-data like the project type, semantic context (using the new C#/VB compiler services aka ‘Roslyn’!), and a few other sprinkles of Microsoft Research magic.

Those pieces along with the query then leverage Bing’s enormous search index and keyword analysis to track down potential pages that might contain high quality examples you can learn from.

From those pages, we isolate and rank the relevant code samples, using a large number of syntactic and semantic code metrics.


Visual Studio Gallery - Bing Code Search for C#

...[Try it out Online ]

The Bing Code Search add-in for Visual Studio 2013 makes it easier for .NET developers to search for and reuse code samples from across the coding community, including MSDN, StackOverflow, Dotnetperls and CSharp411.

Bing Code Search improves developer productivity and speed by bringing the experience of searching for reusable C# code into Visual Studio IDE.

Check out this demo video for more info

Got to love the DevLabs and some of the stuff they throw over the wall to us. Now I'm not going to comment on "Google Bing Coding" as without that my day would be much less productive! But I do wonder if there's a lack of context in using this? So many answers provide more than just code...

Thursday, February 13, 2014

Stateless Designer Visual Studio Extension (with Source)

Visual Studio Gallery - Stateless Designer

Visual Studio extension to support visual design of stateless state machines. Support for Visual Studio 2012 and Visual Studio 2013. The goal for this projects is to allow software developers to design a state machines visually.

Project site



CodePlex - Stateless Designer


About stateless

stateless is a lightweight C# hierarchical state machine framework made by Nicholas Blumhardt. The stateless project is hosted here: If you don't know stateless, here is a comparison between stateless and Windows Workflow Foundation: Comparison between Stateless (on google code) and Windows Workflow. stateless also comes as a NuGet package: stateless is a great alternative to WWF.

About Stateless Designer

The goal for this projects is to allow software developers to design a state machines visually. Why a statemachine can improve your design. The true power of using a state machine is to have a graph showing the states with transitions. Stateless Designer can help you achieve this.

Stateless Developer use case:
- install Stateless Designer
- start Visual Studio
- create or open a C# project
- Add new Item to the C# project
- select Stateless State Machine
- design your state machine
- a C# class is created with your state machine

Getting started using Stateless Designer step-by-step.

Currently supported features

- Triggers without arguments
- OnEntry and OnExit delegates
- Reentrant transitions
- OnUnhandledTrigger delegate - new in Stateless Designer 1.4
- Guard Clauses: PermitIf and PermitReentryIf functionality - new in Stateless Designer 1.4

External articles

Twitter article 1168 - Note: Not in English article 1169 - Note: Not in English

Technology used

- Visual Studio Extensibility
- stateless

Sure Windows Workflow now support State Diagrams, but this is something a little different and I think pretty cool (and WWF just doesn't seem to be getting much press, attention, I wonder...). Anyway, not only do you get the designer, but it's nuget'able and you get the source too it all too. Now that's cool... :)

Thursday, January 30, 2014

Going APE for The Asset Pipeline Editor (think an XNA Content Pipeline for the 10's)

The Asset Pipeline Editor


What Is THE APE?

The APE stands for "The Asset Pipeline Editor" created by Pedro Güida -a former MSFT XNA/DX MVP.

(i) Some of its key features:

  • It is a highly-customizable tool,
  • It eases the task of managing game content throughout the whole development process,
  • It helps you build asset files and processes for the platforms you desire, tailoring them for each platform,
  • It is a perfect choice not only for solo devs but also for teams, and
  • Its GUI is independent from any programming IDE!!!

ii) Build your own import process, the one you dream of, with C# ...

Are you programming your games with C++, Objective-C, C#, Java, Phyton ... <pick your language here> ... and you need a content pipeline? Not using authorware like Unity3D, UDK, CryEngine or others? Have your own game engine? Then the APE will help you (and your team) manage your game assets with ease!

Use the well-known developer-friendly C# language to implement the software elements that will drive the behavior of the APE for your game-dev process.

Why Does APE Exist?

Good question.

(i) The answers ...

  • Microsoft decided not to continue developing the XNA Framework any further,
  • Many alternatives do not come bundled with a handy content pipeline tool,
  • XNA's CP only runs on Windows machines since it uses the MSBuild API,
  • XNA's CP GUI has not been updated to work with the latest versions of the Visual Studio IDE,
  • Can you use the XNA's CP from within VS 2012 or VS 2013? Nope ...,
  • Why non-programmers should use any programming IDE as a CP in the first place?
  • XNA's CP only produces binaries targeting Microsoft's platforms.

(ii) Think of the APE as a replacement of XNA's content pipeline "in spirit" since ...

  • ... it does not strictly work the same way as XNA's CP did, ...
  • ... it does not come bundled with content importers for your game assets, ...
  • ... but it could have some importers if the extended goals are reached (wink!).




While I don't usually highlight projects that in the process of crowd funding, I'm also pretty grumpy with what happen (or didn't) to XNA. So I wanted to make sure and shout-out to this project  from Pedro Güida. Make sure you check out the videos, screenshots and such.

Also of note is that this project has been mentioned by 3D Artist magazine AND Telerik is now sponsoring the campaign with a free license of its WPF controls. It just needs a little backing... :)

Tuesday, January 28, 2014

Blast from the Past - 'The XML Diff and Patch GUI Tool'

I needed to diff some OPML files today and came across this project. Even through it's 10 years old, it still mostly worked and the best part is it's a source distrib... :)

The XML Diff and Patch GUI Tool

Amol Kher
Microsoft Corporation

July 2004

Applies to:
   the XML Diff and Patch GUI tool

Summary: This article shows how to use the XmlDiff class to compare two XML files and show these differences as an HTML document in a .NET Framework 1.1 application. The article also shows how to build a WinForms application for comparing XML files.


An Overview of the XML Diff and Patch API
XML Diff and Patch Meets Winforms
Working with XML DiffGrams
Other Features of the XML Diff and Patch Tool


There is no good command line tool that can be used to compare two XML files and view the differences. There is an online tool called XML Diff and Patch that's available on the GotDotNet website under the XML Tools section. For those who have not, you can find it at Microsoft XML Diff and Patch 1.0 [GD: yes, this link is busted... you can download it below]. It is a very convenient tool for those who want to compare the difference between two XML files. Comparing XML files is different from comparing regular text files because one wants to compare logical differences in the XML nodes not just differences in text. For example one may want to compare XML documents and ignore white space between elements, comments or processing instructions. The XML Diff and Patch tool allows one to perform such comparisons but it is primarily available as an online web application. We cannot take this tool and use it from command line.

This article focuses on developing a command-line tool by reusing code from the XML Diff and Patch installation and samples. The tool works very similar to the WinDiff utility; it presents the differences in a separate window and highlights them.

The XML Diff and Patch tool contains a library that contains an XmlDiff class, which can be used to compare two XML documents. The Compare method on this class takes two files and either returns true, if the files are equal, or generates an output file called an XML diffgram containing a list of differences between the files. The XmlDiff class can be supplied an options class XmlDiffOptions that can be used to set the various options for comparing files.



Microsoft Downloads - XML Diff & Patch GUI Tool

Winforms application that can be used to compare 2 XML files.

Version: 1.0

Date Published: 7/14/2004

xmldiffgui.msi, 278 KB

This code sample shows how to build a Windows forms application that utilizes the XML Diff & Patch library to show the difference between 2 XML files.

There's a bug somewhere in it in that it was giving me an error when trying to load the HTML into an IE window, but that's likely a path thing. In the end, it executed and diff'd the two XML files. And since we do have the source... :)


Another blast from the past is that this was available on the old GotDotNet site. I miss that site... :(