90 instantiations of AtsTypeRef
Aspire.Hosting.CodeGeneration.Java.Tests (7)
Aspire.Hosting.CodeGeneration.Python.Tests (8)
Aspire.Hosting.CodeGeneration.TypeScript.Tests (19)
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
2682return new AtsTypeRef { TypeId = primitiveTypeId, ClrType = type, Category = AtsTypeCategory.Primitive };
2688return new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = type, Category = AtsTypeCategory.Primitive };
2693return new AtsTypeRef
2698KeyType = new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive },
2699ValueType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive },
2706return new AtsTypeRef
2711ElementType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive }
2721return new AtsTypeRef
2744return new AtsTypeRef
2767return new AtsTypeRef
2789return new AtsTypeRef
2809return new AtsTypeRef
2854return new AtsTypeRef
2870return new AtsTypeRef
2882return new AtsTypeRef
2892return new AtsTypeRef
2987allInterfaces.Add(new AtsTypeRef
3054return new AtsTypeRef
3313return new AtsTypeRef
Aspire.Hosting.RemoteHost.Tests (19)
253 references to AtsTypeRef
Aspire.Hosting.CodeGeneration.Go (20)
AtsGoCodeGenerator.cs (20)
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,
847private static List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)>
850var result = new List<(string, string, AtsTypeRef, string, string?)>();
885List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)> listDictGetters)
940List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)> listDictGetters)
1165var returnType = capability.ReturnType!;
1205List<(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description)> listDictGetters)
1265var returnType = capability.ReturnType!;
1337var returnType = capability.ReturnType!;
1601(string Field, string MethodName, AtsTypeRef ReturnType, string CapabilityId, string? Description) g)
1619private (string Wrapper, string TypeArgs) ListDictTypeArgs(AtsTypeRef returnType)
1867private string GetUnionAllowedTypes(AtsTypeRef typeRef)
2075private string MapTypeRefToGo(AtsTypeRef? typeRef, bool isOptional)
2113private string MapDtoPropertyTypeToGo(AtsTypeRef? typeRef, bool isOptional)
Aspire.Hosting.CodeGeneration.Java (26)
AtsJavaCodeGenerator.cs (26)
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)
1879private string GenerateCallbackTypeSignature(IReadOnlyList<AtsCallbackParameterInfo>? callbackParameters, AtsTypeRef? callbackReturnType)
2010private string RenderJavaTransportValueConversion(AtsTypeRef? typeRef, string valueExpression, bool isOptional, int depth = 0)
2044private string RenderJavaDtoPropertyTransportValueConversion(AtsTypeRef? typeRef, string valueExpression, bool isOptional, int depth = 0)
2127private string RenderJavaListTransportValueConversion(AtsTypeRef typeRef, string valueExpression, bool allowNull, int depth)
2140private string MapCallbackTypeToJava(AtsTypeRef? typeRef)
2162private static bool IsListOrDictPropertyGetter(AtsTypeRef? returnType)
2174var returnType = capability.ReturnType!;
2360foreach (var expandedType in capability.ExpandedTargetTypes)
2399var exportedBaseType = handleTypeInfo.BaseTypeHierarchy
2437foreach (var targetType in targetTypes)
2480private string MapTypeRefToJava(AtsTypeRef? typeRef, bool isOptional, bool useBoxedTypes = false)
2512private string MapDtoPropertyTypeToJava(AtsTypeRef? typeRef, bool isOptional, bool useBoxedTypes = false)
2534private string MapInputTypeToJava(AtsTypeRef? typeRef, bool isOptional = false)
2596private static bool IsUnionType(AtsTypeRef? typeRef) => typeRef?.Category == AtsTypeCategory.Union;
2605private static void AddHandleTypeIfNeeded(HashSet<string> handleTypeIds, AtsTypeRef? typeRef)
2625private static void AddListOrDictTypeIfNeeded(Dictionary<string, bool> typeIds, AtsTypeRef? typeRef)
Aspire.Hosting.CodeGeneration.Java.Tests (2)
Aspire.Hosting.CodeGeneration.Python (27)
Aspire.Hosting.CodeGeneration.Python.Tests (5)
Aspire.Hosting.CodeGeneration.Rust (15)
Aspire.Hosting.CodeGeneration.TypeScript (43)
TypeScriptApiProjector.cs (37)
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)
1732internal string MapDtoUnionTypeToTypeScript(AtsTypeRef typeRef)
1785internal string MapUnionTypeToTypeScript(AtsTypeRef typeRef)
1845internal string MapInputTypeToTypeScript(AtsTypeRef? typeRef)
1882internal string MapInputUnionTypeToTypeScript(AtsTypeRef typeRef)
1894foreach (var memberRef in typeRef.UnionTypes)
1941internal string? TryMapInterfaceInputTypeToTypeScript(AtsTypeRef typeRef)
1945foreach (var candidateTypeRef in _typeRefsById.Values)
1967internal static bool IsAssignableToInterface(AtsTypeRef candidateTypeRef, string interfaceTypeId)
1974foreach (var implementedInterface in candidateTypeRef.ImplementedInterfaces)
1990internal static bool IsInterfaceHandleType(AtsTypeRef? typeRef)
1999internal static bool IsCancellationTokenType(AtsTypeRef? typeRef) => typeRef?.TypeId == AtsConstants.CancellationToken;
2384internal string GetGetterOnlyPropertyReturnType(AtsTypeRef? typeRef)
2407internal bool TryGetPromiseWrapperType(AtsTypeRef? typeRef, out string promiseInterfaceName, out string promiseImplementationClassName)
2422internal string GetGetterOnlyPropertyMethodReturnType(AtsTypeRef? typeRef)
2449internal bool IsWidenedHandleType(AtsTypeRef? typeRef)
2546internal static bool IsDictionaryType(AtsTypeRef? typeRef)
2555internal static bool IsListType(AtsTypeRef? typeRef)
2574var typeRefsByTypeId = new Dictionary<string, AtsTypeRef>();
2581var targetTypeRef = cap.TargetType;
2607foreach (var expandedType in expandedTypes)
2653var typeRef = typeRefsByTypeId.GetValueOrDefault(typeId);
2687var typeRef = typeRefsByTypeId.GetValueOrDefault(interfaceTypeId);
2835private static bool IsTypeInHierarchy(AtsTypeRef typeRef, string typeId)
2854internal static Dictionary<string, AtsTypeRef> CollectAllReferencedTypes(IReadOnlyList<AtsCapabilityInfo> capabilities)
2856var typeRefs = new Dictionary<string, AtsTypeRef>();
2858void CollectFromTypeRef(AtsTypeRef? typeRef)
2876foreach (var unionType in typeRef.UnionTypes)
3000internal string? GetPromiseWrapperForReturnType(AtsTypeRef? returnType)
3018internal string GenerateCallbackTypeSignature(IReadOnlyList<AtsCallbackParameterInfo>? callbackParameters, AtsTypeRef? callbackReturnType)
Aspire.Hosting.CodeGeneration.TypeScript.Tests (16)
Aspire.Hosting.RemoteHost (78)
AtsCapabilityScanner.cs (63)
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(
2740var keyTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2741var valueTypeRef = CreateTypeRef(genericArgs[1], enumCollector, assemblyExportedTypeCache);
2763var keyTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2764var valueTypeRef = CreateTypeRef(genericArgs[1], enumCollector, assemblyExportedTypeCache);
2786var elementTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2806var elementTypeRef = CreateTypeRef(genericArgs[0], enumCollector, assemblyExportedTypeCache);
2851var elementTypeRef = CreateTypeRef(elementType, enumCollector, assemblyExportedTypeCache);
2965private static List<AtsTypeRef> CollectAllInterfaces(Type type)
2967var allInterfaces = new List<AtsTypeRef>();
3005private static List<AtsTypeRef> CollectBaseTypeHierarchy(Type type)
3007var baseTypes = new List<AtsTypeRef>();
3036private static AtsTypeRef CreateHandleTypeRef(Type type)
3040AtsTypeRef? baseTypeRef = null;
3287private static AtsTypeRef CreateUnionTypeRef(
3299var unionTypes = new List<AtsTypeRef>();
3302var typeRef = CreateTypeRef(memberType, enumCollector: null, assemblyExportedTypeCache);
Aspire.Hosting.RemoteHost.Tests (4)
Aspire.TypeSystem (17)