diff --git a/src/Compilers/CSharp/Portable/Binder/BinderFactory.cs b/src/Compilers/CSharp/Portable/Binder/BinderFactory.cs index 4820aa0d34c73..a8c2c39f9eb3e 100644 --- a/src/Compilers/CSharp/Portable/Binder/BinderFactory.cs +++ b/src/Compilers/CSharp/Portable/Binder/BinderFactory.cs @@ -105,7 +105,7 @@ internal Binder GetBinder(SyntaxNode node, CSharpSyntaxNode memberDeclarationOpt // Unless this is interactive retrieving a binder for global statements // at the very top-level (i.e. in a completely empty file) use // node.Parent to maintain existing behavior. - if (!InScript || node.Kind() != SyntaxKind.CompilationUnit) + if ((!InScript || node.Kind() != SyntaxKind.CompilationUnit) && node.Parent != null) { node = node.Parent; } diff --git a/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs b/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs index 43dba54a310ff..017a421eafe1a 100644 --- a/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs +++ b/src/Compilers/CSharp/Portable/FlowAnalysis/NullableWalker.cs @@ -306,7 +306,7 @@ internal static void Analyze( DiagnosticBag diagnostics, Action callbackOpt = null) { - if (method.IsImplicitlyDeclared && (!method.IsImplicitConstructor || method.ContainingType.IsImplicitlyDeclared)) + if (method.IsImplicitlyDeclared && !method.IsImplicitConstructor && !method.IsScriptInitializer) { return; } diff --git a/src/Scripting/CSharp/CSharpScriptCompiler.cs b/src/Scripting/CSharp/CSharpScriptCompiler.cs index d2bb58b973b46..342745d3fdc77 100644 --- a/src/Scripting/CSharp/CSharpScriptCompiler.cs +++ b/src/Scripting/CSharp/CSharpScriptCompiler.cs @@ -11,7 +11,7 @@ internal sealed class CSharpScriptCompiler : ScriptCompiler { public static readonly ScriptCompiler Instance = new CSharpScriptCompiler(); - private static readonly CSharpParseOptions s_defaultOptions = new CSharpParseOptions(kind: SourceCodeKind.Script, languageVersion: LanguageVersion.Latest); + internal static readonly CSharpParseOptions DefaultParseOptions = new CSharpParseOptions(kind: SourceCodeKind.Script, languageVersion: LanguageVersion.Latest); private CSharpScriptCompiler() { @@ -23,8 +23,8 @@ private CSharpScriptCompiler() public override bool IsCompleteSubmission(SyntaxTree tree) => SyntaxFactory.IsCompleteSubmission(tree); - public override SyntaxTree ParseSubmission(SourceText text, CancellationToken cancellationToken) => - SyntaxFactory.ParseSyntaxTree(text, s_defaultOptions, cancellationToken: cancellationToken); + public override SyntaxTree ParseSubmission(SourceText text, ParseOptions parseOptions, CancellationToken cancellationToken) => + SyntaxFactory.ParseSyntaxTree(text, parseOptions ?? DefaultParseOptions, cancellationToken: cancellationToken); public override Compilation CreateSubmission(Script script) { @@ -40,7 +40,7 @@ public override Compilation CreateSubmission(Script script) // TODO: report diagnostics diagnostics.Free(); - var tree = SyntaxFactory.ParseSyntaxTree(script.SourceText, s_defaultOptions, script.Options.FilePath); + var tree = SyntaxFactory.ParseSyntaxTree(script.SourceText, script.Options.ParseOptions ?? DefaultParseOptions, script.Options.FilePath); string assemblyName, submissionTypeName; script.Builder.GenerateSubmissionId(out assemblyName, out submissionTypeName); diff --git a/src/Scripting/CSharp/CSharpScriptingResources.Designer.cs b/src/Scripting/CSharp/CSharpScriptingResources.Designer.cs index d2966e38ee570..2447fd24a4fc5 100644 --- a/src/Scripting/CSharp/CSharpScriptingResources.Designer.cs +++ b/src/Scripting/CSharp/CSharpScriptingResources.Designer.cs @@ -1,4 +1,4 @@ -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 diff --git a/src/Scripting/CSharp/PublicAPI.Unshipped.txt b/src/Scripting/CSharp/PublicAPI.Unshipped.txt index 8b137891791fe..89727bec80de1 100644 --- a/src/Scripting/CSharp/PublicAPI.Unshipped.txt +++ b/src/Scripting/CSharp/PublicAPI.Unshipped.txt @@ -1 +1,2 @@ - +Microsoft.CodeAnalysis.CSharp.Scripting.ScriptOptionsExtensions +static Microsoft.CodeAnalysis.CSharp.Scripting.ScriptOptionsExtensions.WithLanguageVersion(this Microsoft.CodeAnalysis.Scripting.ScriptOptions options, Microsoft.CodeAnalysis.CSharp.LanguageVersion languageVersion) -> Microsoft.CodeAnalysis.Scripting.ScriptOptions diff --git a/src/Scripting/CSharp/ScriptOptionsExtensions.cs b/src/Scripting/CSharp/ScriptOptionsExtensions.cs new file mode 100644 index 0000000000000..4bb20238433f2 --- /dev/null +++ b/src/Scripting/CSharp/ScriptOptionsExtensions.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.CodeAnalysis.Scripting; + +namespace Microsoft.CodeAnalysis.CSharp.Scripting +{ + public static class ScriptOptionsExtensions + { + public static ScriptOptions WithLanguageVersion(this ScriptOptions options, LanguageVersion languageVersion) + { + var parseOptions = (options.ParseOptions is null) + ? CSharpScriptCompiler.DefaultParseOptions + : (options.ParseOptions is CSharpParseOptions existing) ? existing : throw new InvalidOperationException(string.Format(ScriptingResources.CannotSetLanguageSpecificOption, LanguageNames.CSharp, nameof(LanguageVersion))); + + return options.WithParseOptions(parseOptions.WithLanguageVersion(languageVersion)); + } + } +} diff --git a/src/Scripting/CSharpTest/ScriptOptionsTests.cs b/src/Scripting/CSharpTest/ScriptOptionsTests.cs new file mode 100644 index 0000000000000..c352186b63ba9 --- /dev/null +++ b/src/Scripting/CSharpTest/ScriptOptionsTests.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Scripting; +using Microsoft.CodeAnalysis.Scripting; +using Microsoft.CodeAnalysis.VisualBasic; +using Roslyn.Test.Utilities; +using Xunit; + +namespace Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests +{ + public class ScriptOptionsTests : TestBase + { + [Fact] + public void WithLanguageVersion() + { + var options = ScriptOptions.Default.WithLanguageVersion(LanguageVersion.CSharp8); + Assert.Equal(LanguageVersion.CSharp8, ((CSharpParseOptions)options.ParseOptions).LanguageVersion); + } + + [Fact] + public void WithLanguageVersion_SameValueTwice_DoesNotCreateNewInstance() + { + var options = ScriptOptions.Default.WithLanguageVersion(LanguageVersion.CSharp8); + Assert.Same(options, options.WithLanguageVersion(LanguageVersion.CSharp8)); + } + + [Fact] + public void WithLanguageVersion_NonCSharpParseOptions_Throws() + { + var options = ScriptOptions.Default.WithParseOptions(new VisualBasicParseOptions(kind: SourceCodeKind.Script, languageVersion: VisualBasic.LanguageVersion.Latest)); + Assert.Throws(() => options.WithLanguageVersion(LanguageVersion.CSharp8)); + } + } +} diff --git a/src/Scripting/CSharpTest/ScriptTests.cs b/src/Scripting/CSharpTest/ScriptTests.cs index 002b01dcab538..c47a8bb3ba66d 100644 --- a/src/Scripting/CSharpTest/ScriptTests.cs +++ b/src/Scripting/CSharpTest/ScriptTests.cs @@ -923,6 +923,31 @@ public void StreamWithOffset() ScriptingTestHelpers.EvaluateScriptWithOutput(script, "Hello World!"); } + [Fact] + public void CreateScriptWithFeatureThatIsNotSupportedInTheSelectedLanguageVersion() + { + var script = CSharpScript.Create(@"string x = default;", ScriptOptions.Default.WithLanguageVersion(LanguageVersion.CSharp7)); + var compilation = script.GetCompilation(); + + compilation.VerifyDiagnostics( + Diagnostic(ErrorCode.ERR_FeatureNotAvailableInVersion7, "default"). + WithArguments("default literal", "7.1"). + WithLocation(1, 12) + ); + } + + [Fact] + public void CreateScriptWithNullableContextWithCSharp8() + { + var script = CSharpScript.Create(@"#nullable enable + string x = null;", ScriptOptions.Default.WithLanguageVersion(LanguageVersion.CSharp8)); + var compilation = script.GetCompilation(); + + compilation.VerifyDiagnostics( + Diagnostic(ErrorCode.WRN_NullAsNonNullable, "null").WithLocation(2, 28) + ); + } + private class StreamOffsetResolver : SourceReferenceResolver { public override bool Equals(object other) => ReferenceEquals(this, other); diff --git a/src/Scripting/Core/Hosting/CommandLine/CommandLineRunner.cs b/src/Scripting/Core/Hosting/CommandLine/CommandLineRunner.cs index 2e05139ef3375..f2724e8c59edb 100644 --- a/src/Scripting/Core/Hosting/CommandLine/CommandLineRunner.cs +++ b/src/Scripting/Core/Hosting/CommandLine/CommandLineRunner.cs @@ -159,7 +159,8 @@ private static ScriptOptions GetScriptOptions(CommandLineArguments arguments, st optimizationLevel: OptimizationLevel.Debug, allowUnsafe: true, checkOverflow: false, - warningLevel: 4); + warningLevel: 4, + parseOptions: null); } internal static MetadataReferenceResolver GetMetadataReferenceResolver(CommandLineArguments arguments, TouchedFileLogger loggerOpt) @@ -239,7 +240,7 @@ private void RunInteractiveLoop(ScriptOptions options, string initialScriptCodeO input.AppendLine(line); - var tree = _scriptCompiler.ParseSubmission(SourceText.From(input.ToString()), cancellationToken); + var tree = _scriptCompiler.ParseSubmission(SourceText.From(input.ToString()), options.ParseOptions, cancellationToken); if (_scriptCompiler.IsCompleteSubmission(tree)) { break; diff --git a/src/Scripting/Core/ScriptCompiler.cs b/src/Scripting/Core/ScriptCompiler.cs index 2f0963825ab20..5048341dde794 100644 --- a/src/Scripting/Core/ScriptCompiler.cs +++ b/src/Scripting/Core/ScriptCompiler.cs @@ -13,7 +13,7 @@ internal abstract class ScriptCompiler public abstract DiagnosticFormatter DiagnosticFormatter { get; } public abstract StringComparer IdentifierComparer { get; } - public abstract SyntaxTree ParseSubmission(SourceText text, CancellationToken cancellationToken); + public abstract SyntaxTree ParseSubmission(SourceText text, ParseOptions parseOptions, CancellationToken cancellationToken); public abstract bool IsCompleteSubmission(SyntaxTree tree); } } diff --git a/src/Scripting/Core/ScriptOptions.cs b/src/Scripting/Core/ScriptOptions.cs index 4d2d32394a999..d972ce85e0d21 100644 --- a/src/Scripting/Core/ScriptOptions.cs +++ b/src/Scripting/Core/ScriptOptions.cs @@ -30,7 +30,8 @@ public sealed class ScriptOptions OptimizationLevel.Debug, checkOverflow: false, allowUnsafe: true, - warningLevel: 4); + warningLevel: 4, + parseOptions: null); private static ImmutableArray GetDefaultMetadataReferences() { @@ -134,6 +135,8 @@ private static ImmutableArray GetDefaultMetadataReferences() /// public int WarningLevel { get; private set; } + internal ParseOptions ParseOptions { get; private set; } + internal ScriptOptions( string filePath, ImmutableArray references, @@ -145,7 +148,8 @@ internal ScriptOptions( OptimizationLevel optimizationLevel, bool checkOverflow, bool allowUnsafe, - int warningLevel) + int warningLevel, + ParseOptions parseOptions) { Debug.Assert(filePath != null); Debug.Assert(!references.IsDefault); @@ -164,6 +168,7 @@ internal ScriptOptions( CheckOverflow = checkOverflow; AllowUnsafe = allowUnsafe; WarningLevel = warningLevel; + ParseOptions = parseOptions; } private ScriptOptions(ScriptOptions other) @@ -177,7 +182,8 @@ private ScriptOptions(ScriptOptions other) optimizationLevel: other.OptimizationLevel, checkOverflow: other.CheckOverflow, allowUnsafe: other.AllowUnsafe, - warningLevel: other.WarningLevel) + warningLevel: other.WarningLevel, + parseOptions: other.ParseOptions) { } @@ -375,5 +381,8 @@ public ScriptOptions WithCheckOverflow(bool checkOverflow) => /// public ScriptOptions WithWarningLevel(int warningLevel) => warningLevel == WarningLevel ? this : new ScriptOptions(this) { WarningLevel = warningLevel }; + + internal ScriptOptions WithParseOptions(ParseOptions parseOptions) => + parseOptions == ParseOptions ? this : new ScriptOptions(this) { ParseOptions = parseOptions }; } } diff --git a/src/Scripting/Core/ScriptingResources.Designer.cs b/src/Scripting/Core/ScriptingResources.Designer.cs index f9d28ab610838..c7514319a1b48 100644 --- a/src/Scripting/Core/ScriptingResources.Designer.cs +++ b/src/Scripting/Core/ScriptingResources.Designer.cs @@ -10,7 +10,6 @@ namespace Microsoft.CodeAnalysis.Scripting { using System; - using System.Reflection; /// @@ -20,7 +19,7 @@ namespace Microsoft.CodeAnalysis.Scripting { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class ScriptingResources { @@ -40,7 +39,7 @@ internal ScriptingResources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.Scripting.ScriptingResources", typeof(ScriptingResources).GetTypeInfo().Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.Scripting.ScriptingResources", typeof(ScriptingResources).Assembly); resourceMan = temp; } return resourceMan; @@ -106,6 +105,15 @@ internal static string CannotSetConstantVariable { } } + /// + /// Looks up a localized string similar to Cannot set {0} specific option {1} because the options were already configured for a different language.. + /// + internal static string CannotSetLanguageSpecificOption { + get { + return ResourceManager.GetString("CannotSetLanguageSpecificOption", resourceCulture); + } + } + /// /// Looks up a localized string similar to Cannot set a read-only variable. /// diff --git a/src/Scripting/Core/ScriptingResources.resx b/src/Scripting/Core/ScriptingResources.resx index 03bad74baabae..3b3ab66001d3b 100644 --- a/src/Scripting/Core/ScriptingResources.resx +++ b/src/Scripting/Core/ScriptingResources.resx @@ -187,4 +187,7 @@ Script directives: Assembly '{0}' has already been loaded from '{1}'. A different assembly with the same name can't be loaded unless it's signed: '{2}'. + + Cannot set {0} specific option {1} because the options were already configured for a different language. + \ No newline at end of file diff --git a/src/Scripting/Core/xlf/ScriptingResources.cs.xlf b/src/Scripting/Core/xlf/ScriptingResources.cs.xlf index 8ed5313d11c4e..78f0749acfa53 100644 --- a/src/Scripting/Core/xlf/ScriptingResources.cs.xlf +++ b/src/Scripting/Core/xlf/ScriptingResources.cs.xlf @@ -2,6 +2,11 @@ + + Cannot set {0} specific option {1} because the options were already configured for a different language. + Cannot set {0} specific option {1} because the options were already configured for a different language. + + !<Stack overflow while evaluating object> !<Přetečení zásobníku během vyhodnocování objektu> diff --git a/src/Scripting/Core/xlf/ScriptingResources.de.xlf b/src/Scripting/Core/xlf/ScriptingResources.de.xlf index 75cd4be790192..2af50f8c6b5f9 100644 --- a/src/Scripting/Core/xlf/ScriptingResources.de.xlf +++ b/src/Scripting/Core/xlf/ScriptingResources.de.xlf @@ -2,6 +2,11 @@ + + Cannot set {0} specific option {1} because the options were already configured for a different language. + Cannot set {0} specific option {1} because the options were already configured for a different language. + + !<Stack overflow while evaluating object> !<Stapelüberlauf beim Auswerten des Objekts.> diff --git a/src/Scripting/Core/xlf/ScriptingResources.es.xlf b/src/Scripting/Core/xlf/ScriptingResources.es.xlf index 63fe003169a70..ea2ff5d99ab16 100644 --- a/src/Scripting/Core/xlf/ScriptingResources.es.xlf +++ b/src/Scripting/Core/xlf/ScriptingResources.es.xlf @@ -2,6 +2,11 @@ + + Cannot set {0} specific option {1} because the options were already configured for a different language. + Cannot set {0} specific option {1} because the options were already configured for a different language. + + !<Stack overflow while evaluating object> !<Desbordamiento de pila al evaluar objeto> diff --git a/src/Scripting/Core/xlf/ScriptingResources.fr.xlf b/src/Scripting/Core/xlf/ScriptingResources.fr.xlf index eaa1c6d7c9025..39eb1ba6ca339 100644 --- a/src/Scripting/Core/xlf/ScriptingResources.fr.xlf +++ b/src/Scripting/Core/xlf/ScriptingResources.fr.xlf @@ -2,6 +2,11 @@ + + Cannot set {0} specific option {1} because the options were already configured for a different language. + Cannot set {0} specific option {1} because the options were already configured for a different language. + + !<Stack overflow while evaluating object> !<Dépassement de capacité de la pile durant l'évaluation de l'objet> diff --git a/src/Scripting/Core/xlf/ScriptingResources.it.xlf b/src/Scripting/Core/xlf/ScriptingResources.it.xlf index 1a69d52160ab1..fb40c08e08d4b 100644 --- a/src/Scripting/Core/xlf/ScriptingResources.it.xlf +++ b/src/Scripting/Core/xlf/ScriptingResources.it.xlf @@ -2,6 +2,11 @@ + + Cannot set {0} specific option {1} because the options were already configured for a different language. + Cannot set {0} specific option {1} because the options were already configured for a different language. + + !<Stack overflow while evaluating object> !<Overflow dello stack durante la valutazione dell'oggetto> diff --git a/src/Scripting/Core/xlf/ScriptingResources.ja.xlf b/src/Scripting/Core/xlf/ScriptingResources.ja.xlf index 61a51a5f5df82..d5a3ddf1f171c 100644 --- a/src/Scripting/Core/xlf/ScriptingResources.ja.xlf +++ b/src/Scripting/Core/xlf/ScriptingResources.ja.xlf @@ -2,6 +2,11 @@ + + Cannot set {0} specific option {1} because the options were already configured for a different language. + Cannot set {0} specific option {1} because the options were already configured for a different language. + + !<Stack overflow while evaluating object> !<オブジェクトの評価中にスタック オーバーフローが発生しました> diff --git a/src/Scripting/Core/xlf/ScriptingResources.ko.xlf b/src/Scripting/Core/xlf/ScriptingResources.ko.xlf index 06d8e2208380e..b4699ce646ab5 100644 --- a/src/Scripting/Core/xlf/ScriptingResources.ko.xlf +++ b/src/Scripting/Core/xlf/ScriptingResources.ko.xlf @@ -2,6 +2,11 @@ + + Cannot set {0} specific option {1} because the options were already configured for a different language. + Cannot set {0} specific option {1} because the options were already configured for a different language. + + !<Stack overflow while evaluating object> !<개체를 평가하는 동안 스택 오버플로가 발생함> diff --git a/src/Scripting/Core/xlf/ScriptingResources.pl.xlf b/src/Scripting/Core/xlf/ScriptingResources.pl.xlf index 7bee07f81e8ab..284da02cd7312 100644 --- a/src/Scripting/Core/xlf/ScriptingResources.pl.xlf +++ b/src/Scripting/Core/xlf/ScriptingResources.pl.xlf @@ -2,6 +2,11 @@ + + Cannot set {0} specific option {1} because the options were already configured for a different language. + Cannot set {0} specific option {1} because the options were already configured for a different language. + + !<Stack overflow while evaluating object> !<Przepełnienie stosu podczas szacowania obiektu> diff --git a/src/Scripting/Core/xlf/ScriptingResources.pt-BR.xlf b/src/Scripting/Core/xlf/ScriptingResources.pt-BR.xlf index 14d5f98cf3597..6c4638b5c5afd 100644 --- a/src/Scripting/Core/xlf/ScriptingResources.pt-BR.xlf +++ b/src/Scripting/Core/xlf/ScriptingResources.pt-BR.xlf @@ -2,6 +2,11 @@ + + Cannot set {0} specific option {1} because the options were already configured for a different language. + Cannot set {0} specific option {1} because the options were already configured for a different language. + + !<Stack overflow while evaluating object> !<Estouro de pilha durante a avaliação do objeto> diff --git a/src/Scripting/Core/xlf/ScriptingResources.ru.xlf b/src/Scripting/Core/xlf/ScriptingResources.ru.xlf index 1995c841d7858..2ae012b272638 100644 --- a/src/Scripting/Core/xlf/ScriptingResources.ru.xlf +++ b/src/Scripting/Core/xlf/ScriptingResources.ru.xlf @@ -2,6 +2,11 @@ + + Cannot set {0} specific option {1} because the options were already configured for a different language. + Cannot set {0} specific option {1} because the options were already configured for a different language. + + !<Stack overflow while evaluating object> !<Переполнение стека при вычислении объекта> diff --git a/src/Scripting/Core/xlf/ScriptingResources.tr.xlf b/src/Scripting/Core/xlf/ScriptingResources.tr.xlf index a0f1e9d159328..5eba81de4a002 100644 --- a/src/Scripting/Core/xlf/ScriptingResources.tr.xlf +++ b/src/Scripting/Core/xlf/ScriptingResources.tr.xlf @@ -2,6 +2,11 @@ + + Cannot set {0} specific option {1} because the options were already configured for a different language. + Cannot set {0} specific option {1} because the options were already configured for a different language. + + !<Stack overflow while evaluating object> !<Nesne değerlendirilirken yığın taşması> diff --git a/src/Scripting/Core/xlf/ScriptingResources.zh-Hans.xlf b/src/Scripting/Core/xlf/ScriptingResources.zh-Hans.xlf index 68578121cf4af..ec94b16269052 100644 --- a/src/Scripting/Core/xlf/ScriptingResources.zh-Hans.xlf +++ b/src/Scripting/Core/xlf/ScriptingResources.zh-Hans.xlf @@ -2,6 +2,11 @@ + + Cannot set {0} specific option {1} because the options were already configured for a different language. + Cannot set {0} specific option {1} because the options were already configured for a different language. + + !<Stack overflow while evaluating object> !<计算对象时堆栈溢出> diff --git a/src/Scripting/Core/xlf/ScriptingResources.zh-Hant.xlf b/src/Scripting/Core/xlf/ScriptingResources.zh-Hant.xlf index b009fcf09b9d1..e67714c6c0b4d 100644 --- a/src/Scripting/Core/xlf/ScriptingResources.zh-Hant.xlf +++ b/src/Scripting/Core/xlf/ScriptingResources.zh-Hant.xlf @@ -2,6 +2,11 @@ + + Cannot set {0} specific option {1} because the options were already configured for a different language. + Cannot set {0} specific option {1} because the options were already configured for a different language. + + !<Stack overflow while evaluating object> !<評估物件時發生堆疊溢位> diff --git a/src/Scripting/CoreTest/ScriptOptionsTests.cs b/src/Scripting/CoreTest/ScriptOptionsTests.cs index 13d87e23991e0..e95d3289c9669 100644 --- a/src/Scripting/CoreTest/ScriptOptionsTests.cs +++ b/src/Scripting/CoreTest/ScriptOptionsTests.cs @@ -308,4 +308,4 @@ public void WarningLevel_Is_AppliedTo_CompilationOption(int warningLevel) Assert.Equal(scriptOptions.WarningLevel, compilation.Options.WarningLevel); } } -} +} \ No newline at end of file diff --git a/src/Scripting/VisualBasic/VisualBasicScriptCompiler.vb b/src/Scripting/VisualBasic/VisualBasicScriptCompiler.vb index a5b33345a6565..0da1df0d298a0 100644 --- a/src/Scripting/VisualBasic/VisualBasicScriptCompiler.vb +++ b/src/Scripting/VisualBasic/VisualBasicScriptCompiler.vb @@ -35,8 +35,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Scripting Return SyntaxFactory.IsCompleteSubmission(tree) End Function - Public Overrides Function ParseSubmission(text As SourceText, cancellationToken As CancellationToken) As SyntaxTree - Return SyntaxFactory.ParseSyntaxTree(text, s_defaultOptions, cancellationToken:=cancellationToken) + Public Overrides Function ParseSubmission(text As SourceText, parseOptions As ParseOptions, cancellationToken As CancellationToken) As SyntaxTree + Return SyntaxFactory.ParseSyntaxTree(text, If(parseOptions, s_defaultOptions), cancellationToken:=cancellationToken) End Function Private Shared Function GetGlobalImportsForCompilation(script As Script) As IEnumerable(Of GlobalImport)