diff --git a/src/libs/AutoSDK/Models/TypeData.cs b/src/libs/AutoSDK/Models/TypeData.cs index c4658f607e..ce104a4218 100644 --- a/src/libs/AutoSDK/Models/TypeData.cs +++ b/src/libs/AutoSDK/Models/TypeData.cs @@ -146,8 +146,10 @@ Default with .ToImmutableArray(); } + var type = GetCSharpType(context); + return new TypeData( - CSharpType: GetCSharpType(context), + CSharpType: type, IsValueType: ContextIsValueType(context), IsArray: context.Schema.IsArray(), IsEnum: context.Schema.IsEnum(), @@ -169,7 +171,9 @@ Default with Properties: properties, EnumValues: enumValues, SubTypes: subTypes, - Namespace: context.Settings.Namespace, + Namespace: type.StartsWith("global::System.", StringComparison.Ordinal) + ? "System" + : context.Settings.Namespace, IsDeprecated: context.Schema.Deprecated, JsonSerializerType: context.Settings.JsonSerializerType, GenerateJsonSerializerContextTypes: context.Settings.GenerateJsonSerializerContextTypes); diff --git a/src/tests/AutoSDK.UnitTests/JsonTests.JsonSerializerContextTypes.cs b/src/tests/AutoSDK.UnitTests/JsonTests.JsonSerializerContextTypes.cs index e1a407dfe2..8819741bfc 100644 --- a/src/tests/AutoSDK.UnitTests/JsonTests.JsonSerializerContextTypes.cs +++ b/src/tests/AutoSDK.UnitTests/JsonTests.JsonSerializerContextTypes.cs @@ -45,6 +45,18 @@ TypeData.Default with ], }, makeNullableRootIfValueType: true).Should().Be("IListIListString"); + GetContextType(TypeData.Default with + { + Namespace = "System.Collections.Generic", + CSharpType = "global::System.Collections.Generic.IList", + IsArray = true, + SubTypes = [ + TypeData.Default with { + Namespace = "System", + CSharpType = "global::System.Guid" } + ], + }, makeNullableRootIfValueType: true).Should().Be("IListGuid"); + GetContextType(TypeData.Default with { CSharpType = "byte[]", @@ -88,9 +100,9 @@ TypeData.Default with GetContextType(TypeData.Default with { - Namespace = "System", + Namespace = "G", IsValueType = true, - CSharpType = "global::System.AllOf", + CSharpType = "global::G.AllOf", SubTypes = [ TypeData.Default with { @@ -105,9 +117,9 @@ TypeData.Default with GetContextType(TypeData.Default with { - Namespace = "System", + Namespace = "Cohere", IsValueType = true, - CSharpType = "global::System.OneOf", + CSharpType = "global::Cohere.OneOf", SubTypes = [ TypeData.Default with {