Open agocke opened 1 year ago
Agreed, that's one of the gray area of the API. Not allowing implicit conversion from string to UPath
would have lead to annoying explicit cast in many places (more than the creation of filesystems but all methods provided by IFileSystem
) so made this choice of simplicity vs correctness, but the downside is that there are a few cases like the one you point out that are not protected against a misusages (and the XML doc is not saying anything about this). Not sure I would want to change this after all these years this API has been released though...
An analyzer might work here, along with an option to enable it. Not taking a breaking change makes sense.
In the meantime I might try an expedient route and see if the BannedApiAnalyzer could catch this.
Aside: the /
operator override is clever. 😄
Just hit this:
I assume the proper way to do this is:
If there weren't an implicit conversion, I probably would have guessed that. Overall, it seems like keeping
UPath
s and strings a bit separate is a good idea. Especially when working with subpaths like this, the chances that you'll confuse one for the other is pretty high.