You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We decide to hide the System.Nullable<T> layer in our type system, for instance, we will not generate model a nullable int type as CSharpType { IsFrameworkType: true, FrameworkType: typeof(Nullable<>), Arguments: [ typeof(int) ]
Instead, we do this:
But when we create an instance of CSharpType from typeof(int?), we still get an instance as a generic type of System.Nullable<T>.
The issue exists in this implementation is that if we do this:
CSharpTypetype=typeof(int?);
Assert.IsTrue(type.IsNullable);// this will fail.
This creates an inconsistency, and when we are creating types, we have to notice that we should not do the above, instead, we should do:
CSharpTypetype=new CSharpType(typeof(int),true);// this creates a nullable int
Assert.IsTrue(type.IsNullable);// this succeeds.
Unfortunately this is not covered by any test cases. We should add more to validate such an important infrastructure is working as expected.
The text was updated successfully, but these errors were encountered:
FixesAzure/autorest.csharp#4678
We are only checking if the input type is a generic type, and then get
its generic argument if it is.
We are not checking if it is this special generic type
`System.Nullable<T>` which appears to be a generic type but we actually
want it to be non-generic but nullable.
This PR changes the final constructor that would be invoke for all cases
that a ctor of CSharpType from a `System.Type` to add a check if it is
`System.Nullable<T>`, we will use `T` as `_type`, and the arguments of
`T` as the real arguments.
Describe the issue or request
We decide to hide the
System.Nullable<T>
layer in our type system, for instance, we will not generate model a nullableint
type asCSharpType { IsFrameworkType: true, FrameworkType: typeof(Nullable<>), Arguments: [ typeof(int) ]
Instead, we do this:
But when we create an instance of
CSharpType
fromtypeof(int?)
, we still get an instance as a generic type ofSystem.Nullable<T>
.The issue exists in this implementation is that if we do this:
This creates an inconsistency, and when we are creating types, we have to notice that we should not do the above, instead, we should do:
Unfortunately this is not covered by any test cases. We should add more to validate such an important infrastructure is working as expected.
The text was updated successfully, but these errors were encountered: