Arbeiten mit Notebooks in VS Code mit der Erweiterung "dotnet interactive"

Screenshot des Notebooks aus VS Code
Screenshot des Notebooks aus VS Code

Heute möchte ich Ihnen von einem so wunderbaren Tool wie "dotnet interactive" erzählen. Ich werde anhand meines Beispiels zeigen, wie und warum ich damit angefangen habe, und kurz beschreiben, wo ich anfangen soll.





Problem

, . , , . « » « » , .





, . , , , , "dotnet-interactive" notebook'a " "-""-""-"", .





notebook'a

, .net5 sdk VS Code. , ".NET Interactive Notebooks". "Preview", .





, , , . VS Code ".NET Interactive: Create new blank notebook" notebook.





:





#load "Load.fsx"

open Load

let Experiment = loadSep "2021.02.03_15.55.58_gen.sep"
      
      



F# , xml-:





#r "nuget: System.Text.Encoding.CodePages"
#r "AKIM.Protocol.dll"

open System.IO
open AKIM.Protocol
open System.Xml.Serialization
open System.Text

let loadSep path=
    
    let deserializeXml (xml : string) =
        let toBytes (x : string) = Encoding.UTF8.GetBytes x
        let xmlSerializer = XmlSerializer(typeof<Experiment>)
        use stream = new MemoryStream(toBytes xml)
        xmlSerializer.Deserialize stream :?> Experiment

    Encoding.RegisterProvider(CodePagesEncodingProvider.Instance)    
    deserializeXml (File.ReadAllText(path, Encoding.GetEncoding(1251)))
      
      



nuget dto-, C#.





notebook'a c#-intaractive # f#,





#r "AKIM.Protocol.dll"

using AKIM.Protocol;
using AKIM.Protocol.Events;
using AKIM.Protocol.Events.OperatorSvn;
using AKIM.Protocol.Events.OperSb;
using AKIM.Protocol.Events.RespUnits;
using AKIM.Protocol.Events.Intruders;
using AKIM.Protocol.Events.Sens;
using AKIM.Protocol.Events.System;

#!share --from fsharp Experiment
      
      



, . ,





var allTests = Experiment.Tests.Count;

var penetrations = Experiment.Tests.Where(t => t.Events.Last() is PenetrationEvent).Count();
var nonPenetrations = Experiment.Tests.Where(t => t.Events.Last() is NonPenetEvent).Count();

var eve = Experiment.Tests.First().Events.FirstOrDefault(t => t is VisContactEvent);

Console.WriteLine(eve?.GetDescription());

Console.WriteLine($"  {penetrations}  {allTests}")
      
      



:





, :





#r "nuget: XPlot.Plotly"

#!share --from csharp penetrations 
#!share --from csharp nonPenetrations
#!share --from csharp allTests

open XPlot.Plotly

Chart.Pie(seq {("- ",penetrations);
               ("",allTests- penetrations-nonPenetrations);
               ("  ",nonPenetrations)}) |> Chart.Show
      
      



, , (upd: XPlot.Plotly.Interactive. c# f# ( )).





Übersichtstabelle

, F# , , , . , , notebook , .





?

# "*.csx" #-interactive. , . , , . markdown $$...$$. (upd: , , markdown )





, .net . : , - , F# C#, , , manage' - . , , , , , ( ).





, Arkadiy Kuznetsov, .





. notebook' VS Code.





.





Die offizielle Rübe, die auch die

.NET Interactive + ML.NET-Dokumentation enthält.

Neue Funktionen f # (verwendet dotnet-intaractive am Anfang des Videos)








All Articles