jaredpar's WebLog

Code, rants and ramblings of a programmer.

Browse by Tags

Tagged Content List
  • Blog Post: Immutable isn’t just for parallel code

    For the last 6 months the BCL team has been hard at work shipping an out of band release of immutable collections for .Net. Most recently delivering an efficient implementation of ImmutableArray<T> http://blogs.msdn.com/b/dotnet/archive/2013/06/24/please-welcome-immutablearray.aspx ...
  • Blog Post: Don’t mix await and compound assignment

    The 5.0 release of C# introduced the await keyword which makes it extremely easy to use Task<T> in a non-blocking fashion.  This allows developers to replace either blocking calls to Task.Wait() or complicated combinations of ContinueWith and callbacks with a nice simple, straight forward...
  • Blog Post: DebuggerDisplay attribute best practices

    The DebuggerDisplayAttribute is a powerful way to customize the way values are displayed at debug time.  Instead of getting a simple type name display, interesting fields, properties or even custom strings can be surfaced to the user in useful combinations [ DebuggerDisplay ( "Student: {FirstName...
  • Blog Post: Why the debugging difference between C# and VB.Net return values?

    A feature which seems to be getting more requests recently is support for seeing the return value of a function in the debugger without the need to assign it into a temporary. C++’s had this feature for some time but it’s been lacking in managed debugging scenarios. James Manning recently...
  • Blog Post: Converting System.Func<T1..TN> to FSharpFunc<T,TResult>

    Interop of delegate style types between F# and other .Net languages is a pain point that results from a fundamental difference in how delegates are represented in the F# language.  Typical .Net languages like C# see a delegate as taking 0 to N parameters and potentially returning a value. ...
  • Blog Post: Extension Methods and the Debugger

    One source of confusion I find myself clearing up a lot is the use of evaluating extension methods in the debugger windows.  Users report evaluation as working sometimes but not others for the exact same piece of code.  Such flaky behavior can only be the result of a poorly implemented feature...
  • Blog Post: Do not throw a NullReferenceException when validing “this” in an extension method

    One pattern I’ve started running into is developers explicitly throwing a NullReferenceException when validating the “this” parameter of an extension method. public static void ForEach<T>( this IEnumerable <T> enumerable, Action <T> action) { if ( null == enumerable) { throw...
  • Blog Post: Using lambdas to create generic factories

    One item I find to be limiting in C# is the new generic constraint.   The syntax construct specifies that the type backing a given generic parameter contains a parameter less constructor.   It allows methods to create instances of generic parameters in a type safe manner. public static...
  • Blog Post: Why is LINQ absent from debugger windows (Part 2)?

    Some readers may remember an article I published almost half a year ago about LINQ being absent from the debugger windows.  That post explored the initial design of the feature, it’s limitations and ultimately why it was absent but promised a future article on a slightly different approach. ...
  • Blog Post: Making Equality Testing Simple

    Getting equality correct on a .Net type is a fairly involved process involving adherence to a large set of rules in order to be considered correct.  Including Object.Equals overrides on reference types must return false for null values Object.Equals overrides must return false for incompatible types...
  • Blog Post: Dictionary<TKey,TValue>.TryGetValue and Anonymous Types

    One of the methods I find to be the most useful in .Net is the method Dictionary<TKey,TValue>.TryGetValue .  This method is a nice compromise between performance, explicit return vs. exception, and a being verbal about the chance of failure.  It returns false on failure and uses an out...
  • Blog Post: Flattening class hierarchies when debugging C#

    One piece of feedback I heard in the MVP sessions this week is that debugging deep class hierarchies in C# is painful.  By default C# will only display the fields and properties declared on a given type.  To get to base class members you must expand the base node.  For large hierarchies...
  • Blog Post: Making F# type inference friendly for C#

    One of my current hobby projects, VsVim , requires me to make a lot of calls between F# and C# projects.  The core Vim engine is a pure F# solution based on Visual Studio’s new editor.  It additionally has a small hosting layer and a large test bed both written in C#.  When working with...
  • Blog Post: The File System is unpredictable

    One of the more frequent questions I answer on StackOverflow is a variation of the following.  I’m doing XXX with a file, how can I know if the file exists? The variations include verify no one else has the file open, if the file is in use, the file is not writable, etc ….  The answer to all...
  • Blog Post: Using F# Discriminated Unions in C# (Beta2)

    While updating my VsVim editor extensions for Beta2 [1] I got hit by a change in the way F# exposed discriminated unions in metadata.  My extension consists of a core F# component with a corresponding set of unit tests written in C#.  It’s mostly API level testing and as such I use a lot of...
  • Blog Post: Why is LINQ absent from debugger windows?

    As the owner of the VB.Net portion of the overall debugging experience, I frequently hear the request from customers to add LINQ support into the Watch / Immediate and Locals window. Virtually every other type of expression is available in the debugger windows so why leave one of the most popular ones...
  • Blog Post: Understanding the is, was and will of programming

    When using an API you must take care to understand not only what it returns, but also for how long the data returned will be valid.  This is very important to consider because programs must make either be making decisions on valid and predictable data or have appropriate fallback mechanisms for...
  • Blog Post: Immutable vs. Mutable Collection Performance

    One argument I commonly hear against immutable collections is they are slow.  I’ve held the opposite belief for some time but shamefully had yet to look at actual numbers on the CLR.  Tonight I decided to change that by benchmarking one of my immutable collections against a mutable collection...
  • Blog Post: Is it Serializable?

    I’ve recently run across several APIs that have a dependency on only dealing with objects that are serializable (in the binary sense).  Unfortunately determining if an object is serializable is a non-trivial task and rife with problems.  These problems have a direct impact on the types of guarantees...
  • Blog Post: Building a WeakReference Hashtable

    Recently I ran into a situation on a personal project where I needed a hashtable like structure for a set of WeakReference values.  When poking around for an existing implementation I saw found several versions which were very thin, type safe wrapper around a Dictionary<TKey,WeakReference>...
  • Blog Post: A more usable API for a mutable thread safe collection

    In my last post we discussed the problems with designing a safer API for mutable thread safe collections that employ only an internal locking system. The result was an API that was more difficult to mess up, yet pretty much unusable. Lets take a look at this problem and see if we can come up with a usable...
  • Blog Post: Why are thread safe collections so hard?

    Writing a collection which is mutable, thread safe and usable is an extremely difficult process. At least that’s what you’ve likely been told all through your schooling. But then you get out on the web and see a multitude of thread safe lists, maps and queues. If it’s so hard, why are there so many examples...
  • Blog Post: BclExtras Library

    I published a .Net utility library on Code Gallery today called BclExtras .  It’s a set of classes meant to be used in addition to the standard .Net base class libraries (BCL).  The main focuses of the library are functional programming, multi-threading, LINQ extensions, unit testing and API...
  • Blog Post: If you implement IEquatable<T> you still must override Object’s Equals and GetHashCode

    CLR 2.0 introduced IEquatable<T> which is an interface that allows for type safe equality comparisons.  Previously, the best available method for comparing equality was the virtual Object Equals method.  The method is loosely typed since it takes an object as a parameter.  This is...
  • Blog Post: NotImplementedException vs. NotSupportedException

    In responding to a recent blog post , one of the readers, Jeremy Gray, noted that I was using a NotImplementedException where I should have been using a NotSupportedException .  At first I did not agree.  There was a method on an interface which my underlying object could not implement therefore...
Page 1 of 3 (72 items) 123