File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ We prefer the latest F# 9 features over the old syntax
2+
3+ Prefer ` voption ` over ` option `
4+
5+ Prefer ` task ` CE over ` async ` CE
6+
7+ This is how you define a non-default F# class constructor:
8+ ``` fsharp
9+ type DerivedClass =
10+ inherit BaseClass
11+
12+ new (``arguments here``) as ``created object``
13+ =
14+ // create any objects used in the base class constructor
15+ let fieldValue = ""
16+ {
17+ inherit
18+ BaseClass (``arguments here``)
19+ }
20+ then
21+ ``created object``.otherField <- fieldValue
22+
23+ [<DefaultValue>]
24+ val mutable otherField : FieldType
25+ ```
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+ ```
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717- Remove ` Newtonsoft.Json ` NuGet dependency #725 [ @xperiandri ]
1818- Add missing rule checks for FL0079-FL0081 #713 [ @BennieCopeland ]
1919- Modify ` .gitignore ` to the Visual Studio standard one #735 [ @xperiandri ]
20+ - Add basic Copilot instructions and GitHub MCP #726 [ @xperiandri ]
2021
2122## [ 0.24.2] - 2024-02-29
2223
You can’t perform that action at this time.
0 commit comments