Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Compiler/AbstractIL/ilwrite.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ let canGenMethodDef (tdef: ILTypeDef) cenv (mdef: ILMethodDef) =
| ILMemberAccess.Public -> true
// When emitting a reference assembly, do not emit methods that are private/protected/internal unless they are virtual/abstract or provide an explicit interface implementation.
| ILMemberAccess.Private | ILMemberAccess.Family | ILMemberAccess.Assembly | ILMemberAccess.FamilyOrAssembly
when mdef.IsVirtual || mdef.IsAbstract || mdef.IsNewSlot || mdef.IsFinal -> true
when mdef.IsVirtual || mdef.IsAbstract || mdef.IsNewSlot || mdef.IsFinal || mdef.IsEntryPoint -> true
// When emitting a reference assembly, only generate internal methods if the assembly contains a System.Runtime.CompilerServices.InternalsVisibleToAttribute.
| ILMemberAccess.FamilyOrAssembly | ILMemberAccess.Assembly
when cenv.hasInternalsVisibleToAttrib -> true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -982,4 +982,35 @@ extends [runtime]System.Object
}

} """ ]

[<Test>]
let ``Build .exe with --refonly ensure it produces a main in the ref assembly`` () =
FSharp """module ReferenceAssembly
open System

Console.WriteLine("Hello World!")"""
|> withOptions ["--refonly"]
|> withName "HasMainCheck"
|> asExe
|> compile
|> shouldSucceed
|> verifyIL [
referenceAssemblyAttributeExpectedIL
""".class private abstract auto ansi sealed '<StartupCode$HasMainCheck>'.$ReferenceAssembly
extends [mscorlib]System.Object
{
.method public static void main@() cil managed
{
.entrypoint
// Code size 2 (0x2)
.maxstack 8
IL_0000: ldnull
IL_0001: throw
} // end of method $ReferenceAssembly::main@

} // end of class '<StartupCode$HasMainCheck>'.$ReferenceAssembly
"""
]
|> ignore

// TODO: Add tests for internal functions, types, interfaces, abstract types (with and without IVTs), (private, internal, public) fields, properties (+ different visibility for getters and setters), events.