Skip to content

Commit a3fb966

Browse files
authored
Rider plugin updates (#1531)
[utbot-rider] 1. moved assembly loading into VSharp process 2. bumped VSharp version 3. Logs, exceptions fixes 4. Action is available only if .NET >=6 installed, and project tfm < 7 5. NUnit tfm checks for VSharp
1 parent d2d2e35 commit a3fb966

File tree

10 files changed

+311
-195
lines changed

10 files changed

+311
-195
lines changed

utbot-rd/src/main/rdgen/org/utbot/rd/models/CSharpModel.kt

+9-2
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,25 @@ import com.jetbrains.rd.generator.nova.*
66
object CSharpRoot: Root()
77

88
object VSharpModel: Ext(CSharpRoot) {
9+
val methodDescriptor = structdef {
10+
field("methodName", PredefinedType.string)
11+
field("typeName", PredefinedType.string)
12+
}
13+
914
val generateArguments = structdef {
1015
field("assemblyPath", PredefinedType.string)
1116
field("projectCsprojPath", PredefinedType.string)
1217
field("solutionFilePath", PredefinedType.string)
13-
field("moduleFqnName", PredefinedType.string)
14-
field("methodToken", PredefinedType.int)
18+
field("method", methodDescriptor)
1519
field("generationTimeoutInSeconds", PredefinedType.int)
20+
field("targetFramework", PredefinedType.string.nullable)
1621
}
1722

1823
val generateResults = structdef {
24+
field("isGenerated", PredefinedType.bool)
1925
field("generatedProjectPath", PredefinedType.string)
2026
field("generatedFilesPaths", array(PredefinedType.string))
27+
field("exceptionMessage", PredefinedType.string.nullable)
2128
}
2229

2330
init {

utbot-rider/src/dotnet/UtBot/UtBot.Rd/Generated/CSharpRoot.Generated.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace UtBot.Rd.Generated
3636

3737

3838
/// <summary>
39-
/// <p>Generated from: CSharpModel.kt:5</p>
39+
/// <p>Generated from: CSharpModel.kt:6</p>
4040
/// </summary>
4141
public class CSharpRoot : RdExtBase
4242
{

utbot-rider/src/dotnet/UtBot/UtBot.Rd/Generated/VSharpModel.Generated.cs

+143-29
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace UtBot.Rd.Generated
3636

3737

3838
/// <summary>
39-
/// <p>Generated from: CSharpModel.kt:7</p>
39+
/// <p>Generated from: CSharpModel.kt:8</p>
4040
/// </summary>
4141
public class VSharpModel : RdExtBase
4242
{
@@ -76,7 +76,7 @@ private VSharpModel (
7676

7777

7878

79-
protected override long SerializationHash => -3661028246701070338L;
79+
protected override long SerializationHash => -2362293640438957269L;
8080

8181
protected override Action<ISerializers> Register => RegisterDeclaredTypesSerializers;
8282
public static void RegisterDeclaredTypesSerializers(ISerializers serializers)
@@ -118,7 +118,7 @@ public override string ToString()
118118

119119

120120
/// <summary>
121-
/// <p>Generated from: CSharpModel.kt:8</p>
121+
/// <p>Generated from: CSharpModel.kt:14</p>
122122
/// </summary>
123123
public sealed class GenerateArguments : IPrintable, IEquatable<GenerateArguments>
124124
{
@@ -127,43 +127,43 @@ public sealed class GenerateArguments : IPrintable, IEquatable<GenerateArguments
127127
[NotNull] public string AssemblyPath {get; private set;}
128128
[NotNull] public string ProjectCsprojPath {get; private set;}
129129
[NotNull] public string SolutionFilePath {get; private set;}
130-
[NotNull] public string ModuleFqnName {get; private set;}
131-
public int MethodToken {get; private set;}
130+
[NotNull] public MethodDescriptor Method {get; private set;}
132131
public int GenerationTimeoutInSeconds {get; private set;}
132+
[CanBeNull] public string TargetFramework {get; private set;}
133133

134134
//private fields
135135
//primary constructor
136136
public GenerateArguments(
137137
[NotNull] string assemblyPath,
138138
[NotNull] string projectCsprojPath,
139139
[NotNull] string solutionFilePath,
140-
[NotNull] string moduleFqnName,
141-
int methodToken,
142-
int generationTimeoutInSeconds
140+
[NotNull] MethodDescriptor method,
141+
int generationTimeoutInSeconds,
142+
[CanBeNull] string targetFramework
143143
)
144144
{
145145
if (assemblyPath == null) throw new ArgumentNullException("assemblyPath");
146146
if (projectCsprojPath == null) throw new ArgumentNullException("projectCsprojPath");
147147
if (solutionFilePath == null) throw new ArgumentNullException("solutionFilePath");
148-
if (moduleFqnName == null) throw new ArgumentNullException("moduleFqnName");
148+
if (method == null) throw new ArgumentNullException("method");
149149

150150
AssemblyPath = assemblyPath;
151151
ProjectCsprojPath = projectCsprojPath;
152152
SolutionFilePath = solutionFilePath;
153-
ModuleFqnName = moduleFqnName;
154-
MethodToken = methodToken;
153+
Method = method;
155154
GenerationTimeoutInSeconds = generationTimeoutInSeconds;
155+
TargetFramework = targetFramework;
156156
}
157157
//secondary constructor
158158
//deconstruct trait
159-
public void Deconstruct([NotNull] out string assemblyPath, [NotNull] out string projectCsprojPath, [NotNull] out string solutionFilePath, [NotNull] out string moduleFqnName, out int methodToken, out int generationTimeoutInSeconds)
159+
public void Deconstruct([NotNull] out string assemblyPath, [NotNull] out string projectCsprojPath, [NotNull] out string solutionFilePath, [NotNull] out MethodDescriptor method, out int generationTimeoutInSeconds, [CanBeNull] out string targetFramework)
160160
{
161161
assemblyPath = AssemblyPath;
162162
projectCsprojPath = ProjectCsprojPath;
163163
solutionFilePath = SolutionFilePath;
164-
moduleFqnName = ModuleFqnName;
165-
methodToken = MethodToken;
164+
method = Method;
166165
generationTimeoutInSeconds = GenerationTimeoutInSeconds;
166+
targetFramework = TargetFramework;
167167
}
168168
//statics
169169

@@ -172,22 +172,24 @@ public void Deconstruct([NotNull] out string assemblyPath, [NotNull] out string
172172
var assemblyPath = reader.ReadString();
173173
var projectCsprojPath = reader.ReadString();
174174
var solutionFilePath = reader.ReadString();
175-
var moduleFqnName = reader.ReadString();
176-
var methodToken = reader.ReadInt();
175+
var method = MethodDescriptor.Read(ctx, reader);
177176
var generationTimeoutInSeconds = reader.ReadInt();
178-
var _result = new GenerateArguments(assemblyPath, projectCsprojPath, solutionFilePath, moduleFqnName, methodToken, generationTimeoutInSeconds);
177+
var targetFramework = ReadStringNullable(ctx, reader);
178+
var _result = new GenerateArguments(assemblyPath, projectCsprojPath, solutionFilePath, method, generationTimeoutInSeconds, targetFramework);
179179
return _result;
180180
};
181+
public static CtxReadDelegate<string> ReadStringNullable = JetBrains.Rd.Impl.Serializers.ReadString.NullableClass();
181182

182183
public static CtxWriteDelegate<GenerateArguments> Write = (ctx, writer, value) =>
183184
{
184185
writer.Write(value.AssemblyPath);
185186
writer.Write(value.ProjectCsprojPath);
186187
writer.Write(value.SolutionFilePath);
187-
writer.Write(value.ModuleFqnName);
188-
writer.Write(value.MethodToken);
188+
MethodDescriptor.Write(ctx, writer, value.Method);
189189
writer.Write(value.GenerationTimeoutInSeconds);
190+
WriteStringNullable(ctx, writer, value.TargetFramework);
190191
};
192+
public static CtxWriteDelegate<string> WriteStringNullable = JetBrains.Rd.Impl.Serializers.WriteString.NullableClass();
191193

192194
//constants
193195

@@ -205,7 +207,7 @@ public bool Equals(GenerateArguments other)
205207
{
206208
if (ReferenceEquals(null, other)) return false;
207209
if (ReferenceEquals(this, other)) return true;
208-
return AssemblyPath == other.AssemblyPath && ProjectCsprojPath == other.ProjectCsprojPath && SolutionFilePath == other.SolutionFilePath && ModuleFqnName == other.ModuleFqnName && MethodToken == other.MethodToken && GenerationTimeoutInSeconds == other.GenerationTimeoutInSeconds;
210+
return AssemblyPath == other.AssemblyPath && ProjectCsprojPath == other.ProjectCsprojPath && SolutionFilePath == other.SolutionFilePath && Equals(Method, other.Method) && GenerationTimeoutInSeconds == other.GenerationTimeoutInSeconds && Equals(TargetFramework, other.TargetFramework);
209211
}
210212
//hash code trait
211213
public override int GetHashCode()
@@ -215,9 +217,9 @@ public override int GetHashCode()
215217
hash = hash * 31 + AssemblyPath.GetHashCode();
216218
hash = hash * 31 + ProjectCsprojPath.GetHashCode();
217219
hash = hash * 31 + SolutionFilePath.GetHashCode();
218-
hash = hash * 31 + ModuleFqnName.GetHashCode();
219-
hash = hash * 31 + MethodToken.GetHashCode();
220+
hash = hash * 31 + Method.GetHashCode();
220221
hash = hash * 31 + GenerationTimeoutInSeconds.GetHashCode();
222+
hash = hash * 31 + (TargetFramework != null ? TargetFramework.GetHashCode() : 0);
221223
return hash;
222224
}
223225
}
@@ -229,9 +231,9 @@ public void Print(PrettyPrinter printer)
229231
printer.Print("assemblyPath = "); AssemblyPath.PrintEx(printer); printer.Println();
230232
printer.Print("projectCsprojPath = "); ProjectCsprojPath.PrintEx(printer); printer.Println();
231233
printer.Print("solutionFilePath = "); SolutionFilePath.PrintEx(printer); printer.Println();
232-
printer.Print("moduleFqnName = "); ModuleFqnName.PrintEx(printer); printer.Println();
233-
printer.Print("methodToken = "); MethodToken.PrintEx(printer); printer.Println();
234+
printer.Print("method = "); Method.PrintEx(printer); printer.Println();
234235
printer.Print("generationTimeoutInSeconds = "); GenerationTimeoutInSeconds.PrintEx(printer); printer.Println();
236+
printer.Print("targetFramework = "); TargetFramework.PrintEx(printer); printer.Println();
235237
}
236238
printer.Print(")");
237239
}
@@ -246,52 +248,66 @@ public override string ToString()
246248

247249

248250
/// <summary>
249-
/// <p>Generated from: CSharpModel.kt:17</p>
251+
/// <p>Generated from: CSharpModel.kt:23</p>
250252
/// </summary>
251253
public sealed class GenerateResults : IPrintable, IEquatable<GenerateResults>
252254
{
253255
//fields
254256
//public fields
257+
public bool IsGenerated {get; private set;}
255258
[NotNull] public string GeneratedProjectPath {get; private set;}
256259
[NotNull] public string[] GeneratedFilesPaths {get; private set;}
260+
[CanBeNull] public string ExceptionMessage {get; private set;}
257261

258262
//private fields
259263
//primary constructor
260264
public GenerateResults(
265+
bool isGenerated,
261266
[NotNull] string generatedProjectPath,
262-
[NotNull] string[] generatedFilesPaths
267+
[NotNull] string[] generatedFilesPaths,
268+
[CanBeNull] string exceptionMessage
263269
)
264270
{
265271
if (generatedProjectPath == null) throw new ArgumentNullException("generatedProjectPath");
266272
if (generatedFilesPaths == null) throw new ArgumentNullException("generatedFilesPaths");
267273

274+
IsGenerated = isGenerated;
268275
GeneratedProjectPath = generatedProjectPath;
269276
GeneratedFilesPaths = generatedFilesPaths;
277+
ExceptionMessage = exceptionMessage;
270278
}
271279
//secondary constructor
272280
//deconstruct trait
273-
public void Deconstruct([NotNull] out string generatedProjectPath, [NotNull] out string[] generatedFilesPaths)
281+
public void Deconstruct(out bool isGenerated, [NotNull] out string generatedProjectPath, [NotNull] out string[] generatedFilesPaths, [CanBeNull] out string exceptionMessage)
274282
{
283+
isGenerated = IsGenerated;
275284
generatedProjectPath = GeneratedProjectPath;
276285
generatedFilesPaths = GeneratedFilesPaths;
286+
exceptionMessage = ExceptionMessage;
277287
}
278288
//statics
279289

280290
public static CtxReadDelegate<GenerateResults> Read = (ctx, reader) =>
281291
{
292+
var isGenerated = reader.ReadBool();
282293
var generatedProjectPath = reader.ReadString();
283294
var generatedFilesPaths = ReadStringArray(ctx, reader);
284-
var _result = new GenerateResults(generatedProjectPath, generatedFilesPaths);
295+
var exceptionMessage = ReadStringNullable(ctx, reader);
296+
var _result = new GenerateResults(isGenerated, generatedProjectPath, generatedFilesPaths, exceptionMessage);
285297
return _result;
286298
};
287299
public static CtxReadDelegate<string[]> ReadStringArray = JetBrains.Rd.Impl.Serializers.ReadString.Array();
300+
public static CtxReadDelegate<string> ReadStringNullable = JetBrains.Rd.Impl.Serializers.ReadString.NullableClass();
288301

289302
public static CtxWriteDelegate<GenerateResults> Write = (ctx, writer, value) =>
290303
{
304+
writer.Write(value.IsGenerated);
291305
writer.Write(value.GeneratedProjectPath);
292306
WriteStringArray(ctx, writer, value.GeneratedFilesPaths);
307+
WriteStringNullable(ctx, writer, value.ExceptionMessage);
293308
};
294309
public static CtxWriteDelegate<string[]> WriteStringArray = JetBrains.Rd.Impl.Serializers.WriteString.Array();
310+
public static CtxWriteDelegate<string> WriteStringNullable = JetBrains.Rd.Impl.Serializers.WriteString.NullableClass();
295311

296312
//constants
297313

@@ -309,15 +325,17 @@ public bool Equals(GenerateResults other)
309325
{
310326
if (ReferenceEquals(null, other)) return false;
311327
if (ReferenceEquals(this, other)) return true;
312-
return GeneratedProjectPath == other.GeneratedProjectPath && GeneratedFilesPaths.SequenceEqual(other.GeneratedFilesPaths);
328+
return IsGenerated == other.IsGenerated && GeneratedProjectPath == other.GeneratedProjectPath && GeneratedFilesPaths.SequenceEqual(other.GeneratedFilesPaths) && Equals(ExceptionMessage, other.ExceptionMessage);
313329
}
314330
//hash code trait
315331
public override int GetHashCode()
316332
{
317333
unchecked {
318334
var hash = 0;
335+
hash = hash * 31 + IsGenerated.GetHashCode();
319336
hash = hash * 31 + GeneratedProjectPath.GetHashCode();
320337
hash = hash * 31 + GeneratedFilesPaths.ContentHashCode();
338+
hash = hash * 31 + (ExceptionMessage != null ? ExceptionMessage.GetHashCode() : 0);
321339
return hash;
322340
}
323341
}
@@ -326,8 +344,104 @@ public void Print(PrettyPrinter printer)
326344
{
327345
printer.Println("GenerateResults (");
328346
using (printer.IndentCookie()) {
347+
printer.Print("isGenerated = "); IsGenerated.PrintEx(printer); printer.Println();
329348
printer.Print("generatedProjectPath = "); GeneratedProjectPath.PrintEx(printer); printer.Println();
330349
printer.Print("generatedFilesPaths = "); GeneratedFilesPaths.PrintEx(printer); printer.Println();
350+
printer.Print("exceptionMessage = "); ExceptionMessage.PrintEx(printer); printer.Println();
351+
}
352+
printer.Print(")");
353+
}
354+
//toString
355+
public override string ToString()
356+
{
357+
var printer = new SingleLinePrettyPrinter();
358+
Print(printer);
359+
return printer.ToString();
360+
}
361+
}
362+
363+
364+
/// <summary>
365+
/// <p>Generated from: CSharpModel.kt:9</p>
366+
/// </summary>
367+
public sealed class MethodDescriptor : IPrintable, IEquatable<MethodDescriptor>
368+
{
369+
//fields
370+
//public fields
371+
[NotNull] public string MethodName {get; private set;}
372+
[NotNull] public string TypeName {get; private set;}
373+
374+
//private fields
375+
//primary constructor
376+
public MethodDescriptor(
377+
[NotNull] string methodName,
378+
[NotNull] string typeName
379+
)
380+
{
381+
if (methodName == null) throw new ArgumentNullException("methodName");
382+
if (typeName == null) throw new ArgumentNullException("typeName");
383+
384+
MethodName = methodName;
385+
TypeName = typeName;
386+
}
387+
//secondary constructor
388+
//deconstruct trait
389+
public void Deconstruct([NotNull] out string methodName, [NotNull] out string typeName)
390+
{
391+
methodName = MethodName;
392+
typeName = TypeName;
393+
}
394+
//statics
395+
396+
public static CtxReadDelegate<MethodDescriptor> Read = (ctx, reader) =>
397+
{
398+
var methodName = reader.ReadString();
399+
var typeName = reader.ReadString();
400+
var _result = new MethodDescriptor(methodName, typeName);
401+
return _result;
402+
};
403+
404+
public static CtxWriteDelegate<MethodDescriptor> Write = (ctx, writer, value) =>
405+
{
406+
writer.Write(value.MethodName);
407+
writer.Write(value.TypeName);
408+
};
409+
410+
//constants
411+
412+
//custom body
413+
//methods
414+
//equals trait
415+
public override bool Equals(object obj)
416+
{
417+
if (ReferenceEquals(null, obj)) return false;
418+
if (ReferenceEquals(this, obj)) return true;
419+
if (obj.GetType() != GetType()) return false;
420+
return Equals((MethodDescriptor) obj);
421+
}
422+
public bool Equals(MethodDescriptor other)
423+
{
424+
if (ReferenceEquals(null, other)) return false;
425+
if (ReferenceEquals(this, other)) return true;
426+
return MethodName == other.MethodName && TypeName == other.TypeName;
427+
}
428+
//hash code trait
429+
public override int GetHashCode()
430+
{
431+
unchecked {
432+
var hash = 0;
433+
hash = hash * 31 + MethodName.GetHashCode();
434+
hash = hash * 31 + TypeName.GetHashCode();
435+
return hash;
436+
}
437+
}
438+
//pretty print
439+
public void Print(PrettyPrinter printer)
440+
{
441+
printer.Println("MethodDescriptor (");
442+
using (printer.IndentCookie()) {
443+
printer.Print("methodName = "); MethodName.PrintEx(printer); printer.Println();
444+
printer.Print("typeName = "); TypeName.PrintEx(printer); printer.Println();
331445
}
332446
printer.Print(")");
333447
}

utbot-rider/src/dotnet/UtBot/UtBot.Rd/RdUtil.cs

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ namespace UtBot.Rd;
33
public static class RdUtil
44
{
55
public static readonly string MainProcessName = "UtBot";
6+
public static readonly string DefaultTestProjectTarget = "net6.0";
67
}

utbot-rider/src/dotnet/UtBot/UtBot.VSharp/UtBot.VSharp.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
<ProjectReference Include="..\UtBot.Rd\UtBot.Rd.csproj" />
1313
</ItemGroup>
1414
<ItemGroup>
15-
<PackageReference Include="VSTeam.VSharp" Version="0.0.4" />
15+
<PackageReference Include="VSTeam.VSharp" Version="0.0.6" />
1616
</ItemGroup>
1717
</Project>

0 commit comments

Comments
 (0)