Skip to content

Path Components, EnvironmentVariable, EnvironmentSpecialFolder, Tests, Safety - #133

Merged
PassivePicasso merged 9 commits into
masterfrom
path-resolution-safety
Aug 22, 2026
Merged

Path Components, EnvironmentVariable, EnvironmentSpecialFolder, Tests, Safety#133
PassivePicasso merged 9 commits into
masterfrom
path-resolution-safety

Conversation

@PassivePicasso

Copy link
Copy Markdown
Owner

New Features

  • Two PathComponents resolve per-machine locations so a shared PathReference no longer
    has to be hand-edited per collaborator SpecialFolder and EnvironmentVariable
    • SpecialFolder selects an Environment.SpecialFolder, so ApplicationData resolves
      to %APPDATA%, ~/.config or ~/Library/Application Support from one asset
    • EnvironmentVariable looks a variable up by name with an optional fallback, so an
      unset variable is reported rather than becoming a literal path segment
    • Neither parses %VAR% or $VAR, so the same asset resolves on Windows, Linux and
      macOS

Fixes

  • Path resolution reports authoring mistakes instead of failing opaquely — new
    PathAssembler and
    PathResolutionScope sit behind
    PathReference.GetPath
    • A cycle through OutputReference or a Resolver token names the chain that caused
      it, rather than recursing until StackOverflowException terminates the Editor
    • Null, invalid, drive-relative and misplaced rooted segments are refused and name the
      PathComponent that produced them, so a segment can no longer silently discard the
      components before it
    • Two PathReference assets sharing a name report both assets instead of surfacing as
      a dictionary key collision
  • PathReference ElementTemplate scaffolds
    GetPathInternal, so generated PathComponents compile — it previously declared an
    override of the non-virtual GetPath

Tests

Cover every PathComponent, PathReference assembly and ResolvePath token
substitution against current behaviour, including the cases that return null,
return an absolute path, or lose the underlying error. Reference cycles are not
covered because they recurse until StackOverflowException.
Unity initialises serialized array fields, so Data on a newly created
PathReference is empty rather than null and GetPath returns an empty string.
Data stays null until a component is added and GetPath fails in the OfType null
check, so the exception is ArgumentNullException.
PathReference.GetPath now resolves inside a PathResolutionScope, so a reference
cycle reports the chain instead of recursing until StackOverflowException, and
PathAssembler rejects null, invalid, drive-relative and misplaced rooted
segments while naming the component that produced them.
Two assets sharing a name previously broke every path resolution in the project
with a bare dictionary key collision; the failure now names the duplicate and
the assets that declare it.
ElementTemplate declared an override of PathComponent.GetPath, which is not
virtual, so every generated component failed to compile; it now overrides
GetPathInternal.
Both resolve per-machine locations by enum or variable name rather than by parsing
%VAR% or $VAR, so one asset resolves on Windows, Linux and macOS, and an unset
variable is reported instead of becoming a literal path segment.
@PassivePicasso

Copy link
Copy Markdown
Owner Author

replaces #132

@PassivePicasso
PassivePicasso merged commit 95a6236 into master Aug 22, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant