Skip to content
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

Method cannot be virtual when the type is generated as a struct #4348

Closed
ArcturusZhang opened this issue Sep 5, 2024 · 2 comments · Fixed by #4630
Closed

Method cannot be virtual when the type is generated as a struct #4348

ArcturusZhang opened this issue Sep 5, 2024 · 2 comments · Fixed by #4630
Assignees
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Comments

@ArcturusZhang
Copy link
Member

This code cannot compile:

public readonly struct Foo
{
	protected virtual void WriteCore() {}
}

It should be:

public readonly struct Foo
{
	private void WriteCore() {}
}

if we want to keep this method, or generate it inline.

@ArcturusZhang ArcturusZhang added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Sep 5, 2024
@m-nash
Copy link
Member

m-nash commented Sep 10, 2024

@JoshLove-msft can you verify if this affects OAI.

@JoshLove-msft
Copy link
Contributor

Yes, there are numerous structs in OAI.

@jorgerangel-msft jorgerangel-msft self-assigned this Oct 8, 2024
github-merge-queue bot pushed a commit that referenced this issue Oct 8, 2024
…r Null Elements (#4630)

This PR fixes several issues with generated structs:
- The `protected virtual` modifiers were removed from the serialization
core methods as the modifiers are not valid for structs.
- When deserializing the struct, `default` is returned rather than
`null` when encountering an JsonElement that is Null.

fixes: #4348,
#4349
github-merge-queue bot pushed a commit that referenced this issue Oct 8, 2024
…r Null Elements (#4630)

This PR fixes several issues with generated structs:
- The `protected virtual` modifiers were removed from the serialization
core methods as the modifiers are not valid for structs.
- When deserializing the struct, `default` is returned rather than
`null` when encountering an JsonElement that is Null.

fixes: #4348,
#4349
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp
Projects
None yet
4 participants