Document verbatim interpolated strings using $@ and @$ syntax in F# #48861
+45
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Syntax section - Added two new syntax forms:
$@"string-text {expr}"
@$"string-text {expr}"
Verbatim interpolated strings section - Restructured and expanded to document both approaches:
$@
or@$
prefix" - Documents how to combine interpolation with verbatim strings, with practical examples showing:""
$@
and@$
order variationsMetadata - Updated
ms.date
to reflect the documentation updateAdded
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:$@
and@$
prefix orders""
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
✨ 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