Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

CC1099: Contract extraction failed: async/iterator issue in async without await #172

Closed
mgaffigan opened this issue Jul 27, 2015 · 11 comments · Fixed by #173
Closed

CC1099: Contract extraction failed: async/iterator issue in async without await #172

mgaffigan opened this issue Jul 27, 2015 · 11 comments · Fixed by #173
Assignees

Comments

@mgaffigan
Copy link

I am getting the error CC1099 on a particular method. I have narrowed the method down to one specific change which will cause the failure. The below sample compiled as a console application with rewriting enabled seems to reliably fail.

Error:

EXEC : error CC1099: Contract extraction failed: async/iterator issue: In method EmptyAsyncTest.Program.Foo, assembly EmptyAsyncTest\EmptyAsyncTest\obj\Debug\EmptyAsyncTest.exe

Code:

using System;
using System.Threading.Tasks;

namespace EmptyAsyncTest
{
    class Program
    {
        static void Main(string[] args)
        {
        }

        async Task Foo()
        {
            if (DateTime.Now.Day == 0 && 1 == 2)
            {
            }
        }
    }
}

The following variations do not trigger the bug:

  • Removing async and returning Task.FromResult(false)
  • Removing && 1 == 2
  • Removing DateTime.Now.Day == 0
  • Adding await Task.Delay(1)

Environment:
VS 2015 CTP, Code Contracts 1.9.10714.2, Windows 8.1, Project is .Net 4.5, Only rewriting is enabled
Also repro'd by compiling fe3bf15 and running foxtrot. Same output.

@SergeyTeplyakov
Copy link
Contributor

grabbed.

@SergeyTeplyakov SergeyTeplyakov self-assigned this Jul 27, 2015
@sharwell
Copy link
Member

@mgaffigan This is a great bug report. Thanks for taking the time to find a simple way to reproduce the problem and explain the variants you tested. 😄

@SergeyTeplyakov
Copy link
Contributor

Investigation results:

  1. This bug is only for VS2015
  2. Only for async methods without awaits
  3. Only for async methods without contracts

I'm running the tests right now for the fix.

SergeyTeplyakov added a commit to SergeyTeplyakov/CodeContracts that referenced this issue Jul 27, 2015
@SergeyTeplyakov
Copy link
Contributor

Created PR with a fix: #173.

@mgaffigan
Copy link
Author

@SergeyTeplyakov, Thank you for the quick response.

@SergeyTeplyakov
Copy link
Contributor

@mgaffigan You're welcome! And thanks a lot for great bug report!

@takinosaji
Copy link

takinosaji commented Sep 28, 2016

Bug still presented. Got this error on such a code:

public override async Task Meth(Int32 number)
In a function without await.

@GreenKn1ght
Copy link

@takinosaji, are you use this pre-release or latest?

@takinosaji
Copy link

@GreenKn1ght nope i am using latest.

@GreenKn1ght
Copy link

@takinosaji just asking because this fix not released yet =/

@NiceStepUp
Copy link

Adding await part to async is fixed this error. Thanks, guys and especially to Sergei Teplyakov!

_Investigation results:

  1. This bug is only for VS2015
  2. Only for async methods without awaits
  3. Only for async methods without contracts_

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants