-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
abp generate-proxy -t csharp command fails with ArgumentOutOfRangeException, but abp generate-proxy -t ng works fine #22275
Comments
Share the full reproduce steps. thanks. |
|
This step is not enough to reproduce, usually related to your application service code. Please provide a test project, thanks. |
public class CustomerAuthAppService : ApplicationService, ICustomerAuthAppService public CustomerAuthAppService( public async Task LoginAsync(CustomerLoginDto input) if (result.Result != CustomerAuthenticationResultType.Success) var customer = result.Customer; // 3. Create identity information // 4. Add necessary claims return new CustomerAuthResultDto public async Task RegisterAsync(CustomerRegisterDto input) // Verify that the email already exists try // 3. Create identity information // 4. Add necessary claims // 5. Set scopes return new CustomerAuthResultDto
abp generate-proxy -t csharp -u https://localhost:44322/
[Required] public class CustomerRegisterDto [Required] [Required] [Required] [Required] [Required] public classCustomer: FullAuditedEntity, ISoftDelete public virtual CustomerLevel Level { get; set; } public virtual DateTime? ExpiryDate { get; set; } public virtual string SecurityStamp { get; protected set; } public Customer(Guid id, string userName, string password, string email, string phoneNumber, DateTime dateOfBirth, string nickname, CustomerLevel customerLevel, DateTime ExpiryDate) public virtual void SetPassword(IPasswordHasher passwordHasher, string password) public virtual bool VerifyPassword(IPasswordHasher passwordHasher, string password) public virtual List GetClaims() // Custom Claims return claims; } |
If remove CustomerAuthAppService and ICustomerAuthAppService,then is work. |
Is there an existing issue for this?
Description
I am encountering an ArgumentOutOfRangeException when using the abp generate-proxy -t csharp command to generate C# client proxies. This issue occurs with ABP CLI version 0.9.23.
Command: abp generate-proxy -t csharp --folder ClientProsies -url https://localhost:44322/
Error Message (Full Stack Trace):
[15:38:47 INF] You are running the second generation of the ABP CLI. If you're interested in the legacy CLI, see https://abp.io/new-cli
(String[] args)[15:38:47 INF] Create ClientProsies\CustomerBookClientProxy.Generated.cs
[15:38:47 INF] Create ClientProsies\ICustomerBookAppService.cs
[15:38:47 INF] Create ClientProsies\CustomerEnglishWordClientProxy.Generated.cs
[15:38:47 INF] Create ClientProsies\ICustomerEnglishWordAppService.cs
[15:38:47 INF] Create ClientProsies\CustomerClientProxy.Generated.cs
[15:38:47 INF] Create ClientProsies\ICustomerAppService.cs
System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value. (Parameter 'length')
Actual value was -1.
at void System.ArgumentOutOfRangeException.ThrowNegative(T value, string paramName)
at void System.ArgumentOutOfRangeException.ThrowIfNegative(T value, string paramName)
at void System.String.ThrowSubstringArgumentOutOfRange(int startIndex, int length)
at string System.String.Substring(int startIndex, int length)
at object Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.WFAIvVOhTRZTfagUEOv(object , int , int )
at string Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.oB5EsTAqMp(object )
at string Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.L6tE2WQdBw(object , List )
at void Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.ynpEnvrBWd(ActionApiDescriptionModel ,
string , StringBuilder , List )
at void Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.A2SEtQqbOi(ActionApiDescriptionModel ,
StringBuilder , List )
at async Task Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.bSiECZlSPQ(GenerateProxyArgs ,
ControllerApiDescriptionModel )
at async Task Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.GenerateProxyAsync(GenerateProxyArgs
args)
at async Task Volo.Abp.Cli.Commands.ProxyCommandBase
1.ExecuteAsync(CommandLineArgs commandLineArgs) at async Task Volo.Abp.Studio.Cli.StudioCliService.RunInternalAsync(CommandLineArgs commandLineArgs) at async Task Volo.Abp.Studio.Cli.StudioCliService.RunAsync(string[] args) Unhandled exception. System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value. (Parameter 'length') Actual value was -1. at System.ArgumentOutOfRangeException.ThrowNegative[T](T value, String paramName) at System.ArgumentOutOfRangeException.ThrowIfNegative[T](T value, String paramName) at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length) at System.String.Substring(Int32 startIndex, Int32 length) at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.WFAIvVOhTRZTfagUEOv(Object, Int32, Int32) at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.oB5EsTAqMp(Object ) at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.L6tE2WQdBw(Object , List
1 )at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.ynpEnvrBWd(ActionApiDescriptionModel , String , StringBuilder , List
1 ) at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.A2SEtQqbOi(ActionApiDescriptionModel , StringBuilder , List
1 )at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.bSiECZlSPQ(GenerateProxyArgs , ControllerApiDescriptionModel )
at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.GenerateProxyAsync(GenerateProxyArgs args)
at Volo.Abp.Cli.Commands.ProxyCommandBase`1.ExecuteAsync(CommandLineArgs commandLineArgs)
at Volo.Abp.Studio.Cli.StudioCliService.RunInternalAsync(CommandLineArgs commandLineArgs)
at Volo.Abp.Studio.Cli.StudioCliService.RunAsync(String[] args)
at Volo.Abp.Studio.Cli.Program.DZOCxkt1y(Object )
at Volo.Abp.Studio.Cli.Program.
Environment:
ABP CLI version: 0.9.23
.NET SDK version: 9.0
OS: Windows 11
Reproduction Steps
Using ABP CLI version 0.9.23.
Run the command abp generate-proxy -t csharp --folder ClientProsies -url https://localhost:44322/ against the specified API endpoint.
Observe the System.ArgumentOutOfRangeException error.
Expected behavior
The abp generate-proxy -t csharp command should successfully generate C# client proxy files in the ClientProsies folder based on the API definition at https://localhost:44322/ when using ABP CLI version 0.9.23.
Actual behavior
Using ABP CLI version 0.9.23, the command fails with a System.ArgumentOutOfRangeException. The stack trace indicates the error originates from Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator, specifically within methods related to string manipulation during C# proxy generation.
Error Message (Full Stack Trace):
[15:38:47 INF] You are running the second generation of the ABP CLI. If you're interested in the legacy CLI, see https://abp.io/new-cli
(String[] args)[15:38:47 INF] Create ClientProsies\CustomerBookClientProxy.Generated.cs
[15:38:47 INF] Create ClientProsies\ICustomerBookAppService.cs
[15:38:47 INF] Create ClientProsies\CustomerEnglishWordClientProxy.Generated.cs
[15:38:47 INF] Create ClientProsies\ICustomerEnglishWordAppService.cs
[15:38:47 INF] Create ClientProsies\CustomerClientProxy.Generated.cs
[15:38:47 INF] Create ClientProsies\ICustomerAppService.cs
System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value. (Parameter 'length')
Actual value was -1.
at void System.ArgumentOutOfRangeException.ThrowNegative(T value, string paramName)
at void System.ArgumentOutOfRangeException.ThrowIfNegative(T value, string paramName)
at void System.String.ThrowSubstringArgumentOutOfRange(int startIndex, int length)
at string System.String.Substring(int startIndex, int length)
at object Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.WFAIvVOhTRZTfagUEOv(object , int , int )
at string Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.oB5EsTAqMp(object )
at string Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.L6tE2WQdBw(object , List )
at void Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.ynpEnvrBWd(ActionApiDescriptionModel ,
string , StringBuilder , List )
at void Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.A2SEtQqbOi(ActionApiDescriptionModel ,
StringBuilder , List )
at async Task Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.bSiECZlSPQ(GenerateProxyArgs ,
ControllerApiDescriptionModel )
at async Task Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.GenerateProxyAsync(GenerateProxyArgs
args)
at async Task Volo.Abp.Cli.Commands.ProxyCommandBase
1.ExecuteAsync(CommandLineArgs commandLineArgs) at async Task Volo.Abp.Studio.Cli.StudioCliService.RunInternalAsync(CommandLineArgs commandLineArgs) at async Task Volo.Abp.Studio.Cli.StudioCliService.RunAsync(string[] args) Unhandled exception. System.ArgumentOutOfRangeException: length ('-1') must be a non-negative value. (Parameter 'length') Actual value was -1. at System.ArgumentOutOfRangeException.ThrowNegative[T](T value, String paramName) at System.ArgumentOutOfRangeException.ThrowIfNegative[T](T value, String paramName) at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length) at System.String.Substring(Int32 startIndex, Int32 length) at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.WFAIvVOhTRZTfagUEOv(Object, Int32, Int32) at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.oB5EsTAqMp(Object ) at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.L6tE2WQdBw(Object , List
1 )at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.ynpEnvrBWd(ActionApiDescriptionModel , String , StringBuilder , List
1 ) at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.A2SEtQqbOi(ActionApiDescriptionModel , StringBuilder , List
1 )at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.bSiECZlSPQ(GenerateProxyArgs , ControllerApiDescriptionModel )
at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.GenerateProxyAsync(GenerateProxyArgs args)
at Volo.Abp.Cli.Commands.ProxyCommandBase`1.ExecuteAsync(CommandLineArgs commandLineArgs)
at Volo.Abp.Studio.Cli.StudioCliService.RunInternalAsync(CommandLineArgs commandLineArgs)
at Volo.Abp.Studio.Cli.StudioCliService.RunAsync(String[] args)
at Volo.Abp.Studio.Cli.Program.DZOCxkt1y(Object )
at Volo.Abp.Studio.Cli.Program.
Regression?
No response
Known Workarounds
Important Note:
Crucially, the command abp generate-proxy -t ng --folder ClientProsies -url https://localhost:44322/ for generating Angular client proxies works perfectly fine against the same API endpoint with ABP CLI version 0.9.23. This clearly demonstrates that the core proxy generation functionality and the API endpoint itself are working correctly. The issue appears to be isolated to the C# proxy generation logic within ABP CLI version 0.9.23.
Possible Root Cause:
It is highly likely that there is a bug within the CSharpServiceProxyGenerator in ABP CLI version 0.9.23. This bug seems to be related to handling string lengths during the C# proxy generation process, potentially triggered by specific patterns in the API definition. The error message length ('-1') must be a non-negative value points towards an issue with substring length calculation in the C# proxy generator for this specific version.
Request:
Please investigate this ArgumentOutOfRangeException error in the abp generate-proxy -t csharp command specifically within ABP CLI version 0.9.23. The successful generation of Angular proxies using abp generate-proxy -t ng against the same API endpoint highlights that the problem is likely confined to the C# proxy generation logic in this specific CLI version. A fix for this issue in ABP CLI version 0.9.23 would be greatly appreciated, or guidance on a compatible ABP CLI version for C# proxy generation with ABP Framework.
Version
abp framework version is 9.0.3, abp cli version is 0.9.23
User Interface
Common (Default)
Database Provider
EF Core (Default)
Tiered or separate authentication server
None (Default)
Operation System
Windows (Default)
Other information
No response
The text was updated successfully, but these errors were encountered: