diff --git a/sdk/core/Azure.Core/src/TokenCredential.cs b/sdk/core/Azure.Core/src/TokenCredential.cs
index 2705f1e09bc1..08a079f891ac 100644
--- a/sdk/core/Azure.Core/src/TokenCredential.cs
+++ b/sdk/core/Azure.Core/src/TokenCredential.cs
@@ -17,7 +17,7 @@ public abstract class TokenCredential
/// The with authentication information.
/// The to use.
/// A valid .
- public abstract Task GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken);
+ public abstract ValueTask GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken);
///
/// Gets an for the specified set of scopes.
diff --git a/sdk/core/Azure.Core/tests/TestFramework/DiagnosticScopeValidatingInterceptor.cs b/sdk/core/Azure.Core/tests/TestFramework/DiagnosticScopeValidatingInterceptor.cs
index 9ef93a3cd7fe..a18f222703bb 100644
--- a/sdk/core/Azure.Core/tests/TestFramework/DiagnosticScopeValidatingInterceptor.cs
+++ b/sdk/core/Azure.Core/tests/TestFramework/DiagnosticScopeValidatingInterceptor.cs
@@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
+using System.Reflection;
using System.Threading.Tasks;
using Azure.Core.Tests;
using Castle.DynamicProxy;
@@ -36,10 +37,26 @@ public void Intercept(IInvocation invocation)
return;
}
- var result = (Task)invocation.ReturnValue;
try
{
- result.GetAwaiter().GetResult();
+ object returnValue = invocation.ReturnValue;
+ if (returnValue is Task t)
+ {
+ t.GetAwaiter().GetResult();
+ }
+ else
+ {
+ // Await ValueTask
+ Type returnType = returnValue.GetType();
+ MethodInfo getAwaiterMethod = returnType.GetMethod("GetAwaiter", BindingFlags.Instance | BindingFlags.Public);
+ MethodInfo getResultMethod = getAwaiterMethod.ReturnType.GetMethod("GetResult", BindingFlags.Instance | BindingFlags.Public);
+
+ getResultMethod.Invoke(
+ getAwaiterMethod.Invoke(returnValue, Array.Empty