@@ -34,13 +34,13 @@ internal sealed class ResultMapExecutor : ResultExtensionsExecutor
|
||||
}
|
||||
""");
|
||||
|
||||
GenerateAsyncMethods("Task", sb, templateArgNames, resultTypeDef, resultValueExpansion);
|
||||
GenerateAsyncMethods("ValueTask", sb, templateArgNames, resultTypeDef, resultValueExpansion);
|
||||
GenerateAsyncMethods("Task", string.Empty, sb, templateArgNames, resultTypeDef, resultValueExpansion);
|
||||
GenerateAsyncMethods("ValueTask", "ValueTask", sb, templateArgNames, resultTypeDef, resultValueExpansion);
|
||||
|
||||
sb.AppendLine("#endregion");
|
||||
}
|
||||
|
||||
private static void GenerateAsyncMethods(string taskType, StringBuilder sb, ImmutableArray<string> templateArgNames, string resultTypeDef, string resultValueExpansion)
|
||||
private static void GenerateAsyncMethods(string taskType, string methodSuffix, StringBuilder sb, ImmutableArray<string> templateArgNames, string resultTypeDef, string resultValueExpansion)
|
||||
{
|
||||
var methodTemplateArgNames = templateArgNames.Add("R");
|
||||
string methodTemplateDecl = GenerateTemplateDecl(methodTemplateArgNames);
|
||||
@@ -49,7 +49,7 @@ internal sealed class ResultMapExecutor : ResultExtensionsExecutor
|
||||
sb.AppendLine($$"""
|
||||
[PureAttribute]
|
||||
[GeneratedCodeAttribute("{{nameof(ResultMapExecutor)}}", "1.0.0.0")]
|
||||
public static async {{taskType}}<Result<R>> Map{{methodTemplateDecl}}(this {{taskType}}<{{resultTypeDef}}> resultTask, Func{{methodTemplateDecl}} mapping)
|
||||
public static async {{taskType}}<Result<R>> Map{{methodSuffix}}{{methodTemplateDecl}}(this {{taskType}}<{{resultTypeDef}}> resultTask, Func{{methodTemplateDecl}} mapping)
|
||||
{
|
||||
var result = await resultTask.ConfigureAwait(false);
|
||||
return result.State switch
|
||||
@@ -64,7 +64,7 @@ internal sealed class ResultMapExecutor : ResultExtensionsExecutor
|
||||
sb.AppendLine($$"""
|
||||
[PureAttribute]
|
||||
[GeneratedCodeAttribute("{{nameof(ResultMapExecutor)}}", "1.0.0.0")]
|
||||
public static async {{taskType}}<Result<R>> Map{{methodTemplateDecl}}(this {{resultTypeDef}} result, Func{{asyncActionTemplateDecl}} mapping)
|
||||
public static async {{taskType}}<Result<R>> Map{{methodSuffix}}{{methodTemplateDecl}}(this {{resultTypeDef}} result, Func{{asyncActionTemplateDecl}} mapping)
|
||||
{
|
||||
return result.State switch
|
||||
{
|
||||
@@ -78,7 +78,7 @@ internal sealed class ResultMapExecutor : ResultExtensionsExecutor
|
||||
sb.AppendLine($$"""
|
||||
[PureAttribute]
|
||||
[GeneratedCodeAttribute("{{nameof(ResultMapExecutor)}}", "1.0.0.0")]
|
||||
public static async {{taskType}}<Result<R>> Map{{methodTemplateDecl}}(this {{taskType}}<{{resultTypeDef}}> resultTask, Func{{asyncActionTemplateDecl}} mapping)
|
||||
public static async {{taskType}}<Result<R>> Map{{methodSuffix}}{{methodTemplateDecl}}(this {{taskType}}<{{resultTypeDef}}> resultTask, Func{{asyncActionTemplateDecl}} mapping)
|
||||
{
|
||||
var result = await resultTask.ConfigureAwait(false);
|
||||
return result.State switch
|
||||
|
||||
Reference in New Issue
Block a user