Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Dotnet.Script.Core/Dotnet.Script.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<ItemGroup>
<PackageReference Include="Gapotchenko.FX" Version="2024.1.3" />
<PackageReference Include="Gapotchenko.FX.Reflection.Loader" Version="2024.1.3" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="5.0.0-2.final" />
<PackageReference Include="ReadLine" Version="2.0.1" />
<PackageReference Include="StrongNamer" Version="0.2.5" PrivateAssets="all" />
</ItemGroup>
Expand Down
51 changes: 48 additions & 3 deletions src/Dotnet.Script.Core/ScriptConsole.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
using System;
using System.IO;
using System.Runtime.CompilerServices;
using Microsoft.CodeAnalysis;
using RL = System.ReadLine;

namespace Dotnet.Script.Core
{
public class ScriptConsole
{
public static readonly ScriptConsole Default = new ScriptConsole(Console.Out, Console.In, Console.Error);
// Lazy to avoid touching anything during type initialization
private static readonly Lazy<ScriptConsole> s_default =
new Lazy<ScriptConsole>(() => new ScriptConsole(Console.Out, Console.In, Console.Error));

public static ScriptConsole Default => s_default.Value;

public virtual TextWriter Error { get; }
public virtual TextWriter Out { get; }
Expand Down Expand Up @@ -69,19 +74,59 @@ public virtual void WriteDiagnostics(Diagnostic[] warningDiagnostics, Diagnostic

public virtual string ReadLine()
{
return In == null ? RL.Read() : In.ReadLine();
if (In != null)
return In.ReadLine();

return ReadLineInteractive();
}

public ScriptConsole(TextWriter output, TextReader input, TextWriter error)
{
if (input == null)
{
RL.HistoryEnabled = true;
TryEnableReadLineHistory();
}

Out = output;
Error = error;
In = input;
}

// Isolate the ReadLine reference so JIT does not resolve it unless called.
[MethodImpl(MethodImplOptions.NoInlining)]
private static string ReadLineInteractive()
{
try
{
return RL.Read();
}
catch (System.IO.FileLoadException)
{
// ReadLine is not strongly named or not resolvable on netfx test hosts; fallback to Console.ReadLine.
return Console.ReadLine();
}
catch (TypeInitializationException tie) when (tie.InnerException is System.IO.FileLoadException)
{
return Console.ReadLine();
}
}

// Isolate the ReadLine reference so JIT does not resolve it unless called.
[MethodImpl(MethodImplOptions.NoInlining)]
private static void TryEnableReadLineHistory()
{
try
{
RL.HistoryEnabled = true;
}
catch (System.IO.FileLoadException)
{
// netfx may require a strong-named dependency chain; ignore for tests.
}
catch (TypeInitializationException tie) when (tie.InnerException is System.IO.FileLoadException)
{
// Same case wrapped by a type initializer; ignore.
}
}
}
}
2 changes: 1 addition & 1 deletion src/Dotnet.Script.Core/ScriptPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Dotnet.Script.Core
{
public class ScriptPublisher
{
private const string ScriptingVersion = "4.11.0";
private const string ScriptingVersion = "5.0.0-2.final";

private readonly ScriptProjectProvider _scriptProjectProvider;
private readonly ScriptEmitter _scriptEmitter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
<Compile Include="..\Dotnet.Script.DependencyModel\ProjectSystem\ScriptParserInternal.cs" Link="ScriptParserInternal.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="5.0.0-2.final" />
</ItemGroup>
</Project>
17 changes: 17 additions & 0 deletions src/Dotnet.Script.Desktop.Tests/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9999.0.0.0" newVersion="9.0.0.0" />
<codeBase version="9.0.0.0" href="System.Collections.Immutable.dll" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9999.0.0.0" newVersion="6.0.1.0" />
<codeBase version="6.0.1.0" href="System.Runtime.CompilerServices.Unsafe.dll" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
61 changes: 33 additions & 28 deletions src/Dotnet.Script.Desktop.Tests/Dotnet.Script.Desktop.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../dotnet-script.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.1" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
<PackageReference Include="StrongNamer" Version="0.2.5" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dotnet.Script.Core\Dotnet.Script.Core.csproj" />
<ProjectReference Include="..\Dotnet.Script.DependencyModel\Dotnet.Script.DependencyModel.csproj" />
<ProjectReference Include="..\Dotnet.Script.Shared.Tests\Dotnet.Script.Shared.Tests.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>../dotnet-script.snk</AssemblyOriginatorKeyFile>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
<ImmutablePkgVersion>9.0.0</ImmutablePkgVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.1" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
<PackageReference Include="System.Collections.Immutable" Version="$(ImmutablePkgVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Dotnet.Script.Core\Dotnet.Script.Core.csproj" />
<ProjectReference Include="..\Dotnet.Script.DependencyModel\Dotnet.Script.DependencyModel.csproj" />
<ProjectReference Include="..\Dotnet.Script.Shared.Tests\Dotnet.Script.Shared.Tests.csproj" />
</ItemGroup>

<!-- overwrite output for Immutable to ensure netstandard2.0 asset! -->
<Target Name="ForceNetStandardAssets" AfterTargets="Build">
<Copy SourceFiles="$(NuGetPackageRoot)system.collections.immutable\$(ImmutablePkgVersion)\lib\netstandard2.0\System.Collections.Immutable.dll"
DestinationFolder="$(OutDir)" OverWriteReadOnlyFiles="true" />
</Target>
</Project>
4 changes: 2 additions & 2 deletions src/Dotnet.Script.Extras/Dotnet.Script.Extras.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.11.0" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="5.0.0-2.final" />
<PackageReference Include="System.Collections.Immutable" Version="9.0.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Dotnet.Script.Tests/ScriptExecutionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void ShouldWriteCompilerWarningsToStandardError()
{
var result = ScriptTestRunner.Default.ExecuteFixture(fixture: "CompilationWarning", "--no-cache");
Assert.True(string.IsNullOrWhiteSpace(result.StandardOut));
Assert.Contains("CS1998", result.StandardError, StringComparison.OrdinalIgnoreCase);
Assert.Contains("CS0162", result.StandardError, StringComparison.OrdinalIgnoreCase);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
public async Task Foo()
using System;

public void Foo()
{
return;
Console.WriteLine("This is unreachable code.");
}
2 changes: 1 addition & 1 deletion src/Dotnet.Script/Dotnet.Script.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<AssemblyOriginatorKeyFile>../dotnet-script.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0-2.final" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.0" Condition="'$(TargetFramework)' == 'net10.0'" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.0" Condition="'$(TargetFramework)' == 'net9.0'" />
Expand Down
Loading