F#:未定义名称空间

时间:2019-06-05 20:34:45

标签: module compilation f# namespaces

我有这个F#项目Rm.Accounting.Domain 包含以下文件(并按此顺序):

  • Model.fsmodule Rm.Accounting.Domain.Model
  • Commands.fsmodule Rm.Accounting.Domain.Commands
  • Events.fsmodule Rm.Accounting.Domain.Events

最后一个引起问题的Behaviour.fs

module Rm.Accounting.Domain.Behaviour

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

let a = 42

这会导致两个错误:

  • 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

如果没有该项目可以编译的文件Behaviour.fs,我不确定为什么这两次导入会引起一些麻烦。

1 个答案:

答案 0 :(得分:1)

感谢评论,尽管出于某些原因,尽管在Rider中对文件进行了重新排序,fsproj并没有得到正确的更新。

<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

重新组织fsproj,做到了:

<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>
相关问题