dotnet / dotnet/fsharp

F# WriteCodeFragment rejects positional literal metadata

Open
#20,550 0 comments 0 reactions 0 assignees View on GitHub
Needs-Triage
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

Please provide a succinct description of the issue.

FSharp.Build's `WriteCodeFragment` treats every metadata key beginning with `_Parameter` as a positional parameter. Standard MSBuild assembly-attribute generation uses companion metadata such as `_Parameter1_IsLiteral`, which FSharp.Build incorrectly parses as a positional index.

**Repro steps**

Provide the steps required to reproduce the problem:

1. Add an `AssemblyAttribute` item with `_Parameter1` and `_Parameter1_IsLiteral=true` metadata. MSTest's `MSTestParallelizeScope` and `MSTestParallelizeWorkers` properties generate this shape.
2. Build an F# project with generated assembly information enabled.

If possible attach a zip file with the repro case. This often makes it easier for others to reproduce.
The zip file should ideally represent the situation just before the call/step that is problematic.

N/A

**Expected behavior**

`_Parameter1_IsLiteral` marks `_Parameter1` as literal code, and FSharp.Build generates the requested assembly attribute.

**Actual behavior**

The build fails with `Unable to parse '1_IsLiteral' as an index`.

**Known workarounds**

Declare the assembly attribute in an F# source file instead of using the MSBuild assembly-attribute properties.

**Related information**

* Operating system: all
* .NET Runtime kind: all SDK-style F# projects
* Editing Tools: N/A

Contributor guide

Open the contributing guide

Research direction

Start at FSharp.Build's WriteCodeFragment implementation and reproduce the failure with an AssemblyAttribute item containing _Parameter1 and _Parameter1_IsLiteral=true. Trace how the metadata key is parsed, then verify that an F# SDK-style project builds and generates the requested assembly attribute without the index error.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.