ReSharper 4.5 Features and Release Date

Here’s short overview of ReSharper 4.5 features and improvements to expect: Better ReSharper performance and less memory usage (this is really important, since Visual Studio 2008 runs as a 32 bit process and is not capable of leveraging more than 3 Gb of RAM). Improved Solution-Wide analysis that allows to identify: Unused code – marking class …

How to use IoC container with nested scopes for application composition?

Well, that’s simple. The idea itself comes from the CAB. Basically you can organize your application (whether it is a desktop client, an automation engine, web UI or something else) in such a manner: This sample desktop application is logically organized into the nested scopes (or contexts or containers). The Application Scope is the top-most. It contains …

Simplified architecture for the xLim 2 solutions

Basically that’s your generic Client-Server application that heavily relies on the Inversion of Control/Dependency Injection (and the inherent pluggability because of that) and uses the composite application approach for the client UIs (supported by the distributed model). Note, that the different types of UIs share the same in this structure. Web UI is just another type of interface, and thus there …

Managing xLim 2 flexibility: IoC Container Inspector

Schema Manager encapsulates three different ideas: Container Inspector Configuration Manager Validation Test Runner These three pieces are logically linked to each other, and because of that there’s the synergy effect. It makes the resulting combination even more efficient and easy to implement. Let’s talk about the container inspector bit for a while. The idea of …

Action Policy

Simple action policy definition in .NET 3.5 is: Action<Action> In old .NET syntax this would look like: public delegate void Action(); public delegate void ActionPolicy(Action action); Basically it is just a delegate that can do something with your action. Simplest example is a policy that would let your calls to retry a couple of times …

.NET Exception Handling Action Policies Application Block

Overview In short, Action Policy is just some reusable decorator that could be easily applied to any given method call or code block to augment the execution. An Exception Handler is just a logical part of an Action Policy that determines which exceptions do we handle and how do we do that. Microsoft Exception Handling Application Block from the Enterprise …

Writing .NET code analysis rules as unit tests

Writing assembly usage rules as unit tests turns out to be unexpectedly simple: [Test] public void Immutable_Types_Should_Be_Immutable() { var decorated = GlobalSetup.Types .Where(t => t.Has<ImmutableAttribute>()); foreach (var type in decorated) { var count = type.GetAllFields().Count(f => !f.IsInitOnly && !f.IsStatic); Assert.AreEqual(0, count, “Type {0} should be immutable”, type); } } This test (based on the functionality …

How to ensure that complex methods are covered with tests

Note: The implementation below is based on NCover, NUnit and CC.NET, but the concept itself does not care about specific tools. We all do unit test coverage to monitor code areas that should be tested. Obviously, not all classes are worth testing. For example, these seem to be reasonable exceptions: Plain old С# classes used just for …

How to improve .NET code by integrating hints for ReSharper

As you already know, ReSharper provides a lot of helpful hints and suggestions for your .NET code. Additionally, it has features, that allow it to help you leverage your own code. You just need to add a couple of annotations. Consider the example below. As you can see, Resharper has detected that one of the …

Const vs. readonly vs. static readonly in C# .NET

Here are the differences between C# .NET const, readonly and static readonly fields. Constants: Static by default Must have compilation-time value (i.e.: you can have “A”+”B” but cannot have method calls) Can be used in attributes Are copied into every assembly that uses them (every assembly gets a local copy of values) Could be declared within functions The compiler performs …