简体   繁体   中英

F#: the namespace is not defined

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.

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>

在此处输入图片说明

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM