Skip to content

Commit b836e50

Browse files
Add suppression for sync-over-async (Azure#52948)
1 parent c2bad81 commit b836e50

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

eng/packages/http-client-csharp/generator/Azure.Generator/src/Visitors/MultiPartFormDataVisitor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.TypeSpec.Generator.Expressions;
88
using Microsoft.TypeSpec.Generator.Providers;
99
using Microsoft.TypeSpec.Generator.Statements;
10+
using static Microsoft.TypeSpec.Generator.Snippets.Snippet;
1011

1112
namespace Azure.Generator.Visitors
1213
{
@@ -25,6 +26,8 @@ protected override MethodBodyStatement VisitExpressionStatement(ExpressionStatem
2526
instanceReference: innerInvoke.InstanceReference,
2627
methodName: nameof(TaskExtensions.EnsureCompleted),
2728
extensionType: typeof(TaskExtensions));
29+
return new SuppressionStatement(statement, Literal("AZC0107"),
30+
"Public asynchronous method shouldn't be called in synchronous scope. Use synchronous version of the method if it is available.");
2831
}
2932
}
3033
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#if NET6_0_OR_GREATER
22
_multipartContent.CopyTo(stream, default, cancellationToken);
33
#else
4+
#pragma warning disable AZC0107 // Public asynchronous method shouldn't be called in synchronous scope. Use synchronous version of the method if it is available.
45
_multipartContent.CopyToAsync(stream).EnsureCompleted();
6+
#pragma warning restore AZC0107 // Public asynchronous method shouldn't be called in synchronous scope. Use synchronous version of the method if it is available.
57
#endif

eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/Internal/MultiPartFormDataBinaryContent.cs

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)