Skip to content

Commit

Permalink
Upgrade AsyncGenerator to 0.17.1 (#2182)
Browse files Browse the repository at this point in the history
* Use .NET Core for async generation
* Add packages.csproj for AsyncGenerator to avoid using nuget
  • Loading branch information
maca88 authored and fredericDelaporte committed Sep 29, 2019
1 parent 2c53c34 commit 01effc3
Show file tree
Hide file tree
Showing 23 changed files with 192 additions and 193 deletions.
4 changes: 2 additions & 2 deletions ReleaseProcedure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ These are the tasks typically needed to create an official NHibernate release.
that is about to happen (as these will show in the milestone).

* Create a draft release in Github with GitReleaseManager. If you have used
the NHibernate build menu, it should be available in Tools\gitreleasemanage.x.x.x\
the NHibernate build menu, it should be available in Tools\gitreleasemanager\x.x.x\
(change x.x.x by its current version in tools).
By example:

Tools\gitreleasemanager.0.7.0\tools\GitReleaseManager.exe create -o nhibernate -r nhibernate-core -m 5.1 -u username -p password
Tools\gitreleasemanager\0.7.0\tools\GitReleaseManager.exe create -o nhibernate -r nhibernate-core -m 5.1 -u username -p password

(Adjust the -m milestone parameter above, and add "-c branchname" if
releasing another branch than master)
Expand Down
7 changes: 6 additions & 1 deletion ShowBuildMenu.bat
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
@echo off
pushd %~dp0

for /f "tokens=* USEBACKQ delims= " %%i in (`findstr /c:"NUnit.Console" "Tools\packages.csproj"`) do set NUNIT_VERSION=%%i
set NUNIT_VERSION=%NUNIT_VERSION:~51%
set NUNIT_VERSION=%NUNIT_VERSION:" />=%

set NANT="%~dp0Tools\nant\bin\NAnt.exe" -t:net-4.0
set BUILD_TOOL_PATH=%~dp0Tools\BuildTool\bin\BuildTool.dll
set BUILDTOOL=dotnet %BUILD_TOOL_PATH%
set AVAILABLE_CONFIGURATIONS=%~dp0available-test-configurations
set CURRENT_CONFIGURATION=%~dp0current-test-configuration
set NUNIT="%~dp0Tools\NUnit.ConsoleRunner.3.10.0\tools\nunit3-console.exe"
set NUNIT="%~dp0Tools\NUnit.ConsoleRunner\%NUNIT_VERSION%\tools\nunit3-console.exe"

if not exist %BUILD_TOOL_PATH% (
pushd %~dp0Tools\BuildTool
Expand Down Expand Up @@ -184,6 +188,7 @@ SET NUNITPLATFORM=
goto test-run

:test-run
%NANT% common.tools-restore
start "nunit3-console" cmd /K %NUNIT% %NUNITPLATFORM% --agents=1 NHibernate.nunit
goto main-menu

Expand Down
25 changes: 7 additions & 18 deletions ShowBuildMenu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ LIB_FILES2=""
CURRENT_CONFIGURATION="./current-test-configuration"
OPTION=0
async_generator_path=""
async_generator_version=""

if [ ! -f $BUILD_TOOL_PATH ]
then
Expand Down Expand Up @@ -177,11 +178,11 @@ testRun(){
}

generateAsync(){
dotnet msbuild /t:Restore ./src/NHibernate.sln
dotnet restore ./src/NHibernate.sln

getAsyncGeneratorPath
cd src
mono ../"$async_generator_path"
dotnet ../"$async_generator_path"
cd ..

mainMenu
Expand All @@ -195,27 +196,15 @@ getAsyncGeneratorPath(){

cd Tools

if [ ! -f nuget.exe ]
then
wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
fi

async_generator_path="CSharpAsyncGenerator.CommandLine.$(cat packages.config | grep id=\"CSharpAsyncGenerator.CommandLine | cut -d\" -f4)/tools"
async_generator_version="$(cat packages.csproj | grep Include=\"CSharpAsyncGenerator.CommandLine | cut -d\" -f4)"
async_generator_path="csharpasyncgenerator.commandline/$async_generator_version/tools"

if [ ! -d $async_generator_path ]
then
mono nuget.exe install
dotnet restore "./packages.csproj" --packages .
fi

if [ ! -f $async_generator_path/SQLitePCLRaw.core.dll ]
then
# This "hidden" dependency causes a failure under some Mono setup, add it explicitly
mono nuget.exe install SQLitePCLRaw.core -Version 1.0.0
cp SQLitePCLRaw.core.1.0.0/lib/net45/SQLitePCLRaw.core.dll $async_generator_path/
fi

async_generator_path="Tools/$async_generator_path/AsyncGenerator.CommandLine.exe"

async_generator_path="Tools/$async_generator_path/netcoreapp2.1/AsyncGenerator.CommandLine.dll"
cd ..
}

Expand Down
11 changes: 6 additions & 5 deletions Tools/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
nuget.exe
NUnit.*
vswhere.*
CSharpAsyncGenerator.CommandLine.*
gitreleasemanager.*
SQLitePCLRaw.core.*
nunit.*
vswhere/
csharpasyncgenerator.commandline/
gitreleasemanager/
obj/
microsoft.*
2 changes: 1 addition & 1 deletion Tools/actual_msbuild.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off

for /f "usebackq tokens=*" %%i in (`%~dp0\vswhere.2.1.4\tools\vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
for /f "usebackq tokens=*" %%i in (`%~dp0\vswhere\2.1.4\tools\vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set InstallDir=%%i
)

Expand Down
13 changes: 0 additions & 13 deletions Tools/packages.config

This file was deleted.

20 changes: 20 additions & 0 deletions Tools/packages.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Remove="**\*" />
<EmbeddedResource Remove="**\*" />
<None Remove="**\*" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CSharpAsyncGenerator.CommandLine" Version="0.17.1" />
<PackageReference Include="vswhere" Version="2.1.4" />
<PackageReference Include="NUnit.Console" Version="3.10.0" />
<PackageReference Include="GitReleaseManager" Version="0.7.0" />
</ItemGroup>

</Project>
8 changes: 4 additions & 4 deletions build-common/common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
/>
</target>

<target name="common.nuget-restore" depends="common.init common.download-nuget">
<exec basedir="${tools.dir}" workingdir="${root.dir}/Tools" program="NuGet.exe">
<arg value="install" />
</exec>
<target name="common.tools-restore" depends="common.init">
<exec workingdir="${root.dir}/Tools" program="dotnet" verbose="true">
<arg line="restore ./packages.csproj --packages ." />
</exec>
</target>

</project>
32 changes: 16 additions & 16 deletions default.build
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,32 @@
</exec>
</target>

<target name="solution-restore" depends="common.nuget-restore">
<target name="solution-restore" depends="common.tools-restore">
<exec program="dotnet" verbose="true">
<arg value="msbuild" />
<arg value="/t:Restore" />
<arg value="${root.dir}/src/NHibernate.sln" />
</exec>
</target>

<target name="get-nuget-package-path" depends="common.nuget-restore">
<target name="get-tool-info" depends="common.tools-restore">
<xmlpeek
file="${tools.dir}/packages.config"
xpath="/packages/package[@id = '${nuget-package-id}']/@version"
property="nuget-package-version" />
<property name="nuget-package-path" value="${tools.dir}/${nuget-package-id}.${nuget-package-version}/" />
file="${tools.dir}/packages.csproj"
xpath="/Project/ItemGroup/PackageReference[@Include = '${tool.id}']/@Version"
property="tool.version" />
<property name="tool.path" value="${tools.dir}/${tool.id}/${tool.version}/" />
</target>

<target name="find-async-generator-console">
<property name="nuget-package-id" value="CSharpAsyncGenerator.CommandLine" />
<call target="get-nuget-package-path" />
<property name="async-generator-console" value="${nuget-package-path}/tools/AsyncGenerator.CommandLine.exe" />
<property name="tool.id" value="CSharpAsyncGenerator.CommandLine" />
<call target="get-tool-info" />
<property name="async-generator-console" value="${tool.path}tools/netcoreapp2.1/AsyncGenerator.CommandLine.dll" />
</target>

<target name="generate-async" depends="common.nuget-restore solution-restore find-async-generator-console">
<exec
workingdir="${root.dir}/src"
program="${async-generator-console}" />
<target name="generate-async" depends="solution-restore find-async-generator-console">
<exec workingdir="${root.dir}/src" program="dotnet" verbose="true">
<arg line=".${async-generator-console}" />
</exec>
</target>

<target name="put-connection-settings-into-defined-app-config">
Expand Down Expand Up @@ -150,9 +150,9 @@
</target>

<target name="find-nunit">
<property name="nuget-package-id" value="NUnit.ConsoleRunner" />
<call target="get-nuget-package-path" />
<property name="nunit-console" value="${nuget-package-path}/tools/nunit3-console.exe" />
<property name="tool.id" value="NUnit.Console" />
<call target="get-tool-info" />
<property name="nunit-console" value="${tools.dir}/NUnit.ConsoleRunner/${tool.version}/tools/nunit3-console.exe" />
</target>

<target name="run-tests" depends="find-nunit" description="Run NUnit tests">
Expand Down
2 changes: 1 addition & 1 deletion doc/documentation.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<property name="root.dir" value=".." />
<include buildfile="${root.dir}/build-common/common.xml" />

<target name="init" depends="common.init common.nuget-restore">
<target name="init" depends="common.init common.tools-restore">
<property name="doc.out.dir" value="${build.dir}/doc" />
<property name="doc.help2.out.dir" value="${doc.out.dir}/help2" />
<property name="doc.chm.out.dir" value="${doc.out.dir}" />
Expand Down
13 changes: 10 additions & 3 deletions src/AsyncGenerator.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
projects:
- filePath: NHibernate/NHibernate.csproj
targetFramework: net461
targetFramework: netcoreapp2.0
concurrentRun: true
applyChanges: true
suppressDiagnosticFailures:
- pattern: ^.*(Hql\.g).*$
analyzation:
methodConversion:
- conversion: Ignore
Expand Down Expand Up @@ -166,17 +168,21 @@
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
assemblyName: AsyncGenerator.Core
- filePath: NHibernate.DomainModel/NHibernate.DomainModel.csproj
targetFramework: net461
targetFramework: netcoreapp2.0
concurrentRun: true
applyChanges: true
suppressDiagnosticFailures:
- pattern: ^.*(Hql\.g).*$
analyzation:
scanMethodBody: true
scanForMissingAsyncMembers:
- all: true
- filePath: NHibernate.Test/NHibernate.Test.csproj
targetFramework: net461
targetFramework: netcoreapp2.0
concurrentRun: true
applyChanges: true
suppressDiagnosticFailures:
- pattern: ^.*(Hql\.g).*$
analyzation:
methodConversion:
- conversion: Copy
Expand All @@ -198,6 +204,7 @@
rule: IsTestCase
- conversion: Ignore
anyBaseTypeRule: IsTestCase
executionPhase: PostProviders
ignoreDocuments:
- filePathEndsWith: Linq/MathTests.cs
- filePathEndsWith: Linq/ExpressionSessionLeakTest.cs
Expand Down
10 changes: 6 additions & 4 deletions src/NHibernate.Test/Ado/BatcherFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,14 @@ public void OneRoundTripUpdate()
Cleanup();
}

#if NETFX
[Test, Ignore("Not fixed yet.")]
[Test, Ignore("Not fixed yet."), NetFxOnly]
[Description("SqlClient: The batcher should run all different INSERT queries in only one roundtrip.")]
public void SqlClientOneRoundTripForUpdateAndInsert()
{
#if NETFX
if (Sfi.Settings.BatcherFactory is SqlClientBatchingBatcherFactory == false)
Assert.Ignore("This test is for SqlClientBatchingBatcher only");
#endif

FillDb();

Expand Down Expand Up @@ -129,12 +130,14 @@ public void SqlClientOneRoundTripForUpdateAndInsert()
Cleanup();
}

[Test]
[Test, NetFxOnly]
[Description("SqlClient: The batcher log output should be formatted")]
public void BatchedoutputShouldBeFormatted()
{
#if NETFX
if (Sfi.Settings.BatcherFactory is SqlClientBatchingBatcherFactory == false)
Assert.Ignore("This test is for SqlClientBatchingBatcher only");
#endif

using (var sqlLog = new SqlLogSpy())
{
Expand All @@ -145,7 +148,6 @@ public void BatchedoutputShouldBeFormatted()

Cleanup();
}
#endif

[Test]
[Description("The batcher should run all DELETE queries in only one roundtrip.")]
Expand Down
7 changes: 3 additions & 4 deletions src/NHibernate.Test/Async/Ado/BatcherFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ public async Task OneRoundTripUpdateAsync()
await (CleanupAsync());
}

#if NETFX

[Test]
[Test, NetFxOnly]
[Description("SqlClient: The batcher log output should be formatted")]
public async Task BatchedoutputShouldBeFormattedAsync()
{
#if NETFX
if (Sfi.Settings.BatcherFactory is SqlClientBatchingBatcherFactory == false)
Assert.Ignore("This test is for SqlClientBatchingBatcher only");
#endif

using (var sqlLog = new SqlLogSpy())
{
Expand All @@ -120,7 +120,6 @@ public async Task BatchedoutputShouldBeFormattedAsync()

await (CleanupAsync());
}
#endif

[Test]
[Description("The batcher should run all DELETE queries in only one roundtrip.")]
Expand Down
6 changes: 3 additions & 3 deletions src/NHibernate.Test/Async/NHSpecificTest/GH1547/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ public async Task LinqWithListParameterPerfAsync()
{
var query = queryFactory(session);
// Warm up.
await (RunBenchmarkUnitAsync(cache, query));
await (RunBenchmarkUnitAsync(cache, query, cancellationToken));

for (var j = 0; j < 1000; j++)
{
sw.Restart();
await (RunBenchmarkUnitAsync(cache, query));
await (RunBenchmarkUnitAsync(cache, query, cancellationToken));
sw.Stop();
timings.Add(sw.Elapsed.TotalMilliseconds);
}
Expand All @@ -122,7 +122,7 @@ public async Task LinqWithListParameterPerfAsync()
$"{test} average time: {avg}ms (s {Math.Sqrt(timings.Sum(t => Math.Pow(t - avg, 2)) / (timings.Count - 1))}ms)");
}

private static Task RunBenchmarkUnitAsync<T>(SoftLimitMRUCache cache, IQueryable<T> query)
private static Task RunBenchmarkUnitAsync<T>(SoftLimitMRUCache cache, IQueryable<T> query, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override Task<object> GetAsync(object key, CancellationToken cancellation
var fmt = new BinaryFormatter
{
#if !NETFX
SurrogateSelector = new SerializationHelper.SurrogateSelector()
SurrogateSelector = new SerializationHelper.SurrogateSelector()
#endif
};
using (var stream = new MemoryStream(entry))
Expand All @@ -55,7 +55,7 @@ public override Task PutAsync(object key, object value, CancellationToken cancel
var fmt = new BinaryFormatter
{
#if !NETFX
SurrogateSelector = new SerializationHelper.SurrogateSelector()
SurrogateSelector = new SerializationHelper.SurrogateSelector()
#endif
};
using (var stream = new MemoryStream())
Expand Down
Loading

0 comments on commit 01effc3

Please sign in to comment.