-
Notifications
You must be signed in to change notification settings - Fork 321
Closed
Labels
bugSomething isn't workingSomething isn't workingemitter:client:csharpIssue for the C# client emitter: @typespec/http-client-csharpIssue for the C# client emitter: @typespec/http-client-csharp
Description
Describe the bug
Encountered an issue with nullable generic types not being handled correctly by CSharpType.
Steps to Reproduce:
-
Define a generic class and attempt to create a nullable generic type:
private class Template<T> { }
var genericType = new CSharpType(typeof(Template<>).GetGenericArguments()[0]).WithNullable(true); // This returns T instead of T?
-
Compare with a non-generic type:
var intType = new CSharpType(typeof(int)).WithNullable(true); // This returns int?
Expected Behavior:
The nullable generic type should return T?.
Actual Behavior:
The nullable generic type incorrectly returns T.
This discrepancy causes issues when working with nullable generic types, as the expected nullable type (T?) is not returned. Please investigate and resolve this inconsistency in CSharpType.
Note: After fixing this issue, uncomment this method -
Line 68 in 98f8d62
| // BuildAssertNotNullStruct(), // Currently, `_nullableT` returns `T` instead of `T?`. Tracking issue here: https://github.com/microsoft/typespec/issues/3490 |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingemitter:client:csharpIssue for the C# client emitter: @typespec/http-client-csharpIssue for the C# client emitter: @typespec/http-client-csharp