#3503·stride

UPath equality and hashing disagree for Unicode paths, breaking settings lookup

Author: cyber-blqCreated Sep 29, 2026Updated Sep 29, 2026
Labelsbug

Release Type: GitHub

Version: master at 6d39685048765f1d55336b51440453e67e0e76ea

Platform: Windows; reproduced in the repository's .NET 10 test project (SDK 10.0.401).

UPath.Equals uses ordinal case-insensitive comparison, while its cached hash lowercases each UTF-16 character separately. Those operations do not have the same Unicode equivalence rules. Equal UFile / UDirectory keys can have different hashes, so dictionaries miss existing entries and hash sets keep duplicate equal keys.

For example, Greek sigma (\u03C3) and final sigma (\u03C2) compare equal but hash differently. The same problem occurs with a supplementary-plane case pair, Deseret \U00010400 / \U00010428.

Reproduction

Run against Stride.Core.Design:

csharp
using System;
using System.Collections.Generic;
using Stride.Core.IO;
using Stride.Core.Settings;

var a = new UFile("Assets/\u03C3.png");
var b = new UFile("Assets/\u03C2.png");
Console.WriteLine(a.Equals(b));                         // True
Console.WriteLine(a.GetHashCode() == b.GetHashCode());  // False
Console.WriteLine(new Dictionary<UFile, int> { [a] = 42 }.ContainsKey(b)); // False
Console.WriteLine(new HashSet<UFile> { a, b }.Count);   // 2

// The same defect is reachable through the public settings API:
var container = new SettingsContainer();
var key = new SettingsKey<int>("Settings/\u03C3", container, 42);
Console.WriteLine(container.GetSettingsKey("Settings/\u03C2") == null); // True

Expected: equal paths have equal hashes, lookup succeeds, the set has one entry, and the settings lookup returns the registered key.

Prepared fix and validation

A local patch is prepared that hashes with StringComparer.OrdinalIgnoreCase, matching the existing equality rule, plus regression coverage for UFile, UDirectory, dictionary/set behavior and the settings API. It does not change path equality or serialization.

  • On the unpatched source, the nine new test cases produce 5 failures and 4 passes, including two failing settings lookups.
  • With the patch, 165 path and settings tests pass, with zero failures or skips, in the repository's own Stride.Core.Design.Tests project.
  • Validation covers the core path and settings APIs. The Game Studio UI and whole-repository test suite have not been exercised.

Paid contribution request

@stride3d/stride-contributors — under the published bounty process, would you consider a US$150 bounty for this focused fix, regression tests and review follow-up? I am open to discussing the amount based on the agreed scope and available budget. If eligible, please reserve the work for cyber-blq before a PR is submitted.

Please also confirm the payout requirements for a contributor in Romania through your Open Source Collective process, including any required identity documents, tax forms or fees. I understand the published payment split is 60% after merge and 40% at the next official engine release. Any private contact or payout details can be supplied through an appropriate private channel if needed.

You can reach me through this GitHub issue. No PR has been submitted for this proposal.