diff --git a/NotebookStudy.ConsoleApp/NotebookStudy.ConsoleApp.csproj b/NotebookStudy.ConsoleApp/NotebookStudy.ConsoleApp.csproj index b8e5116..87574c1 100644 --- a/NotebookStudy.ConsoleApp/NotebookStudy.ConsoleApp.csproj +++ b/NotebookStudy.ConsoleApp/NotebookStudy.ConsoleApp.csproj @@ -1,7 +1,7 @@ Exe - net7.0 + net9.0 enable enable diff --git a/NotebookStudy.Core/GlobalUsing.cs b/NotebookStudy.Core/GlobalUsing.cs new file mode 100644 index 0000000..081cfd3 --- /dev/null +++ b/NotebookStudy.Core/GlobalUsing.cs @@ -0,0 +1,47 @@ +global using System.Collections; +global using System.Collections.Generic; +global using System.Collections.Immutable; +global using System.Collections.Specialized; +global using System.Collections.Concurrent; +global using System.Collections.Frozen; +global using System.Collections.ObjectModel; +global using System.Data; +global using System.Data.Common; +global using System.Data.Odbc; +global using System.Data.OleDb; +//global using System.Data.Sql; +//global using System.Data.SqlTypes; +//global using System.Data.SqlClient; + +global using Microsoft.Data; +global using Microsoft.Data.Sql; +global using Microsoft.Data.SqlClient; +global using Microsoft.Data.SqlTypes; +global using Microsoft.Data.Analysis; +global using Microsoft.Data.Sqlite; + +global using Microsoft.DotNet.Interactive; +global using Microsoft.DotNet.Interactive.Commands; +global using Microsoft.DotNet.Interactive.Connection; +global using Microsoft.DotNet.Interactive.Directives; +global using Microsoft.DotNet.Interactive.Formatting; +global using Microsoft.DotNet.Interactive.Documents; +global using Microsoft.DotNet.Interactive.Events; +global using Microsoft.DotNet.Interactive.Utility; +global using Microsoft.DotNet.Interactive.ValueSharing; +global using Microsoft.DotNet.Interactive.Parsing; +global using Microsoft.DotNet.Interactive.AI; +global using Microsoft.DotNet.Interactive.AIUtilities; +global using Microsoft.DotNet.Interactive.AspNetCore; +global using Microsoft.DotNet.Interactive.Browser; +global using Microsoft.DotNet.Interactive.ExtensionLab; +global using Microsoft.DotNet.Interactive.Http; +global using Microsoft.DotNet.Interactive.CSharp; +global using Microsoft.DotNet.Interactive.FSharp; +global using Microsoft.DotNet.Interactive.PowerShell; +global using Microsoft.DotNet.Interactive.Journey; +global using Microsoft.DotNet.Interactive.Jupyter; +global using Microsoft.DotNet.Interactive.Kql; +global using Microsoft.DotNet.Interactive.SQLite; +global using Microsoft.DotNet.Interactive.SqlServer; +global using Microsoft.DotNet.Interactive.PostgreSql; \ No newline at end of file diff --git a/NotebookStudy.Core/NotebookStudy.Core.csproj b/NotebookStudy.Core/NotebookStudy.Core.csproj index cfadb03..93307a2 100644 --- a/NotebookStudy.Core/NotebookStudy.Core.csproj +++ b/NotebookStudy.Core/NotebookStudy.Core.csproj @@ -1,9 +1,27 @@ - - net7.0 + net9.0 enable enable - - + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/NotebookStudy.Core/Student.cs b/NotebookStudy.Core/Student.cs index 6df437e..26f9f24 100644 --- a/NotebookStudy.Core/Student.cs +++ b/NotebookStudy.Core/Student.cs @@ -4,7 +4,7 @@ { public int Id { get; set; } - public string Name { get; set; } + public required string Name { get; set; } public int Age { get; set; } diff --git a/NotebookStudy.Test/CSharpKernelTest.cs b/NotebookStudy.Test/CSharpKernelTest.cs new file mode 100644 index 0000000..f228bea --- /dev/null +++ b/NotebookStudy.Test/CSharpKernelTest.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NotebookStudy.Test +{ + public class CSharpKernelTest + { + + private ITestOutputHelper _output; + public CSharpKernelTest(ITestOutputHelper output) + { + _output = output; + } + + [Fact] + public async Task Test() + { + var kernel = new CSharpKernel(); + + var textCode = """ + var msg = "我是C#"; + Console.Write("Hello,"); + Console.Write("C#!"); + """; + var result = await kernel.SubmitCodeAsync(textCode); + + //从结果中,找到标准输出对象 + string outText = ""; + var standardOutputValueProduceds = result.Events.Where(e => e.GetType().IsAssignableTo(typeof(StandardOutputValueProduced))).Cast(); + foreach (var produceds in standardOutputValueProduceds) + { + outText += produceds.FormattedValues.First().Value; + } + + _output.WriteLine(outText); + + Assert.Equal("Hello,C#!", outText); + + } + } +} diff --git a/NotebookStudy.Test/GlobalUsings.cs b/NotebookStudy.Test/GlobalUsings.cs index 8c927eb..1d39708 100644 --- a/NotebookStudy.Test/GlobalUsings.cs +++ b/NotebookStudy.Test/GlobalUsings.cs @@ -1 +1,49 @@ -global using Xunit; \ No newline at end of file +global using System.Collections; +global using System.Collections.Generic; +global using System.Collections.Immutable; +global using System.Collections.Specialized; +global using System.Collections.Concurrent; +global using System.Collections.Frozen; +global using System.Collections.ObjectModel; +global using System.Data; +global using System.Data.Common; +global using System.Data.Odbc; +global using System.Data.OleDb; + +global using Microsoft.Data; +global using Microsoft.Data.Sql; +global using Microsoft.Data.SqlClient; +global using Microsoft.Data.SqlTypes; +global using Microsoft.Data.Analysis; +global using Microsoft.Data.Sqlite; + +global using Microsoft.DotNet.Interactive; +global using Microsoft.DotNet.Interactive.Commands; +global using Microsoft.DotNet.Interactive.Connection; +global using Microsoft.DotNet.Interactive.Directives; +global using Microsoft.DotNet.Interactive.Formatting; +global using Microsoft.DotNet.Interactive.Documents; +global using Microsoft.DotNet.Interactive.Events; +global using Microsoft.DotNet.Interactive.Utility; +global using Microsoft.DotNet.Interactive.ValueSharing; +global using Microsoft.DotNet.Interactive.Parsing; +global using Microsoft.DotNet.Interactive.AI; +global using Microsoft.DotNet.Interactive.AIUtilities; +global using Microsoft.DotNet.Interactive.AspNetCore; +global using Microsoft.DotNet.Interactive.Browser; +global using Microsoft.DotNet.Interactive.ExtensionLab; +global using Microsoft.DotNet.Interactive.Http; +global using Microsoft.DotNet.Interactive.CSharp; +global using Microsoft.DotNet.Interactive.FSharp; +global using Microsoft.DotNet.Interactive.PowerShell; +global using Microsoft.DotNet.Interactive.Journey; +global using Microsoft.DotNet.Interactive.Jupyter; +global using Microsoft.DotNet.Interactive.Kql; +global using Microsoft.DotNet.Interactive.SQLite; +global using Microsoft.DotNet.Interactive.SqlServer; +global using Microsoft.DotNet.Interactive.PostgreSql; + +global using Xunit; +global using Xunit.Sdk; +global using Xunit.Extensions; +global using Xunit.Abstractions; \ No newline at end of file diff --git a/NotebookStudy.Test/NotebookStudy.Test.csproj b/NotebookStudy.Test/NotebookStudy.Test.csproj index 398b286..6e637db 100644 --- a/NotebookStudy.Test/NotebookStudy.Test.csproj +++ b/NotebookStudy.Test/NotebookStudy.Test.csproj @@ -1,18 +1,15 @@ - - net7.0 + net9.0 enable enable - false true - - + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -21,9 +18,7 @@ all - - - + \ No newline at end of file