-
Notifications
You must be signed in to change notification settings - Fork 830
Description
Context
👋 .NET 10 is bringing support for Runtime-Async. I started playing around with it in an IcedTasks PR. However, I noticed some of benchmarks being off considerably. One of the requirements is having MethodImplOptions.Async set. I manually added the atttribute, but it doesn't get written to the IL.
Repro steps
Provide the steps required to reproduce the problem:
[<MethodImpl(MethodImplOptions.Async)>]
let fsharp_tenBindAsync_TaskBuilderRuntime () =
IcedTasks.Polyfill.TasksRuntime.TaskBuilder.task {
do! taskYield ()
return 100
}see that the compiled DLL doesn't contain it in the IL/decompiled c#
public static Task<int> fsharp_tenBindAsync_TaskBuilderRuntime()
{
YieldAwaitable.YieldAwaiter awaiter1 = Task.Yield().GetAwaiter();
if (!awaiter1.IsCompleted)
AsyncHelpers.UnsafeAwaitAwaiter<YieldAwaitable.YieldAwaiter>(awaiter1);
awaiter1.GetResult();
ValueTaskAwaiter<int> awaiter11 = ValueTask.FromResult<int>(100).GetAwaiter();
if (!awaiter11.IsCompleted)
AsyncHelpers.UnsafeAwaitAwaiter<ValueTaskAwaiter<int>>(awaiter11);
return Task.FromResult<int>(awaiter11.GetResult());
}ilprint seems to need to have detection and output for it done. However, the current detection relies on MethodImpl being in netstandard2.0, since this is part of net10.0, there would have to be some compat layer here.
fsharp/src/Compiler/AbstractIL/ilprint.fs
Lines 717 to 730 in 6ec56c2
| if md.IsSynchronized then | |
| output_string os "synchronized " | |
| if md.IsMustRun then | |
| output_string os "/* mustrun */ " | |
| if md.IsPreserveSig then | |
| output_string os "preservesig " | |
| if md.IsNoInline then | |
| output_string os "noinlining " | |
| if md.IsAggressiveInline then | |
| output_string os "aggressiveinlining " |
Secondly, as a separate discussion point. Having people manually add this attribute would be extremely inconvenient. What options do you see as possible for a CE to add attributes to the methods that get written out? (We can move to a separate discussion if needed)
Expected behavior
MethodImpl is preserved
Actual behavior
MethodImpl is not preserved
Known workarounds
Hand editing the IL?
Related information
Provide any related information (optional):
- Operating system
- .NET Runtime kind (.NET Core, .NET Framework, Mono)
- Editing Tools (e.g. Visual Studio Version, Visual Studio)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status