Skip to content

Commit 8b1f48b

Browse files
committed
copilot-instructions: remove F# initializers section
FSharpLint already has a (dogfood) way of checking if this approach is being respected: the rule FL0084, called FavourNonMutablePropertyInitialization.
1 parent 9e57062 commit 8b1f48b

File tree

1 file changed

+0
-32
lines changed

1 file changed

+0
-32
lines changed

.github/copilot-instructions.md

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,3 @@ type DerivedClass =
2323
[<DefaultValue>]
2424
val mutable otherField : FieldType
2525
```
26-
27-
Always prefer F# class initializers over property assignment! **You absolutely must use F# class initializers instead of property assignment**!
28-
29-
Class declaration:
30-
``` F#
31-
type MyClass (someConstructorParam : string) =
32-
member ReadOnlyProperty = someConstructorParam
33-
34-
member val MutableProperty1 = "" with get, set
35-
member val MutableProperty2 = "" with get, set
36-
```
37-
38-
Wrong:
39-
``` F#
40-
let myClass = MyClass("some value")
41-
myClass.MutableProperty1 <- "new value"
42-
myClass.MutableProperty2 <- "new value"
43-
```
44-
45-
Right:
46-
``` F#
47-
let myClass =
48-
MyClass(
49-
// constructor parameters go first without names
50-
"some value",
51-
// then mutable properties go next with names
52-
MutableProperty1 = "new value",
53-
MutableProperty2 =
54-
// operations must be placed into parentheses
55-
(5 |> string)
56-
)
57-
```

0 commit comments

Comments
 (0)