Skip to content

Changing F# literals is not propagated properly to dependent projects in incremental builds #18758

@luithefirst

Description

@luithefirst

I have a F# class library with a literal in it and a C# console application that uses it. When the literal is changed, the F# library is rebuilt, but not the C# project, resulting in printing the wrong value. Also, if the C# project is changed and "rebuilt" (incremental), the old literal is used. Only if you make a clean rebuild, the proper literal value is used.

The F# library:

namespace ClassLibrary

module Literals = 
    [<Literal>]
    let Number = 2048

C# app:

Console.WriteLine($"The number is {ClassLibrary.Literals.Number}");
  1. The output of a clean rebuild is 2048.
  2. When the literal is changed to something else, the output is still 2048.
  3. When the C# project is changed to e.g. print ClassLibrary.Literals.Number + 1, it will print 2049 as if the literal still was 2048.

You need to manually trigger a rebuild (RMB -> Rebuild in VS) or clean the solution to resolve the inconsistency.

I'm using VS 17.14.8 with the .NET 8.0.411 SDK.

You can also clone this repository to reproduce the issue:
https://github.com/luithefirst/FSharpLiteral

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions