6

I have this F# project Rm.Accounting.Domain with the following files (and in that order):

  • Model.fs: module Rm.Accounting.Domain.Model
  • Commands.fs: module Rm.Accounting.Domain.Commands
  • Events.fs: module Rm.Accounting.Domain.Events

and the last one causing problems Behaviour.fs:

module Rm.Accounting.Domain.Behaviour

open Rm.Accounting.Domain.Commands
open Rm.Accounting.Domain.Events
open Rm.Accounting.Infrastructure

let a = 42

Which leads to two errors:

  • Behaviour.fs(3, 20): [FS0039] The namespace 'Domain' is not defined. -> open Rm.Accounting.Domain.Commands
  • Behaviour.fs(4, 20): [FS0039] The namespace 'Domain' is not defined. -> open Rm.Accounting.Domain.Events

Without that file Behaviour.fs the project can compile, I am not sure to understand why those two imports cause some troubles.

7
  • In what order are these files listed in your project? Commented Jun 5, 2019 at 21:28
  • @FyodorSoikin like specified in my post Commented Jun 5, 2019 at 21:30
  • I don't see Behavior.fs in that list. Commented Jun 5, 2019 at 21:35
  • @FyodorSoikin "and the last one causing problems Behaviour.fs:" Commented Jun 5, 2019 at 21:42
  • 1
    How do you know that they're in that order? Commented Jun 5, 2019 at 21:42

1 Answer 1

7

Thanks to the comments, it seems that for some reasons despite reordering files in Rider, the fsproj didn't really get updated right.

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
    </PropertyGroup>

    <ItemGroup>
        <Compile Include="Behaviour.fs" />
        <Compile Include="Model.fs" />
        <Compile Include="Commands.fs" />
        <Compile Include="Events.fs" />
    </ItemGroup>

    <ItemGroup>
      <ProjectReference Include="..\Rm.Accounting.Infrastructure\Rm.Accounting.Infrastructure.fsproj" />
    </ItemGroup>

</Project>

enter image description here

Re-organising the fsproj, did the trick:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>netstandard2.0</TargetFramework>
    </PropertyGroup>

    <ItemGroup>
        <Compile Include="Model.fs" />
        <Compile Include="Commands.fs" />
        <Compile Include="Events.fs" />
        <Compile Include="Behaviour.fs" />
    </ItemGroup>

    <ItemGroup>
      <ProjectReference Include="..\Rm.Accounting.Infrastructure\Rm.Accounting.Infrastructure.fsproj" />
    </ItemGroup>

</Project>
Sign up to request clarification or add additional context in comments.

3 Comments

I've seen this behavior in Visual Studio before (I know you're using Rider, but just FYI).
@JimFoye that's good to know, just in case the same behaviour occurs in VS, I will know where to look for.
I just got this in VS Code as well

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.