Skip to content

csharp CodeGen should provide clear message for self-service trouble shooting #5508

@lirenhe

Description

@lirenhe

Clear and concise description of the problem

We need to empower our customers both internal and external to easily trouble shooting and fix spec issues that would block the CodeGen.
If certain TypeSpec features or patterns are not supported by CodeGen, we should clearly point it out and suggest them to update the spec with the features we supported for CodeGen.

Today, csharp CodeGen just returned a big call-stack like below which could not help for self-service resolving the problem.

Unhandled exception. System.NotSupportedException: BinaryData
     at AutoRest.CSharp.Generation.Types.CSharpType.GetElementType() in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Generat
  ion\Types\CSharpType.cs:line 336
     at AutoRest.CSharp.Generation.Types.CSharpType.get_ElementType() in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Genera
  tion\Types\CSharpType.cs:line 224
     at AutoRest.CSharp.Output.Builders.SerializationBuilder.BuildJsonSerialization(InputType inputType, CSharpType valueType, Boolean is
  CollectionElement, SerializationFormat serializationFormat) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Output\Builder
  s\SerializationBuilder.cs:line 162
     at AutoRest.CSharp.Output.Builders.SerializationBuilder.BuildJsonSerialization(InputType inputType, CSharpType valueType, Boolean is
  CollectionElement) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Output\Builders\SerializationBuilder.cs:line 172
     at AutoRest.CSharp.Output.Builders.SerializationBuilder.CreateJsonPropertySerializationFromInputModelProperty(SerializableObjectType
   objectType, ObjectTypeProperty property, TypeFactory typeFactory) in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Output\
  Builders\SerializationBuilder.cs:line 291
     at AutoRest.CSharp.Output.Builders.SerializationBuilder.<>c__DisplayClass16_0.b__0(ObjectTypeProperty p)
  in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Output\Builders\SerializationBuilder.cs:line 441
     at AutoRest.CSharp.Output.Builders.SerializationBuilder.GetPropertySerializationsFromBag[T](PropertyBag`1 propertyBag, Func`2 jsonPr
  opertySerializationFactory)+MoveNext() in D:\a\_work\1\s\autorest.csharp\src\AutoRest.CSharp\Common\Output\Builders\SerializationBuilde
  r.cs:line 331

Expected behavior:

I suggest we could improve the following areas:

  1. Leverage TypeSpec diagnostics APIs to report the errors and provide more context so that users could easily identify the TypeSpec source that cause the error..
  2. Provide a clear message for the unsupported scenarios and ideally provide some suggestions on how to fix.

workstream this request is associated with

This is related to the TypeSpec E2E scenario and ensure service team/customer to self service trouble shooting the problem

stakeholders

@lmazuel / @lirenhe

priority and timeline.

I suggest we should provide a better experience for self-service trouble shooting as part of the TypeSpec GA.

Checklist

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Metadata

Metadata

Assignees

Labels

emitter:client:csharpIssue for the C# client emitter: @typespec/http-client-csharp

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions