From cf89264f7d910729944b598610fe5cc0b38c6bab Mon Sep 17 00:00:00 2001 From: Tomas Matousek Date: Wed, 7 Oct 2015 19:11:58 -0700 Subject: [PATCH] Remove ExitCode from the host object --- .../CSharpTest.Desktop/InteractiveSessionTests.cs | 1 + src/Scripting/CSharpTest/CommandLineRunnerTests.cs | 11 ----------- .../Core/Hosting/CommandLine/CommandLineRunner.cs | 4 +++- .../Hosting/CommandLine/CommandLineScriptGlobals.cs | 5 ----- src/Scripting/Core/PublicAPI.Unshipped.txt | 2 -- src/Scripting/CoreTest/ObjectFormatterTestBase.cs | 6 +++--- 6 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/Scripting/CSharpTest.Desktop/InteractiveSessionTests.cs b/src/Scripting/CSharpTest.Desktop/InteractiveSessionTests.cs index 2e68382ed58..058c692c610 100644 --- a/src/Scripting/CSharpTest.Desktop/InteractiveSessionTests.cs +++ b/src/Scripting/CSharpTest.Desktop/InteractiveSessionTests.cs @@ -302,6 +302,7 @@ public async Task HostObjectBinding_DuplicateReferences() { typeof(object).GetTypeInfo().Assembly.Location, typeof(C).Assembly.Location, + Assembly.Load(new AssemblyName("System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")).Location, // TODO: remove typeof(C).Assembly.Location, typeof(C).Assembly.Location, }, s0.Script.GetCompilation().ExternalReferences.SelectAsArray(m => m.Display)); diff --git a/src/Scripting/CSharpTest/CommandLineRunnerTests.cs b/src/Scripting/CSharpTest/CommandLineRunnerTests.cs index d96f0d8bd38..eee20531836 100644 --- a/src/Scripting/CSharpTest/CommandLineRunnerTests.cs +++ b/src/Scripting/CSharpTest/CommandLineRunnerTests.cs @@ -108,17 +108,6 @@ public void Args() > ", runner.Console.Out.ToString()); } - [Fact] - public void Script_ExitCode() - { - var script = Temp.CreateFile(extension: ".csx").WriteAllText("ExitCode = 42;"); - - var runner = CreateRunner(new[] { script.Path }); - - Assert.Equal(42, runner.RunInteractive()); - Assert.Equal("", runner.Console.Out.ToString()); - } - [Fact] public void Script_NonExistingFile() { diff --git a/src/Scripting/Core/Hosting/CommandLine/CommandLineRunner.cs b/src/Scripting/Core/Hosting/CommandLine/CommandLineRunner.cs index 1ebbd66e8f2..267326bf8f3 100644 --- a/src/Scripting/Core/Hosting/CommandLine/CommandLineRunner.cs +++ b/src/Scripting/Core/Hosting/CommandLine/CommandLineRunner.cs @@ -150,7 +150,9 @@ private int RunScript(ScriptOptions options, string code, string scriptPath, Err try { script.RunAsync(globals, cancellationToken).Wait(); - return globals.ExitCode; + + // TODO: use the return value of the script https://github.com/dotnet/roslyn/issues/5773 + return CommonCompiler.Succeeded; } catch (CompilationErrorException e) { diff --git a/src/Scripting/Core/Hosting/CommandLine/CommandLineScriptGlobals.cs b/src/Scripting/Core/Hosting/CommandLine/CommandLineScriptGlobals.cs index cc91e2f78bb..7c9f0f2cf8a 100644 --- a/src/Scripting/Core/Hosting/CommandLine/CommandLineScriptGlobals.cs +++ b/src/Scripting/Core/Hosting/CommandLine/CommandLineScriptGlobals.cs @@ -33,11 +33,6 @@ public void Print(object value) _outputWriter.WriteLine(_objectFormatter.FormatObject(value, PrintOptions)); } - /// - /// Script exit code. Use a non-zero number to indicate an error. - /// - public int ExitCode { get; set; } - internal ObjectFormattingOptions PrintOptions { get; } public CommandLineScriptGlobals(TextWriter outputWriter, ObjectFormatter objectFormatter) diff --git a/src/Scripting/Core/PublicAPI.Unshipped.txt b/src/Scripting/Core/PublicAPI.Unshipped.txt index a994e197a94..62c84b4065e 100644 --- a/src/Scripting/Core/PublicAPI.Unshipped.txt +++ b/src/Scripting/Core/PublicAPI.Unshipped.txt @@ -3,8 +3,6 @@ Microsoft.CodeAnalysis.Scripting.CompilationErrorException.Diagnostics.get -> Sy Microsoft.CodeAnalysis.Scripting.Hosting.CommandLineScriptGlobals Microsoft.CodeAnalysis.Scripting.Hosting.CommandLineScriptGlobals.Args.get -> System.Collections.Generic.IList Microsoft.CodeAnalysis.Scripting.Hosting.CommandLineScriptGlobals.CommandLineScriptGlobals(System.IO.TextWriter outputWriter, Microsoft.CodeAnalysis.Scripting.Hosting.ObjectFormatter objectFormatter) -> void -Microsoft.CodeAnalysis.Scripting.Hosting.CommandLineScriptGlobals.ExitCode.get -> int -Microsoft.CodeAnalysis.Scripting.Hosting.CommandLineScriptGlobals.ExitCode.set -> void Microsoft.CodeAnalysis.Scripting.Hosting.CommandLineScriptGlobals.Print(object value) -> void Microsoft.CodeAnalysis.Scripting.Hosting.InteractiveAssemblyLoader Microsoft.CodeAnalysis.Scripting.Hosting.InteractiveAssemblyLoader.Dispose() -> void diff --git a/src/Scripting/CoreTest/ObjectFormatterTestBase.cs b/src/Scripting/CoreTest/ObjectFormatterTestBase.cs index 31b03d2e91d..206a29bf2b3 100644 --- a/src/Scripting/CoreTest/ObjectFormatterTestBase.cs +++ b/src/Scripting/CoreTest/ObjectFormatterTestBase.cs @@ -8,9 +8,9 @@ namespace Microsoft.CodeAnalysis.Scripting.Hosting.UnitTests { public abstract class ObjectFormatterTestBase { - internal static readonly ObjectFormattingOptions s_hexa = new ObjectFormattingOptions(useHexadecimalNumbers: true); - internal static readonly ObjectFormattingOptions s_memberList = new ObjectFormattingOptions(memberFormat: MemberDisplayFormat.List); - internal static readonly ObjectFormattingOptions s_inline = new ObjectFormattingOptions(memberFormat: MemberDisplayFormat.Inline); + internal static readonly ObjectFormattingOptions s_hexa = new ObjectFormattingOptions(useHexadecimalNumbers: true, maxOutputLength: int.MaxValue); + internal static readonly ObjectFormattingOptions s_memberList = new ObjectFormattingOptions(memberFormat: MemberDisplayFormat.List, maxOutputLength: int.MaxValue); + internal static readonly ObjectFormattingOptions s_inline = new ObjectFormattingOptions(memberFormat: MemberDisplayFormat.Inline, maxOutputLength: int.MaxValue); public void AssertMembers(string str, params string[] expected) { -- GitLab