A GUI client for Windows and Linux, support Xray core and v2fly core and others
Find a file
Miheichev Aleksandr Sergeevich 62b17203a5 Tighten platform annotations and finalize SQLite native sync
This commit refines the platform-aware bits of the .NET 10 dependency
modernization stack added earlier in this PR. It introduces no new
NuGet packages and does not change any pinned versions: dotnet list
package --outdated against v2rayN.sln returns only the eight Avalonia
12.x packages, all of which are explicitly out of scope for this PR.

ServiceLib/Common/Utils.cs:
- Annotate IsLinux() with [SupportedOSPlatformGuard("linux")] and
  IsMacOS() with [SupportedOSPlatformGuard("macos")] so the analyzer
  can narrow the platform context inside Linux/macOS guards in the same
  way it already does for Utils.IsWindows().
- Rewrite GetSystemHosts() as a cross-platform helper. Previously it
  unconditionally tried to read C:\Windows\System32\drivers\etc\{hosts,
  hosts.ics}, which silently returned an empty dictionary on
  Linux/macOS. The new implementation reads /etc/hosts on those
  platforms, fixing UseSystemHosts=true being a silent no-op outside
  Windows. Behavior on Windows is unchanged (still merges hosts and
  hosts.ics).

ServiceLib/Handler/AutoStartupHandler.cs:
- Mark the Linux helpers (ClearTaskLinux, SetTaskLinux,
  GetHomePathLinux) with [SupportedOSPlatform("linux")] and the macOS
  helpers (ClearTaskOSX, SetTaskOSX, GetLaunchAgentPathMacOS,
  GenerateLaunchAgentPlist) with [SupportedOSPlatform("macos")] for
  symmetry with the Windows helpers in the same file. The dispatch in
  UpdateTask is already gated by Utils.IsWindows / IsLinux / IsMacOS,
  whose new SupportedOSPlatformGuard attributes make these annotations
  enforceable by the analyzer.

ServiceLib/Handler/SysProxy/ProxySettingLinux.cs and
ServiceLib/Handler/SysProxy/ProxySettingOSX.cs:
- Mark the classes with [SupportedOSPlatform("linux")] and
  [SupportedOSPlatform("macos")] respectively. Both are reachable only
  through SysProxyHandler.UpdateSysProxy under the corresponding
  platform guard.

ServiceLib/Manager/AppManager.cs:
- Call SQLitePCL.Batteries_V2.Init() at the top of InitApp() in
  addition to the existing call in SQLiteHelper's static constructor.
  The call is idempotent, so it cooperates with that static
  constructor; the duplication is intentional defense-in-depth so that
  any future code path which reaches the database without going through
  SQLiteHelper (background services, tests, future utilities) will
  still find an initialized native provider rather than throwing
  "Library not initialized" at runtime.

ServiceLib/Manager/CoreManager.cs:
- Add a clarifying comment above the existing
  [SupportedOSPlatform("windows")] field-level attribute on
  _processJob, explaining that the attribute narrows the analyzer's
  platform context for every read/assign of the field and that runtime
  safety is preserved by the IsWindows() guard inside AddProcessJob. No
  code change.

package-rhel-riscv.sh:
- Promote the previously hard-coded SQLite amalgamation version
  (sqlite_year / sqlite_ver) inside build_sqlite_native_riscv64 to two
  env-overridable variables (SQLITE_AMALGAMATION_YEAR and
  SQLITE_AMALGAMATION_VER) declared at the top of the script next to
  SKIA_VER and HARFBUZZ_VER.
- Set the defaults to 2025 / 3500400, which corresponds to SQLite
  3.50.4 and matches SourceGear.sqlite3 3.50.4.5 used on the other
  RIDs (x64/arm64/macOS). Previously the script downloaded SQLite
  3.53.0 amalgamation on RISC-V, which left RISC-V users on a
  different SQLite minor version than every other platform shipped
  from this repository. The accompanying comment block documents the
  mapping rule between SourceGear.sqlite3 X.Y.Z.W and the
  SQLITE_AMALGAMATION_* values, so the next bump can be done in two
  coordinated places (this script and Directory.Packages.props)
  without drift. The version can still be overridden per-build via
  environment variables for ad-hoc testing on RISC-V.

Verification
------------
- dotnet restore + dotnet build v2rayN.sln -c Release: 0 errors,
  1 warning (CS8625 in GlobalHotKeys submodule, pre-existing,
  out-of-scope of this PR).
- dotnet test ServiceLib.Tests: 41/41 passed.
- dotnet publish v2rayN.Desktop.csproj for linux-x64 and osx-x64,
  and v2rayN.csproj for win-x64: all succeed with no new warnings.
- dotnet list package --outdated against v2rayN.sln: only the eight
  Avalonia 12.x packages appear; none are eligible while this PR
  stays on the Avalonia 11.x branch.
2026-05-03 01:28:51 +03:00
.github Update dotnet to 10 2026-05-03 01:25:37 +03:00
v2rayN Tighten platform annotations and finalize SQLite native sync 2026-05-03 01:28:51 +03:00
.editorconfig Update .editorconfig 2025-01-31 15:59:44 +08:00
.gitattributes Remove extra .gitignore file and move .gitattributes to the root folder for consistent storage of .git-related files. (#6545) 2025-01-20 09:28:30 +08:00
.gitignore i18n(ru/zh-Hans/zh-Hant/hu/fa): translate TUN settings, unify MTU, use resx (#7787) 2025-08-18 17:28:59 +08:00
.gitmodules Use project to implement Windows global hotkey 2025-02-27 20:12:07 +08:00
LICENSE Update LICENSE (#7327) 2025-05-28 20:04:12 +08:00
package-debian.sh Update dotnet to 10 2026-05-03 01:25:37 +03:00
package-osx.sh Update package-osx.sh (#8303) 2025-11-11 19:31:06 +08:00
package-rhel-riscv.sh Tighten platform annotations and finalize SQLite native sync 2026-05-03 01:28:51 +03:00
package-rhel.sh Update dotnet to 10 2026-05-03 01:25:37 +03:00
README.md docs: improve README.md formatting and readability (#7376) 2025-06-02 09:52:49 +08:00

v2rayN

A GUI client for Windows, Linux and macOS, support Xray and sing-box and others

GitHub commit activity CodeFactor GitHub Releases Chat on Telegram

How to use

Read the Wiki for details.

Telegram Channel

github_2dust