Shaolinq icon indicating copy to clipboard operation
Shaolinq copied to clipboard

AsyncRewriter - Null conditional extension method call in async method breaks build

Open samcook opened this issue 7 years ago • 0 comments

A null conditional extension method call in an async method breaks the build of a project that uses AsyncRewriter (even if the class or method isn't attributed for rewriting).

namespace CrashTestDummy
{
	public class TestObject
	{
		public List<string> ChildObjects { get; }
	}

	public partial class TestClass
	{
		public async Task<string> GetDataAsync(TestObject obj)
		{
			var firstChild = obj.ChildObjects?.FirstOrDefault(); // null conditional extension method call in async method breaks build
			//var firstChild = obj.ChildObjects?.Find(x => true); // non extension method is fine
			return firstChild;
		}
	}
}

Results in this output at detailed level:

1>Target "GenerateAsyncSource" in file "c:\users\sam\documents\visual studio 2017\Projects\CrashTestDummy\packages\Shaolinq.AsyncRewriter.1.5.0.1286\build\Shaolinq.AsyncRewriter.targets" from project "c:\users\sam\documents\visual studio 2017\Projects\CrashTestDummy\CrashTestDummy\CrashTestDummy.csproj" (target "CoreResGen" depends on it):
1>Building target "GenerateAsyncSource" completely.
1>Input file "TestClass.cs" is newer than output file "obj\\Debug\GeneratedAsync.cs".
1>Using "AsyncRewriterTask" task from assembly "c:\users\sam\documents\visual studio 2017\Projects\CrashTestDummy\packages\Shaolinq.AsyncRewriter.1.5.0.1286\build\..\tools\Shaolinq.AsyncRewriter.exe".
1>Task "AsyncRewriterTask"
1>Done executing task "AsyncRewriterTask" -- FAILED.
1>Done building target "GenerateAsyncSource" in project "CrashTestDummy.csproj" -- FAILED.

samcook avatar Apr 19 '18 12:04 samcook