dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.82k stars 773 forks source link

.fsproj **should not** need to specify individual Compile .fs files #17285

Closed alexandrehtrb closed 3 weeks ago

alexandrehtrb commented 3 weeks ago

Is your feature request related to a problem? Please describe.

If you are using Visual Studio, when you add a new .fs file, it is automatically added to the project's .fsproj. However, if you are using other editors like VS Code, it isn't, and without adding to fsproj, it won't get compiled.

This shouldn't exist:

<ItemGroup>
  <Compile Include="Tests.fs" />
  <Compile Include="Program.fs" />
</ItemGroup>

This is a major source of confusion for C# developers that want to learn F#; this isn't required for csproj, why should it be for fsproj? Even if there was an historical reason for this, I believe it should be removed and the compiler should be smart enough to just compile everything under its directory.

Describe the solution you'd like

No need for explicit mentioning .fs files to compile in .fsproj.

Describe alternatives you've considered

Additional context

vzarytovskii commented 3 weeks ago

Hey, @alexandrehtrb.

Currently, this is the design of the compiler and language, requirement even.

There are no current plans to change that, as it will require a major compiler and typechecker architecture change (and will likely be major performance hit).

We might reevaluate it in future.

smoothdeveloper commented 3 weeks ago

Welcome @alexandrehtrb, you may be interested by this article:

https://fsharpforfunandprofit.com/posts/recipe-part3/

and other things that mandate it remains the same, or at least, make it less practical, to envision a world where F# does not have mandatory file ordering; for the time being.

I don't think it is a blocker for people doing C# to learn F#; with this rhetoric, we can create infinity of good reasons not to learn/use F# (goes same for C#, etc.).

Everyone goes over the hump, I also was irked a bit, but it was due to pre conditionning of 1 class per file for so many years.

I live happier with less files, shorter lines, more expressive and correct code, and code having topological and semantical ordering.

You may read on https://github.com/fsharp/fslang-suggestions/issues/309#issuecomment-1290626807 and discuss suggestions to extend F# in relation to what you are bringing.

En3Tho commented 3 weeks ago

@alexandrehtrb Please do not forget that in C# order of files does not matter while in F# it does. So by specifying files in fsproj you're not only including those into compilation, you're also indicating compiler which file ordering is proper/expected.

Martin521 commented 3 weeks ago

If you are using Visual Studio, when you add a new .fs file, it is automatically added to the project's .fsproj. However, if you are using other editors like VS Code, it isn't, and without adding to fsproj, it won't get compiled.

In VS Code / Ionide, you have a context menu in the solution explorer where you can "Add file above" / "Add file below". These commands automatically update the fsproj file.