Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e39e613cf7
|
||
|
|
ac378452a8 | ||
|
|
280253c3ba | ||
|
|
abb6b4ae20 | ||
|
|
6db1b4c2a1 |
No files matched your search
@@ -49,12 +49,20 @@ jobs:
|
||||
dotnet tool restore
|
||||
dotnet restore AutoClick.slnx
|
||||
|
||||
- name: Build info
|
||||
id: info
|
||||
shell: pwsh
|
||||
run: ./eng/Get-BuildInfo.ps1
|
||||
|
||||
# The product version lets the "previous version" new-code period start at the last version
|
||||
# change; without it, new code would count from the project's first analysis.
|
||||
# The scanner provisions its own Java runtime. Build output and restore files are not sources.
|
||||
- name: Begin analysis
|
||||
env:
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
VERSION: ${{ steps.info.outputs.version }}
|
||||
run: >-
|
||||
dotnet sonarscanner begin /k:poli0981_autoclick /o:poli0981
|
||||
dotnet sonarscanner begin /k:poli0981_autoclick /o:poli0981 /v:"$env:VERSION"
|
||||
/d:sonar.host.url=https://sonarcloud.io /d:sonar.token="$env:SONAR_TOKEN"
|
||||
"/d:sonar.cs.cobertura.reportsPaths=artifacts/test-results/**/*.cobertura.xml"
|
||||
"/d:sonar.exclusions=**/bin/**,**/obj/**,artifacts/**"
|
||||
|
||||
@@ -59,7 +59,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Run zizmor
|
||||
uses: zizmorcore/zizmor-action@f9597c869b2e67095f9b527070297a13a6efe928 # v0.7.0
|
||||
uses: zizmorcore/zizmor-action@85b2b9fb8e3325e7a23d7d0a9d7ba5ae0f999e3e # v0.7.1
|
||||
with:
|
||||
version: 1.31.0
|
||||
# Fail the job on findings instead of uploading them to code scanning.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"sdk": {
|
||||
"version": "10.0.401",
|
||||
"version": "10.0.402",
|
||||
"rollForward": "latestFeature"
|
||||
},
|
||||
"test": {
|
||||
|
||||
@@ -19,10 +19,7 @@ public sealed class ShellLauncher(IElevationService elevation)
|
||||
{
|
||||
try
|
||||
{
|
||||
var startInfo = elevation.IsCurrentProcessElevated
|
||||
? new ProcessStartInfo(ExplorerPath) { ArgumentList = { target }, UseShellExecute = false }
|
||||
: new ProcessStartInfo(target) { UseShellExecute = true };
|
||||
using var process = Process.Start(startInfo);
|
||||
using var process = Process.Start(StartInfo(target, elevation.IsCurrentProcessElevated));
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) when (ex is Win32Exception or InvalidOperationException)
|
||||
@@ -30,4 +27,9 @@ public sealed class ShellLauncher(IElevationService elevation)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal static ProcessStartInfo StartInfo(string target, bool elevated) =>
|
||||
elevated
|
||||
? new ProcessStartInfo(ExplorerPath) { ArgumentList = { target }, UseShellExecute = false }
|
||||
: new ProcessStartInfo(target) { UseShellExecute = true };
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.IO;
|
||||
using AutoClick.Core.Abstractions;
|
||||
|
||||
namespace AutoClick.Win32.Tests;
|
||||
|
||||
public class ShellLauncherTests
|
||||
{
|
||||
[Fact]
|
||||
public void StartInfo_Elevated_StartsExplorerByItsFullPath()
|
||||
{
|
||||
var startInfo = ShellLauncher.StartInfo("https://example.com", elevated: true);
|
||||
|
||||
// A bare "explorer.exe" would be searched in AutoClick's own, user-writable folder first.
|
||||
Assert.True(Path.IsPathFullyQualified(startInfo.FileName));
|
||||
Assert.Equal(Environment.GetFolderPath(Environment.SpecialFolder.Windows), Path.GetDirectoryName(startInfo.FileName), ignoreCase: true);
|
||||
Assert.Equal("explorer.exe", Path.GetFileName(startInfo.FileName), ignoreCase: true);
|
||||
Assert.True(File.Exists(startInfo.FileName));
|
||||
Assert.Equal("https://example.com", Assert.Single(startInfo.ArgumentList));
|
||||
Assert.False(startInfo.UseShellExecute);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryOpen_MissingFile_ReturnsFalse()
|
||||
{
|
||||
// Not elevated: the default handler reports the missing file without showing any UI.
|
||||
var launcher = new ShellLauncher(new NotElevated());
|
||||
|
||||
Assert.False(launcher.TryOpen(Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid():N}.autoclick-missing")));
|
||||
}
|
||||
|
||||
private sealed class NotElevated : IElevationService
|
||||
{
|
||||
public bool IsCurrentProcessElevated => false;
|
||||
|
||||
public ElevationState GetRelativeElevation(int processId) => ElevationState.SameOrLower;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user