T4 template to generate async methods wrapping existing APM
Install from nuget to project you need wrappers in.
Install-Package AsyncGenerator
This will add two files:
AsyncExtensions.ttinclude - this is main implemantation
ExampleAsyncExtensions.tt - example template, it configures and include AsyncExtensions.ttinclude
Example of ExampleAsyncExtensions.tt
, in most cases you only need modify Name
, Namespace
and Assemblies
.
<#
var config = new GenerationConfiguration
{
Name = "ExampleAsyncExtensions", // Name of the class to generate
Namespace = "SuperExample", // Namespace of the class
Assemblies = new []
{
Define(@".\Path\To.dll", // Path to assembly to generate wrappers
"SuperType1", "SuperType2") // List all types you want to include
}
};
#>
<#@ include file="AsyncExtensions.ttinclude" #>
-
AsyncGenerator does not generate async version of methods in object inheritance chain, so for example if you registered A, only BeginMethod1 will be generated.
class A : B { BeginMethod1 } class B { BeginMethod2 }
Licensed under the MIT