Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve template to include tests, live resources, recordings etc #11540

Merged
merged 7 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion eng/ApiListing.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
<GenAPIAdditionalParameters>--exclude-attributes-list "$(MSBuildThisFileDirectory)ApiListing.exclude-attributes.txt" $(GenAPIAdditionalParameters)</GenAPIAdditionalParameters>
<GenAPITargetPath>$(_RefSourceOutputPath)$(AssemblyName).$(TargetFramework).cs</GenAPITargetPath>
</PropertyGroup>
<Delete Files="$(GenAPITargetPath)" />
<ItemGroup>
<!-- Remove all files that don't start with $(AssemblyName) and the current target -->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes an issue where copying Azure.Template and re-running Export-API leaves the original API listing around and confuses people.

<_ListingsToRemove Include="$(_RefSourceOutputPath)*" Exclude="$(_RefSourceOutputPath)$(AssemblyName).*.cs" />
<_ListingsToRemove Include="$(GenAPITargetPath)" />
</ItemGroup>

<Delete Files="@(_ListingsToRemove)" />
<MakeDir Directories="$(_RefSourceOutputPath)"/>
</Target>

Expand Down
7 changes: 4 additions & 3 deletions sdk/core/Azure.Core/tests/TestFramework/RecordEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.Json;
using Azure.Core.Pipeline;
Expand Down Expand Up @@ -75,11 +76,11 @@ private static byte[] DeserializeBody(IDictionary<string, string[]> headers, in
{
if (property.ValueKind == JsonValueKind.Object)
{
var arrayBufferWriter = new ArrayBufferWriter<byte>();
using var writer = new Utf8JsonWriter(arrayBufferWriter);
using var memoryStream = new MemoryStream();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to have IVT from lib to tests or manually include ArrayBufferWriter into test project anymore.

using var writer = new Utf8JsonWriter(memoryStream);
property.WriteTo(writer);
writer.Flush();
return arrayBufferWriter.WrittenMemory.ToArray();
return memoryStream.ToArray();
}
else if (property.ValueKind == JsonValueKind.Array)
{
Expand Down
10 changes: 4 additions & 6 deletions sdk/template/Azure.Template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,12 @@ thing.save()

The [get_thing](not-valid-link) method retrieves a Thing from the service. The `id` parameter is the unique ID of the Thing, not its "name" property.

```Python
thing = client.get_thing(id)
```

### List the things
```C# Snippet:GetSecret
var client = new MiniSecretClient(new Uri(endpoint), new DefaultAzureCredential());

Use [list_things](not-valid-link) to get one or more Thing objects from the service. If there are no Things available, a `404` exception is thrown (see [Troubleshooting](#troubleshooting) for details on handling exceptions).
SecretBundle secret = client.GetSecret("TestSecret");

Console.WriteLine(secret.Value);
```Python
things = client.list_things()
```
Expand Down
72 changes: 17 additions & 55 deletions sdk/template/Azure.Template/api/Azure.Template.netstandard2.0.cs
Original file line number Diff line number Diff line change
@@ -1,70 +1,32 @@
namespace Azure.Template
{
public partial class TemplateClient
public partial class MiniSecretClient
{
protected TemplateClient() { }
public TemplateClient(System.Uri endpoint) { }
public TemplateClient(System.Uri endpoint, Azure.Template.TemplateClientOptions options) { }
public virtual Azure.Response<Azure.Template.Models.ServiceModel> Operation(Azure.Template.Models.ServiceModel body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Template.Models.ServiceModel>> OperationAsync(Azure.Template.Models.ServiceModel body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
protected MiniSecretClient() { }
public MiniSecretClient(System.Uri endpoint, Azure.Core.TokenCredential credential) { }
public MiniSecretClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.Template.MiniSecretClientOptions options) { }
public virtual Azure.Response<Azure.Template.Models.SecretBundle> GetSecret(string secretName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Template.Models.SecretBundle>> GetSecretAsync(string secretName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public partial class TemplateClientOptions : Azure.Core.ClientOptions
public partial class MiniSecretClientOptions : Azure.Core.ClientOptions
{
public TemplateClientOptions(Azure.Template.TemplateClientOptions.ServiceVersion version = Azure.Template.TemplateClientOptions.ServiceVersion.V1) { }
public MiniSecretClientOptions(Azure.Template.MiniSecretClientOptions.ServiceVersion version = Azure.Template.MiniSecretClientOptions.ServiceVersion.V7_0) { }
public enum ServiceVersion
{
V1 = 1,
V7_0 = 1,
}
}
}
namespace Azure.Template.Models
{
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct DaysOfWeek : System.IEquatable<Azure.Template.Models.DaysOfWeek>
public partial class SecretBundle
{
private readonly object _dummy;
private readonly int _dummyPrimitive;
public DaysOfWeek(string value) { throw null; }
public static Azure.Template.Models.DaysOfWeek Friday { get { throw null; } }
public static Azure.Template.Models.DaysOfWeek Monday { get { throw null; } }
public static Azure.Template.Models.DaysOfWeek Saturday { get { throw null; } }
public static Azure.Template.Models.DaysOfWeek Sunday { get { throw null; } }
public static Azure.Template.Models.DaysOfWeek Thursday { get { throw null; } }
public static Azure.Template.Models.DaysOfWeek Tuesday { get { throw null; } }
public static Azure.Template.Models.DaysOfWeek Wednesday { get { throw null; } }
public bool Equals(Azure.Template.Models.DaysOfWeek other) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object obj) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override int GetHashCode() { throw null; }
public static bool operator ==(Azure.Template.Models.DaysOfWeek left, Azure.Template.Models.DaysOfWeek right) { throw null; }
public static implicit operator Azure.Template.Models.DaysOfWeek (string value) { throw null; }
public static bool operator !=(Azure.Template.Models.DaysOfWeek left, Azure.Template.Models.DaysOfWeek right) { throw null; }
public override string ToString() { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct FruitType : System.IEquatable<Azure.Template.Models.FruitType>
{
private readonly object _dummy;
private readonly int _dummyPrimitive;
public FruitType(string value) { throw null; }
public static Azure.Template.Models.FruitType Apple { get { throw null; } }
public static Azure.Template.Models.FruitType Pear { get { throw null; } }
public bool Equals(Azure.Template.Models.FruitType other) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object obj) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override int GetHashCode() { throw null; }
public static bool operator ==(Azure.Template.Models.FruitType left, Azure.Template.Models.FruitType right) { throw null; }
public static implicit operator Azure.Template.Models.FruitType (string value) { throw null; }
public static bool operator !=(Azure.Template.Models.FruitType left, Azure.Template.Models.FruitType right) { throw null; }
public override string ToString() { throw null; }
}
public partial class ServiceModel
{
public ServiceModel(Azure.Template.Models.FruitType fruit, Azure.Template.Models.DaysOfWeek daysOfWeek) { }
public Azure.Template.Models.DaysOfWeek DaysOfWeek { get { throw null; } }
public Azure.Template.Models.FruitType Fruit { get { throw null; } }
public string ModelProperty { get { throw null; } set { } }
internal SecretBundle() { }
public string ContentType { get { throw null; } }
public string Id { get { throw null; } }
public string Kid { get { throw null; } }
public bool? Managed { get { throw null; } }
public System.Collections.Generic.IReadOnlyDictionary<string, string> Tags { get { throw null; } }
public string Value { get { throw null; } }
}
}
65 changes: 0 additions & 65 deletions sdk/template/Azure.Template/src/Generated/Models/DaysOfWeek.cs

This file was deleted.

50 changes: 0 additions & 50 deletions sdk/template/Azure.Template/src/Generated/Models/FruitType.cs

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading