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

Samples update #1

Merged
merged 2 commits into from
Feb 23, 2021
Merged

Conversation

maririos
Copy link

@maririos maririos commented Feb 23, 2021

Some changes for now. I see the dilemma of working with the pageable types when u only want one data point. i.e. one document from the all documents call.
As they are, it is not clear why we need the GetDocumenStatus, so we might want to think how to showcase it better.

@@ -7,6 +7,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.AI.DocumentTranslatio
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.DocumentTranslation.Tests", "tests\Azure.AI.DocumentTranslation.Tests.csproj", "{B0E7B026-E91D-4EEC-8989-AC9902C9BDCE}"
EndProject
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{439F1494-8E96-4931-AB0A-5BBA7EBA15D2}"
Copy link
Author

Choose a reason for hiding this comment

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

adding the project into our solution so when we debug we can go inside the classes

@@ -449,5 +450,26 @@ internal virtual async Task<Response<IReadOnlyList<string>>> GetSupportedStorage
throw;
}
}

#region nobody wants to see these
Copy link
Author

Choose a reason for hiding this comment

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

just general cleanup so this doesn't show in Intellisense

<PropertyGroup>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>

<IsPackable>false</IsPackable>
Copy link
Author

Choose a reason for hiding this comment

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

No needed as our build will check if this is a test, sample. If it is, it will set the property to false.

@@ -7,7 +7,7 @@
using Azure.Core.TestFramework;
using NUnit.Framework;

namespace Azure.AI.DocumentTranslation.Tests.samples
namespace Azure.AI.DocumentTranslation.Tests.Samples
Copy link
Author

Choose a reason for hiding this comment

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

Consolidating all samples so they appear in the same namespace group

@@ -22,32 +22,42 @@ public void TranslateOperationConvenience()

var client = new DocumentTranslationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

var operation = client.StartBatchTranslation(new Uri(sourceUrl), "en", new Uri(targetUrl), "it");
DocumentTranslationOperation operation = client.StartBatchTranslation(new Uri(sourceUrl), "en", new Uri(targetUrl), "it");
Copy link
Author

Choose a reason for hiding this comment

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

Our repo follows the .NET coding style so we avoid the use of var, unless it is clear what the type of the object is. See Coding Style rule Azure#10

Pageable<DocumentStatusDetail> response = operation.GetValues();

var docsEnumerator = response.GetEnumerator();
Console.WriteLine($" Status: {operation.Status}");
Copy link
Author

Choose a reason for hiding this comment

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

I want to show the operation information so the user can see progress.
I only add it to this sample as an example

@@ -22,24 +22,36 @@ public async Task TranslateOperationConvenienceTestAsync()

var client = new DocumentTranslationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

var operation = await client.StartBatchTranslationAsync(new Uri(sourceUrl), "en", new Uri(targetUrl), "it");
DocumentTranslationOperation operation = await client.StartBatchTranslationAsync(new Uri(sourceUrl), "es", new Uri(targetUrl), "en");
Copy link
Author

Choose a reason for hiding this comment

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

oh never mind my language codes, I was playing around with the service and forgot to undo :(


var docsEnumerator = response.Value.GetAsyncEnumerator();
Console.WriteLine("Operation Information:");
Copy link
Author

Choose a reason for hiding this comment

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

because there is no manual polling here (it could totally happen though), I am showing the operation information after it finished

@a-noyass a-noyass merged commit 80e418d into a-noyass:document-translation Feb 23, 2021
@maririos maririos deleted the translation branch March 9, 2021 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants