diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/CSharp/CSharpServiceProxyGenerator.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/CSharp/CSharpServiceProxyGenerator.cs index 49c8899bc4..c2016a4ba2 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/CSharp/CSharpServiceProxyGenerator.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/CSharp/CSharpServiceProxyGenerator.cs @@ -19,7 +19,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase" + $"{Environment.NewLine}" + $"{Environment.NewLine}// ReSharper disable once CheckNamespace" + @@ -44,7 +44,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase;" + $"{Environment.NewLine}" + @@ -53,7 +53,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase" + $"{Environment.NewLine}" + $"{Environment.NewLine}// ReSharper disable once CheckNamespace" + @@ -65,24 +65,22 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase" + - $"{Environment.NewLine}" + - $"{Environment.NewLine}// ReSharper disable once CheckNamespace" + - $"{Environment.NewLine}namespace ;" + - $"{Environment.NewLine}" + - $"{Environment.NewLine}public " + - $"{Environment.NewLine}{{" + - $"{Environment.NewLine} " + - $"{Environment.NewLine}}}" + - $"{Environment.NewLine}"; - private static readonly List ClassUsingNamespaceList = new() + private readonly static string DtoTemplate = "// This file is automatically generated by ABP framework to use MVC Controllers from CSharp" + + $"{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"{Environment.NewLine}// ReSharper disable once CheckNamespace" + + $"{Environment.NewLine}namespace ;" + + $"{Environment.NewLine}" + + $"{Environment.NewLine}public " + + $"{Environment.NewLine}{{" + + $"{Environment.NewLine} " + + $"{Environment.NewLine}}}" + + $"{Environment.NewLine}"; + + private readonly static List ClassUsingNamespaceList = new() { "using System;", + "using System.Collections.Generic;", "using System.Threading.Tasks;", "using Volo.Abp.Application.Dtos;", "using Volo.Abp.Http.Client;", @@ -91,14 +89,23 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase InterfaceUsingNamespaceList = new() + private readonly static List InterfaceUsingNamespaceList = new() { "using System;", + "using System.Collections.Generic;", "using System.Threading.Tasks;", "using Volo.Abp.Application.Dtos;", "using Volo.Abp.Application.Services;" }; + private readonly static List DtoUsingNamespaceList = new() + { + "using System;", + "using System.Collections.Generic;", + "using Volo.Abp.Application.Dtos;", + "using Volo.Abp.ObjectExtending;", + }; + public CSharpServiceProxyGenerator( CliHttpClientFactory cliHttpClientFactory, IJsonSerializer jsonSerializer) : @@ -106,7 +113,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase types.Contains(x.Key))) { var dto = new StringBuilder(DtoTemplate); - var dtoUsingNamespaceList = new List() + var dtoUsingNamespaceList = new List(DtoUsingNamespaceList) { $"using {GetTypeNamespace(type.Key)};" }; @@ -478,7 +485,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase x).Select(x => x))); + dto.Replace($"{UsingPlaceholder}", string.Join(Environment.NewLine, dtoUsingNamespaceList.Distinct().OrderBy(x => x).Select(x => x))); dto.Replace(PropertyPlaceholder, properties.ToString()); var folder = args.Folder.IsNullOrWhiteSpace()