File tree Expand file tree Collapse file tree 5 files changed +25
-1
lines changed
tests/FSharp.Compiler.ComponentTests/EmittedIL Expand file tree Collapse file tree 5 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 6666 .method public hidebysig specialname
6767 instance int32 get_hash() cil managed
6868 {
69+ .custom instance void [runtime]System.Runtime.CompilerServices.IsReadOnlyAttribute::.ctor() = ( 01 00 00 00 )
6970 // Code size 7 (0x7)
7071 .maxstack 8
7172 IL_0000: ldarg.0
Original file line number Diff line number Diff line change 6666 .method public hidebysig specialname
6767 instance int32 get_hash() cil managed
6868 {
69+ .custom instance void [runtime]System.Runtime.CompilerServices.IsReadOnlyAttribute::.ctor() = ( 01 00 00 00 )
6970 // Code size 7 (0x7)
7071 .maxstack 8
7172 IL_0000: ldarg.0
Original file line number Diff line number Diff line change @@ -49,6 +49,16 @@ module ``Struct getters readonly`` =
4949 member _.MyField = myField
5050 """
5151
52+ let structNonRecordVal =
53+ FSharp
54+ """
55+ module TestStructNonRecordVal
56+
57+ [<Struct>]
58+ type MyStruct =
59+ val MyField: int
60+ """
61+
5262 let structWithCustomGetter =
5363 FSharp
5464 """
@@ -93,13 +103,21 @@ module ``Struct getters readonly`` =
93103 |> shouldn't haveAttribute " IsReadOnlyAttribute"
94104
95105 [<Fact>]
96- let ``Struct non - record has readonly getters`` () =
106+ let ``Struct has readonly getters`` () =
97107 structNonRecord
98108 |> compileAssembly
99109 |> getType " TestStructNonRecord+MyStruct"
100110 |> getMethod " get_MyField"
101111 |> should haveAttribute " IsReadOnlyAttribute"
102112
113+ [<Fact>]
114+ let ``Struct val has readonly getter`` () =
115+ structNonRecordVal
116+ |> compileAssembly
117+ |> getType " TestStructNonRecordVal+MyStruct"
118+ |> getMethod " get_MyField"
119+ |> should haveAttribute " IsReadOnlyAttribute"
120+
103121 [<Fact>]
104122 let ``Custom getter on a struct doesn 't have readonly attribute`` () =
105123 structWithCustomGetter
Original file line number Diff line number Diff line change 6565 .method public hidebysig specialname
6666 instance float64 get_F() cil managed
6767 {
68+ .custom instance void [runtime]System.Runtime.CompilerServices.IsReadOnlyAttribute::.ctor() = ( 01 00 00 00 )
6869 // Code size 7 (0x7)
6970 .maxstack 8
7071 IL_0000: ldarg.0
409410 .method public hidebysig specialname
410411 instance float64 get_D() cil managed
411412 {
413+ .custom instance void [runtime]System.Runtime.CompilerServices.IsReadOnlyAttribute::.ctor() = ( 01 00 00 00 )
412414 // Code size 7 (0x7)
413415 .maxstack 8
414416 IL_0000: ldarg.0
Original file line number Diff line number Diff line change 6565 .method public hidebysig specialname
6666 instance float64 get_F() cil managed
6767 {
68+ .custom instance void [runtime]System.Runtime.CompilerServices.IsReadOnlyAttribute::.ctor() = ( 01 00 00 00 )
6869 // Code size 7 (0x7)
6970 .maxstack 8
7071 IL_0000: ldarg.0
376377 .method public hidebysig specialname
377378 instance float64 get_D() cil managed
378379 {
380+ .custom instance void [runtime]System.Runtime.CompilerServices.IsReadOnlyAttribute::.ctor() = ( 01 00 00 00 )
379381 // Code size 7 (0x7)
380382 .maxstack 8
381383 IL_0000: ldarg.0
You can’t perform that action at this time.
0 commit comments