Compare commits

...
Author SHA1 Message Date
poli0981andClaude Opus 5.5 e39e613cf7 test: cover ShellLauncher's start info, including the elevated path
The 2.0.2 fix (Explorer by its full path when elevated) had no test, and
its two lines were the only uncovered new code that kept SonarQube
Cloud's quality gate red (coverage on new code 33.3% < 80%).
StartInfo is now a pure function: one test checks that the elevated
path starts explorer.exe from the Windows folder by its full path, the
other that TryOpen returns false for a missing file (not elevated, no
UI, nothing is launched).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 19:36:37 +07:00
poli0981andClaude Opus 5.5 ac378452a8 ci: send the product version to SonarQube Cloud (#67)
Without a project version every analysis reports "not provided", so the
"previous version" new-code period never moves past the first analysis:
the master quality gate measured coverage on all code changed since
2026-10-16 (33.3% < 80%). The scan now passes the version from
Directory.Build.props (eng/Get-BuildInfo.ps1), so new code starts at the
last version change.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 12:28:46 +00:00
dependabot[bot] 280253c3ba chore(actions): Bump zizmorcore/zizmor-action (#66)
Bumps the actions group with 1 update: [zizmorcore/zizmor-action](https://github.com/zizmorcore/zizmor-action).


Updates `zizmorcore/zizmor-action` from 0.7.0 to 0.7.1
- [Release notes](https://github.com/zizmorcore/zizmor-action/releases)
- [Commits](https://github.com/zizmorcore/zizmor-action/compare/f9597c869b2e67095f9b527070297a13a6efe928...85b2b9fb8e3325e7a23d7d0a9d7ba5ae0f999e3e)

---
updated-dependencies:
- dependency-name: zizmorcore/zizmor-action
  dependency-version: 0.7.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-22 12:16:34 +00:00
dependabot[bot] abb6b4ae20 chore(sdk): Bump dotnet-sdk from 10.0.401 to 10.0.402 (#65)
Bumps [dotnet-sdk](https://github.com/dotnet/sdk) from 10.0.401 to 10.0.402.
- [Release notes](https://github.com/dotnet/sdk/releases)
- [Commits](https://github.com/dotnet/sdk/compare/v10.0.401...v10.0.402)

---
updated-dependencies:
- dependency-name: dotnet-sdk
  dependency-version: 10.0.402
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-22 12:13:35 +00:00
poli0981 6db1b4c2a1 Merge pull request #63 from poli0981/ci/sonarcloud-scanner
ci: SonarQube Cloud analysis in CI with SonarScanner for .NET
2026-10-22 19:07:21 +07:00
poli0981andClaude Opus 5.5 1908464811 refactor: drop SonarCloud suppressions the CI analysis does not need
With a real build the analyzer binds WinEventWatcher's factory calls
(S3453), and the test projects are analyzed as tests, where the
main-code rule S2245 does not apply. The by-design suppressions (S4790,
S6640) stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 19:00:21 +07:00
poli0981andClaude Opus 5.5 67484ec2ce ci: analyze with SonarScanner for .NET instead of Automatic Analysis
SonarQube Cloud's Automatic Analysis does not build: it counted tests/
as product code and could not see CsWin32's generated PInvoke code,
which produced false positives (S2245 in tests, S3453 on
WinEventWatcher).

The new sonarcloud workflow builds, runs the tests with Cobertura
coverage and uploads the analysis (multi-language scan keeps the
workflows, YAML and PowerShell files). Test projects are recognized by
their TestContainer capability. Not a required check; Dependabot and
fork pull requests skip it (no SONAR_TOKEN). The scanner is pinned in
the tool manifest and updated with the other tools by Dependabot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 19:00:21 +07:00
12 changed files with 139 additions and 12 deletions

No files matched your search

+7
View File
@@ -36,6 +36,13 @@
"reportgenerator"
],
"rollForward": false
},
"dotnet-sonarscanner": {
"version": "12.0.0",
"commands": [
"dotnet-sonarscanner"
],
"rollForward": false
}
}
}
+1
View File
@@ -62,6 +62,7 @@ updates:
- "nuget-license"
- "microsoft.sbom.dotnettool"
- "dotnet-reportgenerator-globaltool"
- "dotnet-sonarscanner"
- "Microsoft.Windows.CsWin32"
- package-ecosystem: "dotnet-sdk"
+82
View File
@@ -0,0 +1,82 @@
name: SonarCloud
# SonarQube Cloud analysis with SonarScanner for .NET: issues, security hotspots and test coverage
# for the C# code (test projects are recognized as tests), plus the workflows, YAML and PowerShell
# files. Informational: not a required check. It replaces SonarQube Cloud's Automatic Analysis,
# which must stay turned off for the project (the scan fails otherwise). Dependabot and fork pull
# requests cannot read the SONAR_TOKEN secret and skip the job.
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: sonarcloud-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
sonarcloud:
name: sonarcloud
if: >-
github.actor != 'dependabot[bot]' &&
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
runs-on: windows-latest
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # full history: SonarQube Cloud uses blame to find new code
persist-credentials: false
- name: Setup .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json
- name: Restore
run: |
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 /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/**"
# A plain build: the regular CI job already builds with warnings as errors.
- name: Build
run: dotnet build AutoClick.slnx -c Release --no-restore --no-incremental --disable-build-servers
- name: Test with coverage
run: >-
dotnet test --solution AutoClick.slnx -c Release --no-build
--results-directory artifacts/test-results --coverage --coverage-output-format cobertura
- name: End analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: dotnet sonarscanner end /d:sonar.token="$env:SONAR_TOKEN"
+1 -1
View File
@@ -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
View File
@@ -38,6 +38,7 @@ dotnet jb inspectcode AutoClick.slnx --no-build --properties:Configuration=Relea
- LiveCharts' WPF charts always use the light LiveCharts theme and clear their canvas white unless `Background` is a solid brush: keep `Background="Transparent"` and paint the text from the WPF-UI theme (`DashboardViewModel.ApplyThemeAndTexts`).
- `ThemeService.ThemeChanged` relays WPF-UI's `ApplicationThemeManager.Changed`, so it also fires when Windows switches the theme; it is raised asynchronously, once per burst.
- The smoke test uses `%TEMP%\AutoClick-smoke`. A normal run uses `%LocalAppData%\AutoClick`, which is also the folder of an installed AutoClick (and a running installed copy takes over through the single-instance pipe): delete it after local manual tests only if it did not exist before.
- SonarQube Cloud runs in CI (`.github/workflows/sonarcloud.yml`, secret `SONAR_TOKEN`). Its Automatic Analysis must stay off, or the scan fails; it also counted `tests/` as product code and could not see CsWin32's generated code. Suppress a finding only with `[SuppressMessage]` and a `Justification`.
- Commits in this repository are GPG-signed; never bypass signing.
## Releasing
+3
View File
@@ -29,6 +29,8 @@ The design is described in [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md); the tes
| **dependency-review** | The pull request adds no vulnerable package and no disallowed license (build and test tools that are never shipped are exempt; the list is in the workflow) | GitHub only |
| **analyze (csharp)** | CodeQL security analysis | GitHub only |
SonarQube Cloud also analyzes every pull request from this repository (the **sonarcloud** check, not required): issues, security hotspots and test coverage of the changed code. Pull requests from forks and Dependabot skip it because they cannot read the `SONAR_TOKEN` secret.
Local equivalents of build-test and dead-code (PowerShell):
```powershell
@@ -58,6 +60,7 @@ Please also:
- **File formats are a contract:** profiles keep the 1.x JSON layout (property names, enums as numbers) so 1.x can still read them; settings and sessions are versioned (`schemaVersion`) and older versions must keep loading. Add tests with fixture files under `tests/Fixtures` for any change.
- **Win32:** add new APIs to `src/AutoClick.Win32/NativeMethods.txt` (CsWin32). Anything that converts game coordinates runs inside a `DpiScope` for the game window.
- **No unused code:** the dead-code check fails on it. For a deliberate exception, write `// ReSharper disable once <rule>` with a reason.
- **SonarQube Cloud findings** are fixed, or, when the code is right as it is, suppressed with `[SuppressMessage("Category", "Sxxxx:Title", Justification = "why")]`.
## Translations
+1 -1
View File
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "10.0.401",
"version": "10.0.402",
"rollForward": "latestFeature"
},
"test": {
+6 -4
View File
@@ -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 };
}
-2
View File
@@ -1,4 +1,3 @@
using System.Diagnostics.CodeAnalysis;
using Windows.Win32;
using Windows.Win32.UI.Accessibility;
@@ -8,7 +7,6 @@ namespace AutoClick.Win32;
/// Out-of-context WinEvent hook. Callbacks arrive on the thread that created the watcher
/// (it must pump messages, e.g. the WPF UI thread).
/// </summary>
[SuppressMessage("Reliability", "S3453:Classes should not have only \"private\" constructors", Justification = "Instances come from the static factories below.")]
public sealed class WinEventWatcher : IDisposable
{
private const uint WinEventOutOfContext = 0x0000;
@@ -1,9 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using AutoClick.Core.Models;
namespace AutoClick.Core.Tests;
[SuppressMessage("Security", "S2245:Pseudorandom number generators (PRNGs) should not be used in security contexts", Justification = "Seeded Random keeps the tests reproducible.")]
public class TimingAndColorTests
{
[Fact]
@@ -1,4 +1,3 @@
using System.Diagnostics.CodeAnalysis;
using AutoClick.Core.Abstractions;
using AutoClick.Core.Models;
using AutoClick.Core.Sessions;
@@ -14,7 +13,6 @@ public class ClickEngineTests
private readonly FakeWindowInspector _window = new();
private readonly FakePixelReader _pixels = new();
[SuppressMessage("Security", "S2245:Pseudorandom number generators (PRNGs) should not be used in security contexts", Justification = "Seeded Random keeps the tests reproducible.")]
private ClickEngine CreateEngine() =>
new(_input, _window, _pixels, _time, TestLog.For<ClickEngine>(), () => new Random(7));
@@ -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;
}
}