-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Shell] refactor of processing uris #5852
Conversation
Co-Authored-By: PureWeen <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks cool!
@@ -6,7 +6,7 @@ namespace Xamarin.Forms | |||
{ | |||
public interface IShellItemController : IElementController | |||
{ | |||
Task GoToPart(List<string> parts, Dictionary<string, string> queryData); | |||
Task GoToPart(NavigationRequest navigationRequest, Dictionary<string, string> queryData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be better to allocate this in a new interface
IShellElementController : IElementController
{
Task GoToPart(NavigationRequest navigationRequest, Dictionary<string, string> queryData);
}
|
||
string MakeUriString(List<string> segments) | ||
{ | ||
if(segments[0].StartsWith("/") || segments[0].StartsWith("\\")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this check needs to be extracted into some helper.
Assert.AreEqual(new Uri("app://host/shellroute/path"), ShellUriHandler.ConvertToStandardFormat(shell, CreateUri("app:/shellroute/path"))); | ||
|
||
Assert.AreEqual(new Uri("app://host/shellroute/path"), ShellUriHandler.ConvertToStandardFormat(shell, CreateUri("app://host/shellroute/path"))); | ||
Assert.AreEqual(new Uri("app://host/shellroute/path"), ShellUriHandler.ConvertToStandardFormat(shell, CreateUri("app:/host/shellroute/path"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can make variable new Uri("app://host/shellroute/path")
?
Also need add CreateUri
with backslash separator CreateUri("\\\\path"))
and CreateUri("\\path"))
{ | ||
get | ||
{ | ||
var segments = _path.Split(_pathSeparator, StringSplitOptions.RemoveEmptyEntries).ToList().Skip(1).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a lot of expensive enumeration that is not strictly necessary.
var segments = _path.Split(_pathSeparator, StringSplitOptions.RemoveEmptyEntries).ToList().Skip(1).ToList(); | |
var segments = _path.Split(_pathSeparator, StringSplitOptions.RemoveEmptyEntries).Skip(1); |
{ | ||
get | ||
{ | ||
var segments = _path.Split(_pathSeparator, StringSplitOptions.RemoveEmptyEntries).ToList().Skip(1).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var segments = _path.Split(_pathSeparator, StringSplitOptions.RemoveEmptyEntries).ToList().Skip(1).ToList(); | |
var segmentsCount = _path.Split(_pathSeparator, StringSplitOptions.RemoveEmptyEntries).Skip(1).Count(); |
{ | ||
var segments = _path.Split(_pathSeparator, StringSplitOptions.RemoveEmptyEntries).ToList().Skip(1).ToList(); | ||
|
||
if (segments.Count == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (segments.Count == 0) | |
if (segmentsCount == 0) |
return $"{source}/"; | ||
} | ||
|
||
public static string FormatRoute(List<string> segments) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static string FormatRoute(List<string> segments) | |
public static string FormatRoute(IEnumerable<string> segments) |
{ | ||
var segments = _path.Split(_pathSeparator, StringSplitOptions.RemoveEmptyEntries).ToList().Skip(1).ToList(); | ||
|
||
if (segments.Count == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (segments.Count == 0) | |
if (segments.Count() == 0) |
If it's alright my plan is to sweep through and get rid of everything using Linq for the next Pre, store a few more things locally, etc.. I'd apply a few now but I don't want the UI tests to quit out so we can get this merged and tested |
Description of Change
Issues Resolved
API Changes
Added:
These classes need to still be fleshed out a bit but they are the beginnings of extracting a uri into a request.
Changed:
None
Platforms Affected
Behavioral/Visual Changes
Review #5790 to see how uri's are interpreted
Testing Procedure
PR Checklist