231 instantiations of AtsTypeRef
Aspire.Hosting.CodeGeneration.Go.Tests (30)
GoGeneratorEscapingTests.cs (8)
119var tagsType = new AtsTypeRef { TypeId = "Tests/List<string>", Category = AtsTypeCategory.List, ElementType = stringType };
120var unionType = new AtsTypeRef { TypeId = "Tests/Union", Category = AtsTypeCategory.Union, UnionTypes = [stringType, numberType] };
121var callbackType = new AtsTypeRef { TypeId = "Tests/Callback", Category = AtsTypeCategory.Callback };
122var enumType = new AtsTypeRef { TypeId = StatusTypeId, Category = AtsTypeCategory.Enum };
123var lookupType = new AtsTypeRef { TypeId = "Tests/Dict<string,string>", Category = AtsTypeCategory.Dict, KeyType = stringType, ValueType = stringType, IsReadOnly = true };
124var unknownType = new AtsTypeRef { TypeId = "Tests/Unknown", Category = AtsTypeCategory.Unknown };
223private static AtsTypeRef Primitive(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Primitive };
225private static AtsTypeRef Handle(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Handle };
Aspire.Hosting.CodeGeneration.Java.Tests (46)
AtsJavaCodeGeneratorTests.cs (46)
719var numberType = new AtsTypeRef { TypeId = AtsConstants.Number, Category = AtsTypeCategory.Primitive };
720var booleanType = new AtsTypeRef { TypeId = AtsConstants.Boolean, Category = AtsTypeCategory.Primitive };
2920new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = MutableStringDict() });
2933new AtsTypeRef
2950var stringType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive };
2951var innerArray = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = stringType };
2954new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = innerArray });
2997var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2998var stringType = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive };
2999var innerArray = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = stringType };
3000var matrixType = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = innerArray };
3005Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback },
3007CallbackReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
3014ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive },
3035var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
3039Type = new AtsTypeRef { TypeId = AtsConstants.CancellationToken, Category = AtsTypeCategory.Dto }
3046ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive },
3063var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
3079Type = new AtsTypeRef
3107var resourceType = new AtsTypeRef
3117new AtsTypeRef { TypeId = AtsConstants.Boolean, Category = AtsTypeCategory.Primitive, IsNullable = true }),
3121new AtsTypeRef { TypeId = AtsConstants.Number, Category = AtsTypeCategory.Primitive, IsNullable = true }),
3247var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
3248var nullableNumber = new AtsTypeRef
3254var nullableBoolean = new AtsTypeRef
3260var numberArray = new AtsTypeRef
3266var booleanArray = new AtsTypeRef
3272var booleanMatrix = new AtsTypeRef
3282Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback },
3288CallbackReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
3295ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive },
3537var contextType = new AtsTypeRef { TypeId = "Tests/MutableContext", Category = AtsTypeCategory.Dto };
3553Type = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive }
3566Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback },
3572CallbackReturnType = new AtsTypeRef
3628var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
3629var contextType = new AtsTypeRef { TypeId = "Tests/MutableContext", Category = AtsTypeCategory.Dto };
3634Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback },
3639CallbackReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
3646ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive },
3668Type = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive }
3855Type = new AtsTypeRef { TypeId = "KeywordProbe", Category = AtsTypeCategory.Dto }
3914new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive });
3943private static AtsTypeRef MutableStringDict() => new()
3948KeyType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive },
3949ValueType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive }
Aspire.Hosting.CodeGeneration.Python.Tests (20)
Aspire.Hosting.CodeGeneration.TypeScript.Tests (30)
Aspire.Hosting.Native.CodeGeneration (34)
src\Aspire.Hosting.RemoteHost\AtsCapabilityScanner.cs (34)
933var targetTypeRef = capability.TargetType ?? new AtsTypeRef
963var concreteTypeRef = new AtsTypeRef
1178? new AtsTypeRef { TypeId = "callback", ClrType = prop.PropertyType, Category = AtsTypeCategory.Callback }
1704: new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive };
1706propertyTypeRef = new AtsTypeRef
1731propertyTypeRef = new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive };
2244? new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback }
2301returnTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2305returnTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2313?? new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
2314: new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2319?? new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
2347var voidTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2680private static AtsTypeRef CreateVoidTypeRef() => new AtsTypeRef
2716return new AtsTypeRef
2798return new AtsTypeRef { TypeId = primitiveTypeId, ClrType = type, Category = AtsTypeCategory.Primitive };
2804return new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = type, Category = AtsTypeCategory.Primitive };
2809return new AtsTypeRef
2814KeyType = new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive },
2815ValueType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive },
2822return new AtsTypeRef
2827ElementType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive }
2837return new AtsTypeRef
2860return new AtsTypeRef
2883return new AtsTypeRef
2905return new AtsTypeRef
2925return new AtsTypeRef
2970return new AtsTypeRef
2986return new AtsTypeRef
2998return new AtsTypeRef
3008return new AtsTypeRef
3103allInterfaces.Add(new AtsTypeRef
3170return new AtsTypeRef
3429return new AtsTypeRef
Aspire.Hosting.RemoteHost (39)
AtsCapabilityScanner.cs (34)
933var targetTypeRef = capability.TargetType ?? new AtsTypeRef
963var concreteTypeRef = new AtsTypeRef
1178? new AtsTypeRef { TypeId = "callback", ClrType = prop.PropertyType, Category = AtsTypeCategory.Callback }
1704: new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive };
1706propertyTypeRef = new AtsTypeRef
1731propertyTypeRef = new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive };
2244? new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback }
2301returnTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2305returnTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2313?? new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
2314: new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2319?? new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
2347var voidTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2680private static AtsTypeRef CreateVoidTypeRef() => new AtsTypeRef
2716return new AtsTypeRef
2798return new AtsTypeRef { TypeId = primitiveTypeId, ClrType = type, Category = AtsTypeCategory.Primitive };
2804return new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = type, Category = AtsTypeCategory.Primitive };
2809return new AtsTypeRef
2814KeyType = new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive },
2815ValueType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive },
2822return new AtsTypeRef
2827ElementType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive }
2837return new AtsTypeRef
2860return new AtsTypeRef
2883return new AtsTypeRef
2905return new AtsTypeRef
2925return new AtsTypeRef
2970return new AtsTypeRef
2986return new AtsTypeRef
2998return new AtsTypeRef
3008return new AtsTypeRef
3103allInterfaces.Add(new AtsTypeRef
3170return new AtsTypeRef
3429return new AtsTypeRef
Aspire.Hosting.RemoteHost.Tests (32)
AtsMarshallerTests.cs (12)
169var typeRef = new AtsTypeRef
175new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive },
176new AtsTypeRef { TypeId = AtsConstants.Number, ClrType = typeof(int), Category = AtsTypeCategory.Primitive },
177new AtsTypeRef { TypeId = AtsConstants.Boolean, ClrType = typeof(bool), Category = AtsTypeCategory.Primitive }
192var typeRef = new AtsTypeRef
198new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive },
199new AtsTypeRef { TypeId = "test/IResource", ClrType = typeof(IResource), Category = AtsTypeCategory.Handle }
214var typeRef = new AtsTypeRef
220new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive },
221new AtsTypeRef { TypeId = AtsConstants.Boolean, ClrType = typeof(bool), Category = AtsTypeCategory.Primitive }
291var typeRef = new AtsTypeRef
1021var typeRef = new AtsTypeRef { TypeId = "test/SelfReferencingDto", Category = AtsTypeCategory.Dto };
464 references to AtsTypeRef
aspire-managed (2)
Aspire.Hosting.CodeGeneration.Go (37)
AtsGoCodeGenerator.cs (33)
137foreach (var expandedTarget in capability.ExpandedTargetTypes)
266private static void CollectRequiredType(AtsTypeRef? type, HashSet<string> requiredTypeIds)
278foreach (var unionType in type.UnionTypes ?? [])
282foreach (var implementedInterface in type.ImplementedInterfaces)
443foreach (var expanded in capability.ExpandedTargetTypes)
712private static void CollectHandleTypeIds(HashSet<string> set, AtsTypeRef? typeRef)
741foreach (var u in typeRef.UnionTypes)
831: (IReadOnlyList<AtsTypeRef>)Array.Empty<AtsTypeRef>();
833foreach (var targetType in targetTypes)
1249AtsTypeRef typeRef,
1495private static List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)>
1498var result = new List<(string, string, AtsTypeRef, string, string?)>();
1533List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)> listDictGetters)
1634List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)> listDictGetters)
1860var returnType = capability.ReturnType!;
1900List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)> listDictGetters)
1952var returnType = capability.ReturnType!;
2027var returnType = capability.ReturnType!;
2283private string GetCallbackArgExpression(AtsTypeRef type, int index, string? clientExpression)
2304(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description) g,
2322private (string Wrapper, string TypeArgs) ListDictTypeArgs(AtsTypeRef returnType)
2531private static bool CanUseDirectOptionType(AtsTypeRef type)
2796private string GetUnionAllowedTypes(AtsTypeRef typeRef) => string.Join(", ", GetUnionMemberTypes(typeRef));
2804private string GetUnionTypeSwitchCases(AtsTypeRef typeRef)
2815private string[] GetUnionMemberTypes(AtsTypeRef typeRef)
3046private string MapTypeRefToGo(AtsTypeRef? typeRef, bool isOptional) =>
3053/// everything else use <see cref="MapTypeRefToGo(AtsTypeRef?, bool)"/>.
3055private string MapInputTypeRefToGo(AtsTypeRef? typeRef, bool isOptional) =>
3058private string MapTypeRefToGo(AtsTypeRef? typeRef, bool isOptional, bool asInput)
3099private string MapDtoPropertyTypeToGo(AtsTypeRef? typeRef, bool isOptional)
3137private static bool ShouldApplyNullableType(AtsTypeRef typeRef) =>
3166private static string MapPrimitiveType(AtsTypeRef typeRef) => typeRef.TypeId switch
Aspire.Hosting.CodeGeneration.Go.Tests (62)
AtsGoDerivedBuilderTests.cs (26)
490private static readonly AtsTypeRef s_builder = new() { TypeId = AtsConstants.BuilderTypeId, Category = AtsTypeCategory.Handle, IsInterface = true };
491private static readonly AtsTypeRef s_pool = Handle(PoolId);
492private static readonly AtsTypeRef s_aksPool = Handle(AksPoolId);
493private static readonly AtsTypeRef s_spotPool = Handle(SpotPoolId);
494private static readonly AtsTypeRef s_gpuSpotPool = Handle(GpuSpotPoolId);
495private static readonly AtsTypeRef s_workload = Handle(WorkloadId);
496private static readonly AtsTypeRef s_queue = Handle(QueueId);
497private static readonly AtsTypeRef s_string = new() { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive };
498private static readonly AtsTypeRef s_poolSettings = new() { TypeId = PoolSettingsId, Category = AtsTypeCategory.Dto };
615private static AtsTypeRef Handle(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Handle };
617private static AtsTypeRef ArrayOf(AtsTypeRef element) => new()
625private static AtsTypeRef ListOf(AtsTypeRef element) => new()
632private static AtsTypeRef ReadOnlyDictOf(AtsTypeRef key, AtsTypeRef value) => new()
641private static AtsTypeRef UnionOf(params AtsTypeRef[] members) => new()
648private static AtsParameterInfo Required(string name, AtsTypeRef type) => new() { Name = name, Type = type };
650private static AtsParameterInfo Optional(string name, AtsTypeRef type) => new() { Name = name, Type = type, IsOptional = true, IsNullable = true };
652private static AtsParameterInfo Callback(string name, params (string Name, AtsTypeRef Type)[] parameters) => new()
661private static AtsCapabilityInfo Factory(string methodName, AtsTypeRef returnType) =>
669AtsTypeRef target,
670IReadOnlyList<AtsTypeRef> expandedTargets,
672AtsTypeRef returnType) => new()
GoDocCommentTests.cs (11)
448var stringType = Primitive(AtsConstants.String);
449var boolType = Primitive(AtsConstants.Boolean);
450var voidType = Primitive(AtsConstants.Void);
451var resourceType = new AtsTypeRef { TypeId = ResourceTypeId, Category = AtsTypeCategory.Handle };
452var settingsType = new AtsTypeRef { TypeId = SettingsTypeId, Category = AtsTypeCategory.Dto };
453var statusType = new AtsTypeRef { TypeId = StatusTypeId, Category = AtsTypeCategory.Enum };
454var tagsType = new AtsTypeRef { TypeId = "Tests/List<string>", Category = AtsTypeCategory.List, ElementType = stringType };
565private static AtsTypeRef Primitive(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Primitive };
567private static AtsParameterInfo Parameter(string name, AtsTypeRef type, string? summary = null, bool isOptional = false) => new()
577AtsTypeRef returnType,
586var resourceType = new AtsTypeRef { TypeId = ResourceTypeId, Category = AtsTypeCategory.Handle };
GoGeneratorEscapingTests.cs (18)
115var stringType = Primitive(AtsConstants.String);
116var numberType = Primitive(AtsConstants.Number);
117var voidType = Primitive(AtsConstants.Void);
118var resourceType = Handle(ResourceTypeId);
119var tagsType = new AtsTypeRef { TypeId = "Tests/List<string>", Category = AtsTypeCategory.List, ElementType = stringType };
120var unionType = new AtsTypeRef { TypeId = "Tests/Union", Category = AtsTypeCategory.Union, UnionTypes = [stringType, numberType] };
121var callbackType = new AtsTypeRef { TypeId = "Tests/Callback", Category = AtsTypeCategory.Callback };
122var enumType = new AtsTypeRef { TypeId = StatusTypeId, Category = AtsTypeCategory.Enum };
123var lookupType = new AtsTypeRef { TypeId = "Tests/Dict<string,string>", Category = AtsTypeCategory.Dict, KeyType = stringType, ValueType = stringType, IsReadOnly = true };
124var unknownType = new AtsTypeRef { TypeId = "Tests/Unknown", Category = AtsTypeCategory.Unknown };
215private static AtsExportedValueInfo ExportedValue(IReadOnlyList<string> pathSegments, AtsTypeRef type, JsonNode value) => new()
223private static AtsTypeRef Primitive(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Primitive };
225private static AtsTypeRef Handle(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Handle };
227private static AtsParameterInfo Parameter(string name, AtsTypeRef type, string? summary = null, bool isOptional = false) => new()
235private static AtsParameterInfo Callback(string name, AtsTypeRef type, IReadOnlyList<AtsCallbackParameterInfo> parameters, AtsTypeRef returnType) => new()
247AtsTypeRef returnType,
257var resourceType = Handle(ResourceTypeId);
Aspire.Hosting.CodeGeneration.Java (27)
AtsJavaCodeGenerator.cs (27)
869AtsTypeRef typeRef,
1427foreach (var unionType in unionTypes
1523private static List<List<AtsTypeRef>> CartesianProduct(List<List<AtsTypeRef>> lists)
1525var result = new List<List<AtsTypeRef>> { new() };
1528var temp = new List<List<AtsTypeRef>>();
1531foreach (var item in list)
1533var combined = new List<AtsTypeRef>(existing) { item };
1617foreach (var unionType in unionTypes
1695AtsTypeRef unionType)
1902private string GenerateCallbackTypeSignature(IReadOnlyList<AtsCallbackParameterInfo>? callbackParameters, AtsTypeRef? callbackReturnType)
2043private string RenderJavaTransportValueConversion(AtsTypeRef? typeRef, string valueExpression, bool isOptional, int depth = 0)
2077private string RenderJavaArrayTransportValueConversion(AtsTypeRef typeRef, string valueExpression, bool allowNull, int depth)
2092private string RenderJavaDtoPropertyTransportValueConversion(AtsTypeRef? typeRef, string valueExpression, bool isOptional, int depth = 0)
2209private string RenderJavaListTransportValueConversion(AtsTypeRef typeRef, string valueExpression, bool allowNull, int depth)
2222private string MapCallbackTypeToJava(AtsTypeRef? typeRef)
2244private static bool IsListOrDictPropertyGetter(AtsTypeRef? returnType)
2256var returnType = capability.ReturnType!;
2442foreach (var expandedType in capability.ExpandedTargetTypes)
2481var exportedBaseType = handleTypeInfo.BaseTypeHierarchy
2519foreach (var targetType in targetTypes)
2562private string MapTypeRefToJava(AtsTypeRef? typeRef, bool isOptional, bool useBoxedTypes = false)
2594private string MapDtoPropertyTypeToJava(AtsTypeRef? typeRef, bool isOptional, bool useBoxedTypes = false)
2616private string MapInputTypeToJava(AtsTypeRef? typeRef, bool isOptional = false)
2680private static bool IsUnionType(AtsTypeRef? typeRef) => typeRef?.Category == AtsTypeCategory.Union;
2689private static void AddHandleTypeIfNeeded(HashSet<string> handleTypeIds, AtsTypeRef? typeRef)
2709private static void AddListOrDictTypeIfNeeded(Dictionary<string, bool> typeIds, AtsTypeRef? typeRef)
Aspire.Hosting.CodeGeneration.Java.Tests (29)
AtsJavaCodeGeneratorTests.cs (29)
719var numberType = new AtsTypeRef { TypeId = AtsConstants.Number, Category = AtsTypeCategory.Primitive };
720var booleanType = new AtsTypeRef { TypeId = AtsConstants.Boolean, Category = AtsTypeCategory.Primitive };
2950var stringType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive };
2951var innerArray = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = stringType };
2997var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2998var stringType = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive };
2999var innerArray = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = stringType };
3000var matrixType = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = innerArray };
3035var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
3063var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
3107var resourceType = new AtsTypeRef
3247var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
3248var nullableNumber = new AtsTypeRef
3254var nullableBoolean = new AtsTypeRef
3260var numberArray = new AtsTypeRef
3266var booleanArray = new AtsTypeRef
3272var booleanMatrix = new AtsTypeRef
3537var contextType = new AtsTypeRef { TypeId = "Tests/MutableContext", Category = AtsTypeCategory.Dto };
3628var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
3629var contextType = new AtsTypeRef { TypeId = "Tests/MutableContext", Category = AtsTypeCategory.Dto };
3874var nullableNumbers = Assert.IsType<AtsTypeRef>(AtsCapabilityScanner.CreateTypeRef(typeof(double?[])));
3875var nullableFlags = Assert.IsType<AtsTypeRef>(AtsCapabilityScanner.CreateTypeRef(typeof(bool?[])));
3917private static AtsContext CreateContextWithSingleDtoProperty(string propertyName, AtsTypeRef propertyType)
3943private static AtsTypeRef MutableStringDict() => new()
3952private static AtsContext CreateContextWithProbeCapabilities(AtsTypeRef resourceType, params AtsCapabilityInfo[] capabilities)
3963private static AtsCapabilityInfo CreateProbeCapability(AtsTypeRef resourceType, string methodName, AtsTypeRef returnType)
Aspire.Hosting.CodeGeneration.Python (29)
Aspire.Hosting.CodeGeneration.Python.Tests (10)
Aspire.Hosting.CodeGeneration.Rust (16)
Aspire.Hosting.CodeGeneration.Rust.Tests (4)
Aspire.Hosting.CodeGeneration.TypeScript (44)
TypeScriptApiProjector.cs (38)
102internal Dictionary<string, AtsTypeRef> TypeRefsById => _typeRefsById;
220foreach (var alias in directlyReturnedAliases)
764private string RenderTypeScriptExportedValue(JsonNode? value, AtsTypeRef typeRef)
1573private readonly Dictionary<string, AtsTypeRef> _typeRefsById = new(StringComparer.Ordinal);
1647internal static bool IsHandleType(AtsTypeRef? typeRef) =>
1655internal string MapTypeRefToTypeScript(AtsTypeRef? typeRef)
1708internal static string ApplyNullableType(AtsTypeRef typeRef, string mappedType)
1720internal string MapDtoPropertyTypeToTypeScript(AtsTypeRef? typeRef)
1736private static string FormatArrayType(AtsTypeRef? elementType, string mappedElementType)
1744internal string MapDtoUnionTypeToTypeScript(AtsTypeRef typeRef)
1797internal string MapUnionTypeToTypeScript(AtsTypeRef typeRef)
1857internal string MapInputTypeToTypeScript(AtsTypeRef? typeRef)
1894internal string MapInputUnionTypeToTypeScript(AtsTypeRef typeRef)
1906foreach (var memberRef in typeRef.UnionTypes)
1953internal string? TryMapInterfaceInputTypeToTypeScript(AtsTypeRef typeRef)
1957foreach (var candidateTypeRef in _typeRefsById.Values)
1979internal static bool IsAssignableToInterface(AtsTypeRef candidateTypeRef, string interfaceTypeId)
1986foreach (var implementedInterface in candidateTypeRef.ImplementedInterfaces)
2002internal static bool IsInterfaceHandleType(AtsTypeRef? typeRef)
2011internal static bool IsCancellationTokenType(AtsTypeRef? typeRef) => typeRef?.TypeId == AtsConstants.CancellationToken;
2461internal string GetGetterOnlyPropertyReturnType(AtsTypeRef? typeRef)
2484internal bool TryGetPromiseWrapperType(AtsTypeRef? typeRef, out string promiseInterfaceName, out string promiseImplementationClassName)
2499internal string GetGetterOnlyPropertyMethodReturnType(AtsTypeRef? typeRef)
2526internal bool IsWidenedHandleType(AtsTypeRef? typeRef)
2623internal static bool IsDictionaryType(AtsTypeRef? typeRef)
2632internal static bool IsListType(AtsTypeRef? typeRef)
2651var typeRefsByTypeId = new Dictionary<string, AtsTypeRef>();
2658var targetTypeRef = cap.TargetType;
2684foreach (var expandedType in expandedTypes)
2730var typeRef = typeRefsByTypeId.GetValueOrDefault(typeId);
2764var typeRef = typeRefsByTypeId.GetValueOrDefault(interfaceTypeId);
2912private static bool IsTypeInHierarchy(AtsTypeRef typeRef, string typeId)
2931internal static Dictionary<string, AtsTypeRef> CollectAllReferencedTypes(IReadOnlyList<AtsCapabilityInfo> capabilities)
2933var typeRefs = new Dictionary<string, AtsTypeRef>();
2935void CollectFromTypeRef(AtsTypeRef? typeRef)
2953foreach (var unionType in typeRef.UnionTypes)
3077internal string? GetPromiseWrapperForReturnType(AtsTypeRef? returnType)
3095internal string GenerateCallbackTypeSignature(IReadOnlyList<AtsCallbackParameterInfo>? callbackParameters, AtsTypeRef? callbackReturnType)
Aspire.Hosting.CodeGeneration.TypeScript.Tests (25)
Aspire.Hosting.Native.CodeGeneration (70)
src\Aspire.Hosting.RemoteHost\AtsCapabilityScanner.cs (66)
682private static void CollectEnumClrTypes(AtsTypeRef? typeRef, Dictionary<string, Type> enumTypes)
702foreach (var unionType in typeRef.UnionTypes)
766private static void ResolveTypeRef(AtsTypeRef? typeRef, HashSet<string> validTypes)
787foreach (var memberType in typeRef.UnionTypes)
862private static string? FindUnknownType(AtsTypeRef? typeRef)
887foreach (var memberType in typeRef.UnionTypes)
933var targetTypeRef = capability.TargetType ?? new AtsTypeRef
950private static Dictionary<string, List<AtsTypeRef>> BuildTypeCompatibilityMap(
953var typeToCompatibleTypes = new Dictionary<string, List<AtsTypeRef>>();
963var concreteTypeRef = new AtsTypeRef
978foreach (var iface in typeInfo.ImplementedInterfaces)
984foreach (var baseType in typeInfo.BaseTypeHierarchy)
997Dictionary<string, List<AtsTypeRef>> map,
999AtsTypeRef concreteTypeRef)
1177var propTypeRef = isCallback
1194AtsTypeRef? callbackReturnType = null;
1348var typeRef = CreateTypeRef(memberType, enumCollector: null, assemblyExportedTypeCache);
1386AtsTypeRef? typeRef,
1413AtsTypeRef typeRef,
1441var propertyTypeRef = CreateTypeRef(property.PropertyType, enumCollector: null, assemblyExportedTypeCache);
1684AtsTypeRef? propertyTypeRef;
1699var keyTypeRef = CreateTypeRef(propType.GetGenericArguments().First(), enumCollector: null, assemblyExportedTypeCache);
1702var valueTypeRef = propertyUnionAttr != null
1747var getterTypeRef = WithNullability(propertyTypeRef!, propType, propertyNullability.ReadState);
1748var setterTypeRef = WithNullability(propertyTypeRef!, propType, propertyNullability.WriteState);
1751var contextTypeRef = CreateHandleTypeRef(contextType);
1864var instanceContextTypeRef = CreateHandleTypeRef(contextType);
1985var returnTypeRef = CreateReturnTypeRef(method, assemblyExportedTypeCache);
2106AtsTypeRef? extendsTypeRef = null;
2162var returnTypeRef = CreateReturnTypeRef(method, assemblyExportedTypeCache);
2203var unionTypeRef = CreateUnionTypeRef(unionAttr, $"parameter '{paramName}'", assemblyExportedTypeCache);
2220var typeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2232AtsTypeRef? callbackReturnType = null;
2243var finalTypeRef = isCallback
2264private static (IReadOnlyList<AtsCallbackParameterInfo>? Parameters, AtsTypeRef? ReturnType) ExtractCallbackSignature(
2283var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2297AtsTypeRef? returnTypeRef;
2330private static (IReadOnlyList<AtsCallbackParameterInfo>? Parameters, AtsTypeRef? ReturnType) ExtractWellKnownDelegateSignature(
2347var voidTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2356var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2377var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2389AtsTypeRef returnTypeRef;
2674public static AtsTypeRef? CreateTypeRef(Type? type) =>
2680private static AtsTypeRef CreateVoidTypeRef() => new AtsTypeRef
2686private static AtsTypeRef? CreateReturnTypeRef(MethodInfo method, AssemblyExportedTypeCache assemblyExportedTypeCache)
2688var typeRef = CreateTypeRef(method.ReturnType, enumCollector: null, assemblyExportedTypeCache);
2707private static AtsTypeRef WithNullability(AtsTypeRef typeRef, Type declaredType, NullabilityState nullabilityState)
2736private static AtsTypeRef? CreateTypeRef(
2790var typeRef = CreateTypeRef(underlyingType, enumCollector, assemblyExportedTypeCache);
2856var keyTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2857var valueTypeRef = CreateTypeRef(genericArgs[1], enumCollector, assemblyExportedTypeCache);
2879var keyTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2880var valueTypeRef = CreateTypeRef(genericArgs[1], enumCollector, assemblyExportedTypeCache);
2902var elementTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2922var elementTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2967var elementTypeRef = CreateTypeRef(elementType, enumCollector, assemblyExportedTypeCache);
3081private static List<AtsTypeRef> CollectAllInterfaces(Type type)
3083var allInterfaces = new List<AtsTypeRef>();
3121private static List<AtsTypeRef> CollectBaseTypeHierarchy(Type type)
3123var baseTypes = new List<AtsTypeRef>();
3152private static AtsTypeRef CreateHandleTypeRef(Type type)
3156AtsTypeRef? baseTypeRef = null;
3403private static AtsTypeRef CreateUnionTypeRef(
3415var unionTypes = new List<AtsTypeRef>();
3418var typeRef = CreateTypeRef(memberType, enumCollector: null, assemblyExportedTypeCache);
Aspire.Hosting.RemoteHost (84)
AtsCapabilityScanner.cs (66)
682private static void CollectEnumClrTypes(AtsTypeRef? typeRef, Dictionary<string, Type> enumTypes)
702foreach (var unionType in typeRef.UnionTypes)
766private static void ResolveTypeRef(AtsTypeRef? typeRef, HashSet<string> validTypes)
787foreach (var memberType in typeRef.UnionTypes)
862private static string? FindUnknownType(AtsTypeRef? typeRef)
887foreach (var memberType in typeRef.UnionTypes)
933var targetTypeRef = capability.TargetType ?? new AtsTypeRef
950private static Dictionary<string, List<AtsTypeRef>> BuildTypeCompatibilityMap(
953var typeToCompatibleTypes = new Dictionary<string, List<AtsTypeRef>>();
963var concreteTypeRef = new AtsTypeRef
978foreach (var iface in typeInfo.ImplementedInterfaces)
984foreach (var baseType in typeInfo.BaseTypeHierarchy)
997Dictionary<string, List<AtsTypeRef>> map,
999AtsTypeRef concreteTypeRef)
1177var propTypeRef = isCallback
1194AtsTypeRef? callbackReturnType = null;
1348var typeRef = CreateTypeRef(memberType, enumCollector: null, assemblyExportedTypeCache);
1386AtsTypeRef? typeRef,
1413AtsTypeRef typeRef,
1441var propertyTypeRef = CreateTypeRef(property.PropertyType, enumCollector: null, assemblyExportedTypeCache);
1684AtsTypeRef? propertyTypeRef;
1699var keyTypeRef = CreateTypeRef(propType.GetGenericArguments().First(), enumCollector: null, assemblyExportedTypeCache);
1702var valueTypeRef = propertyUnionAttr != null
1747var getterTypeRef = WithNullability(propertyTypeRef!, propType, propertyNullability.ReadState);
1748var setterTypeRef = WithNullability(propertyTypeRef!, propType, propertyNullability.WriteState);
1751var contextTypeRef = CreateHandleTypeRef(contextType);
1864var instanceContextTypeRef = CreateHandleTypeRef(contextType);
1985var returnTypeRef = CreateReturnTypeRef(method, assemblyExportedTypeCache);
2106AtsTypeRef? extendsTypeRef = null;
2162var returnTypeRef = CreateReturnTypeRef(method, assemblyExportedTypeCache);
2203var unionTypeRef = CreateUnionTypeRef(unionAttr, $"parameter '{paramName}'", assemblyExportedTypeCache);
2220var typeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2232AtsTypeRef? callbackReturnType = null;
2243var finalTypeRef = isCallback
2264private static (IReadOnlyList<AtsCallbackParameterInfo>? Parameters, AtsTypeRef? ReturnType) ExtractCallbackSignature(
2283var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2297AtsTypeRef? returnTypeRef;
2330private static (IReadOnlyList<AtsCallbackParameterInfo>? Parameters, AtsTypeRef? ReturnType) ExtractWellKnownDelegateSignature(
2347var voidTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2356var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2377var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2389AtsTypeRef returnTypeRef;
2674public static AtsTypeRef? CreateTypeRef(Type? type) =>
2680private static AtsTypeRef CreateVoidTypeRef() => new AtsTypeRef
2686private static AtsTypeRef? CreateReturnTypeRef(MethodInfo method, AssemblyExportedTypeCache assemblyExportedTypeCache)
2688var typeRef = CreateTypeRef(method.ReturnType, enumCollector: null, assemblyExportedTypeCache);
2707private static AtsTypeRef WithNullability(AtsTypeRef typeRef, Type declaredType, NullabilityState nullabilityState)
2736private static AtsTypeRef? CreateTypeRef(
2790var typeRef = CreateTypeRef(underlyingType, enumCollector, assemblyExportedTypeCache);
2856var keyTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2857var valueTypeRef = CreateTypeRef(genericArgs[1], enumCollector, assemblyExportedTypeCache);
2879var keyTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2880var valueTypeRef = CreateTypeRef(genericArgs[1], enumCollector, assemblyExportedTypeCache);
2902var elementTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2922var elementTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2967var elementTypeRef = CreateTypeRef(elementType, enumCollector, assemblyExportedTypeCache);
3081private static List<AtsTypeRef> CollectAllInterfaces(Type type)
3083var allInterfaces = new List<AtsTypeRef>();
3121private static List<AtsTypeRef> CollectBaseTypeHierarchy(Type type)
3123var baseTypes = new List<AtsTypeRef>();
3152private static AtsTypeRef CreateHandleTypeRef(Type type)
3156AtsTypeRef? baseTypeRef = null;
3403private static AtsTypeRef CreateUnionTypeRef(
3415var unionTypes = new List<AtsTypeRef>();
3418var typeRef = CreateTypeRef(memberType, enumCollector: null, assemblyExportedTypeCache);
Aspire.Hosting.RemoteHost.Tests (8)
Aspire.TypeSystem (17)