question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Polyglot VSCode thinks F# notebooks generated by FSharp.Formatting are C# notebooks

See original GitHub issue

Describe the bug

  1. This is probably the same issue as #2289, and it breaks all documentation notebooks previously created by F# Formatting.
  2. For new F# notebooks, I can do a PR to update the F# Formatting library to generate F# notebooks with the metadata that the Polyglot notebooks extension wants. What metadata should we add?

Details follow:

The F# Formatting Library generates .NET interactive notebooks. The VSCode extension previously recognized the code cells as F#, but now the polyglot extension converts them to C#. As far as I can tell it’s necessary to manually go through every cell and change it to F# (not practical). This breaks all documentation notebooks previously created by F# Formatting.

For example, the extension now thinks the F# code in this notebook from the F# Data Library is C# code:

image

Regarding metadata … A simple notebook generated by the F# formatting tool looks like this below in json and is what used to work with the old VSCode extension.

        {
            "cells": [
          {
           "cell_type": "code",
           "metadata": {},
            "execution_count": 1, "outputs": [],
           "source": ["let x = 100\n"]
          }
,
          {
           "cell_type": "code",
           "metadata": {},
            "execution_count": 2, "outputs": [],
           "source": ["let y = 100\n"]
          }],
            "metadata": {
            "kernelspec": {"display_name": ".NET (F#)", "language": "F#", "name": ".net-fsharp"},
            "langauge_info": {
        "file_extension": ".fs",
        "mimetype": "text/x-fsharp",
        "name": "C#",
        "pygments_lexer": "fsharp",
        "version": "4.5"
        }
        },
            "nbformat": 4,
            "nbformat_minor": 1
        }

From experimentation, it looks like if we change "metadata": {} in code cells to what I have here then the cells are recognized as being F# code. Is this correct, is there anything else that you suggest?

 "metadata": {
    "dotnet_interactive": {
     "language": "fsharp"
    },
    "polyglot_notebook": {
     "kernelName": "fsharp"
    }
   }

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):

.NET Interactive Version: 1.0.360602+9bf026dabac44a6256a65168fa93dcb7e2edcca4 Library version: 1.0.0-beta.22606.2+9bf026dabac44a6256a65168fa93dcb7e2edcca4 Build date: 2023-01-31T11:33:36.0115292Z

Screenshots

If applicable, add screenshots to help explain your problem.

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
brettfocommented, Feb 9, 2023

@nhirschey we published a new extension to our insiders channel, can you give it a shot to see if it fixes this issue? You’ll need to install VS Code - Insiders and then install the extension like normal, it should automatically pick up the correct version, which should be 1.0.4108061.

0reactions
nhirscheycommented, Feb 11, 2023

@brettfo yes I checked docs from a few repos and it’s fixed in the insiders version of VS Code. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Polyglot Notebooks - Now with .NET 7, C# 11, and F# 7 ...
We are pleased to announce the December 2022 improvements to Polyglot Notebooks for Visual Studio Code. Make sure to install the Polyglot ......
Read more >
Polyglot Programming with Notebooks in Visual Studio Code
In Polyglot Notebooks, this engine behaves as the notebook's kernel and is the reason that the .NET 7 SDK is required. Getting started....
Read more >
Polyglot Notebooks in the Wild | #dotNETConf: Focus on F#
https://aka.ms/dotNETConfFocusFSharp Join Paige for a conversation about Notebooks.
Read more >
LIVE : .NET Interactive Notebooks with C#/F# in VS Code
NET Interactive and Notebooks - 3:00 Demo - 8:40 Polyglot notebooks - 10:50 Custom extensions - 12:40 D3.js - 16:10 Value ingestion -...
Read more >
The Power of Polyglot Notebooks | .NET Conf 2022 - YouTube
This talk will introduce and demo the use of .NET Interactive in VS Code Jupyter Notebooks, a cutting-edge kernel that allows data ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found