diff --git a/src/libs/AutoSDK/Sources/Sources.PathBuilder.cs b/src/libs/AutoSDK/Sources/Sources.PathBuilder.cs index a706cad5d0..84ba6bc01c 100644 --- a/src/libs/AutoSDK/Sources/Sources.PathBuilder.cs +++ b/src/libs/AutoSDK/Sources/Sources.PathBuilder.cs @@ -15,12 +15,20 @@ public static string GeneratePathBuilder( namespace {settings.Namespace} {{ + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder {{ private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; - + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -29,10 +37,16 @@ public PathBuilder( {{ _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); }} - + _stringBuilder.Append(path); }} - + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -50,10 +64,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); - + return this; }} - + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -69,12 +91,22 @@ public PathBuilder AddRequiredParameter( return this; }} - + AddRequiredParameter(name, string.Join(delimiter, value)); - + return this; }} - + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -83,10 +115,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) {{ AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); - + return this; }} - + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -95,10 +133,18 @@ public PathBuilder AddOptionalParameter( {{ AddRequiredParameter(name, value); }} - + return this; }} - + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -109,10 +155,20 @@ public PathBuilder AddOptionalParameter( {{ AddRequiredParameter(name, value, delimiter, explode); }} - + return this; }} - + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -124,10 +180,19 @@ public PathBuilder AddOptionalParameter( {{ AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); }} - + return this; }} - + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -136,10 +201,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable {{ AddRequiredParameter(name, value.ToString(format, formatProvider)); - + return this; }} - + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -151,10 +225,14 @@ public PathBuilder AddOptionalParameter( {{ AddOptionalParameter(name, value.ToString(format, formatProvider)); }} - + return this; }} - + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); }} }}".RemoveBlankLinesWhereOnlyWhitespaces(); diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Ai21/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Ai21/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Ai21/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Ai21/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Anthropic/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Anthropic/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Anthropic/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Anthropic/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Anthropic/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Anthropic/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Anthropic/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Anthropic/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/AssemblyAi/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/AssemblyAi/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/AssemblyAi/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/AssemblyAi/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/AssemblyAi/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/AssemblyAi/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/AssemblyAi/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/AssemblyAi/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Cohere/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Cohere/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Cohere/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Cohere/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Cohere/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Cohere/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Cohere/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Cohere/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Dedoose/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Dedoose/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Dedoose/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Dedoose/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Dedoose/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Dedoose/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Dedoose/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Dedoose/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Empty/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Empty/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Empty/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Empty/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Empty/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Empty/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Empty/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Empty/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Filtering/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Filtering/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Filtering/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Filtering/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Filtering/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Filtering/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Filtering/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Filtering/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/GitHub/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/GitHub/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/GitHub/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/GitHub/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/GitHub/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/GitHub/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/GitHub/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/GitHub/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/HuggingFace/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/HuggingFace/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/HuggingFace/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/HuggingFace/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/HuggingFace/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/HuggingFace/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/HuggingFace/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/HuggingFace/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/IpInfo/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/IpInfo/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/IpInfo/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/IpInfo/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/IpInfo/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/IpInfo/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/IpInfo/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/IpInfo/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/LangSmith/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/LangSmith/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/LangSmith/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/LangSmith/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/LangSmith/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/LangSmith/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/LangSmith/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/LangSmith/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Leonardo/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Leonardo/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Leonardo/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Leonardo/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Leonardo/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Leonardo/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Leonardo/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Leonardo/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Mystic/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Mystic/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Mystic/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Mystic/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Mystic/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Mystic/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Mystic/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Mystic/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Ollama/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Ollama/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Ollama/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Ollama/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Ollama/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Ollama/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Ollama/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Ollama/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/OpenAi/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/OpenAi/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/OpenAi/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/OpenAi/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/OpenAi/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/OpenAi/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/OpenAi/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/OpenAi/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/PetStore/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/PetStore/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/PetStore/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/PetStore/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/PetStore/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/PetStore/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/PetStore/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/PetStore/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Replicate/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Replicate/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Replicate/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Replicate/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Replicate/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Replicate/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Replicate/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Replicate/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/SpecialCases/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/SpecialCases/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/SpecialCases/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/SpecialCases/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/SpecialCases/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/SpecialCases/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/SpecialCases/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/SpecialCases/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Together/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Together/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Together/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Together/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Together/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Together/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Together/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Together/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Twitch/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Twitch/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Twitch/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Twitch/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/Twitch/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/Twitch/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/Twitch/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/Twitch/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/heygen/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/heygen/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/heygen/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/heygen/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/heygen/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/heygen/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/heygen/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/heygen/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/instill/NewtonsoftJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/instill/NewtonsoftJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/instill/NewtonsoftJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/instill/NewtonsoftJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.SnapshotTests/Snapshots/instill/SystemTextJson/_#G.PathBuilder.g.verified.cs b/src/tests/AutoSDK.SnapshotTests/Snapshots/instill/SystemTextJson/_#G.PathBuilder.g.verified.cs index b01f6257f6..7faa748137 100644 --- a/src/tests/AutoSDK.SnapshotTests/Snapshots/instill/SystemTextJson/_#G.PathBuilder.g.verified.cs +++ b/src/tests/AutoSDK.SnapshotTests/Snapshots/instill/SystemTextJson/_#G.PathBuilder.g.verified.cs @@ -5,11 +5,20 @@ namespace G { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -18,8 +27,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } + _stringBuilder.Append(path); } + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -37,8 +54,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -54,9 +81,22 @@ public PathBuilder AddRequiredParameter( return this; } + AddRequiredParameter(name, string.Join(delimiter, value)); + return this; } + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -65,8 +105,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); + return this; } + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -75,8 +123,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -87,8 +145,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } + return this; } + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -100,8 +170,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } + return this; } + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -110,8 +191,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); + return this; } + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -123,8 +215,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } + return this; } + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file diff --git a/src/tests/AutoSDK.UnitTests/Helpers/PathBuilder.cs b/src/tests/AutoSDK.UnitTests/Helpers/PathBuilder.cs index bfeff7406c..e68ef52d82 100644 --- a/src/tests/AutoSDK.UnitTests/Helpers/PathBuilder.cs +++ b/src/tests/AutoSDK.UnitTests/Helpers/PathBuilder.cs @@ -3,12 +3,20 @@ namespace AutoSDK.UnitTests.Helpers { + /// + /// A helper class to build URL paths with optional and required parameters. + /// public class PathBuilder { private readonly global::System.Text.StringBuilder _stringBuilder = new global::System.Text.StringBuilder(capacity: 256); private bool _firstParameter = true; - + + /// + /// Initializes a new instance of the class. + /// + /// The base path for the URL. + /// The base URI to prepend to the path, if any. public PathBuilder( string path, global::System.Uri? baseUri = null) @@ -17,10 +25,16 @@ public PathBuilder( { _stringBuilder.Append(baseUri.AbsoluteUri.TrimEnd('/')); } - + _stringBuilder.Append(path); } - + + /// + /// Adds a required parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter. + /// The current instance. public PathBuilder AddRequiredParameter( string name, string value) @@ -38,10 +52,18 @@ public PathBuilder AddRequiredParameter( _stringBuilder.Append(global::System.Uri.EscapeDataString(name)); _stringBuilder.Append('='); _stringBuilder.Append(global::System.Uri.EscapeDataString(value)); - + return this; } - + + /// + /// Adds a required parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -57,12 +79,22 @@ public PathBuilder AddRequiredParameter( return this; } - + AddRequiredParameter(name, string.Join(delimiter, value)); - + return this; } - + + /// + /// Adds a required parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddRequiredParameter( string name, global::System.Collections.Generic.IEnumerable value, @@ -71,10 +103,16 @@ public PathBuilder AddRequiredParameter( bool explode = false) { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); - + return this; } - + + /// + /// Adds an optional parameter to the URL. + /// + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The current instance. public PathBuilder AddOptionalParameter( string name, string? value) @@ -83,10 +121,18 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value); } - + return this; } - + + /// + /// Adds an optional parameter with multiple values to the URL. + /// + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -97,10 +143,20 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value, delimiter, explode); } - + return this; } - + + /// + /// Adds an optional parameter with multiple values to the URL, using a selector function. + /// + /// The type of the values. + /// The name of the parameter. + /// The values of the parameter, or null if not present. + /// The function to select the string representation of each value. + /// The delimiter to use between values. + /// Whether to explode the values into separate parameters. + /// The current instance. public PathBuilder AddOptionalParameter( string name, global::System.Collections.Generic.IEnumerable? value, @@ -112,10 +168,19 @@ public PathBuilder AddOptionalParameter( { AddRequiredParameter(name, value.Select(selector).ToArray(), delimiter, explode); } - + return this; } - + + /// + /// Adds a required parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddRequiredParameter( string name, T value, @@ -124,10 +189,19 @@ public PathBuilder AddRequiredParameter( where T : global::System.IFormattable { AddRequiredParameter(name, value.ToString(format, formatProvider)); - + return this; } - + + /// + /// Adds an optional parameter to the URL, using a formattable value. + /// + /// The type of the value. + /// The name of the parameter. + /// The value of the parameter, or null if not present. + /// The format string. + /// The format provider. + /// The current instance. public PathBuilder AddOptionalParameter( string name, T? value, @@ -139,10 +213,14 @@ public PathBuilder AddOptionalParameter( { AddOptionalParameter(name, value.ToString(format, formatProvider)); } - + return this; } - + + /// + /// Returns the constructed URL as a string. + /// + /// The constructed URL. public override string ToString() => _stringBuilder.ToString(); } } \ No newline at end of file