Path Components, EnvironmentVariable, EnvironmentSpecialFolder, Tests, Safety - #133
Merged
Conversation
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.
Owner
Author
|
replaces #132 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New Features
PathComponents resolve per-machine locations so a shared PathReference no longerhas to be hand-edited per collaborator SpecialFolder and EnvironmentVariable
SpecialFolderselects anEnvironment.SpecialFolder, soApplicationDataresolvesto
%APPDATA%,~/.configor~/Library/Application Supportfrom one assetEnvironmentVariablelooks a variable up by name with an optional fallback, so anunset variable is reported rather than becoming a literal path segment
%VAR%or$VAR, so the same asset resolves on Windows, Linux andmacOS
Fixes
PathAssembler and
PathResolutionScope sit behind
PathReference.GetPathOutputReferenceor aResolvertoken names the chain that causedit, rather than recursing until
StackOverflowExceptionterminates the EditorPathComponentthat produced them, so a segment can no longer silently discard thecomponents before it
PathReferenceassets sharing a name report both assets instead of surfacing asa dictionary key collision
ElementTemplatescaffoldsGetPathInternal, so generatedPathComponents compile — it previously declared anoverride of the non-virtual
GetPathTests
PathComponentTests,
PathComponentFileSystemTests,
PathReferenceCombineTests,
PathReferenceCycleTests and
PathReferenceAssetTests
Templates/, includingConstant("..")anda rooted first component, so future validation cannot outlaw them
ManifestNameandManifestVersionreturn null rather than enteringtheir reported-error paths, and that
FindFileandFindDirectorylose theunderlying cause outside pipeline execution
new components, including the unset-variable diagnostic and that shell syntax in a
variable name is looked up verbatim rather than unwrapped