Skip to content

Exception in file system shim when referencing old FSharp.Core #12901

@auduchinok

Description

@auduchinok

Add old FSharp.Core version reference to a fsproj and open the project in an IDE:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net6.0</TargetFramework>
        <DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="FSharp.Core" Version="3.0.2" />
    </ItemGroup>

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

</Project>

There's an exception when trying to load FSharp.Core data:

System.NotSupportedException: Stream does not support writing.
   at System.IO.Stream.CopyTo(Stream destination)
   at FSharp.Compiler.IO.DefaultFileSystem.OpenFileForReadShim(String filePath, FSharpOption`1 useMemoryMappedFile, FSharpOption`1 shouldShadowCopy) in C:\Developer\fsharp\src\fsharp\utils\FileSystem.fs:line 522
   at GetRawFSharpSignatureData@684.Invoke(Unit unitVar0) in C:\Developer\fsharp\src\fsharp\CompilerImports.fs:line 684
   at FSharp.Compiler.CompilerImports.ccuRawDataAndInfos@1520.Invoke(Tuple`2 tupledArg) in C:\Developer\fsharp\src\fsharp\CompilerImports.fs:line 1521
   at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x) in D:\a\_work\1\s\src\fsharp\FSharp.Core\local.fs:line 244
   at FSharp.Compiler.CompilerImports.TcImports.PrepareToImportReferencedFSharpAssembly(CompilationThreadToken ctok, Range m, String filename, ImportedBinary dllinfo) in C:\Developer\fsharp\src\fsharp\CompilerImports.fs:line 1519
   at FSharp.Compiler.CompilerImports.TryRegisterAndPrepareToImportReferencedDll@1640-2.Invoke(ProjectAssemblyDataResult contentsOpt) in C:\Developer\fsharp\src\fsharp\CompilerImports.fs:line 1678

Screenshot 2022-03-30 at 12 26 22

The exception happens when trying to shadow copy the satellite F# signature data file (which used to be not included into assembly resources) but I suppose it can happed in other cases when shadow copying is involved?

cc @vzarytovskii, as it's file system related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions