Eho*_*ret 5 f# namespaces module compilation
我的 F# 项目Rm.Accounting.Domain
包含以下文件(按顺序):
Model.fs:module Rm.Accounting.Domain.ModelCommands.fs:module Rm.Accounting.Domain.CommandsEvents.fs:module 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
Run Code Online (Sandbox Code Playgroud)
这会导致两个错误:
Behaviour.fs(3, 20): [FS0039] The namespace 'Domain' is not defined.->open Rm.Accounting.Domain.CommandsBehaviour.fs(4, 20): [FS0039] The namespace 'Domain' is not defined.->open Rm.Accounting.Domain.Events如果没有该文件Behaviour.fs,项目就可以编译,我不确定为什么这两个导入会引起一些麻烦。
感谢这些评论,似乎由于某些原因,尽管在 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>
Run Code Online (Sandbox Code Playgroud)
重新组织 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>
Run Code Online (Sandbox Code Playgroud)