
WPF Series -1- Project Setup
Before starting development we first had to set up a new WPF project. The projects target framework is .NET Framework 4.6.2 and we used Microsoft Visual Studio Community 2015 as […]
Audit and Consulting of Information Systems and Business Processes
Before starting development we first had to set up a new WPF project. The projects target framework is .NET Framework 4.6.2 and we used Microsoft Visual Studio Community 2015 as […]
We at d-fens use Microsoft Code Contracts every day. And certainly with every great tool there are some things that might benefit from some improvement – and code contracts are […]
Today I ran into a problem when all of a sudden my code contracts stopped working – as it seemed. In reality I was missing a simple override in the implementation of a class that derived from a base class. But now for a a concrete example. Suppose you have the following scenario: ContractClassForIArbitraryObject this class holds the contract for […]
I recently noticed an — at least for me — unexpected behaviour when working with Code Contracts in interfaces. When you define a contract for an interface (via ContractClassFor) and implement a class from that interface that contract is certainly enforced. However when you define additional requirements on that implementation class these contracts are evaluated BEFORE the interface contracts. Here […]
I recently ran into a problem when trying to use Code Contracts on Auto-Implemented Properties (i.e. Automatic Properties) combined with a C# interface. I started with a normal interface IScriptInvokerImpl where I wanted to define a method for running a PowerShell script and a public property for the PowerShell instance being used: A first implementation So a first implementation of […]
When using Microsoft CodeContracts your Contract.Requires and Contract.Ensures statements will throw a ContractException which you cannot catch (per design). This means that you cannot use the [ExceptedException] attribute to assert them. Furthermore when mocking with Telerik Justock you cannot use Contract.Ensures and Contract.Requires at all in your stubs, as the stub is expected to be a Func in the form […]
If your are not already using CodeContracts I really recommend to start using them now. And if you are already using them, you will have noticed that their exceptions cannot easily be caught. This is due to a design decision from the design team as stated in their Code Contracts User Manual: 7.6 ContractException The ContractException type is not a […]
In this post I would like to present you a way of how to easily perform assertions like error checking and result validation with PowerShell based on an idea of the Microsoft Code Contracts library. We at d-fens spend quite some time writing PowerShell scripts that automate and integrate various backend systems where unforeseen events not only happen but are […]
When writing ODATA controllers for our projects we spend quite some time on writing boilerplate code and input parameter validation. In addition, for our error handling we would like detailed information for internal troubleshooting but not so detailed information sent back to the client (i.e. no stack traces). In order to achieve this without extra work we started looking at […]