Replies: 1 comment 6 replies
-
Hey @torbenj, that's an interesting conversation. Do you have some "real world" examples where overriding the Your examples are great to showcase how the feature would work, but they are clearly an exaggerated way of using it (which fits the purpose). For instance, given C# has string interpolation, I would not expect anyone would want to do this: var dir = DirectoryPath.FromString("C:") / "Foo" / "Bar" / file; When they can instead do this (much better & easier to read IMO): var dir = DirectoryPath.FromString($"C:/Foo/Bar/{file}"); Are there cases where string interpolation are not working as expected which could potentially justify overriding the |
Beta Was this translation helpful? Give feedback.
-
Hey folks,
as I'm currently working a bit more with CakeBuild(-Frosting) I'm wondering if there is anything planned regarding to overloading operators on the DirectoryPath class for easier concatenation of paths?
The current solution to concatenate for example two
DirectoryPath
instances is to use theCombine
method orCombineWithFilePath
method if I want to add a file path to it.The default way to combine path segments in .NET is to use
Path.Combine
but that would mean to mix APIs a lot when working with Cake and I think it's cleaner to just stick to the Cake way when working with it.From C++ I'm used to have the
/
operator overloaded when working with theirstd::filesystem::path
class to do concatenation and I think it would be quite nice to have it in Cake too.Instead of having to do write something like this
using operator overloading we could shorten this to
In this example I would interpret anything other than a
FilePath
parameter to the/
operator ofDirectoryPath
as a segment for a directory path (and thus return a newDirectoryPath
) and return aFilePath
otherwise.What do you think of this?
Is there maybe a better alternative already existing/in work?
Beta Was this translation helpful? Give feedback.
All reactions