You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
Using Visual Studio 2017 Enterprise RC, 15.0.0-RC.4+26206.0
Output:
error CC1017: Malformed contract section in method 'AsyncContracts.AsyncContracts+<DoTheThingSlowly>d__0.MoveNext'
Code that triggers this bug:
using System;
using System.Diagnostics.Contracts;
using System.IO;
using System.Threading.Tasks;
namespace AsyncContracts
{
public class AsyncContracts
{
public static async Task<string> DoTheThingSlowly(object o)
{
Contract.Requires(o != null);
await Task.Delay(TimeSpan.FromSeconds(1));
using (var s = new MemoryStream())
{
await Task.Delay(TimeSpan.FromSeconds(1));
await Task.Delay(TimeSpan.FromSeconds(1));
return o.ToString();
}
}
}
}
It appears that this block of IL, which exists before the calls to Contract.Requires, is confusing the rewriter. The rewriter seems to understand a switch statement and a simple condition, but not this subtraction-based condition.
Using Visual Studio 2017 Enterprise RC, 15.0.0-RC.4+26206.0
Output:
Code that triggers this bug:
IL of the generated async state machine:
IL from VS2015, this works with ccrewrite:
It appears that this block of IL, which exists before the calls to
Contract.Requires
, is confusing the rewriter. The rewriter seems to understand a switch statement and a simple condition, but not this subtraction-based condition.(Related to VS2017, so tagging #451 here).
@SergeyTeplyakov Is this something that can be easily fixed?
The text was updated successfully, but these errors were encountered: