-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing PathHelpers
functionality to RelativePath
and AbsolutePath
in a standardized way.
#10
Comments
I'm guessing you want to add common operations like |
Walk, Parts, DropFirst, RelativeTo, etc... |
Depending on the methods you want to add, it's important to choose the correct return type. If we take struct AbsolutePath
{
AbsolutePath Combine(RelativePath part);
} struct RelativePath
{
RelativePath Combine(RelativePath part);
} If you want to add
interface IPath<TPath> where TPath : IPath, struct
{
TPath Combine(RelativePath part);
}
interface IPath
{
IPath Combine(RelativePath part);
} The first option would result in identical runtime characteristics as the original code. However, the downside is having to deal with generics, which are infectious by design and require every dependent to have the same restrictions. The second option doesn't have generics and seems like the way to go. However, our path types are all value types. A conversion from |
PathHelpers
functionality to RelativePath
and AbsolutePath
in a standardized way.
Using paths was a pain the last two times I had to deal with them, there is lots of missing useful functionality and lots of unexpected differences between There are 3 levels of things that can be done here: 1. Adding missing functionality from
|
From @Sewer56 on discord regarding point 3.
|
As a quick note. Originally (before you joined onboard) we did actually have There was a concern however (think @halgari raised it), that if an API consumer makes use of those paths, the operation should ideally run on the 'true' source of the path. More specifically, there existed a risk that someone could create an While at the current moment we use As @halgari was working with code that relied heavily on paths; they were swinging both ways, as there are benefits to both a design where I somehow didn't think of it at the time; but in retrospective, I can't see why we can't have both to reap benefits of both designs. Much like the Base Class Libraries have |
Currently IPath is a very anemic interface:
NexusMods.Paths/src/NexusMods.Paths/IPath.cs
Lines 1 to 17 in dd77c8a
It covers AbsolutePath and RelativePath. The objective is to add common functionality and then implement the interface also on GamePath from NexusMods.App project.
The goal is to allow common path manipulations on all of these. In particular for Nexus-Mods/NexusMods.App#553
The text was updated successfully, but these errors were encountered: