Closed hazzik closed 2 years ago
Published version 0.20.0
which works also with .NET 6.
Having some issues converting NHibernate.Tests:
[exec] info: AsyncCodeGenerator[0]
[exec] Opening project 'C:\Projects\Private\nhibernate-core\src\NHibernate.Test\NHibernate.Test.csproj' started
[exec] warn: AsyncCodeGenerator[0]
[exec] One or more warnings occurred while opening the project:
[exec] Found project reference without a matching metadata reference: C:\Projects\Private\nhibernate-core\src\NHibernate\NHibernate.csproj
[exec] Found project reference without a matching metadata reference: C:\Projects\Private\nhibernate-core\src\NHibernate.DomainModel\NHibernate.DomainModel.csproj
[exec]
[exec] info: AsyncCodeGenerator[0]
[exec] Opening project 'C:\Projects\Private\nhibernate-core\src\NHibernate.Test\NHibernate.Test.csproj' completed
[exec] info: AsyncCodeGenerator[0]
[exec] Configuring project prior analyzation started
[exec] info: AsyncCodeGenerator[0]
[exec] Configuring project prior analyzation completed
[exec] info: AsyncCodeGenerator[0]
[exec] Compiling project 'NHibernate.Test' started
[exec] info: AsyncCodeGenerator[0]
[exec] Compiling project 'NHibernate.Test' completed
[exec] info: AsyncCodeGenerator[0]
[exec] Initializing registered plugins for project 'NHibernate.Test' started
[exec] crit: AsyncGenerator.CommandLine[0]
[exec] Unable to find NUnit.Framework.Assert type
[exec] System.InvalidOperationException: Unable to find NUnit.Framework.Assert type
[exec] at AsyncGenerator.Core.Plugins.NUnitPlugin.Initialize(Project project, IProjectConfiguration configuration, Compilation compilation) in C:\Workspace\Git\AsyncGenerator\Source\AsyncGenerator.Core\Plugins\NUnitPlugin.cs:line 61
[exec] at AsyncGenerator.AsyncCodeGenerator.GenerateProject(ProjectData projectData, ILoggerFactory loggerFactory, ILogger logger, CancellationToken cancellationToken) in C:\Workspace\Git\AsyncGenerator\Source\AsyncGenerator\AsyncCodeGenerator.cs:line 0
[exec] at AsyncGenerator.AsyncCodeGenerator.GenerateAsync(AsyncCodeConfiguration configuration, CancellationToken cancellationToken) in C:\Workspace\Git\AsyncGenerator\Source\AsyncGenerator\AsyncCodeGenerator.cs:line 84
[exec] at AsyncGenerator.CommandLine.Program.Main(String[] args) in C:\Workspace\Git\AsyncGenerator\Source\AsyncGenerator.CommandLine\Program.cs:line 51
I am able to get this error only on nhibernate/nhibernate-core/pull/2951 pull request. By removing netcoreapp2.0
from the NHibernate test project, the targetFramework
inside AsyncGenerator.yml
for the test project needs to be changed to either net6.0
or net461
. By changing it to net6.0
, I noticed that there is a bug with Assert.That
that I will fix tomorrow, for ignoring .NET 6 only methods, the following configuration can be added to the test project configuration:
ignoreSearchForAsyncCounterparts:
- name: Wait
containingTypeName: Task
- name: Prepare
containingTypeName: DbCommand
- name: Close
containingTypeName: DbConnection
- name: Close
containingTypeName: DbDataReader
Thanks
With the newly released version 0.20.1
the mentioned bug for Assert.That
method is fixed.
Hm.. Installing .NET 6 breaks async generation. I see the same exception as hazzik for master branch. So for master it seems 0.20.1 will solve the problem. What about 5.3 branch? Any workarounds? Trick with global.json no longer works for me with .NET 6 installed
Yea you are right, for some reason global.json
does not work for lower .NET Core versions anymore, even when using "rollForward": "disable"
. I was not able to find any workaround yet. For now, the easiest way to fix the issue would be to port nhibernate/nhibernate-core/pull/2605 in 5.3.x
branch. I tried to run 0.20.1
version on 5.3.x
branch and it does not produce any code changes.
Alternatively you can publish 0.18.3 version with MsBuildLocator restricted to .NET Core 2.1. So instead of:
Use something like:
var instance = MSBuildLocator.QueryVisualStudioInstances()
#if NETCOREAPP2_1
.Where(o => o.Version.Major == 2)
#endif
.OrderByDescending(o => o.Version)
.FirstOrDefault();
In Windows QueryVisualStudioInstances()
will return the installed Visual Studios, in my case I get two instances, one for VS2019 and one for VS2022. If VS2019 is selected, then the global.json
works and so the code generation. So basically this means that if a developer has only VS2022 installed, it won't work. Based on that, I still think that porting the mentioned PR is a better alternative, but if you disagree I can publish a new version with the proposed logic that would work also on Windows (if VS2019 is installed).
In Windows QueryVisualStudioInstances() will return the installed Visual Studios
Did you run it under .NET Core or NetFx? It seems true for NetFx only.
Here is example I run under .NET 6 on Windows with latest Microsoft.Build.Locator 1.4.1:
using Microsoft.Build.Locator;
var instance = MSBuildLocator.QueryVisualStudioInstances()
//.Where(o => o.Version.Major == 2)
.OrderByDescending(o => o.Version)
.ToList();
foreach (var i in instance)
{
Console.WriteLine(i.Version);
Console.WriteLine(i.MSBuildPath);
}
Output I see lists all .NET Core SDKs:
6.0.100
C:\Program Files\dotnet\sdk\6.0.100\
5.0.201
C:\Program Files\dotnet\sdk\5.0.201\
2.1.602
C:\Program Files\dotnet\sdk\2.1.602\
2.1.601
C:\Program Files\dotnet\sdk\2.1.601\
2.1.504
C:\Program Files\dotnet\sdk\2.1.504\
2.1.503
C:\Program Files\dotnet\sdk\2.1.503\
2.1.502
C:\Program Files\dotnet\sdk\2.1.502\
2.1.500
C:\Program Files\dotnet\sdk\2.1.500\
2.1.202
C:\Program Files\dotnet\sdk\2.1.202\
2.1.201
C:\Program Files\dotnet\sdk\2.1.201\
P.S. I have only VS 2019 installed.
Did you run it under .NET Core or NetFx?
My bad, I didn't noticed that I had net472
for the target framework.
I published version 0.18.3
which avoids selecting not supported MSBuild versions.
Thanks!