From 519687d5bf972d8acf9a83818c050da4b89fb579 Mon Sep 17 00:00:00 2001 From: filipw Date: Thu, 31 Jan 2019 10:21:17 +0100 Subject: [PATCH 1/5] updated to Roslyn 3.0.0-beta2-final --- src/Dotnet.Script.Core/Dotnet.Script.Core.csproj | 4 ++-- .../Dotnet.Script.DependencyModel.NuGet.csproj | 2 +- src/Dotnet.Script.Extras/Dotnet.Script.Extras.csproj | 2 +- src/Dotnet.Script/Dotnet.Script.csproj | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Dotnet.Script.Core/Dotnet.Script.Core.csproj b/src/Dotnet.Script.Core/Dotnet.Script.Core.csproj index b4f879be..e4b1314b 100644 --- a/src/Dotnet.Script.Core/Dotnet.Script.Core.csproj +++ b/src/Dotnet.Script.Core/Dotnet.Script.Core.csproj @@ -33,9 +33,9 @@ - + - + diff --git a/src/Dotnet.Script.DependencyModel.Nuget/Dotnet.Script.DependencyModel.NuGet.csproj b/src/Dotnet.Script.DependencyModel.Nuget/Dotnet.Script.DependencyModel.NuGet.csproj index 76546602..6400a9c9 100644 --- a/src/Dotnet.Script.DependencyModel.Nuget/Dotnet.Script.DependencyModel.NuGet.csproj +++ b/src/Dotnet.Script.DependencyModel.Nuget/Dotnet.Script.DependencyModel.NuGet.csproj @@ -14,6 +14,6 @@ dotnet-script - + diff --git a/src/Dotnet.Script.Extras/Dotnet.Script.Extras.csproj b/src/Dotnet.Script.Extras/Dotnet.Script.Extras.csproj index 3a135b4e..4834e439 100644 --- a/src/Dotnet.Script.Extras/Dotnet.Script.Extras.csproj +++ b/src/Dotnet.Script.Extras/Dotnet.Script.Extras.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/Dotnet.Script/Dotnet.Script.csproj b/src/Dotnet.Script/Dotnet.Script.csproj index 031c65be..001282cc 100644 --- a/src/Dotnet.Script/Dotnet.Script.csproj +++ b/src/Dotnet.Script/Dotnet.Script.csproj @@ -22,7 +22,7 @@ latest - + From 570e88b2f2345f6da93dc413739260e2cbe01c9f Mon Sep 17 00:00:00 2001 From: filipw Date: Thu, 31 Jan 2019 10:35:04 +0100 Subject: [PATCH 2/5] updated versions --- src/Dotnet.Script.Core/Dotnet.Script.Core.csproj | 2 +- .../Dotnet.Script.DependencyModel.NuGet.csproj | 2 +- src/Dotnet.Script/Dotnet.Script.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Dotnet.Script.Core/Dotnet.Script.Core.csproj b/src/Dotnet.Script.Core/Dotnet.Script.Core.csproj index e4b1314b..9577292d 100644 --- a/src/Dotnet.Script.Core/Dotnet.Script.Core.csproj +++ b/src/Dotnet.Script.Core/Dotnet.Script.Core.csproj @@ -2,7 +2,7 @@ A cross platform library allowing you to run C# (CSX) scripts with support for debugging and inline NuGet packages. Based on Roslyn. - 0.29.0 + 0.29.0-beta1 filipw netstandard2.0 Dotnet.Script.Core diff --git a/src/Dotnet.Script.DependencyModel.Nuget/Dotnet.Script.DependencyModel.NuGet.csproj b/src/Dotnet.Script.DependencyModel.Nuget/Dotnet.Script.DependencyModel.NuGet.csproj index 6400a9c9..861c74b2 100644 --- a/src/Dotnet.Script.DependencyModel.Nuget/Dotnet.Script.DependencyModel.NuGet.csproj +++ b/src/Dotnet.Script.DependencyModel.Nuget/Dotnet.Script.DependencyModel.NuGet.csproj @@ -8,7 +8,7 @@ https://github.com/filipw/dotnet-script.git git script;csx;csharp;roslyn;nuget - 0.7.1 + 0.8.0-beta1 A MetadataReferenceResolver that allows inline nuget references to be specified in script(csx) files. dotnet-script dotnet-script diff --git a/src/Dotnet.Script/Dotnet.Script.csproj b/src/Dotnet.Script/Dotnet.Script.csproj index 001282cc..89b91b43 100644 --- a/src/Dotnet.Script/Dotnet.Script.csproj +++ b/src/Dotnet.Script/Dotnet.Script.csproj @@ -1,7 +1,7 @@  Dotnet CLI tool allowing you to run C# (CSX) scripts. - 0.29.0 + 0.29.0-beta1 filipw Dotnet.Script netcoreapp2.1 From 8bd933fc40b73436515a539ef8cc79d50199f434 Mon Sep 17 00:00:00 2001 From: filipw Date: Thu, 31 Jan 2019 10:45:21 +0100 Subject: [PATCH 3/5] fixed version --- src/Dotnet.Script.Core/Versioning/VersionProvider.cs | 1 - src/Dotnet.Script.Tests/EnvironmentTests.cs | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Dotnet.Script.Core/Versioning/VersionProvider.cs b/src/Dotnet.Script.Core/Versioning/VersionProvider.cs index 70c0ba1c..11107a5e 100644 --- a/src/Dotnet.Script.Core/Versioning/VersionProvider.cs +++ b/src/Dotnet.Script.Core/Versioning/VersionProvider.cs @@ -43,7 +43,6 @@ VersionInfo ParseTagName(string json) public VersionInfo GetCurrentVersion() { var versionAttribute = typeof(VersionProvider).Assembly.GetCustomAttributes().Single(); - var version = Version.Parse(versionAttribute.InformationalVersion); return new VersionInfo(versionAttribute.InformationalVersion, isResolved:true); } } diff --git a/src/Dotnet.Script.Tests/EnvironmentTests.cs b/src/Dotnet.Script.Tests/EnvironmentTests.cs index ea1dd5e8..a41b90ff 100644 --- a/src/Dotnet.Script.Tests/EnvironmentTests.cs +++ b/src/Dotnet.Script.Tests/EnvironmentTests.cs @@ -15,6 +15,12 @@ public class EnvironmentTests public void ShouldPrintVersionNumber(string versionFlag) { var result = ScriptTestRunner.Default.Execute(versionFlag); + + if (result.exitCode != 0) + { + Console.WriteLine(result.output); + } + Assert.Equal(0, result.exitCode); // TODO test that version appears on first line of output! Assert.Matches(@"^[0-9]+(\.[0-9]+){2}$", result.output); From dcfc93859f9fb2fffb9cc20ba0049a53c0ab85a6 Mon Sep 17 00:00:00 2001 From: filipw Date: Thu, 31 Jan 2019 11:37:57 +0100 Subject: [PATCH 4/5] fixed test regex --- src/Dotnet.Script.Tests/EnvironmentTests.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Dotnet.Script.Tests/EnvironmentTests.cs b/src/Dotnet.Script.Tests/EnvironmentTests.cs index a41b90ff..6d789e3d 100644 --- a/src/Dotnet.Script.Tests/EnvironmentTests.cs +++ b/src/Dotnet.Script.Tests/EnvironmentTests.cs @@ -15,15 +15,10 @@ public class EnvironmentTests public void ShouldPrintVersionNumber(string versionFlag) { var result = ScriptTestRunner.Default.Execute(versionFlag); - - if (result.exitCode != 0) - { - Console.WriteLine(result.output); - } - Assert.Equal(0, result.exitCode); // TODO test that version appears on first line of output! - Assert.Matches(@"^[0-9]+(\.[0-9]+){2}$", result.output); + // semver regex from https://github.com/semver/semver/issues/232#issue-48635632 + Assert.Matches(@"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$", result.output); } [Fact] From 407b47c7d17d3261d215e2a449db483d56d05cde Mon Sep 17 00:00:00 2001 From: filipw Date: Fri, 1 Feb 2019 12:21:15 +0100 Subject: [PATCH 5/5] manually reset to C#8.0 --- src/Dotnet.Script.Core/ScriptCompiler.cs | 6 ++++++ src/Dotnet.Script.Tests/ScriptExecutionTests.cs | 8 ++++++++ .../TestFixtures/CSharp80/CSharp80.csx | 5 +++++ 3 files changed, 19 insertions(+) create mode 100644 src/Dotnet.Script.Tests/TestFixtures/CSharp80/CSharp80.csx diff --git a/src/Dotnet.Script.Core/ScriptCompiler.cs b/src/Dotnet.Script.Core/ScriptCompiler.cs index 7d57f645..1679219f 100644 --- a/src/Dotnet.Script.Core/ScriptCompiler.cs +++ b/src/Dotnet.Script.Core/ScriptCompiler.cs @@ -34,6 +34,12 @@ static ScriptCompiler() { CSharpScript.Create("1", ScriptOptions.Default, typeof(CommandLineScriptGlobals), new InteractiveAssemblyLoader()).RunAsync(new CommandLineScriptGlobals(Console.Out, CSharpObjectFormatter.Instance)).GetAwaiter().GetResult(); }); + + // reset default scripting mode to latest language version to enable C# 8.0 features + // this is not needed once Roslyn 3.0 stable ships + var csharpScriptCompilerType = typeof(CSharpScript).GetTypeInfo().Assembly.GetType("Microsoft.CodeAnalysis.CSharp.Scripting.CSharpScriptCompiler"); + var parseOptionsField = csharpScriptCompilerType?.GetField("s_defaultOptions", BindingFlags.Static | BindingFlags.NonPublic); + parseOptionsField?.SetValue(null, new CSharpParseOptions(LanguageVersion.CSharp8, kind: SourceCodeKind.Script)); } protected virtual IEnumerable ImportedNamespaces => new[] diff --git a/src/Dotnet.Script.Tests/ScriptExecutionTests.cs b/src/Dotnet.Script.Tests/ScriptExecutionTests.cs index 483db521..8cb84fd4 100644 --- a/src/Dotnet.Script.Tests/ScriptExecutionTests.cs +++ b/src/Dotnet.Script.Tests/ScriptExecutionTests.cs @@ -186,6 +186,14 @@ public void ShouldHandleCSharp72() Assert.Contains("hi", result.output); } + [Fact] + public void ShouldHandleCSharp80() + { + var result = ScriptTestRunner.Default.ExecuteFixture("CSharp80"); + Assert.Equal(0, result.exitCode); + + } + [Fact] public void ShouldEvaluateCode() { diff --git a/src/Dotnet.Script.Tests/TestFixtures/CSharp80/CSharp80.csx b/src/Dotnet.Script.Tests/TestFixtures/CSharp80/CSharp80.csx new file mode 100644 index 00000000..2cca6b83 --- /dev/null +++ b/src/Dotnet.Script.Tests/TestFixtures/CSharp80/CSharp80.csx @@ -0,0 +1,5 @@ +// static local functions are C# 8.0 feature +void Foo() +{ + static void Bar() { }; +} \ No newline at end of file