Skip to content

Commit 237c802

Browse files
authored
Merge pull request #68 from skbkontur/add-net8-support
Add NET8 support, fix various tests on non-Windows platforms
2 parents 0232730 + 629202a commit 237c802

9 files changed

Lines changed: 43 additions & 34 deletions

File tree

AspNetCoreExample.Api/AspNetCoreExample.Api.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<LangVersion>latest</LangVersion>
@@ -13,8 +13,8 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.4" />
17-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
16+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0" />
17+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
1818
</ItemGroup>
1919

2020
</Project>

AspNetCoreExample.Generator/AspNetCoreExample.Generator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<OutputType>Exe</OutputType>
66
<Nullable>enable</Nullable>
77
<ImplicitUsings>enable</ImplicitUsings>

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
</PropertyGroup>
2020

2121
<ItemGroup>
22-
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.128" PrivateAssets="All" />
23-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
22+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" PrivateAssets="All" />
23+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
2424
</ItemGroup>
2525

2626
</Project>

TypeScript.ContractGenerator.Cli/TypeScript.ContractGenerator.Cli.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net7.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<AssemblyName>SkbKontur.TypeScript.ContractGenerator.Cli</AssemblyName>
77
<RootNamespace>SkbKontur.TypeScript.ContractGenerator.Cli</RootNamespace>
88
<PackageId>SkbKontur.TypeScript.ContractGenerator.Cli</PackageId>

TypeScript.ContractGenerator.Roslyn/TypeScript.ContractGenerator.Roslyn.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.7.0" />
15+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
1616
</ItemGroup>
1717

1818
</Project>

TypeScript.ContractGenerator.Tests/CliTest.cs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ public class CliTest
1313
[Test]
1414
public void CliGenerated()
1515
{
16-
RunCmdCommand($"dotnet {pathToSlnDirectory}/TypeScript.ContractGenerator.Cli/bin/{configuration}/net7.0/SkbKontur.TypeScript.ContractGenerator.Cli.dll " +
17-
$"-a {pathToSlnDirectory}/AspNetCoreExample.Api/bin/{configuration}/net7.0/AspNetCoreExample.Api.dll " +
18-
$"-o {TestContext.CurrentContext.TestDirectory}/cliOutput " +
19-
"--nullabilityMode NullableReference " +
20-
"--lintMode TsLint");
16+
RunDotnetCommand($"{pathToSlnDirectory}/TypeScript.ContractGenerator.Cli/bin/{configuration}/{targetFramework}/SkbKontur.TypeScript.ContractGenerator.Cli.dll " +
17+
$"-a {pathToSlnDirectory}/AspNetCoreExample.Api/bin/{configuration}/{targetFramework}/AspNetCoreExample.Api.dll " +
18+
$"-o {TestContext.CurrentContext.TestDirectory}/cliOutput " +
19+
"--nullabilityMode NullableReference " +
20+
"--lintMode TsLint");
2121

2222
var expectedDirectory = $"{pathToSlnDirectory}/AspNetCoreExample.Generator/output";
2323
var actualDirectory = $"{TestContext.CurrentContext.TestDirectory}/cliOutput";
@@ -27,40 +27,47 @@ public void CliGenerated()
2727
[Test]
2828
public void RoslynCliGenerated()
2929
{
30-
RunCmdCommand($"dotnet {pathToSlnDirectory}/TypeScript.ContractGenerator.Cli/bin/{configuration}/net7.0/SkbKontur.TypeScript.ContractGenerator.Cli.dll " +
31-
$"-d {pathToSlnDirectory}/AspNetCoreExample.Api " +
32-
$"-a {typeof(ControllerBase).Assembly.Location} " +
33-
$"-o {TestContext.CurrentContext.TestDirectory}/roslynCliOutput " +
34-
"--nullabilityMode NullableReference " +
35-
"--lintMode TsLint");
30+
RunDotnetCommand($"{pathToSlnDirectory}/TypeScript.ContractGenerator.Cli/bin/{configuration}/{targetFramework}/SkbKontur.TypeScript.ContractGenerator.Cli.dll " +
31+
$"-d {pathToSlnDirectory}/AspNetCoreExample.Api " +
32+
$"-a {typeof(ControllerBase).Assembly.Location} " +
33+
$"-o {TestContext.CurrentContext.TestDirectory}/roslynCliOutput " +
34+
"--nullabilityMode NullableReference " +
35+
"--lintMode TsLint");
3636

3737
var expectedDirectory = $"{pathToSlnDirectory}/AspNetCoreExample.Generator/output";
3838
var actualDirectory = $"{TestContext.CurrentContext.TestDirectory}/roslynCliOutput";
3939
TestBase.CheckDirectoriesEquivalenceInner(expectedDirectory, actualDirectory, generatedOnly : true);
4040
}
4141

42-
private static void RunCmdCommand(string command)
42+
private static void RunDotnetCommand(string command)
4343
{
4444
var process = new Process
4545
{
46-
StartInfo =
46+
StartInfo = new ProcessStartInfo("dotnet", command)
4747
{
48-
FileName = "cmd.exe",
4948
WindowStyle = ProcessWindowStyle.Hidden,
50-
Arguments = "/C " + command,
51-
}
49+
RedirectStandardOutput = true,
50+
RedirectStandardError = true,
51+
UseShellExecute = false
52+
},
5253
};
54+
5355
process.Start();
5456
process.WaitForExit();
57+
5558
process.ExitCode.Should().Be(0);
59+
process.StandardOutput.ReadToEnd().Trim().Should().Be("Generating TypeScript");
60+
process.StandardError.ReadToEnd().Trim().Should().BeEmpty();
5661
}
5762

5863
private static readonly string pathToSlnDirectory = $"{TestContext.CurrentContext.TestDirectory}/../../../../";
5964

65+
private const string targetFramework = "net8.0";
66+
6067
#if RELEASE
61-
const string configuration = "Release";
68+
private const string configuration = "Release";
6269
#elif DEBUG
63-
const string configuration = "Debug";
70+
private const string configuration = "Debug";
6471
#endif
6572
}
6673
}

TypeScript.ContractGenerator.Tests/CustomTypeGenerators/SimpleStructureTypeLocator.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System.IO;
2+
13
using SkbKontur.TypeScript.ContractGenerator.Abstractions;
24
using SkbKontur.TypeScript.ContractGenerator.CodeDom;
35
using SkbKontur.TypeScript.ContractGenerator.TypeBuilders;
@@ -8,7 +10,7 @@ public class SimpleStructureTypeLocator : ICustomTypeGenerator
810
{
911
public string GetTypeLocation(ITypeInfo type)
1012
{
11-
return $"{type.Name}\\{type.Name}";
13+
return $"{type.Name}{Path.DirectorySeparatorChar}{type.Name}";
1214
}
1315

1416
public ITypeBuildingContext? ResolveType(string initialUnitPath, ITypeGenerator typeGenerator, ITypeInfo type, ITypeScriptUnitFactory unitFactory)

TypeScript.ContractGenerator.Tests/TypeScript.ContractGenerator.Tests.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net48;net6.0;net7.0</TargetFrameworks>
4+
<TargetFrameworks>net48;net6.0;net8.0</TargetFrameworks>
55
<AssemblyName>SkbKontur.TypeScript.ContractGenerator.Tests</AssemblyName>
66
<RootNamespace>SkbKontur.TypeScript.ContractGenerator.Tests</RootNamespace>
77
</PropertyGroup>
@@ -11,12 +11,12 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="DiffPlex" Version="1.7.1" />
15-
<PackageReference Include="FluentAssertions" Version="6.11.0" />
14+
<PackageReference Include="DiffPlex" Version="1.7.2" />
15+
<PackageReference Include="FluentAssertions" Version="6.12.0" />
1616
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.3" />
17-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
18-
<PackageReference Include="NUnit" Version="3.13.3" />
19-
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
18+
<PackageReference Include="NUnit" Version="3.14.0" />
19+
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
2020
</ItemGroup>
2121

2222
<ItemGroup>

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "7.0.0",
3+
"version": "8.0.0",
44
"rollForward": "latestFeature"
55
}
66
}

0 commit comments

Comments
 (0)