Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve "Main module of program is empty: nothing will happen when it is run"

I have two projects in an F# solution.
1. main project with [EntryPoint] and set as the StarUp project.
2. support, the second project, holds a group of support modules. I.e. they are only called and never initiate anything nor serve as the entry point nor are the StartUp project.

For the last module in the support project, compiling in Visual Studio gives

warning FS0988: Main module of program is empty; nothing will happen when it is run

While using compiler option nowarn inline as #nowarn "988" in the module causing the warning does suppress the message I would rather add something like a dummy function with comments that resolves the issue.

How does one make such a dummy function to resolve the warning?

EDIT

Jack is correct in that my support project was setup as a Console Application instead of a Class Library. Changing to Class Library resolved the warning. It is also nice to know about do () for the other case.

EDIT

While it seemed odd that I would have set a support project as a Console Application, I recently found that for some reason when I made a change to the code in the project, something changed the Output type from Class Library to Console Application. I suspect it has to do with the F# PowerPack and it's build rules, but it's only a guess.

like image 628
Guy Coder Avatar asked Mar 01 '13 13:03

Guy Coder


1 Answers

Are you building the support project as a Library or as a Console Application? (This is set via the project properties page.)

If you're building it as a library, then you may need to add a do() at the end of the last file in the project. This is necessary to make the F# compiler happy in a few specific scenarios, like when you create a module which contains only assembly-level attributes (because they're applied to the assembly, the module appears "empty" to the compiler).

You can see an example in my code here: https://github.com/jack-pappas/FSharp.Compatibility/blob/master/FSharp.Compatibility.OCaml/AssemblyInfo.fs

like image 106
Jack P. Avatar answered Oct 20 '22 03:10

Jack P.