Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal sealed class ClientUriBuilderDefinition : TypeProvider
modifiers: MethodSignatureModifiers.Private,
name: "UriBuilder",
type: typeof(UriBuilder),
body: new ExpressionPropertyBody(new BinaryOperatorExpression(" ??= ", _uriBuilderField, New.Instance(typeof(UriBuilder)))),
body: new ExpressionPropertyBody(new BinaryOperatorExpression("??=", _uriBuilderField, New.Instance(typeof(UriBuilder)))),
description: null,
enclosingType: this);

Expand All @@ -51,7 +51,7 @@ internal sealed class ClientUriBuilderDefinition : TypeProvider
modifiers: MethodSignatureModifiers.Private,
name: "PathAndQuery",
type: typeof(StringBuilder),
body: new ExpressionPropertyBody(new BinaryOperatorExpression(" ??= ", _pathAndQueryField, New.Instance(typeof(StringBuilder)))),
body: new ExpressionPropertyBody(new BinaryOperatorExpression("??=", _pathAndQueryField, New.Instance(typeof(StringBuilder)))),
description: null,
enclosingType: this);

Expand Down Expand Up @@ -153,14 +153,14 @@ private MethodProvider[] BuildAppendPathMethods()
},
MethodBodyStatement.Empty,
// Check for double slashes: if path ends with '/' and value starts with '/'
new IfStatement(pathLength.GreaterThan(Int(0)).And(stringBuilder.Index(new BinaryOperatorExpression(" - ", pathLength, Int(1))).Equal(Literal('/'))).And(valueParameter.As<string>().Index(Int(0)).Equal(Literal('/'))))
new IfStatement(pathLength.GreaterThan(Int(0)).And(stringBuilder.Index(new BinaryOperatorExpression("-", pathLength, Int(1))).Equal(Literal('/'))).And(valueParameter.As<string>().Index(Int(0)).Equal(Literal('/'))))
{
stringBuilder.Remove(new BinaryOperatorExpression(" - ", pathLength, Int(1)), Int(1)).Terminate(),
_pathLengthField.Assign(new BinaryOperatorExpression(" - ", pathLength, Int(1))).Terminate()
stringBuilder.Remove(new BinaryOperatorExpression("-", pathLength, Int(1)), Int(1)).Terminate(),
_pathLengthField.Assign(new BinaryOperatorExpression("-", pathLength, Int(1))).Terminate()
},
MethodBodyStatement.Empty,
stringBuilder.Invoke("Insert", [pathLength, valueParameter]).Terminate(),
_pathLengthField.Assign(new BinaryOperatorExpression(" + ", pathLength, valueParameter.As<string>().Length())).Terminate()
_pathLengthField.Assign(new BinaryOperatorExpression("+", pathLength, valueParameter.As<string>().Length())).Terminate()
};

return
Expand Down Expand Up @@ -222,7 +222,7 @@ private MethodProvider[] BuildAppendQueryMethods()
{
stringBuilder.Append(Literal('?')).Terminate()
},
new IfStatement(stringBuilder.Length().GreaterThan(pathLength).And(stringBuilder.Index(new BinaryOperatorExpression(" - ", stringBuilder.Length(), Int(1))).NotEqual(Literal('?'))))
new IfStatement(stringBuilder.Length().GreaterThan(pathLength).And(stringBuilder.Index(new BinaryOperatorExpression("-", stringBuilder.Length(), Int(1))).NotEqual(Literal('?'))))
{
stringBuilder.Append(Literal('&')).Terminate()
},
Expand Down Expand Up @@ -353,7 +353,7 @@ private MethodProvider BuildToUriMethod()
// Set the query portion if it exists
new IfStatement(stringBuilder.Length().GreaterThan(pathLength))
{
UriBuilderQuery.Assign(stringBuilder.Invoke("ToString", [new BinaryOperatorExpression(" + ", pathLength, Int(1)), new BinaryOperatorExpression(" - ", new BinaryOperatorExpression(" - ", stringBuilder.Length(), pathLength), Int(1))])).Terminate()
UriBuilderQuery.Assign(stringBuilder.Invoke("ToString", [new BinaryOperatorExpression("+", pathLength, Int(1)), new BinaryOperatorExpression("-", new BinaryOperatorExpression("-", stringBuilder.Length(), pathLength), Int(1))])).Terminate()
},
new IfStatement(stringBuilder.Length().Equal(pathLength))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public ClientUriBuilder()
{
}

private UriBuilder UriBuilder => _uriBuilder ??= new UriBuilder();
private UriBuilder UriBuilder => _uriBuilder ??= new UriBuilder();

private StringBuilder PathAndQuery => _pathAndQuery ??= new StringBuilder();
private StringBuilder PathAndQuery => _pathAndQuery ??= new StringBuilder();

public void Reset(Uri uri)
{
Expand All @@ -40,13 +40,13 @@ public void AppendPath(string value, bool escape)
{
value = Uri.EscapeDataString(value);
}
if (_pathLength > 0 && PathAndQuery[_pathLength - 1] == '/' && value[0] == '/')
if (_pathLength > 0 && PathAndQuery[_pathLength - 1] == '/' && value[0] == '/')
{
PathAndQuery.Remove(_pathLength - 1, 1);
_pathLength = _pathLength - 1;
PathAndQuery.Remove(_pathLength - 1, 1);
_pathLength = _pathLength - 1;
}
PathAndQuery.Insert(_pathLength, value);
_pathLength = _pathLength + value.Length;
_pathLength = _pathLength + value.Length;
}

public void AppendPath(bool value, bool escape = false) => AppendPath(TypeFormatters.ConvertToString(value), escape);
Expand Down Expand Up @@ -80,7 +80,7 @@ public void AppendQuery(string name, string value, bool escape)
{
PathAndQuery.Append('?');
}
if (PathAndQuery.Length > _pathLength && PathAndQuery[PathAndQuery.Length - 1] != '?')
if (PathAndQuery.Length > _pathLength && PathAndQuery[PathAndQuery.Length - 1] != '?')
{
PathAndQuery.Append('&');
}
Expand Down Expand Up @@ -127,7 +127,7 @@ public Uri ToUri()
UriBuilder.Path = PathAndQuery.ToString(0, _pathLength);
if (PathAndQuery.Length > _pathLength)
{
UriBuilder.Query = PathAndQuery.ToString(_pathLength + 1, PathAndQuery.Length - _pathLength - 1);
UriBuilder.Query = PathAndQuery.ToString(_pathLength + 1, PathAndQuery.Length - _pathLength - 1);
}
if (PathAndQuery.Length == _pathLength)
{
Expand Down
Loading