Nexus-Mods / NexusMods.App

Home of the development of the Nexus Mods App
https://nexus-mods.github.io/NexusMods.App/
GNU General Public License v3.0
1.1k stars 52 forks source link

Debug Assertions in NexusMods.Paths cause GameFinder failure in Xbox/MS Store paths with subfolder. #363

Closed Sewer56 closed 1 year ago

Sewer56 commented 1 year ago

Bug Report

Summary

Developers with Xbox Game Pass/MS Store game paths that are in a subdirectory of a volume/drive cannot execute NexusMods.App in Debug mode; due to a failed assertion.

Steps to reproduce

What is the expected behaviour?

No exception occurs.

Other information

This issue occurs because we convert the path obtained from .GamingRoot file to RelativePath verbatim.

Somewhat recently, we changed the spec and normalized relative paths to use /; and the input path being converted in this case is Games\Xbox. Because the path contains a backslash, assertion fails.

Since those changes were made, the Sanitize method was added; probably just calling that should be sufficient.

Stack Trace:

PathHelpers.IsSanitized() at NexusMods.App\src\NexusMods.Paths\Utilities\PathHelpers.cs:line 98
PathHelpers.DebugAssertIsSanitized() at NexusMods.App\src\NexusMods.Paths\Utilities\PathHelpers.cs:line 71
new RelativePath()
StringExtensions.ToRelativePath()
XboxHandler.ParseGamingRootFile()
XboxHandler.GetAppFolders()

Example File to Reproduce: GamingRoot.zip

Steps to Resolve

This was caused by a change made to NexusMods.Paths.

With commit dc12a50f98e8ce2bb1f78934abdbed7c6e589339 , it appears that it is now expected that paths call PathHelpers.Sanitize before presenting themselves as RelativePath.

We have 2 options, either update GameFinder to call Sanitize before converting to RelativePath, or make the conversion auto-sanitize.

The former appears to be the 'intended' choice; but that does leave an issue:

How will external libraries (e.g. GameFinder) that can't build against Debug NexusMods.Paths (NuGet Packages are 'release'), know that they'll pass the necessary asserts?

erri120 commented 1 year ago

I'll update GameFinder over the weekend, after the new library versions are on NuGet.

Al12rs commented 1 year ago

Blocked by #478

erri120 commented 1 year ago

Fixed with #479 with GameFinder 3.2.1.