Skip to content

Commit

Permalink
Update CONTRIBUTING.md (Azure#10817)
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym authored Apr 16, 2020
1 parent 7c91b6d commit a2d1f94
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,69 @@ If you are adding a new service directory, ensure that it is mapped to a friendl
8. Copy existing generate.ps1 file from another service and update the `ResourceProvider` name that is applicable to your SDK. Resource provider refers to the relative path of your REST spec directory in Azure-Rest-Api-Specs repository
During SDK generation, this path helps to locate the REST API spec from the `https://github.com/Azure/azure-rest-api-specs`

# On-boarding New generated code library

1. Make a copy of `/sdk/template/Azure.Template` in you appropriate service directory and rename projects to `Azure.Management.*` for management libraries or `Azure.*` (e.g. `sdk/storage/Azure.Management.Storage` or `sdk/storage/Azure.Storage.Blobs`)
2. Modify `autorest.md` to point to you Swagger file or central README.md file. E.g.

``` yaml
input-file:
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/blob.json
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/file.json
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/storage.json
```
``` yaml
require: https://github.com/Azure/azure-rest-api-specs/blob/49fc16354df7211f8392c56884a3437138317d1f/specification/azsadmin/resource-manager/storage/readme.md
```
3. Run `dotnet msbuild /t:GenerateCode` in src directory of the project (e.g. `net\sdk\storage\Azure.Management.Storage\src`). This would run Autorest and generate the code. (NOTE: this step requires Node 13).
4. For management plan libraries add `azure-arm: true` setting to `autorest.md` client constructors and options would be auto-generated. For data-plane libraries follow the next two steps.
4. Add a `*ClientOptions` type that inherits from `ClientOptions` and has a service version enum:

``` C#
namespace Azure.Management.Storage
{
public class StorageManagementClientOptions: ClientOptions
{
private const ServiceVersion Latest = ServiceVersion.V2019_06_01;
internal static StorageManagementClientOptions Default { get; } = new StorageManagementClientOptions();
public StorageManagementClientOptions(ServiceVersion serviceVersion = Latest)
{
VersionString = serviceVersion switch
{
ServiceVersion.V2019_06_01 => "2019-06-01",
_ => throw new ArgumentOutOfRangeException(nameof(serviceVersion))
};
}
internal string VersionString { get; }
public enum ServiceVersion
{
#pragma warning disable CA1707
V2019_06_01 = 1
#pragma warning restore CA1707
}
}
}
```
5. Add public constructors to all the clients using a partial class.
``` C#
public partial class FileSharesClient
{
public FileSharesClient(string subscriptionId, TokenCredential tokenCredential): this(subscriptionId, tokenCredential, StorageManagementClientOptions.Default)
{
}
public FileSharesClient(string subscriptionId, TokenCredential tokenCredential, StorageManagementClientOptions options):
this(new ClientDiagnostics(options), ManagementClientPipeline.Build(options, tokenCredential), subscriptionId, apiVersion: options.VersionString)
{
}
}
```

### Code Review Process

Before a pull request will be considered by the Azure SDK team, the following requirements must be met:
Expand Down

0 comments on commit a2d1f94

Please sign in to comment.