Skip to content

Commit 04aa22b

Browse files
committed
attributes
1 parent 8b8136f commit 04aa22b

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

docs/fsharp/language-reference/attributes.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,82 @@ Although you do not usually need to specify the attribute target explicitly, val
8181
[<``module``: MyCustomAttributeThatWorksOnModules>]
8282
```
8383

84+
</td>
85+
</tr>
86+
<tr>
87+
<td>method</td>
88+
<td>
89+
90+
```fsharp
91+
[<MyCustomAttributeThatWorksOnMethods>]
92+
let someFunction() = 42
93+
```
94+
95+
</td>
96+
</tr>
97+
<tr>
98+
<td>class</td>
99+
<td>
100+
101+
```fsharp
102+
[<MyCustomAttributeThatWorksOnClasses>]
103+
type MyClass(myValue: int) =
104+
member _.MyValue = myValue
105+
```
106+
107+
</td>
108+
</tr>
109+
<tr>
110+
<td>struct</td>
111+
<td>
112+
113+
```fsharp
114+
[<MyCustomAttributeThatWorksOnStructs>]
115+
[<Struct>]
116+
type MyStruct(myValue: int) =
117+
member _.MyValue = myValue
118+
```
119+
120+
</td>
121+
</tr>
122+
<tr>
123+
<td>interface</td>
124+
<td>
125+
126+
```fsharp
127+
[<MyCustomAttributeThatWorksOnInterfaces>]
128+
type MyInterface =
129+
abstract member Prop: string
130+
```
131+
132+
</td>
133+
</tr>
134+
<tr>
135+
<td>enum</td>
136+
<td>
137+
138+
```fsharp
139+
[<MyCustomAttributeThatWorksOnEnums>]
140+
type Color =
141+
| Red = 0
142+
| Green = 1
143+
| Blue = 2
144+
```
145+
146+
</td>
147+
</tr>
148+
<tr>
149+
<td>constructor</td>
150+
<td>
151+
152+
```fsharp
153+
type MyClass(myValue: int) =
154+
member _.MyValue = myValue
155+
156+
[<MyCustomAttributeThatWorksOnCtors>]
157+
new () = MyClass 42
158+
```
159+
84160
</td>
85161
</tr>
86162
<tr>

0 commit comments

Comments
 (0)