Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 1, 2025

Closes #[issue number]

Summary

This PR documents the ability to combine the $ (interpolation) and @ (verbatim string) prefixes in F# interpolated strings, answering a user question about whether the following syntax is valid:

printfn $@"Migrate notes of file ""{oldId}"" to new file ""{newId}""."

Answer: Yes! F# has supported verbatim interpolated strings using both $@ and @$ prefixes since F# 5, but this feature was not documented.

Changes

Updated docs/fsharp/language-reference/interpolated-strings.md

  1. Syntax section - Added two new syntax forms:

    • $@"string-text {expr}"
    • @$"string-text {expr}"
  2. Verbatim interpolated strings section - Restructured and expanded to document both approaches:

    • New subsection: "Using $@ or @$ prefix" - Documents how to combine interpolation with verbatim strings, with practical examples showing:
      • File paths with backslashes (no escaping needed)
      • Embedding quotes using ""
      • Multi-line strings
      • Both $@ and @$ order variations
    • Existing content: "Using triple quotes" - Preserved as a subsection for the alternative triple-quote approach
  3. Metadata - Updated ms.date to reflect the documentation update

Added docs/fsharp/language-reference/snippets/interpolated-strings/verbatim.fsx

Created a new snippet file with working examples demonstrating verbatim interpolated strings, including multi-line usage and quote embedding.

Testing

All code examples were tested with dotnet fsi and verified to work correctly, including:

  • Both $@ and @$ prefix orders
  • File paths with backslashes
  • Embedded quotes using ""
  • Multi-line strings
  • Format specifiers with verbatim interpolated strings

This feature works identically to C#'s verbatim interpolated strings, providing developers with a familiar and convenient syntax for working with strings containing backslashes and quotes.

Original prompt

This section details on the original issue you should resolve

<issue_title>Can I combine leading @ with interpolated strings</issue_title>
<issue_description>Hello,

Is the following possible in F#?

printfn $@"Migrate notes of file ""{oldId}"" to new file ""{newId}""."

The combination of $ and @.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Comments on the Issue (you are @copilot in this section)

Fixes #23806

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


Internal previews

📄 File 🔗 Preview link
docs/fsharp/language-reference/interpolated-strings.md docs/fsharp/language-reference/interpolated-strings

@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Oct 1, 2025
@Copilot Copilot AI changed the title [WIP] Can I combine leading @ with interpolated strings Document verbatim interpolated strings using $@ and @$ syntax in F# Oct 1, 2025
@Copilot Copilot AI requested a review from BillWagner October 1, 2025 13:31
Copilot finished work on behalf of BillWagner October 1, 2025 13:31
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM and is ready for final review.

@BillWagner BillWagner marked this pull request as ready for review October 2, 2025 12:52
@BillWagner BillWagner requested review from a team as code owners October 2, 2025 12:52
@BillWagner BillWagner requested a review from IEvangelist October 2, 2025 12:52
@T-Gro T-Gro merged commit 2d8e549 into main Oct 3, 2025
14 checks passed
@T-Gro T-Gro deleted the copilot/fix-67a930d0-51d0-4295-8263-6f81a4ee0d1e branch October 3, 2025 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-fsharp/svc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can I combine leading @ with interpolated strings
3 participants