Skip to content

Commit

Permalink
Update autorest.csharp to 3.0.0-beta.20221012.1 (#31770)
Browse files Browse the repository at this point in the history
* Update autorest.csharp to 3.0.0-beta.20221012.1

* Remove workarounds for Question Answering

Now that we're fixing Azure/autorest.csharp#2726 I can remove the workarounds. Also, some tests were only recorded because we have never sent the `Accept` request header in LROs, which the explicit method calls generated on the client did. That's tracked in Azure/autorest.csharp#2765

Co-authored-by: Heath Stewart <heaths@microsoft.com>
  • Loading branch information
AlexanderSher and heaths authored Oct 13, 2022
1 parent 41980e6 commit 4ced6e7
Show file tree
Hide file tree
Showing 12 changed files with 758 additions and 1,170 deletions.
2 changes: 1 addition & 1 deletion eng/Packages.Data.props
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
All should have PrivateAssets="All" set so they don't become package dependencies
-->
<ItemGroup>
<PackageReference Update="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20220923.1" PrivateAssets="All" />
<PackageReference Update="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20221012.1" PrivateAssets="All" />
<PackageReference Update="Azure.ClientSdk.Analyzers" Version="0.1.1-dev.20220111.2" PrivateAssets="All" />
<PackageReference Update="coverlet.collector" Version="1.3.0" PrivateAssets="All" />
<PackageReference Update="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.1" PrivateAssets="All" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ public async Task DeployProject()
Operation<AsyncPageable<BinaryData>> updateSourcesOperation = await Client.UpdateSourcesAsync(WaitUntil.Completed, testProjectName, updateSourcesRequestContent);

string testDeploymentName = "production";
Operation<BinaryData> deploymentOperation = await Client.DeployProjectAsync(WaitUntil.Started, testProjectName, testDeploymentName);

await deploymentOperation.WaitForCompletionAsync();
AsyncPageable<BinaryData> deployments = Client.GetDeploymentsAsync(testProjectName);
Operation<BinaryData> deploymentOperation = await Client.DeployProjectAsync(WaitUntil.Completed, testProjectName, testDeploymentName);
BinaryData deployment = deploymentOperation.Value;

Assert.True(deploymentOperation.HasCompleted);
Assert.That((await deployments.ToEnumerableAsync()).Any(deployment => deployment.ToString().Contains(testDeploymentName)));
Assert.That(deployment.ToString(), Contains.Substring(testDeploymentName));
}

[RecordedTest]
Expand Down Expand Up @@ -114,12 +112,7 @@ public async Task UpdateQnAs()
});

Operation<AsyncPageable<BinaryData>> updateQnasOperation = await Client.UpdateQnasAsync(WaitUntil.Completed, testProjectName, updateQnasRequestContent);

// BUGBUG: This gets the job state.
// AsyncPageable<BinaryData> sources = updateQnasOperation.Value;

// This works, but is not the intended use case.
AsyncPageable<BinaryData> sources = Client.GetQnasAsync(testProjectName);
AsyncPageable<BinaryData> sources = updateQnasOperation.Value;

Assert.True(updateQnasOperation.HasCompleted);
Assert.AreEqual(200, updateQnasOperation.GetRawResponse().Status);
Expand Down Expand Up @@ -152,12 +145,7 @@ public async Task UpdateSources()
});

Operation<AsyncPageable<BinaryData>> updateSourcesOperation = await Client.UpdateSourcesAsync(WaitUntil.Completed, testProjectName, updateSourcesRequestContent);

// BUGBUG: This gets the job state.
// AsyncPageable<BinaryData> sources = updateSourcesOperation.Value;

// This works, but is not the intended use case.
AsyncPageable<BinaryData> sources = Client.GetSourcesAsync(testProjectName);
AsyncPageable<BinaryData> sources = updateSourcesOperation.Value;

Assert.True(updateSourcesOperation.HasCompleted);
Assert.AreEqual(200, updateSourcesOperation.GetRawResponse().Status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,8 @@ public void CreateAndDeploy()

Operation<Pageable<BinaryData>> updateSourcesOperation = client.UpdateSources(WaitUntil.Completed, newProjectName, updateSourcesRequestContent);

#if SNIPPET
// Knowledge Sources can be retrieved as follows
Pageable<BinaryData> sources = updateSourcesOperation.Value;
#else
// TODO: Remove this condition once https://github.com/Azure/autorest.csharp/issues/2726 is fixed.
Pageable<BinaryData> sources = client.GetSources(newProjectName);
#endif

Console.WriteLine("Sources: ");
foreach (BinaryData source in sources)
Expand Down Expand Up @@ -186,13 +181,8 @@ public async Task CreateAndDeployAsync()

Operation<AsyncPageable<BinaryData>> updateSourcesOperation = await client.UpdateSourcesAsync(WaitUntil.Completed, newProjectName, updateSourcesRequestContent);

#if SNIPPET
// Knowledge Sources can be retrieved as follows
AsyncPageable<BinaryData> sources = updateSourcesOperation.Value;
#else
// TODO: Remove this condition once https://github.com/Azure/autorest.csharp/issues/2726 is fixed.
AsyncPageable<BinaryData> sources = client.GetSourcesAsync(newProjectName);
#endif

Console.WriteLine("Sources: ");
await foreach (BinaryData source in sources)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,8 @@ public void KnowledgeSources()

Operation<Pageable<BinaryData>> updateSourcesOperation = client.UpdateSources(WaitUntil.Completed, testProjectName, updateSourcesRequestContent);

#if SNIPPET
// Updated Knowledge Sources can be retrieved as follows
Pageable<BinaryData> sources = updateSourcesOperation.Value;
#else
// TODO: Remove this condition once https://github.com/Azure/autorest.csharp/issues/2726 is fixed.
Pageable<BinaryData> sources = client.GetSources(testProjectName);
#endif

Console.WriteLine("Sources: ");
foreach (BinaryData source in sources)
Expand Down Expand Up @@ -89,13 +84,8 @@ public void KnowledgeSources()

Operation<Pageable<BinaryData>> updateQnasOperation = Client.UpdateQnas(WaitUntil.Completed, testProjectName, updateQnasRequestContent);

#if SNIPPET
// QnAs can be retrieved as follows
Pageable<BinaryData> qnas = updateQnasOperation.Value;
#else
// TODO: Remove this condition once https://github.com/Azure/autorest.csharp/issues/2726 is fixed.
Pageable<BinaryData> qnas = client.GetQnas(testProjectName);
#endif

Console.WriteLine("Qnas: ");
foreach (var qna in qnas)
Expand Down Expand Up @@ -201,13 +191,8 @@ public async Task KnowledgeSourcesAsync()

Operation<AsyncPageable<BinaryData>> updateSourcesOperation = await client.UpdateSourcesAsync(WaitUntil.Completed, testProjectName, updateSourcesRequestContent);

#if SNIPPET
// Updated Knowledge Sources can be retrieved as follows
AsyncPageable<BinaryData> sources = updateSourcesOperation.Value;
#else
// TODO: Remove this condition once https://github.com/Azure/autorest.csharp/issues/2726 is fixed.
AsyncPageable<BinaryData> sources = client.GetSourcesAsync(testProjectName);
#endif

Console.WriteLine("Sources: ");
await foreach (BinaryData source in sources)
Expand Down Expand Up @@ -243,13 +228,8 @@ public async Task KnowledgeSourcesAsync()

Operation<AsyncPageable<BinaryData>> updateQnasOperation = await Client.UpdateQnasAsync(WaitUntil.Completed, testProjectName, updateQnasRequestContent);

#if SNIPPET
// QnAs can be retrieved as follows
AsyncPageable<BinaryData> qnas = updateQnasOperation.Value;
#else
// TODO: Remove this condition once https://github.com/Azure/autorest.csharp/issues/2726 is fixed.
AsyncPageable<BinaryData> qnas = client.GetQnasAsync(testProjectName);
#endif

Console.WriteLine("Qnas: ");
await foreach (var qna in qnas)
Expand Down
Loading

0 comments on commit 4ced6e7

Please sign in to comment.