Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 407b47c

Browse filesBrowse files
committed
manually reset to C#8.0
1 parent dcfc938 commit 407b47c
Copy full SHA for 407b47c

File tree

3 files changed

+19
-0
lines changed
Filter options

3 files changed

+19
-0
lines changed

‎src/Dotnet.Script.Core/ScriptCompiler.cs

Copy file name to clipboardExpand all lines: src/Dotnet.Script.Core/ScriptCompiler.cs
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ static ScriptCompiler()
3434
{
3535
CSharpScript.Create<object>("1", ScriptOptions.Default, typeof(CommandLineScriptGlobals), new InteractiveAssemblyLoader()).RunAsync(new CommandLineScriptGlobals(Console.Out, CSharpObjectFormatter.Instance)).GetAwaiter().GetResult();
3636
});
37+
38+
// reset default scripting mode to latest language version to enable C# 8.0 features
39+
// this is not needed once Roslyn 3.0 stable ships
40+
var csharpScriptCompilerType = typeof(CSharpScript).GetTypeInfo().Assembly.GetType("Microsoft.CodeAnalysis.CSharp.Scripting.CSharpScriptCompiler");
41+
var parseOptionsField = csharpScriptCompilerType?.GetField("s_defaultOptions", BindingFlags.Static | BindingFlags.NonPublic);
42+
parseOptionsField?.SetValue(null, new CSharpParseOptions(LanguageVersion.CSharp8, kind: SourceCodeKind.Script));
3743
}
3844

3945
protected virtual IEnumerable<string> ImportedNamespaces => new[]

‎src/Dotnet.Script.Tests/ScriptExecutionTests.cs

Copy file name to clipboardExpand all lines: src/Dotnet.Script.Tests/ScriptExecutionTests.cs
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,14 @@ public void ShouldHandleCSharp72()
186186
Assert.Contains("hi", result.output);
187187
}
188188

189+
[Fact]
190+
public void ShouldHandleCSharp80()
191+
{
192+
var result = ScriptTestRunner.Default.ExecuteFixture("CSharp80");
193+
Assert.Equal(0, result.exitCode);
194+
195+
}
196+
189197
[Fact]
190198
public void ShouldEvaluateCode()
191199
{
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// static local functions are C# 8.0 feature
2+
void Foo()
3+
{
4+
static void Bar() { };
5+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.