Skip to content

Commit 01effc3

Browse files
maca88fredericDelaporte
authored andcommitted
Upgrade AsyncGenerator to 0.17.1 (nhibernate#2182)
* Use .NET Core for async generation * Add packages.csproj for AsyncGenerator to avoid using nuget
1 parent 2c53c34 commit 01effc3

23 files changed

+192
-193
lines changed

ReleaseProcedure.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ These are the tasks typically needed to create an official NHibernate release.
44
that is about to happen (as these will show in the milestone).
55

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

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

1313
(Adjust the -m milestone parameter above, and add "-c branchname" if
1414
releasing another branch than master)

ShowBuildMenu.bat

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
@echo off
22
pushd %~dp0
33

4+
for /f "tokens=* USEBACKQ delims= " %%i in (`findstr /c:"NUnit.Console" "Tools\packages.csproj"`) do set NUNIT_VERSION=%%i
5+
set NUNIT_VERSION=%NUNIT_VERSION:~51%
6+
set NUNIT_VERSION=%NUNIT_VERSION:" />=%
7+
48
set NANT="%~dp0Tools\nant\bin\NAnt.exe" -t:net-4.0
59
set BUILD_TOOL_PATH=%~dp0Tools\BuildTool\bin\BuildTool.dll
610
set BUILDTOOL=dotnet %BUILD_TOOL_PATH%
711
set AVAILABLE_CONFIGURATIONS=%~dp0available-test-configurations
812
set CURRENT_CONFIGURATION=%~dp0current-test-configuration
9-
set NUNIT="%~dp0Tools\NUnit.ConsoleRunner.3.10.0\tools\nunit3-console.exe"
13+
set NUNIT="%~dp0Tools\NUnit.ConsoleRunner\%NUNIT_VERSION%\tools\nunit3-console.exe"
1014

1115
if not exist %BUILD_TOOL_PATH% (
1216
pushd %~dp0Tools\BuildTool
@@ -184,6 +188,7 @@ SET NUNITPLATFORM=
184188
goto test-run
185189

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

ShowBuildMenu.sh

+7-18
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ LIB_FILES2=""
1212
CURRENT_CONFIGURATION="./current-test-configuration"
1313
OPTION=0
1414
async_generator_path=""
15+
async_generator_version=""
1516

1617
if [ ! -f $BUILD_TOOL_PATH ]
1718
then
@@ -177,11 +178,11 @@ testRun(){
177178
}
178179

179180
generateAsync(){
180-
dotnet msbuild /t:Restore ./src/NHibernate.sln
181+
dotnet restore ./src/NHibernate.sln
181182

182183
getAsyncGeneratorPath
183184
cd src
184-
mono ../"$async_generator_path"
185+
dotnet ../"$async_generator_path"
185186
cd ..
186187

187188
mainMenu
@@ -195,27 +196,15 @@ getAsyncGeneratorPath(){
195196

196197
cd Tools
197198

198-
if [ ! -f nuget.exe ]
199-
then
200-
wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
201-
fi
202-
203-
async_generator_path="CSharpAsyncGenerator.CommandLine.$(cat packages.config | grep id=\"CSharpAsyncGenerator.CommandLine | cut -d\" -f4)/tools"
199+
async_generator_version="$(cat packages.csproj | grep Include=\"CSharpAsyncGenerator.CommandLine | cut -d\" -f4)"
200+
async_generator_path="csharpasyncgenerator.commandline/$async_generator_version/tools"
204201

205202
if [ ! -d $async_generator_path ]
206203
then
207-
mono nuget.exe install
204+
dotnet restore "./packages.csproj" --packages .
208205
fi
209206

210-
if [ ! -f $async_generator_path/SQLitePCLRaw.core.dll ]
211-
then
212-
# This "hidden" dependency causes a failure under some Mono setup, add it explicitly
213-
mono nuget.exe install SQLitePCLRaw.core -Version 1.0.0
214-
cp SQLitePCLRaw.core.1.0.0/lib/net45/SQLitePCLRaw.core.dll $async_generator_path/
215-
fi
216-
217-
async_generator_path="Tools/$async_generator_path/AsyncGenerator.CommandLine.exe"
218-
207+
async_generator_path="Tools/$async_generator_path/netcoreapp2.1/AsyncGenerator.CommandLine.dll"
219208
cd ..
220209
}
221210

Tools/.gitignore

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
nuget.exe
2-
NUnit.*
3-
vswhere.*
4-
CSharpAsyncGenerator.CommandLine.*
5-
gitreleasemanager.*
6-
SQLitePCLRaw.core.*
2+
nunit.*
3+
vswhere/
4+
csharpasyncgenerator.commandline/
5+
gitreleasemanager/
6+
obj/
7+
microsoft.*

Tools/actual_msbuild.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@echo off
22

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

Tools/packages.config

-13
This file was deleted.

Tools/packages.csproj

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<Compile Remove="**\*" />
9+
<EmbeddedResource Remove="**\*" />
10+
<None Remove="**\*" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="CSharpAsyncGenerator.CommandLine" Version="0.17.1" />
15+
<PackageReference Include="vswhere" Version="2.1.4" />
16+
<PackageReference Include="NUnit.Console" Version="3.10.0" />
17+
<PackageReference Include="GitReleaseManager" Version="0.7.0" />
18+
</ItemGroup>
19+
20+
</Project>

build-common/common.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
/>
4040
</target>
4141

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

4848
</project>

default.build

+16-16
Original file line numberDiff line numberDiff line change
@@ -46,32 +46,32 @@
4646
</exec>
4747
</target>
4848

49-
<target name="solution-restore" depends="common.nuget-restore">
49+
<target name="solution-restore" depends="common.tools-restore">
5050
<exec program="dotnet" verbose="true">
5151
<arg value="msbuild" />
5252
<arg value="/t:Restore" />
5353
<arg value="${root.dir}/src/NHibernate.sln" />
5454
</exec>
5555
</target>
5656

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

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

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

7777
<target name="put-connection-settings-into-defined-app-config">
@@ -150,9 +150,9 @@
150150
</target>
151151

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

158158
<target name="run-tests" depends="find-nunit" description="Run NUnit tests">

doc/documentation.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<property name="root.dir" value=".." />
1010
<include buildfile="${root.dir}/build-common/common.xml" />
1111

12-
<target name="init" depends="common.init common.nuget-restore">
12+
<target name="init" depends="common.init common.tools-restore">
1313
<property name="doc.out.dir" value="${build.dir}/doc" />
1414
<property name="doc.help2.out.dir" value="${doc.out.dir}/help2" />
1515
<property name="doc.chm.out.dir" value="${doc.out.dir}" />

src/AsyncGenerator.yml

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
projects:
22
- filePath: NHibernate/NHibernate.csproj
3-
targetFramework: net461
3+
targetFramework: netcoreapp2.0
44
concurrentRun: true
55
applyChanges: true
6+
suppressDiagnosticFailures:
7+
- pattern: ^.*(Hql\.g).*$
68
analyzation:
79
methodConversion:
810
- conversion: Ignore
@@ -166,17 +168,21 @@
166168
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
167169
assemblyName: AsyncGenerator.Core
168170
- filePath: NHibernate.DomainModel/NHibernate.DomainModel.csproj
169-
targetFramework: net461
171+
targetFramework: netcoreapp2.0
170172
concurrentRun: true
171173
applyChanges: true
174+
suppressDiagnosticFailures:
175+
- pattern: ^.*(Hql\.g).*$
172176
analyzation:
173177
scanMethodBody: true
174178
scanForMissingAsyncMembers:
175179
- all: true
176180
- filePath: NHibernate.Test/NHibernate.Test.csproj
177-
targetFramework: net461
181+
targetFramework: netcoreapp2.0
178182
concurrentRun: true
179183
applyChanges: true
184+
suppressDiagnosticFailures:
185+
- pattern: ^.*(Hql\.g).*$
180186
analyzation:
181187
methodConversion:
182188
- conversion: Copy
@@ -198,6 +204,7 @@
198204
rule: IsTestCase
199205
- conversion: Ignore
200206
anyBaseTypeRule: IsTestCase
207+
executionPhase: PostProviders
201208
ignoreDocuments:
202209
- filePathEndsWith: Linq/MathTests.cs
203210
- filePathEndsWith: Linq/ExpressionSessionLeakTest.cs

src/NHibernate.Test/Ado/BatcherFixture.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,14 @@ public void OneRoundTripUpdate()
9090
Cleanup();
9191
}
9292

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

101102
FillDb();
102103

@@ -129,12 +130,14 @@ public void SqlClientOneRoundTripForUpdateAndInsert()
129130
Cleanup();
130131
}
131132

132-
[Test]
133+
[Test, NetFxOnly]
133134
[Description("SqlClient: The batcher log output should be formatted")]
134135
public void BatchedoutputShouldBeFormatted()
135136
{
137+
#if NETFX
136138
if (Sfi.Settings.BatcherFactory is SqlClientBatchingBatcherFactory == false)
137139
Assert.Ignore("This test is for SqlClientBatchingBatcher only");
140+
#endif
138141

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

146149
Cleanup();
147150
}
148-
#endif
149151

150152
[Test]
151153
[Description("The batcher should run all DELETE queries in only one roundtrip.")]

src/NHibernate.Test/Async/Ado/BatcherFixture.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ public async Task OneRoundTripUpdateAsync()
102102
await (CleanupAsync());
103103
}
104104

105-
#if NETFX
106-
107-
[Test]
105+
[Test, NetFxOnly]
108106
[Description("SqlClient: The batcher log output should be formatted")]
109107
public async Task BatchedoutputShouldBeFormattedAsync()
110108
{
109+
#if NETFX
111110
if (Sfi.Settings.BatcherFactory is SqlClientBatchingBatcherFactory == false)
112111
Assert.Ignore("This test is for SqlClientBatchingBatcher only");
112+
#endif
113113

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

121121
await (CleanupAsync());
122122
}
123-
#endif
124123

125124
[Test]
126125
[Description("The batcher should run all DELETE queries in only one roundtrip.")]

src/NHibernate.Test/Async/NHSpecificTest/GH1547/Fixture.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ public async Task LinqWithListParameterPerfAsync()
103103
{
104104
var query = queryFactory(session);
105105
// Warm up.
106-
await (RunBenchmarkUnitAsync(cache, query));
106+
await (RunBenchmarkUnitAsync(cache, query, cancellationToken));
107107

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

125-
private static Task RunBenchmarkUnitAsync<T>(SoftLimitMRUCache cache, IQueryable<T> query)
125+
private static Task RunBenchmarkUnitAsync<T>(SoftLimitMRUCache cache, IQueryable<T> query, CancellationToken cancellationToken = default(CancellationToken))
126126
{
127127
try
128128
{

src/NHibernate.Test/Async/NHSpecificTest/NH2898/BinaryFormatterCache.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public override Task<object> GetAsync(object key, CancellationToken cancellation
3434
var fmt = new BinaryFormatter
3535
{
3636
#if !NETFX
37-
SurrogateSelector = new SerializationHelper.SurrogateSelector()
37+
SurrogateSelector = new SerializationHelper.SurrogateSelector()
3838
#endif
3939
};
4040
using (var stream = new MemoryStream(entry))
@@ -55,7 +55,7 @@ public override Task PutAsync(object key, object value, CancellationToken cancel
5555
var fmt = new BinaryFormatter
5656
{
5757
#if !NETFX
58-
SurrogateSelector = new SerializationHelper.SurrogateSelector()
58+
SurrogateSelector = new SerializationHelper.SurrogateSelector()
5959
#endif
6060
};
6161
using (var stream = new MemoryStream())

0 commit comments

Comments
 (0)