@@ -607,6 +607,104 @@ extends [runtime]System.Object
607607
608608 }""" ]
609609
610+ [<Test>]
611+ let ``Cli events are emitted even for CliEvent members which are not last in a file`` () =
612+ FSharp """
613+ module LibraryWithTwoClassesAndTwoEvents
614+ open System
615+
616+ let event = new DelegateEvent<EventHandler<EventArgs>>()
617+ type MyClass() =
618+ [<CLIEvent>]
619+ member this.EventFromFirstType = event.Publish
620+
621+ let event2 = new DelegateEvent<EventHandler<EventArgs>>()
622+ type MyClass2() =
623+ [<CLIEvent>]
624+ member this.EventFromSecondType = event2.Publish
625+ """
626+ |> withOptions [ " --refonly" ]
627+ |> compile
628+ |> shouldSucceed
629+ |> verifyIL [
630+ referenceAssemblyAttributeExpectedIL
631+ """ .class auto ansi serializable nested public MyClass
632+ extends [runtime]System.Object
633+ {
634+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 )
635+ .method public specialname rtspecialname
636+ instance void .ctor() cil managed
637+ {
638+
639+ .maxstack 8
640+ IL_0000: ldnull
641+ IL_0001: throw
642+ }
643+
644+ .method public hidebysig specialname
645+ instance void add_EventFromFirstType(class [runtime]System.EventHandler`1<class [runtime]System.EventArgs> 'handler') cil managed
646+ {
647+
648+ .maxstack 8
649+ IL_0000: ldnull
650+ IL_0001: throw
651+ }
652+
653+ .method public hidebysig specialname
654+ instance void remove_EventFromFirstType(class [runtime]System.EventHandler`1<class [runtime]System.EventArgs> 'handler') cil managed
655+ {
656+
657+ .maxstack 8
658+ IL_0000: ldnull
659+ IL_0001: throw
660+ }
661+
662+ .event class [runtime]System.EventHandler`1<class [runtime]System.EventArgs> EventFromFirstType
663+ {
664+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CLIEventAttribute::.ctor() = ( 01 00 00 00 )
665+ .addon instance void LibraryWithTwoClassesAndTwoEvents/MyClass::add_EventFromFirstType(class [runtime]System.EventHandler`1<class [runtime]System.EventArgs>)
666+ .removeon instance void LibraryWithTwoClassesAndTwoEvents/MyClass::remove_EventFromFirstType(class [runtime]System.EventHandler`1<class [runtime]System.EventArgs>)
667+ }
668+ }
669+
670+ .class auto ansi serializable nested public MyClass2
671+ extends [runtime]System.Object
672+ {
673+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 )
674+ .method public specialname rtspecialname
675+ instance void .ctor() cil managed
676+ {
677+
678+ .maxstack 8
679+ IL_0000: ldnull
680+ IL_0001: throw
681+ }
682+
683+ .method public hidebysig specialname
684+ instance void add_EventFromSecondType(class [runtime]System.EventHandler`1<class [runtime]System.EventArgs> 'handler') cil managed
685+ {
686+
687+ .maxstack 8
688+ IL_0000: ldnull
689+ IL_0001: throw
690+ }
691+
692+ .method public hidebysig specialname
693+ instance void remove_EventFromSecondType(class [runtime]System.EventHandler`1<class [runtime]System.EventArgs> 'handler') cil managed
694+ {
695+
696+ .maxstack 8
697+ IL_0000: ldnull
698+ IL_0001: throw
699+ }
700+
701+ .event class [runtime]System.EventHandler`1<class [runtime]System.EventArgs> EventFromSecondType
702+ {
703+ .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CLIEventAttribute::.ctor() = ( 01 00 00 00 )
704+ .addon instance void LibraryWithTwoClassesAndTwoEvents/MyClass2::add_EventFromSecondType(class [runtime]System.EventHandler`1<class [runtime]System.EventArgs>)
705+ .removeon instance void LibraryWithTwoClassesAndTwoEvents/MyClass2::remove_EventFromSecondType(class [runtime]System.EventHandler`1<class [runtime]System.EventArgs>)
706+ """ ]
707+
610708 [<Test>]
611709 let ``Properties are emitted for CliMutable records`` () =
612710 FSharp """
0 commit comments