Skip to content

[http-client-csharp] malformed code is generated on some kind of customization code #9403

@ArcturusZhang

Description

@ArcturusZhang

Sometimes, in customized code, roslyn cannot analyze the correct namespace of some symbols (or maybe not?), and code like this is generated:
Image

We need to fix this.
The above code was generated when we have the following customization:
Image

To reproduce:
Prepare typespec:

model Foo {
	bar?: Bar;
}

model Bar {
	b?: string;
}

In the generated code, add the following:

[CodeGenSerialization(nameof(Bars), "bars"]
public partial class Foo
{
	public IList<Bar> Bars {get;}
}

then generate the code.

Metadata

Metadata

Assignees

No one assigned

    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