jaredpar's WebLog

Code, rants and ramblings of a programmer.

Browse by Tags

Tagged Content List
  • Blog Post: Immutable Collections and Compatibility with Existing Frameworks

    When developing my immutable collections library , I spent a lot of time on usability. After all, if a library is not useful then what’s the point? A big portion of usability is being able to work with existing frameworks and technologies. For .Net and collections that means items like Data binding...
  • Blog Post: Gotcha: Generic overload resolution when called generically

    Both VB and C# have a feature of generic overload resolution that is fairly helpful and yet a source of gotchas. Lets say you have two methods with the same number of arguments. One method has arguments with generic types and the other does not. For Example: class C1 <T> { public void F1( int...
  • Blog Post: Design Guidelines: Provide type inference friendly Create function for generic objects

    Really this guideline is a bit longer but putting it all in a blog title seemed a bit too much.  The full guideline should read: "If a generic class constructor arguments contain types of all generic parameters, provide a static method named Create on a static class of the same class name as...
  • Blog Post: Have an IComparer<T> but need an IComparable<T>?

    Previously we discussed the opposite problem.  This is a lesser but often more frustrating problem because there is no, AFAIK, built in solution for the BCL.  However it's problem that can be solved once and reused with a generic solution. IComparable<T> has all of the methods necessary...
  • Blog Post: Tuples Part 8: Finishing up

    There are only a few missing features from our tuple implementation.  Mainly FxCop compliance, debugging support and test case code.  The actual functional work is complete.  The one issue with FxCop compliance is the chosen names.  Namely using A,B etc.  FxCop, rightly, believes...
  • Blog Post: Tuples Part 6: Comparing

    Part 5 produced equality tests for Tuples. This section will add comparison support through the IComparable<T> interface. Implementing comparable is very similar to adding equality support. Once again there is a generic class available to make all of the comparison decisions for us; Comparer<T>...
  • Blog Post: Tuples Part 5: Equality

    Part 4 left us with a reusable, abstract and inference friendly Tuple class.  The next step is to be able to test for Tuple equality.  For the Tuple implementation, two tuples will be defined as equal if all of their members are equal.  Seems fairly straight forward.  The trick is...
  • Blog Post: C# Lambda Type Inference

    One of the limitations of C# type inference is that you cannot use it to infer the type of a lambda expression. For example, the following code will not compile var f = () => 4; Normally this is not too much of an issue because you can just explicitly declare the type of the lambda expression...
  • Blog Post: Type Inference and IEnumerable

    This is somewhat of a follow up on a previous post I did on the difference between IEnumerable(Of T) and the IEnumerable interfaces. I've seen several people type in the following code and wonder if there was a fundamental bug in the type inference code. Private Sub Form1_Load( ByVal sender As System...
  • Blog Post: Names of Anonymous Type Members

    Recently I was asked how can you get a list of anonymous type member names given a query of anonymous types. The quick answer is that you can use a quick bit of reflection to get back the names. Public Function GetAnonymousTypeMemberNames( Of T)( ByVal anonymousType As T) As List( Of String ) Dim type...
  • Blog Post: IEnumerable and IEnumerable(Of T) 2

    Quick follow up to my earlier post . Fixing this issue in C# is even easier because of the existence of iterators. public static IEnumerable < object > Shim(System.Collections. IEnumerable enumerable) { foreach ( var cur in enumerable) { yield return cur; } }
  • Blog Post: IEnumerable and IEnumerable(Of T)

    IEnumerable(Of T) is a huge step up in the 2.0 framework from the original IEnumerable interface. It provides a typed enumeration which eliminates lots of nasty casts. The best part is that IEnumerable(Of T) is backwards compatible with IEnumerable (it inherits from it). What's frustrating is that IEnumerable...
  • Blog Post: Casting to an Anonymous Type

    This discussion is building upon a previous post on how to acquire an anonymous type ... type . The next question is, how can you cast an arbitrary object into an anonymous type? At a glance this doesn't seem possible as you cannot directly express the type of an anonymous type in code. For instance...
  • Blog Post: Singleton Pattern

    Quite awhile back I posted about how to create a re-usable singleton pattern in .Net. Link is here . A bit of time has passed and I've altered the pattern a bit. The reasons for the change are some new type inference patterns and FxCop cleanliness. The first pattern I introduced had a couple of FxCop...
Page 1 of 1 (14 items)