dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.38k stars 4.75k forks source link

[Uri] Provide lossless roundtripping for Uri between platforms (Windows / Linux) #33029

Closed NinoFloris closed 1 month ago

NinoFloris commented 4 years ago

Related to https://github.com/dotnet/runtime/issues/22103

Uri seems to be missing a capability to operate in a platform independent manner. We ran into this during testing. Today there seems to be no way to round-trip Uri across windows and unix machines. This must be an oversight.

Concretely, transforming backslashes to forward slashes significantly changes meaning of the URI and could be dangerous. Especially when not done universally (as it happens here, depending on runtime platform) as I would expect very few to actually run tests on all platforms.

This speaks to a broader problem for .NET when it moved xplat, as seen in Sockets, Path, Uri, and other concepts that Unix/Windows have in common.

Platform dependent implementations of universal concepts are fine as long as they either:

  1. Have knobs or escape hatches
  2. Strictly keep uniform semantics

As an example Path would be exempted because it's inherently tied to platform capabilities. Uri however is universal, though it provides neither escape hatches nor uniform semantics. I would argue Uri is a prime example of an api that must allow for lossless round-tripping.

karelz commented 4 years ago

Triage: Having consistency between platforms makes sense.

RokeJulianLockhart commented 1 month ago

https://github.com/dotnet/runtime/issues/33029#event-14651253699

I suggest that this be reopened, @NinoFloris and @karelz. Irrespective, it's certainly not completed.