c# - What is the minimum set of types required to compile `async` code? -
out of curiosity, i'm trying simple async
/await
code compile under .net 3.5 client profile:
async void awaitfoo() { await new foo(); } class foo { public ifooawaiter getawaiter() { … } } interface ifooawaiter : system.runtime.compilerservices.inotifycompletion { bool iscompleted { get; } void getresult(); }
i'm aware .net 3.5 not support language feature, expressed compilation error:
cannot find types required
async
modifier. targeting wrong framework version, or missing reference assembly?
i aware of nuget package microsoft.bcl.async
, not have support .net 3.5.
question: minimum set of types & type members required async
code compile? minimal set officially documented; , if so, where? (note i'm interested in successful compilation, not execution.)
what i've got far:
i've been trying find minimum set of types experiment, appears possible since compiler reports required, missing types 1 one:
predefined type
system.runtime.compilerservices.iasyncstatemachine
not defined or imported.
defining reported type according msdn reference pages leads next missing type being reported. have far:
system.runtime.compilerservices.iasyncstatemachine
system.runtime.compilerservices.inotifycompletion
(required example code above)system.threading.tasks.cancellationtoken
(requiredtask
)system.threading.tasks.taskcreationoptions
(requiredtask
)system.threading.tasks.task
at point stopped, since task
has lots of members, compiler not report members requires; reports type whole. might therefore reproduce more of type definition needed.
in terms of c# compiler, need:
asynctaskmethodbuilder
asynctaskmethodbuilder<tresult>
asyncvoidmethodbuilder
asyncstatemachineattribute
- possibly
icriticalnotifycompletion
although believe that' used builder.
i wouldn't expect either taskcreationoptions
or cancellationtoken
required - can't think they'd used in generated code.
fundamentally though, need whole tpl support work - having compile isn't going you. if you're interested in curiosity, that's different matter. might interested in eduasync blog series, crude version of getting ctp release of compiler work without asyncctplibrary.dll
assembly (against .net 4.0) - supplying relevant types.
the source code won't work against c# 5 compiler things changed bit final release, of concepts have stayed same.
Comments
Post a Comment