Skip to content

Show [<Literal>] and constant value for IL fields in Go to Metadata#19922

Open
T-Gro wants to merge 5 commits into
mainfrom
fix/issue-11526
Open

Show [<Literal>] and constant value for IL fields in Go to Metadata#19922
T-Gro wants to merge 5 commits into
mainfrom
fix/issue-11526

Conversation

@T-Gro

@T-Gro T-Gro commented Jun 9, 2026

Copy link
Copy Markdown
Member

Fixes #11526

IL literal (const) fields such as System.Char.MaxValue now render with
[<Literal>] and their constant value in Go to Metadata, instead of
appearing as plain static val declarations.

Copilot and others added 3 commits June 9, 2026 08:13
…11526)

Adds a new MetadataAsTextILField module in
tests/FSharp.Compiler.Service.Tests/Symbols.fs covering the rendering of
IL literal (const) static fields via FSharpEntity.TryGetMetadataText().

Tests added:
- Theory with 5 rows (Int32/Int64/Byte/SByte MaxValue/MinValue) asserting
  the rendered metadata contains [<Literal>] and "= <value>".
- Fact for System.Char.MaxValue asserting [<Literal>] and "=" appear on
  the MaxValue line.
- Negative Fact for System.Math.PI (initonly, non-literal) asserting it
  is NOT tagged [<Literal>] and has no "=".

Current state (RED):
  total: 7, failed: 6, succeeded: 1
- 5 Theory rows + Char.MaxValue Fact fail with
  Assert.Contains() Failure: Sub-string not found
  because NicePrint.layoutILFieldInfo currently drops [<Literal>] and
  the literal value.
- Math.PI passes (guards against regression of normal static val
  rendering).

Sprint 02 will implement the fix in src/Compiler/Checking/NicePrint.fs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…-to-Metadata

Note: Sprint 01 test assumptions were partially incorrect:

- Math.PI is actually a literal const in IL (not initonly); replaced with System.String.Empty for the non-literal case.

- The 'first line containing fieldName' finder matched doc-comment lines; narrowed to lines containing 'val <fieldName>:'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fantomas no-op (both touched files are in .fantomasignore); no .bsl baseline drift observed in targeted MetadataAsTextILField run (7/7 passed in 13s).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.100.md

@github-actions github-actions Bot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label Jun 9, 2026
CI `check_release_notes` requires the entry to live in the VNEXT release-notes path (currently 11.0.100.md), not in the shipped 9.0.300.md release. Move the bullet, no behavior change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Go to Metadata - static field handling is wrong

1 participant