Why I dislike DLR
It took me hours last night to work out why I was getting a null result from the Value property in the following code when accessed via IronPython public interface ISomeInterface { decimal Value { get ; } } How could a non nullable type possibly return a null (or “None”)? It turns out that when I set my variable using the .NET scripting API ScriptScope.SetVariable(variableName, (ISomeInterface)value); The scripting engine still works on the implementing object rather than the interface. This means that if my object has a method “DoSomethingThatScriptingShouldNotHaveAccessTo()” then scripting has access to it! In my case this bit me because I had a Nullable<decimal> property called “Value”, and the Value property implemented explicitly for the interface looked like this decimal ISomeInterface.Value { get { if ( this .Value == null ) CalculateValue(); return this .Value; } } In this case I expected the script to access the variable’s “Value” propert