StephenCleary / AsyncEx

A helper library for async/await.
MIT License
3.53k stars 356 forks source link

Resharper conflict VS2013 - RS9 #25

Closed StephenCleary closed 9 years ago

StephenCleary commented 9 years ago

Migrated from CodePlex

Steps:

  1. Create new console app in 2013
  2. PM> Install-Package Nito.AsyncEx -Version 3.0.0
  3. Code:
class Program
{
  static void Main(string[] args)
  {
    AsyncContext.Run(() => MainAsync(args));
  }

  static async void MainAsync(string[] args)
  {
    await Task.Delay(TimeSpan.FromSeconds(1));
  }
}

Resharper complains about System.Runtime, but actually code runs fine unless you let resharper add that reference to runtime, then it fails to build. Interestingly, suspending and resuming resharper then does not show error.

Understand if you regard this as resharper bug, but thought that adding reference to System.Runtime 4.0.0.0 should not stop compilation with your nuget package.

nitoasync

StephenCleary commented 9 years ago

I was unable to reproduce this issue with the steps provided on Re# 9.1.1.

If creating a .NET 4.5 Console app, then there are no references to System.Runtime.

If creating a .NET 4.0 Console app, then a reference to System.Runtime is created for you.

Since the example code uses Task.Delay, I believe it is a .NET 4.5 console app that somehow has the .NET 4.0 version of AsyncEx references. This can happen if you install AsyncEx into a .NET 4.0 console app and then change the target framework to .NET 4.5. In general, NuGet packages do not work correctly when changing frameworks; the correct procedure is to uninstall all NuGet packages, change the target framework, and then re-install them all.