Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty .ipnyb files modified by .NET Interactive are saved as C#, regardless of content #2289

Closed
K8-and-a-half-1000 opened this issue Sep 26, 2022 · 2 comments

Comments

@K8-and-a-half-1000
Copy link

Reproduction steps:

In VS Code, with .NET Interactive installed:

  • create an empty file, give it a .ipynb extension
  • open the file and add a code cell, by default C#
  • change the cell language to e.g. PowerShell
  • save the file

If you open the file in a text editor, in the metadata section, you'll get:

"metadata": {
  "language_info": {
   "name": "csharp"
  },
  "orig_nbformat": 4
 }

This makes no sense. ^
At this point we have no data stored, just a single empty cell with "language": "pwsh"
If you actually add some sample PowerShell code, and then save, the metadata becomes:

 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "file_extension": ".cs",
   "mimetype": "text/x-csharp",
   "name": "C#",
   "pygments_lexer": "csharp",
   "version": "9.0"
  },
  "orig_nbformat": 4
 }

.. which is worse.
At this point, you are basically expecting polyglot support for everything that works with .ipynb files, which is silly.
Please align the notebook metadata with the cell language, and don't hard-code C# as the default.

@wsmelton
Copy link

It seems to also happen after picking the default language with cells created in that language using it, and then removing them all will cause it to revert back to C#.

  1. Create new Polyglot notebook
  2. Set default language to PowerShell (or whatever)
  3. Add specified language cells
  4. Remove them all
  5. Next code cell created will default to C#

@jonsequitur
Copy link
Contributor

This has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants