Visual Studio

How to cook a loop

Posted on by osmirnov Posted in .NET, Visual Studio | Leave a comment

With coming of Linq we rarely write loops. Actually, the most part of data fetching tasks, those earlier was done by loops, today could be simply done by Linq-to-Objects. Nevertheless, the loops are widely used for different scenarios and a developer should try to write a good loop. This post was written for beginners, but I hope that experienced developers will find in it something useful.
Read more

Expression cannot contain lambda expressions

Posted on by osmirnov Posted in .NET, ORMs, Visual Studio | Leave a comment

Try to open any of  Watch / Immediate and Locals windows of Visual Studio in debug mode and to add lambda expressions, and you will see this message. Own reasons exist for it  and they are very detailed in these posts. Unfortunately, the posts also lack information about resolving this problem. While developers are confronted daily with the need to filter collections in debug windows and the support for lambda expressions would greatly simplify their work.
Read more

To repeat or not to repeat yourself?

Posted on by osmirnov Posted in .NET, Patterns, Visual Studio | 1 Comment

What do modern developers if they are forced to write repeated code? Of course, they follow DRY principle and try to write generic code that covers as much as possible cases and can easily be extended to the rest. But sometimes such a change is complex, inefficient, or simply impossible. Here template engines come into play that allow the developer to set the rules and get your service code. I propose to try to take the advantages of both these approaches.
Read more

Code Contracts (Part III): Evolution

Posted on by osmirnov Posted in .NET, Visual Studio | Leave a comment

Code Contracts are continuously evolving. As an evidence, the team has recently released an extension for the Visual Studio editor. It allows you to see a code contract in a tooltip. However, this isn’t exactly a direction of development that developers would like to see. The implementation of the Code Contracts library still isn’t good enough. Many looking at the official forum are afraid to use contracts in production. And there are reasons. Now I’d like to discuss them and to express my wishes regarding development of Code Contracts by Microsoft Research.
Read more

Code Contracts (Part II): In Action

Posted on by osmirnov Posted in .NET, Visual Studio | 3 Comments

While the team PostS#arp worked on 1.5 version (in which one of the most significant improvements was increasing of speed making injections), Microsoft Research team announced a new library for programming by contract named as Code Contracts. The library is based on rewritting of IL code at compile time. If PostS#arp seeks to implementation of the AOP approach, the Code Contracts realize only potential of programming by contract. Do I need to remind you that the library was included in the release of .Net 4.0 framework and is now available in the System.Diagnostics.Contracts namespace?
Read more

Code Contracts (Part I): Beginning

Posted on by osmirnov Posted in .NET, Visual Studio | 2 Comments

An approach Programming by Contract (Design by contract) is known for a long time. But for .Net up to 4.0 version, it was more a style of development than using of special classes or extensions. In these series of posts I’ll share my opinion on programming by contract with using of new features of .Net 4.0 framework – Code Contracts. You can known about the life of developers with and without them, their advantages and disadvantages, and which I’d like to see them in the future.
Read more