Skip to content

Conversation

@live1206
Copy link
Contributor

resolves #9084

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Nov 25, 2025
@github-actions
Copy link
Contributor

No changes needing a change description found.

@ArcturusZhang
Copy link
Member

I think the root cause of this issue is not how post processor handle it - it should be why the class is generated as public in the first place.
Its corresponding typeprovider should read the customized code and use the same modifier, this is the root cause.
We can even mark something to internal in this way - your issue indicates this is not working.

As for the post processor, everything in customization code should be root - if this is not root, all its related generated part would be removed if not used, but actually I think the purpose we write such a customization code could be "we want the class to be generated"

@live1206 live1206 changed the title Only take custom public class as root Recalculate modifiers during namespace update Nov 25, 2025
@JoshLove-msft
Copy link
Contributor

I think the root cause of this issue is not how post processor handle it - it should be why the class is generated as public in the first place. Its corresponding typeprovider should read the customized code and use the same modifier, this is the root cause. We can even mark something to internal in this way - your issue indicates this is not working.

We have a test that validates you can mark a type as internal using customization code - https://github.com/microsoft/typespec/blob/main/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelCustomizationTests.cs#L598.

@JoshLove-msft
Copy link
Contributor

I think the root cause of this issue is not how post processor handle it - it should be why the class is generated as public in the first place. Its corresponding typeprovider should read the customized code and use the same modifier, this is the root cause. We can even mark something to internal in this way - your issue indicates this is not working.

We have a test that validates you can mark a type as internal using customization code - https://github.com/microsoft/typespec/blob/main/packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelCustomizationTests.cs#L598.

Ah okay the issue is when the namespace is changed in a visitor and the modifiers have already been cached.

@JoshLove-msft JoshLove-msft added this pull request to the merge queue Nov 25, 2025
Merged via the queue into microsoft:main with commit 394559f Nov 25, 2025
22 checks passed
@live1206 live1206 deleted the fix-custom-root branch November 26, 2025 00:29
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

Development

Successfully merging this pull request may close these issues.

[http-client-csharp] internal custom class is treated as root

3 participants