Skip to content

Commit

Permalink
Migrate to netstandard2.0 (#17) (#18)
Browse files Browse the repository at this point in the history
* Migrate to netstandard2.0

* Add non-async methods to backward compatibility

Update Cake to 0.28.0 version for build

* Update Cake.FileHelpers to 3.1.0

* Fix nuget package generation

* Delete temporary file

* Remove redundant code
  • Loading branch information
wozzo committed Oct 2, 2018
1 parent 1b110a9 commit 3d14795
Show file tree
Hide file tree
Showing 18 changed files with 121 additions and 126 deletions.
2 changes: 1 addition & 1 deletion docs-prep.cake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#addin nuget:?package=Cake.FileHelpers&version=2.0.0
#addin nuget:?package=Cake.FileHelpers&version=3.1.0

Task("Copy-Readme-For-Docs")
.WithCriteria(() => FileExists("README.md"))
Expand Down
4 changes: 2 additions & 2 deletions nuspec/nuget/Cake.Graph.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<tags>Cake Script Build Graph Nodes Dependencies Tasks</tags>
</metadata>
<files>
<file src="net46\Cake.Graph.dll" target="lib\net46" />
<file src="net46\Cake.Graph.pdb" target="lib\net46" />
<file src="netstandard2.0\Cake.Graph.dll" target="lib\netstandard2.0" />
<file src="netstandard2.0\Cake.Graph.pdb" target="lib\netstandard2.0" />
</files>
</package>
62 changes: 24 additions & 38 deletions src/Cake.Graph.Tests/Cake.Graph.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,60 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\packages\xunit.core.2.3.1\build\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.3.1\build\xunit.core.props')" />
<PropertyGroup>
<TargetFramework>net46</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net46|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp2.0|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net46|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netcoreapp2.0|AnyCPU'">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net46'">
<PackageReference Include="AutoFixture" version="4.0.1" />
<PackageReference Include="Cake.Core" version="0.28.0" PrivateAssets="All" />
<PackageReference Include="Castle.Core" version="4.2.1" />
<PackageReference Include="Microsoft.AspNet.Razor" version="3.2.3" />
<PackageReference Include="Moq" version="4.8.1" />
<PackageReference Include="RazorEngine" version="3.10.0" />
<PackageReference Include="Shouldly" version="3.0.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" version="4.3.0" />
<PackageReference Include="System.ValueTuple" version="4.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" version="15.6.2" />
<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.0.1" />
<PackageReference Include="Cake.Core" Version="0.30.0" PrivateAssets="All" />
<PackageReference Include="Castle.Core" Version="4.2.1" />
<PackageReference Include="Microsoft.AspNet.Razor" Version="3.2.3" />
<PackageReference Include="Moq" Version="4.8.1" />
<PackageReference Include="RazorEngine" Version="3.10.0" />
<PackageReference Include="Shouldly" Version="3.0.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.3.0" />
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.2" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
<PackageReference Include="xunit" version="2.3.1" />
<PackageReference Include="xunit.runner.console" version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" version="2.3.1" />
<PackageReference Include="xunit.abstractions" version="2.0.1" />
<PackageReference Include="xunit.analyzers" version="0.8.0" />
<PackageReference Include="xunit.assert" version="2.3.1" />
<PackageReference Include="xunit.core" version="2.3.1" />
<PackageReference Include="xunit.extensibility.core" version="2.3.1" />
<PackageReference Include="xunit.extensibility.execution" version="2.3.1" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.console" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit.abstractions" Version="2.0.1" />
<PackageReference Include="xunit.analyzers" Version="0.8.0" />
<PackageReference Include="xunit.assert" Version="2.3.1" />
<PackageReference Include="xunit.core" Version="2.3.1" />
<PackageReference Include="xunit.extensibility.core" Version="2.3.1" />
<PackageReference Include="xunit.extensibility.execution" Version="2.3.1" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Data\index.cshtml" />
Expand Down
5 changes: 3 additions & 2 deletions src/Cake.Graph.Tests/GraphGeneratorTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Cake.Core;
using Cake.Graph.Generators;
using Shouldly;
Expand All @@ -25,11 +26,11 @@ public GraphGeneratorTests()
[InlineData(typeof(MermaidHtmlGenerator), TestHelpers.TaskCMermaidPattern)]
[InlineData(typeof(CytoscapeHtmlGenerator), TestHelpers.TaskCCytoscapePattern)]
[InlineData(typeof(CytoscapeWyamGenerator), TestHelpers.TaskCCytoscapePattern)]
public void Serializes_Tasks_With_Dependencies_Correctly(Type generatorType, string expectedResult)
public async Task Serializes_Tasks_With_Dependencies_Correctly(Type generatorType, string expectedResult)
{
var mockContext = TestHelpers.GetMockCakeContext();
var graphGenerator = (ITaskGraphGenerator)Activator.CreateInstance(generatorType);
var result = graphGenerator.Serialize(mockContext.Object, taskC, tasks);
var result = await graphGenerator.SerializeAsync(mockContext.Object, taskC, tasks);
result.ShouldMatch(expectedResult);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Graph.Tests/GraphRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void Deploy_Creates_Files_For_Each_Task()
var tasks = TestHelpers.CreateTasksWithDependencies();

var emptyGenerator = TestHelpers.GetEmptyTaskGraphGenerator();
cakeContext.Object.Graph(tasks).Deploy(s => s
cakeContext.Object.Graph(tasks).DeployAsync(s => s
.WithCustomGenerator(emptyGenerator)
.SetOutputPath(outputPath)
);
Expand Down
7 changes: 4 additions & 3 deletions src/Cake.Graph.Tests/GraphTemplateManagerTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Reflection;
using System.Threading.Tasks;
using Cake.Graph.Templates;
using Shouldly;
using Xunit;
Expand All @@ -16,12 +17,12 @@ public class GraphTemplateManagerTests
});

[Fact]
public void Manager_Parses_Razor_Template()
public async Task Manager_Parses_Razor_Template()
{
const string test = "test";
var graphTemplateManager = new GraphTemplateManager(graphTemplateRepository);
var result = graphTemplateManager.ParseTemplate(TemplateTypes.Cytoscape, test);
result = graphTemplateManager.ParseTemplate(TemplateTypes.Cytoscape, test);
var result = await graphTemplateManager.ParseTemplateAsync(TemplateTypes.Cytoscape, test);
result = await graphTemplateManager.ParseTemplateAsync(TemplateTypes.Cytoscape, test);

result.ShouldBe(GraphTemplateRepositoryTests.TestFileContent.Replace("@Model", test));
}
Expand Down
5 changes: 3 additions & 2 deletions src/Cake.Graph.Tests/TestHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Graph.Generators;
Expand All @@ -24,9 +25,9 @@ public static ITaskGraphGenerator GetEmptyTaskGraphGenerator()
mockTaskGraphGenerator
.Setup(x => x.Extension)
.Returns("test");
mockTaskGraphGenerator.Setup(x => x.Serialize(It.IsAny<ICakeContext>(), It.IsAny<ICakeTaskInfo>(),
mockTaskGraphGenerator.Setup(x => x.SerializeAsync(It.IsAny<ICakeContext>(), It.IsAny<ICakeTaskInfo>(),
It.IsAny<IReadOnlyList<ICakeTaskInfo>>()))
.Returns((ICakeContext context, ICakeTaskInfo task, IReadOnlyList<ICakeTaskInfo> tasks) => "");
.Returns((ICakeContext context, ICakeTaskInfo task, IReadOnlyList<ICakeTaskInfo> tasks) => Task.FromResult(""));

return mockTaskGraphGenerator.Object;
}
Expand Down
33 changes: 11 additions & 22 deletions src/Cake.Graph/Cake.Graph.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net46</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net46|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
Expand All @@ -13,7 +14,7 @@
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Cake.Graph.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net46|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
Expand All @@ -27,24 +28,12 @@
<EmbeddedResource Include="Content\cytoscapewyam.cshtml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Cake.Core" version="0.28.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNet.Mvc" version="5.2.3" />
<PackageReference Include="Microsoft.AspNet.Razor" version="3.2.3" />
<PackageReference Include="Microsoft.AspNet.WebPages" version="3.2.3" />
<PackageReference Include="Microsoft.Web.Infrastructure" version="1.0.0.0" />
<PackageReference Include="Newtonsoft.Json" version="10.0.3" />
<PackageReference Include="RazorEngine" version="3.10.0" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<PackageReference Include="Cake.Core" Version="0.30.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.3" />
<PackageReference Include="Microsoft.AspNet.Razor" Version="3.2.3" />
<PackageReference Include="Microsoft.AspNet.WebPages" Version="3.2.3" />
<PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="RazorLight" Version="2.0.0-beta1" />
</ItemGroup>
</Project>
5 changes: 3 additions & 2 deletions src/Cake.Graph/Generators/CytoscapeGraphGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Cake.Core;
using Cake.Core.Diagnostics;
using Newtonsoft.Json;
Expand All @@ -18,12 +19,12 @@ public class CytoscapeGraphGenerator : ITaskGraphGenerator
/// <param name="task"></param>
/// <param name="tasks"></param>
/// <returns></returns>
public string Serialize(ICakeContext context, ICakeTaskInfo task, IReadOnlyList<ICakeTaskInfo> tasks)
public Task<string> SerializeAsync(ICakeContext context, ICakeTaskInfo task, IReadOnlyList<ICakeTaskInfo> tasks)
{
TaskGraphGeneratorHelpers.ValidateParameters(context, task, tasks);

var nodes = GetTaskGraphNodes(context, task, tasks);
return JsonConvert.SerializeObject(nodes);
return Task.FromResult(JsonConvert.SerializeObject(nodes));
}

/// <summary>
Expand Down
7 changes: 4 additions & 3 deletions src/Cake.Graph/Generators/CytoscapeHtmlGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Cake.Core;
using Cake.Graph.Models;
using Cake.Graph.Templates;
Expand Down Expand Up @@ -48,11 +49,11 @@ public CytoscapeHtmlGenerator(IGraphTemplateManager graphTemplateManager)
protected TemplateTypes templateType = TemplateTypes.Cytoscape;

/// <inheritdoc />
public string Serialize(ICakeContext context, ICakeTaskInfo task, IReadOnlyList<ICakeTaskInfo> tasks)
public async Task<string> SerializeAsync(ICakeContext context, ICakeTaskInfo task, IReadOnlyList<ICakeTaskInfo> tasks)
{
var graph = graphGenerator.Serialize(context, task, tasks);
var graph = await graphGenerator.SerializeAsync(context, task, tasks);
var model = new GraphHtmlModel(task.Name, CytoscapeJsSource, graph);
var html = graphTemplateManager.ParseTemplate(templateType, model);
var html = await graphTemplateManager.ParseTemplateAsync(templateType, model);
return html;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Cake.Graph/Generators/ITaskGraphGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Cake.Core;

namespace Cake.Graph.Generators
Expand All @@ -15,7 +16,7 @@ public interface ITaskGraphGenerator
/// <param name="task"></param>
/// <param name="tasks"></param>
/// <returns></returns>
string Serialize(ICakeContext context, ICakeTaskInfo task, IReadOnlyList<ICakeTaskInfo> tasks);
Task<string> SerializeAsync(ICakeContext context, ICakeTaskInfo task, IReadOnlyList<ICakeTaskInfo> tasks);
/// <summary>
/// The file extension to use for this type of graph file
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion src/Cake.Graph/Generators/MermaidGraphGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cake.Core;
using Cake.Core.Diagnostics;

Expand All @@ -24,7 +25,7 @@ public class MermaidGraphGenerator : ITaskGraphGenerator
/// <param name="task"></param>
/// <param name="tasks"></param>
/// <returns></returns>
public string Serialize(ICakeContext context, ICakeTaskInfo task, IReadOnlyList<ICakeTaskInfo> tasks)
public async Task<string> SerializeAsync(ICakeContext context, ICakeTaskInfo task, IReadOnlyList<ICakeTaskInfo> tasks)
{
TaskGraphGeneratorHelpers.ValidateParameters(context, task, tasks);

Expand Down
7 changes: 4 additions & 3 deletions src/Cake.Graph/Generators/MermaidHtmlGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Cake.Core;
using Cake.Graph.Models;
using Cake.Graph.Templates;
Expand Down Expand Up @@ -45,11 +46,11 @@ public MermaidHtmlGenerator(IGraphTemplateManager graphTemplateManager)
/// <param name="task"></param>
/// <param name="tasks"></param>
/// <returns></returns>
public string Serialize(ICakeContext context, ICakeTaskInfo task, IReadOnlyList<ICakeTaskInfo> tasks)
public async Task<string> SerializeAsync(ICakeContext context, ICakeTaskInfo task, IReadOnlyList<ICakeTaskInfo> tasks)
{
var graph = graphGenerator.Serialize(context, task, tasks);
var graph = await graphGenerator.SerializeAsync(context, task, tasks);
var model = new GraphHtmlModel(task.Name, MermaidJsSource, graph);
var html = graphTemplateManager.ParseTemplate(TemplateTypes.Mermaid, model);
var html = await graphTemplateManager.ParseTemplateAsync(TemplateTypes.Mermaid, model);
return html;
}
}
Expand Down

0 comments on commit 3d14795

Please sign in to comment.