1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using System . Diagnostics ;
3
4
using System . IO ;
4
5
using System . Linq ;
5
6
using System . Reflection ;
26
27
using JetBrains . ReSharper . UnitTestFramework . Exploration . Artifacts ;
27
28
using JetBrains . Rider . Model ;
28
29
using JetBrains . Util ;
30
+ using JetBrains . Util . Dotnet . TargetFrameworkIds ;
29
31
using UtBot . Rd . Generated ;
30
32
using UtBot . VSharp ;
31
33
using Thread = System . Threading . Thread ;
@@ -68,7 +70,8 @@ protected override void Process(CSharpGeneratorContext context, IProgressIndicat
68
70
var typeElement = context . ClassDeclaration . DeclaredElement ;
69
71
if ( typeElement == null ) return ;
70
72
if ( ! ( typeElement is IClass ) && ! ( typeElement is IStruct ) ) return ;
71
- var assembly = project . GetOutputFilePath ( context . PsiModule . TargetFrameworkId ) ;
73
+ var tfm = context . PsiModule . TargetFrameworkId ;
74
+ var assembly = project . GetOutputFilePath ( tfm ) ;
72
75
var descriptors = new List < UnitTestMethodDescriptor > ( ) ;
73
76
foreach ( var inputElement in context . InputElements . WithProgress ( progress , "Generating Unit tests" )
74
77
. OfType < GeneratorDeclaredElement < IMethod > > ( ) )
@@ -83,7 +86,7 @@ protected override void Process(CSharpGeneratorContext context, IProgressIndicat
83
86
{
84
87
try
85
88
{
86
- Generate ( indicator , project , assembly , descriptors ) ;
89
+ Generate ( indicator , project , assembly , descriptors , tfm ) ;
87
90
}
88
91
finally
89
92
{
@@ -93,7 +96,7 @@ protected override void Process(CSharpGeneratorContext context, IProgressIndicat
93
96
}
94
97
95
98
private void Generate ( IBackgroundProgressIndicator progressIndicator , IProject project ,
96
- VirtualFileSystemPath assemblyPath , List < UnitTestMethodDescriptor > descriptors )
99
+ VirtualFileSystemPath assemblyPath , List < UnitTestMethodDescriptor > descriptors , TargetFrameworkId tfm )
97
100
{
98
101
SolutionBuilderRequest buildRequest ;
99
102
var contextUnloaded = false ;
@@ -136,7 +139,7 @@ private void Generate(IBackgroundProgressIndicator progressIndicator, IProject p
136
139
_logger . Verbose ( "Start Generation" ) ;
137
140
_logger . Catch ( ( ) =>
138
141
{
139
- project . Locks . AssertNonMainThread ( ) ;
142
+ project . Locks . AssertNonMainThread ( ) ;
140
143
var pluginPath = FileSystemPath . Parse ( Assembly . GetExecutingAssembly ( ) . Location )
141
144
. Parent ;
142
145
var vsharpRunner = pluginPath . Combine ( "UtBot.VSharp.dll" ) ;
@@ -148,7 +151,7 @@ private void Generate(IBackgroundProgressIndicator progressIndicator, IProject p
148
151
var args = new GenerateArguments ( assemblyPath . FullPath , projectCsprojPath , solutionFilePath ,
149
152
moduleFqnName , methodToken , _generationTimeout ) ;
150
153
var result = proc . VSharpModel . Generate . Sync ( args , RpcTimeouts . Maximal ) ;
151
- unitTestProjectLocation = result ? . GeneratedProjectPath ?? "" ;
154
+ unitTestProjectLocation = result ? . GeneratedProjectPath ?? "" ;
152
155
_shellLocks . ExecuteOrQueue ( _lifetime , "UnitTestBuilder::Generate" , ( ) =>
153
156
{
154
157
if ( solution . IsValid ( ) )
@@ -233,4 +236,4 @@ private IProject TryToFindProject(ISolution solution, VirtualFileSystemPath unit
233
236
{
234
237
return solution . FindProjectItemsByLocation ( unitTestProjectPath ) . SingleItem ( ) as IProject ;
235
238
}
236
- }
239
+ }
0 commit comments