* max cols setting

* added sample

* go default comm cols to 120

* regen

* package-version for go
This commit is contained in:
Johannes Bader 2017-06-26 10:15:30 -07:00 коммит произвёл GitHub
Родитель 71a36b5a17
Коммит 8e9c2d3704
12 изменённых файлов: 28 добавлений и 28 удалений

Просмотреть файл

@ -4,8 +4,7 @@
package
// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"github.com/Azure/go-autorest/autorest"

Просмотреть файл

@ -1,8 +1,7 @@
package
// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"github.com/Azure/go-autorest/autorest"

Просмотреть файл

@ -1,8 +1,7 @@
package
// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// UserAgent returns the UserAgent string to use when sending http.Requests.

Просмотреть файл

@ -61,6 +61,7 @@ Some settings are specific to plugins, such as:
- `sync-methods` which allows specifying whether synchronous wrappers for asynchronous methods should be generated (discouraged!)
- `payload-flattening-threshold` which controls whether a body parameter should be passed directly (as an argument to the generated method) or whether its properties should be passed as arguments. As the latter option makes sense for body parameter types with few properties (less overhead for `new`ing), this setting is a threshold specifying when to use which option.
- `client-side-validation` which controls whether or not client side validation of constrains such as `minLength`, `maximum` or `pattern` is desired
- `max-comment-columns` which controls the maximum number columns occupied by multiline comments
``` yaml
csharp:
@ -71,4 +72,5 @@ csharp:
sync-methods: none # other possible values: essential, all
payload-flattening-threshold: 3 # body parameter types with 3 or less properties cause method to expect those properties instead of an object
client-side-validation: false # disable client side validation
max-comment-columns: 80 # multiline comments shall not be wider than 80 characters
```

Просмотреть файл

@ -4,8 +4,7 @@
package
// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"github.com/Azure/go-autorest/autorest"

Просмотреть файл

@ -1,8 +1,7 @@
package
// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"github.com/Azure/go-autorest/autorest"
@ -20,17 +19,15 @@ func NewImageGroupClient() ImageGroupClient {
return NewImageGroupClientWithBaseURI(DefaultBaseURI, )
}
// NewImageGroupClientWithBaseURI creates an instance of the ImageGroupClient
// client.
// NewImageGroupClientWithBaseURI creates an instance of the ImageGroupClient client.
func NewImageGroupClientWithBaseURI(baseURI string, ) ImageGroupClient {
return ImageGroupClient{ NewWithBaseURI(baseURI, )}
}
// AMethod sends the a method request.
//
// imageParameter is an image stream. imageParameter will be closed upon
// successful return. Callers should ensure closure when receiving an
// error.imageContentType is the content type of the image.
// imageParameter is an image stream. imageParameter will be closed upon successful return. Callers should ensure
// closure when receiving an error.imageContentType is the content type of the image.
func (client ImageGroupClient) AMethod(imageParameter io.ReadCloser, imageContentType ContentTypeEnum) (result autorest.Response, err error) {
req, err := client.AMethodPreparer(imageParameter, imageContentType)
if err != nil {
@ -87,9 +84,8 @@ func (client ImageGroupClient) AMethodResponder(resp *http.Response) (result aut
// BMethod sends the b method request.
//
// imageParameter is an image stream. imageParameter will be closed upon
// successful return. Callers should ensure closure when receiving an
// error.imageContentType is the content type of the image.
// imageParameter is an image stream. imageParameter will be closed upon successful return. Callers should ensure
// closure when receiving an error.imageContentType is the content type of the image.
func (client ImageGroupClient) BMethod(imageParameter io.ReadCloser, imageContentType ContentTypeEnum) (result autorest.Response, err error) {
req, err := client.BMethodPreparer(imageParameter, imageContentType)
if err != nil {

Просмотреть файл

@ -1,8 +1,7 @@
package
// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// ContentTypeEnum enumerates the values for content type enum.
type ContentTypeEnum string

Просмотреть файл

@ -1,8 +1,7 @@
package
// Code generated by Microsoft (R) AutoRest Code Generator 1.1.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
// UserAgent returns the UserAgent string to use when sending http.Requests.

Просмотреть файл

@ -33,6 +33,8 @@ namespace AutoRest.Core
}
public class Settings : IsSingleton<Settings>
{
public const int DefaultMaximumCommentColumns = 80;
public const string DefaultCodeGenerationHeader = @"Code generated by Microsoft (R) AutoRest Code Generator {0}
Changes may cause incorrect behavior and will be lost if the code is regenerated.";
@ -88,6 +90,7 @@ Licensed under the MIT License. See License.txt in the project root for license
ValidationLevel = Category.Error;
ModelsName = "Models";
CodeGenerationMode = "rest-client";
MaximumCommentColumns = DefaultMaximumCommentColumns;
}
/// <summary>
@ -112,6 +115,8 @@ Licensed under the MIT License. See License.txt in the project root for license
#region ordered_properties
public int MaximumCommentColumns { get; set; }
/// <summary>
/// Gets or sets the path to the input specification file.
/// </summary>

Просмотреть файл

@ -16,8 +16,6 @@ namespace AutoRest.Core
/// </summary>
public class Template<T> : ITemplate
{
protected const int MaximumCommentColumn = 80;
private string _indentation;
private string _lastLiteral = String.Empty;
@ -232,7 +230,7 @@ namespace AutoRest.Core
}
int available =
MaximumCommentColumn - // Maximum desired width
(Settings.Instance?.MaximumCommentColumns ?? Settings.DefaultMaximumCommentColumns) - // Maximum desired width
Indentation.Length - // - Space used for indent
prefix.Length - // - Prefix //'s length
1; // - Extra space between prefix and text

Просмотреть файл

@ -84,6 +84,8 @@ public class Generator : NewPlugin
Settings.Instance.CustomSettings.Add("SyncMethods", GetXmsCodeGenSetting<string>(sd, "syncMethods") ?? await GetValue("sync-methods") ?? "essential");
Settings.Instance.CustomSettings.Add("UseDateTimeOffset", GetXmsCodeGenSetting<bool?>(sd, "useDateTimeOffset") ?? await GetValue<bool?>("use-datetimeoffset") ?? false);
Settings.Instance.CustomSettings["ClientSideValidation"] = await GetValue<bool?>("client-side-validation") ?? false;
int defaultMaximumCommentColumns = codeGenerator == "go" ? 120 : Settings.DefaultMaximumCommentColumns;
Settings.Instance.MaximumCommentColumns = await GetValue<int?>("max-comment-columns") ?? defaultMaximumCommentColumns;
if (codeGenerator == "csharp")
{
Settings.Instance.OutputFileName = await GetValue<string>("output-file");
@ -96,6 +98,10 @@ public class Generator : NewPlugin
Settings.Instance.PackageName = await GetValue("package-name");
Settings.Instance.PackageVersion = await GetValue("package-version");
}
if (codeGenerator == "go")
{
Settings.Instance.PackageVersion = await GetValue("package-version");
}
// process
var plugin = ExtensionsLoader.GetPlugin(

Просмотреть файл

@ -19,14 +19,13 @@ namespace AutoRest.Python
comment = comment.Replace("\\", "\\\\");
int available =
MaximumCommentColumn - // Maximum desired width
(Settings.Instance?.MaximumCommentColumns ?? Settings.DefaultMaximumCommentColumns) - // Maximum desired width
Indentation.Length - // - Space used for indent
prefix.Length - // - Prefix //'s length
1 - // - Extra space between prefix and text
1; // - Extra space for parameter start
return string.Join(Environment.NewLine + " ", comment.WordWrap(available)
.Select(s => string.Format(CultureInfo.InvariantCulture, "{0}{1}", prefix, s)));
return string.Join(Environment.NewLine + " ", comment.WordWrap(available).Select(s => $"{prefix}{s}"));
}
}
}