interactive: New code cells in F#- (or any non-C# language-) defaulted notebook are missing metadata, are treated as C#
Describe the bug
I mainly write notebooks for F# and PowerShell, with the occasional C# cell in the mix. The default notebook language setting is set to fsharp.
The last few times I worked with the notebooks, I noticed that new code cells show in the top bottom corner my default language setting “fsharp - F# Script Code”. However, if valid F# code is entered in the cell, it gets a lot of red squiggles (screenshot 1). When executing the cell, there are a lot of CS errors, indicating that the code is treated as C# (screenshot 2).
When I open the notebook in a text editor, I see that the metadata node of the cell is empty. Other working cells have metadata indicating F# in there (screenshot 3). See also a gist of the file in that state: https://gist.github.com/FH-Inway/34984cfacc39b27e206873048a16fb3e?short_path=51a4666
When I explicitely set the code cell via the language selector in the bottom right corner to F#, all is well again.
When I close a notebook with such an “invalid” cell, it is opened again right away, showing unsaved changes. The cell can now be executed successfully and after saving the file, the cell shows F# metadata.
Please complete the following:
Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):
Version: 1.0.522904+cdfa48b2ea1a27dfe0f545c42a34fd3ec7119074
Library version: 1.0.0-beta.24229.4+cdfa48b2ea1a27dfe0f545c42a34fd3ec7119074
Build date: 2024-05-05T09:37:02.5479468Z
- OS
- Windows 11
- Browser
- Edge
- Frontend
- Visual Studio Code
Screenshots
Related issues
#3263 Polyglot Notebook: [DevExE2E][Regression] The kernelName and language show as csharp in the created Untitled-1.ipynb contents. #3480 Default language not applied after open an python ipynb file #2794 New cells use notebook default language instead of previous cell language
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 16 (9 by maintainers)
Note that this affects only
.ipynbfiles and not.dibfiles.@DonJayamanne, does this ring any bells? It seems related to the removal of support for the
custommetadata field and appeared around the time that was removed.This is fixed by #3861.
This bug is because when you click “+ code” to create a cell, the “metadata” field inside the json is not populated, so the cell is parsed as C# by default.
Example text view of problem cell:
Add metadata and it works
If I manually re-select the “fsharp” language in the bottom right of the code sell, the metadata gets set and I can run the code using the F# kernel.