140 instantiations of AtsTypeRef
Aspire.Hosting.CodeGeneration.Java.Tests (44)
AtsJavaCodeGeneratorTests.cs (44)
2646new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = MutableStringDict() });
2659new AtsTypeRef
2676var stringType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive };
2677var innerArray = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = stringType };
2680new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = innerArray });
2723var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2724var stringType = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive };
2725var innerArray = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = stringType };
2726var matrixType = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = innerArray };
2731Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback },
2733CallbackReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
2740ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive },
2761var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2765Type = new AtsTypeRef { TypeId = AtsConstants.CancellationToken, Category = AtsTypeCategory.Dto }
2772ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive },
2789var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2805Type = new AtsTypeRef
2831var resourceType = new AtsTypeRef
2841new AtsTypeRef { TypeId = AtsConstants.Boolean, Category = AtsTypeCategory.Primitive, IsNullable = true }),
2845new AtsTypeRef { TypeId = AtsConstants.Number, Category = AtsTypeCategory.Primitive, IsNullable = true }));
2963var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2964var nullableNumber = new AtsTypeRef
2970var nullableBoolean = new AtsTypeRef
2976var numberArray = new AtsTypeRef
2982var booleanArray = new AtsTypeRef
2988var booleanMatrix = new AtsTypeRef
2998Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback },
3004CallbackReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
3011ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive },
3219var contextType = new AtsTypeRef { TypeId = "Tests/MutableContext", Category = AtsTypeCategory.Dto };
3235Type = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive }
3248Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback },
3254CallbackReturnType = new AtsTypeRef
3310var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
3311var contextType = new AtsTypeRef { TypeId = "Tests/MutableContext", Category = AtsTypeCategory.Dto };
3316Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback },
3321CallbackReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
3328ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive },
3350Type = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive }
3537Type = new AtsTypeRef { TypeId = "KeywordProbe", Category = AtsTypeCategory.Dto }
3596new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive });
3625private static AtsTypeRef MutableStringDict() => new()
3630KeyType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive },
3631ValueType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive }
Aspire.Hosting.CodeGeneration.Python.Tests (19)
Aspire.Hosting.CodeGeneration.TypeScript.Tests (21)
Aspire.Hosting.RemoteHost (37)
AtsCapabilityScanner.cs (34)
853var targetTypeRef = capability.TargetType ?? new AtsTypeRef
883var concreteTypeRef = new AtsTypeRef
1097? new AtsTypeRef { TypeId = "callback", ClrType = prop.PropertyType, Category = AtsTypeCategory.Callback }
1617: new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive };
1619propertyTypeRef = new AtsTypeRef
1644propertyTypeRef = new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive };
2150? new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback }
2207returnTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2211returnTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2219?? new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
2220: new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2225?? new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
2253var voidTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2586private static AtsTypeRef CreateVoidTypeRef() => new AtsTypeRef
2601return new AtsTypeRef
2683return new AtsTypeRef { TypeId = primitiveTypeId, ClrType = type, Category = AtsTypeCategory.Primitive };
2689return new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = type, Category = AtsTypeCategory.Primitive };
2694return new AtsTypeRef
2699KeyType = new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive },
2700ValueType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive },
2707return new AtsTypeRef
2712ElementType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive }
2722return new AtsTypeRef
2745return new AtsTypeRef
2768return new AtsTypeRef
2790return new AtsTypeRef
2810return new AtsTypeRef
2855return new AtsTypeRef
2871return new AtsTypeRef
2883return new AtsTypeRef
2893return new AtsTypeRef
2988allInterfaces.Add(new AtsTypeRef
3055return new AtsTypeRef
3314return new AtsTypeRef
Aspire.Hosting.RemoteHost.Tests (19)
301 references to AtsTypeRef
Aspire.Hosting.CodeGeneration.Go (21)
AtsGoCodeGenerator.cs (21)
181foreach (var expanded in capability.ExpandedTargetTypes)
309private static void CollectHandleTypeIds(HashSet<string> set, AtsTypeRef? typeRef)
338foreach (var u in typeRef.UnionTypes)
428: (IReadOnlyList<AtsTypeRef>)Array.Empty<AtsTypeRef>();
430foreach (var targetType in targetTypes)
683AtsTypeRef typeRef,
857private static List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)>
860var result = new List<(string, string, AtsTypeRef, string, string?)>();
895List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)> listDictGetters)
950List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)> listDictGetters)
1176var returnType = capability.ReturnType!;
1216List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)> listDictGetters)
1276var returnType = capability.ReturnType!;
1348var returnType = capability.ReturnType!;
1617(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description) g)
1635private (string Wrapper, string TypeArgs) ListDictTypeArgs(AtsTypeRef returnType)
1883private string GetUnionAllowedTypes(AtsTypeRef typeRef)
2091private string MapTypeRefToGo(AtsTypeRef? typeRef, bool isOptional)
2129private string MapDtoPropertyTypeToGo(AtsTypeRef? typeRef, bool isOptional)
2163private static bool ShouldApplyNullableType(AtsTypeRef typeRef) =>
Aspire.Hosting.CodeGeneration.Go.Tests (4)
Aspire.Hosting.CodeGeneration.Java (27)
AtsJavaCodeGenerator.cs (27)
853AtsTypeRef typeRef,
1407foreach (var unionType in unionTypes
1503private static List<List<AtsTypeRef>> CartesianProduct(List<List<AtsTypeRef>> lists)
1505var result = new List<List<AtsTypeRef>> { new() };
1508var temp = new List<List<AtsTypeRef>>();
1511foreach (var item in list)
1513var combined = new List<AtsTypeRef>(existing) { item };
1597foreach (var unionType in unionTypes
1675AtsTypeRef unionType)
1882private string GenerateCallbackTypeSignature(IReadOnlyList<AtsCallbackParameterInfo>? callbackParameters, AtsTypeRef? callbackReturnType)
2023private string RenderJavaTransportValueConversion(AtsTypeRef? typeRef, string valueExpression, bool isOptional, int depth = 0)
2057private string RenderJavaArrayTransportValueConversion(AtsTypeRef typeRef, string valueExpression, bool allowNull, int depth)
2072private string RenderJavaDtoPropertyTransportValueConversion(AtsTypeRef? typeRef, string valueExpression, bool isOptional, int depth = 0)
2189private string RenderJavaListTransportValueConversion(AtsTypeRef typeRef, string valueExpression, bool allowNull, int depth)
2202private string MapCallbackTypeToJava(AtsTypeRef? typeRef)
2224private static bool IsListOrDictPropertyGetter(AtsTypeRef? returnType)
2236var returnType = capability.ReturnType!;
2422foreach (var expandedType in capability.ExpandedTargetTypes)
2461var exportedBaseType = handleTypeInfo.BaseTypeHierarchy
2499foreach (var targetType in targetTypes)
2542private string MapTypeRefToJava(AtsTypeRef? typeRef, bool isOptional, bool useBoxedTypes = false)
2574private string MapDtoPropertyTypeToJava(AtsTypeRef? typeRef, bool isOptional, bool useBoxedTypes = false)
2596private string MapInputTypeToJava(AtsTypeRef? typeRef, bool isOptional = false)
2660private static bool IsUnionType(AtsTypeRef? typeRef) => typeRef?.Category == AtsTypeCategory.Union;
2669private static void AddHandleTypeIfNeeded(HashSet<string> handleTypeIds, AtsTypeRef? typeRef)
2689private static void AddListOrDictTypeIfNeeded(Dictionary<string, bool> typeIds, AtsTypeRef? typeRef)
Aspire.Hosting.CodeGeneration.Java.Tests (27)
AtsJavaCodeGeneratorTests.cs (27)
2676var stringType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive };
2677var innerArray = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = stringType };
2723var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2724var stringType = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive };
2725var innerArray = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = stringType };
2726var matrixType = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = innerArray };
2761var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2789var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2831var resourceType = new AtsTypeRef
2963var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
2964var nullableNumber = new AtsTypeRef
2970var nullableBoolean = new AtsTypeRef
2976var numberArray = new AtsTypeRef
2982var booleanArray = new AtsTypeRef
2988var booleanMatrix = new AtsTypeRef
3219var contextType = new AtsTypeRef { TypeId = "Tests/MutableContext", Category = AtsTypeCategory.Dto };
3310var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle };
3311var contextType = new AtsTypeRef { TypeId = "Tests/MutableContext", Category = AtsTypeCategory.Dto };
3556var nullableNumbers = Assert.IsType<AtsTypeRef>(AtsCapabilityScanner.CreateTypeRef(typeof(double?[])));
3557var nullableFlags = Assert.IsType<AtsTypeRef>(AtsCapabilityScanner.CreateTypeRef(typeof(bool?[])));
3599private static AtsContext CreateContextWithSingleDtoProperty(string propertyName, AtsTypeRef propertyType)
3625private static AtsTypeRef MutableStringDict() => new()
3634private static AtsContext CreateContextWithProbeCapabilities(AtsTypeRef resourceType, params AtsCapabilityInfo[] capabilities)
3645private 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)
1569private readonly Dictionary<string, AtsTypeRef> _typeRefsById = new(StringComparer.Ordinal);
1643internal static bool IsHandleType(AtsTypeRef? typeRef) =>
1651internal string MapTypeRefToTypeScript(AtsTypeRef? typeRef)
1704internal static string ApplyNullableType(AtsTypeRef typeRef, string mappedType)
1716internal string MapDtoPropertyTypeToTypeScript(AtsTypeRef? typeRef)
1732private static string FormatArrayType(AtsTypeRef? elementType, string mappedElementType)
1740internal string MapDtoUnionTypeToTypeScript(AtsTypeRef typeRef)
1793internal string MapUnionTypeToTypeScript(AtsTypeRef typeRef)
1853internal string MapInputTypeToTypeScript(AtsTypeRef? typeRef)
1890internal string MapInputUnionTypeToTypeScript(AtsTypeRef typeRef)
1902foreach (var memberRef in typeRef.UnionTypes)
1949internal string? TryMapInterfaceInputTypeToTypeScript(AtsTypeRef typeRef)
1953foreach (var candidateTypeRef in _typeRefsById.Values)
1975internal static bool IsAssignableToInterface(AtsTypeRef candidateTypeRef, string interfaceTypeId)
1982foreach (var implementedInterface in candidateTypeRef.ImplementedInterfaces)
1998internal static bool IsInterfaceHandleType(AtsTypeRef? typeRef)
2007internal static bool IsCancellationTokenType(AtsTypeRef? typeRef) => typeRef?.TypeId == AtsConstants.CancellationToken;
2457internal string GetGetterOnlyPropertyReturnType(AtsTypeRef? typeRef)
2480internal bool TryGetPromiseWrapperType(AtsTypeRef? typeRef, out string promiseInterfaceName, out string promiseImplementationClassName)
2495internal string GetGetterOnlyPropertyMethodReturnType(AtsTypeRef? typeRef)
2522internal bool IsWidenedHandleType(AtsTypeRef? typeRef)
2619internal static bool IsDictionaryType(AtsTypeRef? typeRef)
2628internal static bool IsListType(AtsTypeRef? typeRef)
2647var typeRefsByTypeId = new Dictionary<string, AtsTypeRef>();
2654var targetTypeRef = cap.TargetType;
2680foreach (var expandedType in expandedTypes)
2726var typeRef = typeRefsByTypeId.GetValueOrDefault(typeId);
2760var typeRef = typeRefsByTypeId.GetValueOrDefault(interfaceTypeId);
2908private static bool IsTypeInHierarchy(AtsTypeRef typeRef, string typeId)
2927internal static Dictionary<string, AtsTypeRef> CollectAllReferencedTypes(IReadOnlyList<AtsCapabilityInfo> capabilities)
2929var typeRefs = new Dictionary<string, AtsTypeRef>();
2931void CollectFromTypeRef(AtsTypeRef? typeRef)
2949foreach (var unionType in typeRef.UnionTypes)
3073internal string? GetPromiseWrapperForReturnType(AtsTypeRef? returnType)
3091internal string GenerateCallbackTypeSignature(IReadOnlyList<AtsCallbackParameterInfo>? callbackParameters, AtsTypeRef? callbackReturnType)
Aspire.Hosting.CodeGeneration.TypeScript.Tests (18)
Aspire.Hosting.RemoteHost (79)
AtsCapabilityScanner.cs (64)
602private static void CollectEnumClrTypes(AtsTypeRef? typeRef, Dictionary<string, Type> enumTypes)
622foreach (var unionType in typeRef.UnionTypes)
686private static void ResolveTypeRef(AtsTypeRef? typeRef, HashSet<string> validTypes)
707foreach (var memberType in typeRef.UnionTypes)
782private static string? FindUnknownType(AtsTypeRef? typeRef)
807foreach (var memberType in typeRef.UnionTypes)
853var targetTypeRef = capability.TargetType ?? new AtsTypeRef
870private static Dictionary<string, List<AtsTypeRef>> BuildTypeCompatibilityMap(
873var typeToCompatibleTypes = new Dictionary<string, List<AtsTypeRef>>();
883var concreteTypeRef = new AtsTypeRef
898foreach (var iface in typeInfo.ImplementedInterfaces)
904foreach (var baseType in typeInfo.BaseTypeHierarchy)
917Dictionary<string, List<AtsTypeRef>> map,
919AtsTypeRef concreteTypeRef)
1096var propTypeRef = isCallback
1113AtsTypeRef? callbackReturnType = null;
1262var typeRef = CreateTypeRef(memberType, enumCollector: null, assemblyExportedTypeCache);
1299AtsTypeRef? typeRef,
1326AtsTypeRef typeRef,
1354var propertyTypeRef = CreateTypeRef(property.PropertyType, enumCollector: null, assemblyExportedTypeCache);
1597AtsTypeRef? propertyTypeRef;
1612var keyTypeRef = CreateTypeRef(propType.GetGenericArguments().First(), enumCollector: null, assemblyExportedTypeCache);
1615var valueTypeRef = propertyUnionAttr != null
1660var getterTypeRef = WithNullability(propertyTypeRef!, propType, propertyNullability.ReadState);
1661var setterTypeRef = WithNullability(propertyTypeRef!, propType, propertyNullability.WriteState);
1664var contextTypeRef = CreateHandleTypeRef(contextType);
1774var instanceContextTypeRef = CreateHandleTypeRef(contextType);
1895var returnTypeRef = CreateTypeRef(method.ReturnType, enumCollector: null, assemblyExportedTypeCache);
2013AtsTypeRef? extendsTypeRef = null;
2069var returnTypeRef = CreateTypeRef(method.ReturnType, enumCollector: null, assemblyExportedTypeCache);
2109var unionTypeRef = CreateUnionTypeRef(unionAttr, $"parameter '{paramName}'", assemblyExportedTypeCache);
2126var typeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2138AtsTypeRef? callbackReturnType = null;
2149var finalTypeRef = isCallback
2170private static (IReadOnlyList<AtsCallbackParameterInfo>? Parameters, AtsTypeRef? ReturnType) ExtractCallbackSignature(
2189var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2203AtsTypeRef? returnTypeRef;
2236private static (IReadOnlyList<AtsCallbackParameterInfo>? Parameters, AtsTypeRef? ReturnType) ExtractWellKnownDelegateSignature(
2253var voidTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive };
2262var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2283var paramTypeRef = CreateTypeRef(paramType, enumCollector: null, assemblyExportedTypeCache);
2295AtsTypeRef returnTypeRef;
2580public static AtsTypeRef? CreateTypeRef(Type? type) =>
2586private static AtsTypeRef CreateVoidTypeRef() => new AtsTypeRef
2592private static AtsTypeRef WithNullability(AtsTypeRef typeRef, Type declaredType, NullabilityState nullabilityState)
2621private static AtsTypeRef? CreateTypeRef(
2675var typeRef = CreateTypeRef(underlyingType, enumCollector, assemblyExportedTypeCache);
2741var keyTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2742var valueTypeRef = CreateTypeRef(genericArgs[1], enumCollector, assemblyExportedTypeCache);
2764var keyTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2765var valueTypeRef = CreateTypeRef(genericArgs[1], enumCollector, assemblyExportedTypeCache);
2787var elementTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2807var elementTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2852var elementTypeRef = CreateTypeRef(elementType, enumCollector, assemblyExportedTypeCache);
2966private static List<AtsTypeRef> CollectAllInterfaces(Type type)
2968var allInterfaces = new List<AtsTypeRef>();
3006private static List<AtsTypeRef> CollectBaseTypeHierarchy(Type type)
3008var baseTypes = new List<AtsTypeRef>();
3037private static AtsTypeRef CreateHandleTypeRef(Type type)
3041AtsTypeRef? baseTypeRef = null;
3288private static AtsTypeRef CreateUnionTypeRef(
3300var unionTypes = new List<AtsTypeRef>();
3303var typeRef = CreateTypeRef(memberType, enumCollector: null, assemblyExportedTypeCache);
Aspire.Hosting.RemoteHost.Tests (5)
Aspire.TypeSystem (17)