Skip to content

Commit 1488d52

Browse files
committed
[fix] Check sdks instead of runtimes, remove logging from Notifications
1 parent b04990f commit 1488d52

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

utbot-rider/src/dotnet/UtBot/UtBot/UnitTestBuilder.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected override void Process(CSharpGeneratorContext context, IProgressIndicat
8080

8181
if (!_dotNetVersionUtils.CanRunVSharp)
8282
{
83-
_notifications.ShowError($"At least .NET {DotNetVersionUtils.MinCompatibleSdkMajor} runtime is required for UnitTestBot.NET");
83+
_notifications.ShowError($"At least .NET {DotNetVersionUtils.MinCompatibleSdkMajor} SDK is required for UnitTestBot.NET");
8484
return;
8585
}
8686

@@ -120,8 +120,6 @@ protected override void Process(CSharpGeneratorContext context, IProgressIndicat
120120
_backgroundProgressIndicatorManager.CreateIndicator(progressLifetimeDef.Lifetime, true, true,
121121
"Generating unit tests");
122122

123-
124-
125123
_shellLocks.Tasks.StartNew(_lifetime, Scheduling.FreeThreaded, () =>
126124
{
127125
try

utbot-rider/src/dotnet/UtBot/UtBot/Utils/DotNetVersionUtils.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,12 @@ public TestProjectTargetFramework GetTestProjectFramework(IProject project)
7878
return new(defaultTfm, true);
7979
}
8080

81-
// TODO: is there a case when --list-runtimes is not available, but runtime is installed?
8281
private static bool GetCanRunVSharp(string workingDir)
8382
{
8483
var sdksInfo = RunProcess(new ProcessStartInfo
8584
{
8685
FileName = "dotnet",
87-
Arguments = "--list-runtimes",
86+
Arguments = "--list-sdks",
8887
WorkingDirectory = workingDir
8988
});
9089

@@ -93,7 +92,7 @@ private static bool GetCanRunVSharp(string workingDir)
9392
return false;
9493
}
9594

96-
var matches = Regex.Matches(sdksInfo, @"\.(\S+)\.App (\d+)\.(\d+)\.(\d+)");
95+
var matches = Regex.Matches(sdksInfo, @"(\d+)\.(\d+)\.(\d+)");
9796

9897
if (matches.Count < 1)
9998
{
@@ -102,12 +101,7 @@ private static bool GetCanRunVSharp(string workingDir)
102101

103102
for (var i = 0; i < matches.Count; ++i)
104103
{
105-
if (matches[i].Groups[1].Value == "AspNetCore")
106-
{
107-
continue;
108-
}
109-
110-
if (!int.TryParse(matches[i].Groups[2].Value, out var majorVersion))
104+
if (!int.TryParse(matches[i].Groups[1].Value, out var majorVersion))
111105
{
112106
continue;
113107
}

utbot-rider/src/dotnet/UtBot/UtBot/Utils/Notifications.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ public void ShowError(
6060
bool closeAfterExecution = true,
6161
UserNotificationCommand command = null)
6262
{
63-
_logger.Error(message: body);
64-
6563
ShowNotification(
6664
NotificationSeverity.CRITICAL,
6765
Title,

utbot-rider/src/dotnet/UtBot/UtBot/Utils/ProjectPublisher.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void PublishSync(IProject project, IProjectConfiguration config, VirtualF
3030
var name = $"Publish::{project.Name}";
3131
Directory.CreateDirectory(outputDir.FullPath);
3232
var projectName = project.ProjectFileLocation.Name;
33-
var rid = RuntimeInformation.RuntimeIdentifier;
33+
var architecture = GetArchitecture();
3434
var tfm = config.TargetFrameworkId.TryGetShortIdentifier();
3535
var command = config.TargetFrameworkId.IsNetFramework ? "build" : "publish";
3636

@@ -43,7 +43,7 @@ public void PublishSync(IProject project, IProjectConfiguration config, VirtualF
4343
{
4444
FileName = "dotnet",
4545
Arguments =
46-
$"{command} \"{projectName}\" --sc -c {config.Name} -r {rid} -o {outputDir.FullPath} -f {tfm}",
46+
$"{command} \"{projectName}\" --sc -c {config.Name} -a {architecture} -o {outputDir.FullPath} -f {tfm}",
4747
WorkingDirectory = project.ProjectFileLocation.Directory.FullPath,
4848
RedirectStandardError = true,
4949
RedirectStandardOutput = true
@@ -80,4 +80,19 @@ void Schedule(SingleThreadScheduler scheduler)
8080
publishLifetimeDef.Terminate();
8181
}
8282
}
83+
84+
private string GetArchitecture()
85+
{
86+
var arch = RuntimeInformation.OSArchitecture;
87+
return arch switch
88+
{
89+
Architecture.X86 => "x86",
90+
Architecture.X64 => "x64",
91+
Architecture.Arm => "arm",
92+
Architecture.Arm64 => "arm64",
93+
Architecture.Wasm or Architecture.S390x =>
94+
throw new InvalidOperationException($"Unsupported architecture: {arch}"),
95+
_ => throw new ArgumentOutOfRangeException()
96+
};
97+
}
8398
}

0 commit comments

Comments
 (0)