|
|
|
@ -19,7 +19,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi |
|
|
|
|
|
|
|
private const string ProxyDirectory = "ClientProxies"; |
|
|
|
|
|
|
|
private readonly static string[] ServicePostfixes = { "AppService", "ApplicationService", "IntService", "IntegrationService" , "Service"}; |
|
|
|
private static readonly string[] ServicePostfixes = { "AppService", "ApplicationService", "IntService", "IntegrationService" , "Service"}; |
|
|
|
private const string AppServicePrefix = "Volo.Abp.Application.Services"; |
|
|
|
|
|
|
|
private const string NamespacePlaceholder = "<namespace>"; |
|
|
|
@ -29,7 +29,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi |
|
|
|
private const string ClassNamePlaceholder = "<className>"; |
|
|
|
private const string ServiceInterfacePlaceholder = "<serviceInterface>"; |
|
|
|
private const string DtoClassNamePlaceholder = "<dtoName>"; |
|
|
|
private readonly static string ClassTemplate = "// This file is automatically generated by ABP framework to use MVC Controllers from CSharp" + |
|
|
|
private static readonly string ClassTemplate = "// This file is automatically generated by ABP framework to use MVC Controllers from CSharp" + |
|
|
|
$"{Environment.NewLine}<using>" + |
|
|
|
$"{Environment.NewLine}" + |
|
|
|
$"{Environment.NewLine}// ReSharper disable once CheckNamespace" + |
|
|
|
@ -44,7 +44,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi |
|
|
|
$"{Environment.NewLine}}}" + |
|
|
|
$"{Environment.NewLine}"; |
|
|
|
|
|
|
|
private readonly static string ClassTemplateEmptyPart = "// This file is part of <className>, you can customize it here" + |
|
|
|
private static readonly string ClassTemplateEmptyPart = "// This file is part of <className>, you can customize it here" + |
|
|
|
$"{Environment.NewLine}// ReSharper disable once CheckNamespace" + |
|
|
|
$"{Environment.NewLine}namespace <namespace>;" + |
|
|
|
$"{Environment.NewLine}" + |
|
|
|
@ -53,7 +53,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi |
|
|
|
$"{Environment.NewLine}}}" + |
|
|
|
$"{Environment.NewLine}"; |
|
|
|
|
|
|
|
private readonly static string InterfaceTemplate = "// This file is automatically generated by ABP framework to use MVC Controllers from CSharp" + |
|
|
|
private static readonly string InterfaceTemplate = "// This file is automatically generated by ABP framework to use MVC Controllers from CSharp" + |
|
|
|
$"{Environment.NewLine}<using>" + |
|
|
|
$"{Environment.NewLine}" + |
|
|
|
$"{Environment.NewLine}// ReSharper disable once CheckNamespace" + |
|
|
|
@ -65,7 +65,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi |
|
|
|
$"{Environment.NewLine}}}" + |
|
|
|
$"{Environment.NewLine}"; |
|
|
|
|
|
|
|
private readonly static string DtoTemplate = "// This file is automatically generated by ABP framework to use MVC Controllers from CSharp" + |
|
|
|
private static readonly string DtoTemplate = "// This file is automatically generated by ABP framework to use MVC Controllers from CSharp" + |
|
|
|
$"{Environment.NewLine}<using>" + |
|
|
|
$"{Environment.NewLine}" + |
|
|
|
$"{Environment.NewLine}// ReSharper disable once CheckNamespace" + |
|
|
|
@ -77,7 +77,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi |
|
|
|
$"{Environment.NewLine}}}" + |
|
|
|
$"{Environment.NewLine}"; |
|
|
|
|
|
|
|
private readonly static List<string> ClassUsingNamespaceList = new() |
|
|
|
private static readonly List<string> ClassUsingNamespaceList = new() |
|
|
|
{ |
|
|
|
"using System;", |
|
|
|
"using System.Collections.Generic;", |
|
|
|
@ -90,7 +90,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi |
|
|
|
"using Volo.Abp.Http.Client.ClientProxying;" |
|
|
|
}; |
|
|
|
|
|
|
|
private readonly static List<string> InterfaceUsingNamespaceList = new() |
|
|
|
private static readonly List<string> InterfaceUsingNamespaceList = new() |
|
|
|
{ |
|
|
|
"using System;", |
|
|
|
"using System.Collections.Generic;", |
|
|
|
@ -100,7 +100,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi |
|
|
|
"using Volo.Abp.Application.Services;" |
|
|
|
}; |
|
|
|
|
|
|
|
private readonly static List<string> DtoUsingNamespaceList = new() |
|
|
|
private static readonly List<string> DtoUsingNamespaceList = new() |
|
|
|
{ |
|
|
|
"using System;", |
|
|
|
"using System.Collections.Generic;", |
|
|
|
@ -116,7 +116,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
public async override Task GenerateProxyAsync(GenerateProxyArgs args) |
|
|
|
public override async Task GenerateProxyAsync(GenerateProxyArgs args) |
|
|
|
{ |
|
|
|
CheckWorkDirectory(args.WorkDirectory); |
|
|
|
CheckFolder(args.Folder); |
|
|
|
@ -305,9 +305,16 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi |
|
|
|
StringBuilder methodBuilder, |
|
|
|
List<string> usingNamespaceList) |
|
|
|
{ |
|
|
|
var returnSign = returnTypeName == "void" ? "Task" : $"Task<{returnTypeName}>"; |
|
|
|
var isAsyncEnumerable = returnTypeName.StartsWith("IAsyncEnumerable<"); |
|
|
|
var asyncEnumerableTypeName = isAsyncEnumerable |
|
|
|
? returnTypeName.Substring("IAsyncEnumerable<".Length, returnTypeName.Length - "IAsyncEnumerable<".Length - 1) |
|
|
|
: null; |
|
|
|
|
|
|
|
var returnSign = isAsyncEnumerable ? returnTypeName : returnTypeName == "void" ? "Task" : $"Task<{returnTypeName}>"; |
|
|
|
|
|
|
|
methodBuilder.AppendLine($"public virtual async {returnSign} {action.Name}(<args>)"); |
|
|
|
methodBuilder.AppendLine(isAsyncEnumerable |
|
|
|
? $"public virtual {returnSign} {action.Name}(<args>)" |
|
|
|
: $"public virtual async {returnSign} {action.Name}(<args>)"); |
|
|
|
|
|
|
|
foreach (var parameter in action.ParametersOnMethod) |
|
|
|
{ |
|
|
|
@ -325,9 +332,11 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi |
|
|
|
|
|
|
|
var args = action.ParametersOnMethod.Any() ? argsTemplate : string.Empty; |
|
|
|
|
|
|
|
methodBuilder.AppendLine(returnTypeName == "void" |
|
|
|
? $" await RequestAsync(nameof({action.Name}), {args});" |
|
|
|
: $" return await RequestAsync<{returnTypeName}>(nameof({action.Name}), {args});"); |
|
|
|
methodBuilder.AppendLine(isAsyncEnumerable |
|
|
|
? $" return RequestAsyncEnumerable<{asyncEnumerableTypeName}>(nameof({action.Name}), {args});" |
|
|
|
: returnTypeName == "void" |
|
|
|
? $" await RequestAsync(nameof({action.Name}), {args});" |
|
|
|
: $" return await RequestAsync<{returnTypeName}>(nameof({action.Name}), {args});"); |
|
|
|
|
|
|
|
foreach (var parameter in action.ParametersOnMethod) |
|
|
|
{ |
|
|
|
@ -543,7 +552,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi |
|
|
|
{ |
|
|
|
AddGenericTypeUsingNamespace(typeName, usingNamespaceList); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var type = new StringBuilder(); |
|
|
|
var s1 = typeName.Split("<"); |
|
|
|
for (var i = 0; i < s1.Length; i++) |
|
|
|
|