diff --git a/CLAP/Validation/ValidateAttribute.cs b/CLAP/Validation/ValidateAttribute.cs index 2507ca0..4a9dc18 100644 --- a/CLAP/Validation/ValidateAttribute.cs +++ b/CLAP/Validation/ValidateAttribute.cs @@ -1,7 +1,6 @@ using System; using System.Data; using System.Linq; -using CLAP; namespace CLAP.Validation { @@ -13,6 +12,7 @@ namespace CLAP.Validation /// For full documentation, see MSDN: /// http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx /// + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)] public sealed class ValidateAttribute : ParametersValidationAttribute { /// diff --git a/Tests/Samples.cs b/Tests/Samples.cs index 3880b6c..7403f6a 100644 --- a/Tests/Samples.cs +++ b/Tests/Samples.cs @@ -740,6 +740,7 @@ public void Foo(string str, int num, bool b, Case c, int[] numbers) public class Sample_42 : BaseSample { public MyType TheType { get; private set; } + public MyType TheType_Global { get; private set; } public int[][] Array { get; private set; } [Verb(IsDefault = true)] @@ -753,6 +754,12 @@ public void Bar(int[][] arr) { Array = arr; } + + [Global] + public void Glob(MyType t) + { + TheType_Global = t; + } } public enum Case diff --git a/Tests/Tests.cs b/Tests/Tests.cs index 931110a..f9f83ab 100644 --- a/Tests/Tests.cs +++ b/Tests/Tests.cs @@ -1494,6 +1494,20 @@ public void ComplexType_JsonDeserialized_MyType() Assert.AreEqual("blah", s.TheType.Name); } + [Test] + public void ComplexType_JsonDeserialized_MyType_AsGlobal() + { + var s = new Sample_42(); + + Parser.Run(new[] + { + "-glob:{ Number: 881, Name: 'balooloo' }", + }, s); + + Assert.AreEqual(881, s.TheType_Global.Number); + Assert.AreEqual("balooloo", s.TheType_Global.Name); + } + [Test] public void ComplexType_JsonDeserialized_MultiArray() {