Yes, and eventually—as I’ve discussed with Glenn several times—we may implement a Contract class of our own with the single-minded purpose of standardizing argument validation. Observation: Contracts work beautifully and build times are fantastic.

On May 1, 2014, at 8:27 PM, Denis Gladkikh <notifications@github.com<mailto:notifications@github.com>> wrote:


In src/Splunk.Client/Splunk/Client/Contract.cs:

> @@ -0,0 +1,17 @@
> +﻿using System;
> +
> +namespace Splunk.Client
> +{
> +     #if __MonoCS__
> +     public static class Contract


Exactly and this is what I'm trying to say - using Code Contracts for Runtime argument checking is like "use a sledge-hammer to crack nuts". For argument checking you can just write one class with set of static methods like Glenn wrote for Mono (only include 1-3 lines of implementation). At summary it will be 10 lines of code. The same runtime checking, less dependencies and you will get faster build (because Code Contracts I believe still do instrumentation after build). And of course it will work on all platforms.

As I said they are more useful when a) you want to define contracts for interface http://msdn.microsoft.com/en-us/library/dd264808(v=vs.110).aspx (see example at the bottom) or b) when you have very complicated business logic.

This is just a suggestion.

—
Reply to this email directly or view it on GitHub<https://github.com/splunk/splunk-sdk-csharp-pcl/pull/7/files#r12218643>.