It will compile for enums, as in

1
2
3
4
5
6
7
8
9
10
11
#light

type Color = 
    | Red=1 
    | Green=2

type MyAttribute(color:Color) =
    inherit System.Attribute()

[<My(Color.Red)>]
type Yadda() = class end    

It does not work for discriminated unions, as they are objects, and .Net attributes cannot take arbitrary objects (I forget the exact list, but only something like integers/enums, strings, and typeof()s are allowed as values passed to an attribute).

By on 3/10/2009 9:54 AM ()

Perfect! That fixed it.

When I tried changing to an Enum before, I didn't qualify with the type (i.e. in your example it would have been [<My(Red)>]) which gave the same error as before. Fully qualifying the enum resolved it though.

Thanks very much for the speedy response.

Cheers,
Ryan

By on 3/10/2009 10:01 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper