File tree Expand file tree Collapse file tree 3 files changed +64
-0
lines changed
samples/snippets/fsharp/VS_Snippets_CLR/AttrTargs/FS Expand file tree Collapse file tree 3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+ //<Snippet1>
2+ open System
3+
4+ // This attribute is only valid on a class.
5+ [<AttributeUsage( AttributeTargets.Class) >]
6+ type ClassTargetAttribute () =
7+ inherit Attribute()
8+
9+ // This attribute is only valid on a method.
10+ [<AttributeUsage( AttributeTargets.Method) >]
11+ type MethodTargetAttribute () =
12+ inherit Attribute()
13+
14+ // This attribute is only valid on a constructor.
15+ [<AttributeUsage( AttributeTargets.Constructor) >]
16+ type ConstructorTargetAttribute () =
17+ inherit Attribute()
18+
19+ // This attribute is only valid on a field.
20+ [<AttributeUsage( AttributeTargets.Field) >]
21+ type FieldTargetAttribute () =
22+ inherit Attribute()
23+
24+ // This attribute is valid on a class or a method.
25+ [<AttributeUsage( AttributeTargets.Class ||| AttributeTargets.Method) >]
26+ type ClassMethodTargetAttribute () =
27+ inherit Attribute()
28+
29+ // This attribute is valid on a generic type parameter.
30+ [<AttributeUsage( AttributeTargets.GenericParameter) >]
31+ type GenericParameterTargetAttribute () =
32+ inherit Attribute()
33+
34+ // This attribute is valid on any target.
35+ [<AttributeUsage( AttributeTargets.All) >]
36+ type AllTargetsAttribute () =
37+ inherit Attribute()
38+
39+ [<ClassTarget>]
40+ [<ClassMethodTarget>]
41+ [<AllTargets>]
42+ type TestClassAttribute [<ConstructorTarget>] [<AllTargets>] () =
43+ [<FieldTarget>]
44+ [<AllTargets>]
45+ let myInt = 0
46+
47+ [<MethodTarget>]
48+ [<ClassMethodTarget>]
49+ [<AllTargets>]
50+ member _.Method1 () = ()
51+
52+ member _.GenericMethod <[< GenericParameterTarget ; AllTargets >] 'T >( x : 'T ) = ()
53+
54+ //</Snippet1>
Original file line number Diff line number Diff line change 1+ <Project Sdk =" Microsoft.NET.Sdk" >
2+ <PropertyGroup >
3+ <OutputType >Exe</OutputType >
4+ <TargetFramework >net6.0</TargetFramework >
5+ </PropertyGroup >
6+ <ItemGroup >
7+ <Compile Include =" attrtargs.fs" />
8+ </ItemGroup >
9+ </Project >
Original file line number Diff line number Diff line change 7272
7373 :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/AttrTargs/CPP/attrtargs.cpp" id="Snippet1":::
7474 :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/AttrTargs/CS/attrtargs.cs" id="Snippet1":::
75+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/AttrTargs/FS/attrtargs.fs" id="Snippet1":::
7576 :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/AttrTargs/VB/AttrTargs.vb" id="Snippet1":::
7677
7778 ]]> </format >
You can’t perform that action at this time.
0 commit comments