223 instantiations of AtsTypeRef
Aspire.Hosting.CodeGeneration.Go.Tests (24)
GoGeneratorEscapingTests.cs (8)
95var tagsType = new AtsTypeRef { TypeId = "Tests/List<string>", Category = AtsTypeCategory.List, ElementType = stringType };
96var unionType = new AtsTypeRef { TypeId = "Tests/Union", Category = AtsTypeCategory.Union, UnionTypes = [stringType, numberType] };
97var callbackType = new AtsTypeRef { TypeId = "Tests/Callback", Category = AtsTypeCategory.Callback };
98var enumType = new AtsTypeRef { TypeId = StatusTypeId, Category = AtsTypeCategory.Enum };
99var lookupType = new AtsTypeRef { TypeId = "Tests/Dict<string,string>", Category = AtsTypeCategory.Dict, KeyType = stringType, ValueType = stringType, IsReadOnly = true };
100var unknownType = new AtsTypeRef { TypeId = "Tests/Unknown", Category = AtsTypeCategory.Unknown };
197private static AtsTypeRef Primitive(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Primitive };
199private static AtsTypeRef Handle(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Handle };
Aspire.Hosting.CodeGeneration.Java.Tests (44)
AtsJavaCodeGeneratorTests.cs (44)
2698new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = MutableStringDict() });
2711new AtsTypeRef
2728var stringType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive };
2729var innerArray = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = stringType };
2732new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = innerArray });
2775var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2776var stringType = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive };
2777var innerArray = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = stringType };
2778var matrixType = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = innerArray };
2783Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback },
2785CallbackReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
2792ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive },
2813var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2817Type = new AtsTypeRef { TypeId = AtsConstants.CancellationToken, Category = AtsTypeCategory.Dto }
2824ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive },
2841var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2857Type = new AtsTypeRef
2885var resourceType = new AtsTypeRef
2895new AtsTypeRef { TypeId = AtsConstants.Boolean, Category = AtsTypeCategory.Primitive, IsNullable = true }),
2899new AtsTypeRef { TypeId = AtsConstants.Number, Category = AtsTypeCategory.Primitive, IsNullable = true }),
3025var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
3026var nullableNumber = new AtsTypeRef
3032var nullableBoolean = new AtsTypeRef
3038var numberArray = new AtsTypeRef
3044var booleanArray = new AtsTypeRef
3050var booleanMatrix = new AtsTypeRef
3060Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback },
3066CallbackReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
3073ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive },
3315var contextType = new AtsTypeRef { TypeId = "Tests/MutableContext", Category = AtsTypeCategory.Dto };
3331Type = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive }
3344Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback },
3350CallbackReturnType = new AtsTypeRef
3406var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
3407var contextType = new AtsTypeRef { TypeId = "Tests/MutableContext", Category = AtsTypeCategory.Dto };
3412Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback },
3417CallbackReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
3424ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive },
3446Type = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive }
3633Type = new AtsTypeRef { TypeId = "KeywordProbe", Category = AtsTypeCategory.Dto }
3692new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive });
3721private static AtsTypeRef MutableStringDict() => new()
3726KeyType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive },
3727ValueType = 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)
927var targetTypeRef = capability.TargetType ?? new AtsTypeRef
957var concreteTypeRef = new AtsTypeRef
1171? new AtsTypeRef { TypeId = "callback", ClrType = prop.PropertyType, Category = AtsTypeCategory.Callback }
1691: new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive };
1693propertyTypeRef = new AtsTypeRef
1718propertyTypeRef = new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive };
2231? new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback }
2288returnTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2292returnTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2300?? new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
2301: new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2306?? new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
2334var voidTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2667private static AtsTypeRef CreateVoidTypeRef() => new AtsTypeRef
2703return new AtsTypeRef
2785return new AtsTypeRef { TypeId = primitiveTypeId, ClrType = type, Category = AtsTypeCategory.Primitive };
2791return new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = type, Category = AtsTypeCategory.Primitive };
2796return new AtsTypeRef
2801KeyType = new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive },
2802ValueType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive },
2809return new AtsTypeRef
2814ElementType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive }
2824return new AtsTypeRef
2847return new AtsTypeRef
2870return new AtsTypeRef
2892return new AtsTypeRef
2912return new AtsTypeRef
2957return new AtsTypeRef
2973return new AtsTypeRef
2985return new AtsTypeRef
2995return new AtsTypeRef
3090allInterfaces.Add(new AtsTypeRef
3157return new AtsTypeRef
3416return new AtsTypeRef
Aspire.Hosting.RemoteHost (39)
AtsCapabilityScanner.cs (34)
927var targetTypeRef = capability.TargetType ?? new AtsTypeRef
957var concreteTypeRef = new AtsTypeRef
1171? new AtsTypeRef { TypeId = "callback", ClrType = prop.PropertyType, Category = AtsTypeCategory.Callback }
1691: new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive };
1693propertyTypeRef = new AtsTypeRef
1718propertyTypeRef = new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive };
2231? new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback }
2288returnTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2292returnTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2300?? new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
2301: new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2306?? new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
2334var voidTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2667private static AtsTypeRef CreateVoidTypeRef() => new AtsTypeRef
2703return new AtsTypeRef
2785return new AtsTypeRef { TypeId = primitiveTypeId, ClrType = type, Category = AtsTypeCategory.Primitive };
2791return new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = type, Category = AtsTypeCategory.Primitive };
2796return new AtsTypeRef
2801KeyType = new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive },
2802ValueType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive },
2809return new AtsTypeRef
2814ElementType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive }
2824return new AtsTypeRef
2847return new AtsTypeRef
2870return new AtsTypeRef
2892return new AtsTypeRef
2912return new AtsTypeRef
2957return new AtsTypeRef
2973return new AtsTypeRef
2985return new AtsTypeRef
2995return new AtsTypeRef
3090allInterfaces.Add(new AtsTypeRef
3157return new AtsTypeRef
3416return 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 };
453 references to AtsTypeRef
aspire-managed (2)
Aspire.Hosting.CodeGeneration.Go (31)
AtsGoCodeGenerator.cs (27)
217foreach (var expanded in capability.ExpandedTargetTypes)
441private static void CollectHandleTypeIds(HashSet<string> set, AtsTypeRef? typeRef)
470foreach (var u in typeRef.UnionTypes)
560: (IReadOnlyList<AtsTypeRef>)Array.Empty<AtsTypeRef>();
562foreach (var targetType in targetTypes)
977AtsTypeRef typeRef,
1223private static List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)>
1226var result = new List<(string, string, AtsTypeRef, string, string?)>();
1261List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)> listDictGetters)
1359List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)> listDictGetters)
1608var returnType = capability.ReturnType!;
1648List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)> listDictGetters)
1700var returnType = capability.ReturnType!;
1772var returnType = capability.ReturnType!;
2044private string GetCallbackArgExpression(AtsTypeRef type, int index, string? clientExpression)
2060(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description) g,
2076private (string Wrapper, string TypeArgs) ListDictTypeArgs(AtsTypeRef returnType)
2343private string GetUnionAllowedTypes(AtsTypeRef typeRef) => string.Join(", ", GetUnionMemberTypes(typeRef));
2351private string GetUnionTypeSwitchCases(AtsTypeRef typeRef)
2362private string[] GetUnionMemberTypes(AtsTypeRef typeRef)
2582private string MapTypeRefToGo(AtsTypeRef? typeRef, bool isOptional) =>
2589/// everything else use <see cref="MapTypeRefToGo(AtsTypeRef?, bool)"/>.
2591private string MapInputTypeRefToGo(AtsTypeRef? typeRef, bool isOptional) =>
2594private string MapTypeRefToGo(AtsTypeRef? typeRef, bool isOptional, bool asInput)
2635private string MapDtoPropertyTypeToGo(AtsTypeRef? typeRef, bool isOptional)
2673private static bool ShouldApplyNullableType(AtsTypeRef typeRef) =>
Aspire.Hosting.CodeGeneration.Go.Tests (59)
AtsGoDerivedBuilderTests.cs (26)
489private static readonly AtsTypeRef s_builder = new() { TypeId = AtsConstants.BuilderTypeId, Category = AtsTypeCategory.Handle, IsInterface = true };
490private static readonly AtsTypeRef s_pool = Handle(PoolId);
491private static readonly AtsTypeRef s_aksPool = Handle(AksPoolId);
492private static readonly AtsTypeRef s_spotPool = Handle(SpotPoolId);
493private static readonly AtsTypeRef s_gpuSpotPool = Handle(GpuSpotPoolId);
494private static readonly AtsTypeRef s_workload = Handle(WorkloadId);
495private static readonly AtsTypeRef s_queue = Handle(QueueId);
496private static readonly AtsTypeRef s_string = new() { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive };
497private static readonly AtsTypeRef s_poolSettings = new() { TypeId = PoolSettingsId, Category = AtsTypeCategory.Dto };
614private static AtsTypeRef Handle(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Handle };
616private static AtsTypeRef ArrayOf(AtsTypeRef element) => new()
624private static AtsTypeRef ListOf(AtsTypeRef element) => new()
631private static AtsTypeRef ReadOnlyDictOf(AtsTypeRef key, AtsTypeRef value) => new()
640private static AtsTypeRef UnionOf(params AtsTypeRef[] members) => new()
647private static AtsParameterInfo Required(string name, AtsTypeRef type) => new() { Name = name, Type = type };
649private static AtsParameterInfo Optional(string name, AtsTypeRef type) => new() { Name = name, Type = type, IsOptional = true, IsNullable = true };
651private static AtsParameterInfo Callback(string name, params (string Name, AtsTypeRef Type)[] parameters) => new()
660private static AtsCapabilityInfo Factory(string methodName, AtsTypeRef returnType) =>
668AtsTypeRef target,
669IReadOnlyList<AtsTypeRef> expandedTargets,
671AtsTypeRef returnType) => new()
GoDocCommentTests.cs (11)
358var stringType = Primitive(AtsConstants.String);
359var boolType = Primitive(AtsConstants.Boolean);
360var voidType = Primitive(AtsConstants.Void);
361var resourceType = new AtsTypeRef { TypeId = ResourceTypeId, Category = AtsTypeCategory.Handle };
362var settingsType = new AtsTypeRef { TypeId = SettingsTypeId, Category = AtsTypeCategory.Dto };
363var statusType = new AtsTypeRef { TypeId = StatusTypeId, Category = AtsTypeCategory.Enum };
364var tagsType = new AtsTypeRef { TypeId = "Tests/List<string>", Category = AtsTypeCategory.List, ElementType = stringType };
475private static AtsTypeRef Primitive(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Primitive };
477private static AtsParameterInfo Parameter(string name, AtsTypeRef type, string? summary = null, bool isOptional = false) => new()
487AtsTypeRef returnType,
496var resourceType = new AtsTypeRef { TypeId = ResourceTypeId, Category = AtsTypeCategory.Handle };
GoGeneratorEscapingTests.cs (18)
91var stringType = Primitive(AtsConstants.String);
92var numberType = Primitive(AtsConstants.Number);
93var voidType = Primitive(AtsConstants.Void);
94var resourceType = Handle(ResourceTypeId);
95var tagsType = new AtsTypeRef { TypeId = "Tests/List<string>", Category = AtsTypeCategory.List, ElementType = stringType };
96var unionType = new AtsTypeRef { TypeId = "Tests/Union", Category = AtsTypeCategory.Union, UnionTypes = [stringType, numberType] };
97var callbackType = new AtsTypeRef { TypeId = "Tests/Callback", Category = AtsTypeCategory.Callback };
98var enumType = new AtsTypeRef { TypeId = StatusTypeId, Category = AtsTypeCategory.Enum };
99var lookupType = new AtsTypeRef { TypeId = "Tests/Dict<string,string>", Category = AtsTypeCategory.Dict, KeyType = stringType, ValueType = stringType, IsReadOnly = true };
100var unknownType = new AtsTypeRef { TypeId = "Tests/Unknown", Category = AtsTypeCategory.Unknown };
189private static AtsExportedValueInfo ExportedValue(IReadOnlyList<string> pathSegments, AtsTypeRef type, JsonNode value) => new()
197private static AtsTypeRef Primitive(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Primitive };
199private static AtsTypeRef Handle(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Handle };
201private static AtsParameterInfo Parameter(string name, AtsTypeRef type, string? summary = null, bool isOptional = false) => new()
209private static AtsParameterInfo Callback(string name, AtsTypeRef type, IReadOnlyList<AtsCallbackParameterInfo> parameters, AtsTypeRef returnType) => new()
221AtsTypeRef returnType,
231var 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 (27)
AtsJavaCodeGeneratorTests.cs (27)
2728var stringType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive };
2729var innerArray = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = stringType };
2775var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2776var stringType = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive };
2777var innerArray = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = stringType };
2778var matrixType = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = innerArray };
2813var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2841var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2885var resourceType = new AtsTypeRef
3025var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
3026var nullableNumber = new AtsTypeRef
3032var nullableBoolean = new AtsTypeRef
3038var numberArray = new AtsTypeRef
3044var booleanArray = new AtsTypeRef
3050var booleanMatrix = new AtsTypeRef
3315var contextType = new AtsTypeRef { TypeId = "Tests/MutableContext", Category = AtsTypeCategory.Dto };
3406var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
3407var contextType = new AtsTypeRef { TypeId = "Tests/MutableContext", Category = AtsTypeCategory.Dto };
3652var nullableNumbers = Assert.IsType<AtsTypeRef>(AtsCapabilityScanner.CreateTypeRef(typeof(double?[])));
3653var nullableFlags = Assert.IsType<AtsTypeRef>(AtsCapabilityScanner.CreateTypeRef(typeof(bool?[])));
3695private static AtsContext CreateContextWithSingleDtoProperty(string propertyName, AtsTypeRef propertyType)
3721private static AtsTypeRef MutableStringDict() => new()
3730private static AtsContext CreateContextWithProbeCapabilities(AtsTypeRef resourceType, params AtsCapabilityInfo[] capabilities)
3741private 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)
676private static void CollectEnumClrTypes(AtsTypeRef? typeRef, Dictionary<string, Type> enumTypes)
696foreach (var unionType in typeRef.UnionTypes)
760private static void ResolveTypeRef(AtsTypeRef? typeRef, HashSet<string> validTypes)
781foreach (var memberType in typeRef.UnionTypes)
856private static string? FindUnknownType(AtsTypeRef? typeRef)
881foreach (var memberType in typeRef.UnionTypes)
927var targetTypeRef = capability.TargetType ?? new AtsTypeRef
944private static Dictionary<string, List<AtsTypeRef>> BuildTypeCompatibilityMap(
947var typeToCompatibleTypes = new Dictionary<string, List<AtsTypeRef>>();
957var concreteTypeRef = new AtsTypeRef
972foreach (var iface in typeInfo.ImplementedInterfaces)
978foreach (var baseType in typeInfo.BaseTypeHierarchy)
991Dictionary<string, List<AtsTypeRef>> map,
993AtsTypeRef concreteTypeRef)
1170var propTypeRef = isCallback
1187AtsTypeRef? callbackReturnType = null;
1336var typeRef = CreateTypeRef(memberType, enumCollector: null, assemblyExportedTypeCache);
1373AtsTypeRef? typeRef,
1400AtsTypeRef typeRef,
1428var propertyTypeRef = CreateTypeRef(property.PropertyType, enumCollector: null, assemblyExportedTypeCache);
1671AtsTypeRef? propertyTypeRef;
1686var keyTypeRef = CreateTypeRef(propType.GetGenericArguments().First(), enumCollector: null, assemblyExportedTypeCache);
1689var valueTypeRef = propertyUnionAttr != null
1734var getterTypeRef = WithNullability(propertyTypeRef!, propType, propertyNullability.ReadState);
1735var setterTypeRef = WithNullability(propertyTypeRef!, propType, propertyNullability.WriteState);
1738var contextTypeRef = CreateHandleTypeRef(contextType);
1851var instanceContextTypeRef = CreateHandleTypeRef(contextType);
1972var returnTypeRef = CreateReturnTypeRef(method, assemblyExportedTypeCache);
2093AtsTypeRef? extendsTypeRef = null;
2149var returnTypeRef = CreateReturnTypeRef(method, assemblyExportedTypeCache);
2190var unionTypeRef = CreateUnionTypeRef(unionAttr, $"parameter '{paramName}'", assemblyExportedTypeCache);
2207var typeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2219AtsTypeRef? callbackReturnType = null;
2230var finalTypeRef = isCallback
2251private static (IReadOnlyList<AtsCallbackParameterInfo>? Parameters, AtsTypeRef? ReturnType) ExtractCallbackSignature(
2270var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2284AtsTypeRef? returnTypeRef;
2317private static (IReadOnlyList<AtsCallbackParameterInfo>? Parameters, AtsTypeRef? ReturnType) ExtractWellKnownDelegateSignature(
2334var voidTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2343var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2364var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2376AtsTypeRef returnTypeRef;
2661public static AtsTypeRef? CreateTypeRef(Type? type) =>
2667private static AtsTypeRef CreateVoidTypeRef() => new AtsTypeRef
2673private static AtsTypeRef? CreateReturnTypeRef(MethodInfo method, AssemblyExportedTypeCache assemblyExportedTypeCache)
2675var typeRef = CreateTypeRef(method.ReturnType, enumCollector: null, assemblyExportedTypeCache);
2694private static AtsTypeRef WithNullability(AtsTypeRef typeRef, Type declaredType, NullabilityState nullabilityState)
2723private static AtsTypeRef? CreateTypeRef(
2777var typeRef = CreateTypeRef(underlyingType, enumCollector, assemblyExportedTypeCache);
2843var keyTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2844var valueTypeRef = CreateTypeRef(genericArgs[1], enumCollector, assemblyExportedTypeCache);
2866var keyTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2867var valueTypeRef = CreateTypeRef(genericArgs[1], enumCollector, assemblyExportedTypeCache);
2889var elementTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2909var elementTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2954var elementTypeRef = CreateTypeRef(elementType, enumCollector, assemblyExportedTypeCache);
3068private static List<AtsTypeRef> CollectAllInterfaces(Type type)
3070var allInterfaces = new List<AtsTypeRef>();
3108private static List<AtsTypeRef> CollectBaseTypeHierarchy(Type type)
3110var baseTypes = new List<AtsTypeRef>();
3139private static AtsTypeRef CreateHandleTypeRef(Type type)
3143AtsTypeRef? baseTypeRef = null;
3390private static AtsTypeRef CreateUnionTypeRef(
3402var unionTypes = new List<AtsTypeRef>();
3405var typeRef = CreateTypeRef(memberType, enumCollector: null, assemblyExportedTypeCache);
Aspire.Hosting.RemoteHost (84)
AtsCapabilityScanner.cs (66)
676private static void CollectEnumClrTypes(AtsTypeRef? typeRef, Dictionary<string, Type> enumTypes)
696foreach (var unionType in typeRef.UnionTypes)
760private static void ResolveTypeRef(AtsTypeRef? typeRef, HashSet<string> validTypes)
781foreach (var memberType in typeRef.UnionTypes)
856private static string? FindUnknownType(AtsTypeRef? typeRef)
881foreach (var memberType in typeRef.UnionTypes)
927var targetTypeRef = capability.TargetType ?? new AtsTypeRef
944private static Dictionary<string, List<AtsTypeRef>> BuildTypeCompatibilityMap(
947var typeToCompatibleTypes = new Dictionary<string, List<AtsTypeRef>>();
957var concreteTypeRef = new AtsTypeRef
972foreach (var iface in typeInfo.ImplementedInterfaces)
978foreach (var baseType in typeInfo.BaseTypeHierarchy)
991Dictionary<string, List<AtsTypeRef>> map,
993AtsTypeRef concreteTypeRef)
1170var propTypeRef = isCallback
1187AtsTypeRef? callbackReturnType = null;
1336var typeRef = CreateTypeRef(memberType, enumCollector: null, assemblyExportedTypeCache);
1373AtsTypeRef? typeRef,
1400AtsTypeRef typeRef,
1428var propertyTypeRef = CreateTypeRef(property.PropertyType, enumCollector: null, assemblyExportedTypeCache);
1671AtsTypeRef? propertyTypeRef;
1686var keyTypeRef = CreateTypeRef(propType.GetGenericArguments().First(), enumCollector: null, assemblyExportedTypeCache);
1689var valueTypeRef = propertyUnionAttr != null
1734var getterTypeRef = WithNullability(propertyTypeRef!, propType, propertyNullability.ReadState);
1735var setterTypeRef = WithNullability(propertyTypeRef!, propType, propertyNullability.WriteState);
1738var contextTypeRef = CreateHandleTypeRef(contextType);
1851var instanceContextTypeRef = CreateHandleTypeRef(contextType);
1972var returnTypeRef = CreateReturnTypeRef(method, assemblyExportedTypeCache);
2093AtsTypeRef? extendsTypeRef = null;
2149var returnTypeRef = CreateReturnTypeRef(method, assemblyExportedTypeCache);
2190var unionTypeRef = CreateUnionTypeRef(unionAttr, $"parameter '{paramName}'", assemblyExportedTypeCache);
2207var typeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2219AtsTypeRef? callbackReturnType = null;
2230var finalTypeRef = isCallback
2251private static (IReadOnlyList<AtsCallbackParameterInfo>? Parameters, AtsTypeRef? ReturnType) ExtractCallbackSignature(
2270var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2284AtsTypeRef? returnTypeRef;
2317private static (IReadOnlyList<AtsCallbackParameterInfo>? Parameters, AtsTypeRef? ReturnType) ExtractWellKnownDelegateSignature(
2334var voidTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2343var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2364var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2376AtsTypeRef returnTypeRef;
2661public static AtsTypeRef? CreateTypeRef(Type? type) =>
2667private static AtsTypeRef CreateVoidTypeRef() => new AtsTypeRef
2673private static AtsTypeRef? CreateReturnTypeRef(MethodInfo method, AssemblyExportedTypeCache assemblyExportedTypeCache)
2675var typeRef = CreateTypeRef(method.ReturnType, enumCollector: null, assemblyExportedTypeCache);
2694private static AtsTypeRef WithNullability(AtsTypeRef typeRef, Type declaredType, NullabilityState nullabilityState)
2723private static AtsTypeRef? CreateTypeRef(
2777var typeRef = CreateTypeRef(underlyingType, enumCollector, assemblyExportedTypeCache);
2843var keyTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2844var valueTypeRef = CreateTypeRef(genericArgs[1], enumCollector, assemblyExportedTypeCache);
2866var keyTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2867var valueTypeRef = CreateTypeRef(genericArgs[1], enumCollector, assemblyExportedTypeCache);
2889var elementTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2909var elementTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2954var elementTypeRef = CreateTypeRef(elementType, enumCollector, assemblyExportedTypeCache);
3068private static List<AtsTypeRef> CollectAllInterfaces(Type type)
3070var allInterfaces = new List<AtsTypeRef>();
3108private static List<AtsTypeRef> CollectBaseTypeHierarchy(Type type)
3110var baseTypes = new List<AtsTypeRef>();
3139private static AtsTypeRef CreateHandleTypeRef(Type type)
3143AtsTypeRef? baseTypeRef = null;
3390private static AtsTypeRef CreateUnionTypeRef(
3402var unionTypes = new List<AtsTypeRef>();
3405var typeRef = CreateTypeRef(memberType, enumCollector: null, assemblyExportedTypeCache);
Aspire.Hosting.RemoteHost.Tests (8)
Aspire.TypeSystem (17)