Await DataReader.LoadAsync() causes a build error

Hello,

I wrote a code like this:

using UnityEngine;
using System.Collections;

#if UNITY_WSA && !UNITY_EDITOR
using System.Threading.Tasks;
using Windows.Storage.Streams;
#endif

public class Foo : MonoBehaviour {
    // Use this for initialization
    void Start () {}

    // Update is called once per frame
    void Update () {}

#if UNITY_WSA && !UNITY_EDITOR
    private async Task Bar(DataReader reader)
    {
        reader.InputStreamOptions = InputStreamOptions.Partial;
        await reader.LoadAsync(reader.UnconsumedBufferLength);
    }
#endif
}

and built it to Windows Store for Universal 10 SDK.
Then I got this build error:

Assets\Foo.cs(25,9): error CS4036: ‘DataReaderLoadOperation’ does not contain a definition for ‘GetAwaiter’ and no extension method ‘GetAwaiter’ accepting a first argument of type ‘DataReaderLoadOperation’ could be found (are you missing a using directive for ‘System’?)

This works before upgrade (I don’t remember exact version but I think it was Unity 5.2) plus, the code works in VS2015 Windows Store App.
How can I make it work?

Environment:

  • Unity 5.3.4p1 x64
  • Windows 10 x64
  • Platform: Windows Store
  • SDK: Universal 10

thanks,
Daisuke

Reading error messages sometimes helps. Add at the top of the file this line and it will compile:

using System;

Thanks, it works.
I’ll read error messages one more time from now on :eyes: