Repository navigation
Emit a warning when referencing console applications exe's without a main #602
Description
Activity
i think is the same problem as fsharp/fsharp#326 , the console project doesn't initialize
hellobecause you dont declare/execute themainfunction.see @latkin 's comment for detailed explaination and workaround
@latkin @dsyme we need to add a warning? with c# you can reference the console app without problem, so is a bit unintuitive/annoying
Yrs, an explicit Main is required, and this is currently considered by design, for better or worse.
Adding a warning on referencing such a component may well be feasible.
What's best?
- warning (error?) if a console app doesnt have a main
- warning if a referenced fsharp assembly (discriminate on .exe extension?) doesn't have a main
#2 - emit an attribute or other bit when no main on .exe, and detect that when the component is referenced
#2 - emit an attribute or other bit when no main on .exe, and detect that when the component is referenced
- changed the title
[-]no initialization of modules in referenced console applications[/-][+]emit a warning when referencing console applications exe's without a main[/+]on Jan 9, 2016 1 remaining item
- addedImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.and removed
on Sep 16, 2021 - changed the title
[-]emit a warning when referencing console applications exe's without a main[/-][+]Emit a warning when referencing console applications exe's without a main[/+]on Nov 4, 2021 - addedArea-Diagnosticsmistakes and possible improvements to diagnosticsmistakes and possible improvements to diagnosticsand removed
on Mar 31, 2022 - moved this from Done to In Progress in F# Compiler and Tooling
on Jan 5, 2024 github-actions commented
on Sep 25, 2026 on Sep 25, 2026 – with GitHub ActionsContributorMore actions🤖 This is an automated response from Repo Assist.
Confirmed this still reproduces at commit
7bcc3aea97ce976a1a6644d9bcceb518acfc5298(2026-09-24), using the compiler produced by the current Release build's Proto stage:Microsoft (R) F# Interactive version 15.2.101.0 for F# 11.0 Language Version: 11.0 FSharp.Core: 11.0.0.0 .NET: .NET 11.0.0-rc.1.26420.103 OS: Linux 6.17.0-1022-azure (X64)I compiled the two-file repro from the issue as separate executables, with the second referencing the first. Both compiler invocations completed with no diagnostics. Running the consumer prints:
SharedValue.hello is null!So the requested diagnostic is still absent: referencing an F# executable with no explicit entry point does not warn that its top-level bindings will remain uninitialized.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
southcentralus0.in.applicationinsights.azure.com
To allow these domains, add them to the
network.allowedlist in your workflow frontmatter:network: allowed: - defaults - "southcentralus0.in.applicationinsights.azure.com"
See Network Configuration for more information.
Generated by 🌈 Repo Assist, see workflow run. Learn more.
Add this agentic workflows to your repo
To install this agentic workflow, run
gh aw add githubnext/agentics/workflows/repo-assist.md@7c7feb61a52b662eb2089aa2945588b7a200d404
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Progress
Create a solution with two Console Application projects:
ConsoleApplication1\Program.fs:
ConsoleApplication2\Program.fs (references ConsoleApplication1)
Expected output:
all goodActual output:
SharedValue.hello is null!needless to say, getting a null value from an F# project is quite surprising.
Changing the type of ConsoleApplication1 to a Library fixes this.