Skip to content

Commit

Permalink
Support for .NET SDK 9
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov committed Nov 7, 2024
2 parents a2848db + 58e7a87 commit 002b66f
Show file tree
Hide file tree
Showing 22 changed files with 961 additions and 1,677 deletions.
2 changes: 1 addition & 1 deletion Build/Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>$(Framework)</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
24 changes: 18 additions & 6 deletions Build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
const string packageId = "CSharpInteractive";
const string toolPackageId = "dotnet-csi";
const string templatesPackageId = "CSharpInteractive.Templates";
var frameworks = new[] {"net6.0", "net7.0", "net8.0", "net9.0"};

var currentDir = Environment.CurrentDirectory;
if (!File.Exists(solutionFile))
Expand Down Expand Up @@ -40,6 +39,19 @@

Info(packageVersion.ToString());

const int minSdk = 6;
var maxSdk = minSdk;
new DotNet().WithVersion(true)
.Run(output => maxSdk = NuGetVersion.Parse(output.Line).Major)
.EnsureSuccess();

var allFrameworks = Enumerable.Range(6, maxSdk - minSdk + 1).Select(i => $"net{i}.0").ToArray();
var frameworks = string.Join(";", allFrameworks);
var framework = $"net{maxSdk}.0";

Info($"frameworks: {frameworks}");
Info($"framework: {framework}");

var packages = new[]
{
new PackageInfo(
Expand Down Expand Up @@ -226,9 +238,9 @@
.AddSources(templateOutputDir)
.Run().EnsureSuccess();

foreach (var framework in frameworks)
foreach (var checkingFramework in allFrameworks)
{
CheckCompatibilityAsync(framework, packageVersion, defaultNuGetSource, outputDir);
CheckCompatibilityAsync(checkingFramework, packageVersion, defaultNuGetSource, outputDir);
}

if (!skipTests && (integrationTests || dockerLinuxTests))
Expand Down Expand Up @@ -263,7 +275,7 @@
return 0;

void CheckCompatibilityAsync(
string framework,
string checkingFramework,
NuGetVersion nuGetVersion,
string nuGetSource,
string output)
Expand All @@ -276,7 +288,7 @@ void CheckCompatibilityAsync(
new DotNetNew()
.WithTemplateName("build")
.WithNoRestore(true)
.WithArgs($"--version={nuGetVersion}", "-T", framework)
.WithArgs($"--version={nuGetVersion}", "-T", checkingFramework)
.WithWorkingDirectory(buildProjectDir)
.Run().EnsureSuccess();

Expand All @@ -289,7 +301,7 @@ void CheckCompatibilityAsync(
.WithWorkingDirectory(buildProjectDir)
.WithNoRestore(true)
.WithNoBuild(true)
.WithFramework(framework)
.WithFramework(checkingFramework)
.Run().EnsureSuccess();

new DotNetCsi()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,21 @@ public static CommandLine AddProps(this CommandLine cmd, string propertyName, pa
// ReSharper disable once UnusedParameter.Global
public static string[] ToArgs<T>(this T value, string name, string collectionSeparator)
{
var valueStr = value?.ToString();
if (string.IsNullOrWhiteSpace(valueStr))
{
return [];
}

if (!string.IsNullOrWhiteSpace(collectionSeparator))
{
return [$"{name}{collectionSeparator}{value}"];
}

var valueStr = value?.ToString();
return string.IsNullOrWhiteSpace(valueStr) ? [] : [name, valueStr!];
return [name, valueStr!];
}

public static string[] ToArgs<T>(this IEnumerable<(string name, T value) > values, string name, string separator)
public static string[] ToArgs<T>(this IEnumerable<(string name, T value)> values, string name, string separator)
{
return values.SelectMany(i => new [] { name, $"{i.name}{separator}{i.value}"}).ToArray();
}
Expand Down
2 changes: 1 addition & 1 deletion CSharpInteractive.Tests/CSharpInteractive.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;$(Framework)</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<ImplicitUsings>enable</ImplicitUsings>
<DefineConstants>$(DefineConstants);PUREDI_API_SUPPRESSION</DefineConstants>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ public void ShouldSendBuildProblemWhenScripIsUncompleted()
result.ExitCode.ShouldBe(1);
result.StdErr.ShouldBeEmpty();
var messages = result.StdOut.ParseMessages();
messages.ShouldContainBuildProblem(i => i.Contains("; expected"), i => i.Contains("CS1002"));
messages.ShouldContainBuildProblem(i => i.Contains("script.csx(1,9): error CS1002"), i => i.Contains("CS1002"));
}
}
Loading

0 comments on commit 002b66f

Please sign in to comment.