Skip to content

Commit

Permalink
Merge pull request #2001 from OmniSharp/feature/scripting-lang-version
Browse files Browse the repository at this point in the history
C# scripting should use language version "latest" by default
  • Loading branch information
filipw authored Nov 4, 2020
2 parents 93d2807 + 14825ba commit 0ed85e3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/OmniSharp.Script/ScriptProjectProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ScriptProjectProvider
"System.Threading.Tasks"
};

private static readonly CSharpParseOptions ParseOptions = new CSharpParseOptions(LanguageVersion.CSharp8, DocumentationMode.Parse, SourceCodeKind.Script);
private static readonly CSharpParseOptions ParseOptions = new CSharpParseOptions(LanguageVersion.Latest, DocumentationMode.Parse, SourceCodeKind.Script);

private readonly Lazy<CSharpCompilationOptions> _compilationOptions;
private readonly Lazy<CSharpCommandLineArguments> _commandLineArgs;
Expand Down Expand Up @@ -103,7 +103,6 @@ private CSharpCompilationOptions CreateCompilationOptions()

compilationOptions = compilationOptions
.WithAllowUnsafe(true)

.WithMetadataReferenceResolver(metadataReferenceResolver)
.WithSourceReferenceResolver(sourceResolver)
.WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.Default)
Expand Down
23 changes: 23 additions & 0 deletions tests/OmniSharp.Script.Tests/ScriptProjectProviderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Scripting.Hosting;
using Microsoft.Extensions.Logging;
using OmniSharp.Services;
using Xunit;

namespace OmniSharp.Script.Tests
{
public class ScriptProjectProviderTests
{
[Fact]
public void DefaultLanguageVersionShouldBeLatest()
{
var scriptProjectProvider = new ScriptProjectProvider(new ScriptOptions(), new OmniSharpEnvironment(), new LoggerFactory(), true, false);
var scriptProjectInfo = scriptProjectProvider.CreateProject("test.csx", Enumerable.Empty<MetadataReference>(), Path.GetTempPath(), typeof(CommandLineScriptGlobals));
Assert.Equal(LanguageVersion.Latest, ((CSharpParseOptions)scriptProjectInfo.ParseOptions).SpecifiedLanguageVersion);
Assert.Equal(LanguageVersion.CSharp9, ((CSharpParseOptions)scriptProjectInfo.ParseOptions).LanguageVersion);
}
}
}
1 change: 1 addition & 0 deletions tests/OmniSharp.Script.Tests/WorkspaceInformationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Scripting.Hosting;
using OmniSharp.Models.FilesChanged;
using OmniSharp.Models.WorkspaceInformation;
Expand Down

0 comments on commit 0ed85e3

Please sign in to comment.