autorest icon indicating copy to clipboard operation
autorest copied to clipboard

Class with property with the same type causes DpgClientSampleProvider to crash

Open gregoks opened this issue 6 months ago • 0 comments

I ran autorest csharp command on my openapi 3.0.1:

autorest --csharp --input-file="final.json" --namespace=MyNamespace --output-folder="..\Generated" --add-credentials

And I get the following error:

at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider.BuildResponseParseStatementsForModelType(Boolean, AutoRest.CSharp.Common.Input.InputModelType, AutoRest.CSharp.Common.Output.Expressions.ValueExpressions.ValueExpression, System.Collections.Generic.List1<AutoRest.CSharp.Common.Output.Expressions.Statements.MethodBodyStatement>, System.Collections.Generic.HashSet1<AutoRest.CSharp.Common.Input.InputType>) at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider.BuildResponseParseStatements(Boolean, AutoRest.CSharp.Common.Input.InputType, AutoRest.CSharp.Common.Output.Expressions.ValueExpressions.ValueExpression, System.Collections.Generic.List1<AutoRest.CSharp.Common.Output.Expressions.Statements.MethodBodyStatement>, System.Collections.Generic.HashSet1<AutoRest.CSharp.Common.Input.InputType>) at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider.BuildResponseParseStatements(Boolean, AutoRest.CSharp.Common.Input.InputType, AutoRest.CSharp.Common.Output.Expressions.ValueExpressions.ValueExpression, System.Collections.Generic.List1<AutoRest.CSharp.Common.Output.Expressions.Statements.MethodBodyStatement>, System.Collections.Generic.HashSet1<AutoRest.CSharp.Common.Input.InputType>) at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider.BuildResponseParseStatementsForModelType(Boolean, AutoRest.CSharp.Common.Input.InputModelType, AutoRest.CSharp.Common.Output.Expressions.ValueExpressions.ValueExpression, System.Collections.Generic.List1<AutoRest.CSharp.Common.Output.Expressions.Statements.MethodBodyStatement>, System.Collections.Generic.HashSet1<AutoRest.CSharp.Common.Input.InputType>) at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider.BuildResponseParseStatements(Boolean, AutoRest.CSharp.Common.Input.InputType, AutoRest.CSharp.Common.Output.Expressions.ValueExpressions.ValueExpression, System.Collections.Generic.List1<AutoRest.CSharp.Common.Output.Expressions.Statements.MethodBodyStatement>, System.Collections.Generic.HashSet1<AutoRest.CSharp.Common.Input.InputType>) at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider.BuildResponseParseStatements(Boolean, AutoRest.CSharp.Common.Input.InputType, AutoRest.CSharp.Common.Output.Expressions.ValueExpressions.ValueExpression, System.Collections.Generic.List1<AutoRest.CSharp.Common.Output.Expressions.Statements.MethodBodyStatement>, System.Collections.Generic.HashSet1<AutoRest.CSharp.Common.Input.InputType>) at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider.BuildResponseParseStatementsForModelType(Boolean, AutoRest.CSharp.Common.Input.InputModelType, AutoRest.CSharp.Common.Output.Expressions.ValueExpressions.ValueExpression, System.Collections.Generic.List1<AutoRest.CSharp.Common.Output.Expressions.Statements.MethodBodyStatement>, System.Collections.Generic.HashSet1<AutoRest.CSharp.Common.Input.InputType>) at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider.BuildResponseParseStatements(Boolean, AutoRest.CSharp.Common.Input.InputType, AutoRest.CSharp.Common.Output.Expressions.ValueExpressions.ValueExpression, System.Collections.Generic.List1<AutoRest.CSharp.Common.Output.Expressions.Statements.MethodBodyStatement>, System.Collections.Generic.HashSet1<AutoRest.CSharp.Common.Input.InputType>) at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider.BuildResponseParseStatementsForModelType(Boolean, AutoRest.CSharp.Common.Input.InputModelType, AutoRest.CSharp.Common.Output.Expressions.ValueExpressions.ValueExpression, System.Collections.Generic.List1<AutoRest.CSharp.Common.Output.Expressions.Statements.MethodBodyStatement>, System.Collections.Generic.HashSet1<AutoRest.CSharp.Common.Input.InputType>) at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider.BuildResponseParseStatements(Boolean, AutoRest.CSharp.Common.Input.InputType, AutoRest.CSharp.Common.Output.Expressions.ValueExpressions.ValueExpression, System.Collections.Generic.List1<AutoRest.CSharp.Common.Output.Expressions.Statements.MethodBodyStatement>, System.Collections.Generic.HashSet1<AutoRest.CSharp.Common.Input.InputType>) at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider.BuildResponseParseStatements(Boolean, AutoRest.CSharp.Common.Input.InputType, AutoRest.CSharp.Common.Output.Expressions.ValueExpressions.ValueExpression, System.Collections.Generic.List1<AutoRest.CSharp.Common.Output.Expressions.Statements.MethodBodyStatement>, System.Collections.Generic.HashSet1<AutoRest.CSharp.Common.Input.InputType>) at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider.BuildResponseParseStatementsForModelType(Boolean, AutoRest.CSharp.Common.Input.InputModelType, AutoRest.CSharp.Common.Output.Expressions.ValueExpressions.ValueExpression, System.Collections.Generic.List1<AutoRest.CSharp.Common.Output.Expressions.Statements.MethodBodyStatement>, System.Collections.Generic.HashSet1<AutoRest.CSharp.Common.Input.InputType>) at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider.BuildResponseParseStatements(Boolean, AutoRest.CSharp.Common.Input.InputType, AutoRest.CSharp.Common.Output.Expressions.ValueExpressions.ValueExpression, System.Collections.Generic.List1<AutoRest.CSharp.Common.Output.Expressions.Statements.MethodBodyStatement>, System.Collections.Generic.HashSet1<AutoRest.CSharp.Common.Input.InputType>) at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider+<BuildNormalResponse>d__14.MoveNext() at System.Collections.Generic.LargeArrayBuilder1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].AddRange(System.Collections.Generic.IEnumerable1<System.__Canon>) at System.Collections.Generic.EnumerableHelpers.ToArray[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e] at AutoRest.CSharp.LowLevel.Output.DpgClientTestProvider+<BuildSampleOperationInvocation>d__12.MoveNext() at System.Collections.Generic.LargeArrayBuilder1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].AddRange(System.Collections.Generic.IEnumerable1<System.__Canon>) at System.Collections.Generic.EnumerableHelpers.ToArray[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e] at AutoRest.CSharp.LowLevel.Output.DpgClientTestProvider.BuildSampleMethod(AutoRest.CSharp.Output.Samples.Models.DpgOperationSample, Boolean) at AutoRest.CSharp.LowLevel.Output.Samples.DpgClientSampleProvider+<BuildMethods>d__8.MoveNext() at System.Collections.Generic.LargeArrayBuilder1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].AddRange(System.Collections.Generic.IEnumerable1<System.__Canon>) at System.Collections.Generic.EnumerableHelpers.ToArray[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e] at AutoRest.CSharp.Output.Models.Types.ExpressionTypeProvider.get_Methods() at AutoRest.CSharp.LowLevel.Output.DpgClientTestProvider.get_IsEmpty() at AutoRest.CSharp.Output.Models.Types.DpgOutputLibrary.EnsureDpgSampleProviders() at AutoRest.CSharp.Output.Models.Types.DpgOutputLibrary.get_DpgClientSampleProviders() at AutoRest.CSharp.Output.Models.Types.DpgOutputLibrary.GetSampleForClient(AutoRest.CSharp.Output.Models.LowLevelClient) at AutoRest.CSharp.Generation.Writers.DpgClientWriter.WriteSampleRefsIfNecessary(AutoRest.CSharp.Output.Models.MethodSignature, Boolean) at AutoRest.CSharp.Generation.Writers.DpgClientWriter.WriteProtocolMethodDocumentationWithExternalXmlDoc(AutoRest.CSharp.Output.Models.LowLevelClientMethod, Boolean) at AutoRest.CSharp.Generation.Writers.DpgClientWriter.WriteClient() at AutoRest.CSharp.AutoRest.Plugins.LowLevelTarget+<ExecuteAsync>d__0.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[AutoRest.CSharp.AutoRest.Plugins.LowLevelTarget+<ExecuteAsync>d__0, AutoRest.CSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8]](<ExecuteAsync>d__0 ByRef) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[AutoRest.CSharp.AutoRest.Plugins.LowLevelTarget+<ExecuteAsync>d__0, AutoRest.CSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8]](<ExecuteAsync>d__0 ByRef) at AutoRest.CSharp.AutoRest.Plugins.LowLevelTarget.ExecuteAsync(AutoRest.CSharp.AutoRest.Plugins.GeneratedCodeWorkspace, AutoRest.CSharp.Common.Input.InputNamespace, AutoRest.CSharp.Input.Source.SourceInputModel, Boolean) at AutoRest.CSharp.AutoRest.Plugins.CSharpGen+<ExecuteAsync>d__0.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[AutoRest.CSharp.AutoRest.Plugins.CSharpGen+<ExecuteAsync>d__0, AutoRest.CSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8]](<ExecuteAsync>d__0 ByRef) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[AutoRest.CSharp.AutoRest.Plugins.CSharpGen+<ExecuteAsync>d__0, AutoRest.CSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8]](<ExecuteAsync>d__0 ByRef) at AutoRest.CSharp.AutoRest.Plugins.CSharpGen.ExecuteAsync(AutoRest.CSharp.Input.CodeModel) at AutoRest.CSharp.AutoRest.Plugins.CSharpGen+<Execute>d__4.MoveNext() at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[[System.Boolean, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[AutoRest.CSharp.AutoRest.Plugins.CSharpGen+<Execute>d__4, AutoRest.CSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8]].ExecutionContextCallback(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[[System.Boolean, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[AutoRest.CSharp.AutoRest.Plugins.CSharpGen+<Execute>d__4, AutoRest.CSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8]].MoveNext(System.Threading.Thread) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[[System.Boolean, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[AutoRest.CSharp.AutoRest.Plugins.CSharpGen+<Execute>d__4, AutoRest.CSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8]].MoveNext() at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Runtime.CompilerServices.IAsyncStateMachineBox, Boolean) at System.Threading.Tasks.Task.RunContinuations(System.Object) at System.Threading.Tasks.Task1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetResult(System.__Canon) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].SetExistingTaskResult(System.Threading.Tasks.Task1<System.__Canon>, System.__Canon) at AutoRest.CSharp.AutoRest.Communication.MessageHandling.JsonRpcConnection+<Request>d__181[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext() at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[AutoRest.CSharp.AutoRest.Communication.MessageHandling.JsonRpcConnection+<Request>d__181[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], AutoRest.CSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8]].ExecutionContextCallback(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[AutoRest.CSharp.AutoRest.Communication.MessageHandling.JsonRpcConnection+<Request>d__181[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], AutoRest.CSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8]].MoveNext(System.Threading.Thread) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1+AsyncStateMachineBox1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[AutoRest.CSharp.AutoRest.Communication.MessageHandling.JsonRpcConnection+<Request>d__181[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], AutoRest.CSharp, Version=3.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8]].MoveNext() at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Runtime.CompilerServices.IAsyncStateMachineBox, Boolean) at System.Threading.Tasks.Task.RunContinuations(System.Object) at System.Threading.Tasks.Task1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetResult(System.__Canon) at System.Threading.Tasks.TaskCompletionSource1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetResult(System.__Canon) at AutoRest.CSharp.AutoRest.Communication.MessageHandling.JsonRpcConnection+<>c__DisplayClass16_0.<HandleIncomingResponse>b__0() at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread) at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart() fatal | Process() cancelled due to failure error | [Exception] AutoRest extension '@autorest/csharp' terminated. error | Error: [Exception] AutoRest extension '@autorest/csharp' terminated.

From my investigation, it happens because I have class that looks like that: public class ColumnModel { ///

/// Gets or sets Children columns from schema substring /// [JsonProperty("Children")] public ColumnModel[] Children { get; set; } }

And this is the swagger part:

"Column": { "type": "object", "properties": { "Children": { "type": "array", "items": { "$ref": "#/components/schemas/Column" }, "description": "Gets or sets Children columns from schema substring", "nullable": true } }, "description": "Model for column in a resource." }

Also if I remove the "nullable" notation then it works.

Thanks

gregoks avatar Aug 21 '24 17:08 gregoks