Description
I am currently trying the runtime-async feature on my code base. One of my methods is not supported, so the compilers yields
...\MethodHandler.cs(255,13): error CS9328: Method 'MethodHandler.UnwrapAsync(object?)' uses a feature that is not supported by runtime async currently. Opt the method out of runtime async by attributing it with 'System.Runtime.CompilerServices.RuntimeAsyncMethodGenerationAttribute(false)'.
Yet when attributing the method with given attribute, the compiler yields
... net11.0 failed with 2 error(s) (0.4s)
...\MethodHandler.cs(240,38): error CS0234: The type or namespace name 'RuntimeAsyncMethodGenerationAttribute' does not exist in the namespace 'System.Runtime.CompilerServices' (are you missing an assembly reference?)
This is on 11.0.100-preview.4.26230.115
I suppose the documentation somehow drifted?
Reproduction Steps
Create a method that is not supported by runtime-async, for example:
private static async ValueTask<object?> UnwrapAsync(object? result)
{
if (result == null)
{
return null;
}
var type = result.GetType();
if (type == typeof(ValueTask) || type == typeof(Task))
{
dynamic task = result;
await task;
return null;
}
return result;
}
Compile and get error CS9328.
Add the attribute to opt out:
[System.Runtime.CompilerServices.RuntimeAsyncMethodGeneration(false)]
private static async ValueTask<object?> UnwrapAsync(object? result)
Expected behavior
Code does compile, the method opted out of runtime-async.
Actual behavior
Compiler shows error CS0234.
Regression?
No response
Known Workarounds
No response
Configuration
.NET 11.0.100-preview.4.26230.115
Microsoft Windows 25H2 26200.8457 (x64)
Other information
No response
Description
I am currently trying the
runtime-asyncfeature on my code base. One of my methods is not supported, so the compilers yieldsYet when attributing the method with given attribute, the compiler yields
This is on
11.0.100-preview.4.26230.115I suppose the documentation somehow drifted?
Reproduction Steps
Create a method that is not supported by
runtime-async, for example:Compile and get error
CS9328.Add the attribute to opt out:
Expected behavior
Code does compile, the method opted out of
runtime-async.Actual behavior
Compiler shows error
CS0234.Regression?
No response
Known Workarounds
No response
Configuration
.NET 11.0.100-preview.4.26230.115
Microsoft Windows 25H2 26200.8457 (x64)
Other information
No response