90 writes to TypeId
Aspire.Hosting.CodeGeneration.Java.Tests (7)
AtsJavaCodeGeneratorTests.cs (7)
606new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = MutableStringDict() }); 621TypeId = "list", 647Type = new AtsTypeRef { TypeId = "KeywordProbe", Category = AtsTypeCategory.Dto } 667new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive }); 698TypeId = "dict", 701KeyType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive }, 702ValueType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive }
Aspire.Hosting.CodeGeneration.Python.Tests (8)
AtsPythonCodeGeneratorTests.cs (8)
390TypeId = "Tests/KeywordResource", 415TypeId = AtsConstants.String, 446TypeId = "Tests/AcronymResource", 471TypeId = AtsConstants.String, 505TypeId = genericBaseType.AssemblyQualifiedName!, 512TypeId = genericInterfaceType.AssemblyQualifiedName!, 520TypeId = "Tests/GenericResource", 545TypeId = AtsConstants.Void,
Aspire.Hosting.CodeGeneration.TypeScript.Tests (19)
AtsTypeScriptCodeGeneratorTests.cs (19)
783TypeId = "test/EmptyUnion", 1264TypeId = $"{resourceType.Assembly.GetName().Name}/{resourceType.FullName}", 1510TypeId = GetAtsTypeId(typeof(TResource)), 1523TypeId = AtsConstants.Void, 1546TypeId = AtsConstants.Void, 2416TypeId = $"{ApiExportPackageName}/PromiseContext", 2421TypeId = AtsConstants.String, 2426TypeId = AtsConstants.Void, 2621TypeId = $"{eventHubsPackage}/AzureEventHubsEmulatorResource", 2629TypeId = $"{serviceBusPackage}/AzureServiceBusEmulatorResource", 2715TypeId = targetTypeId, 2730TypeId = AtsConstants.Void, 2833TypeId = $"Aspire.Hosting/{targetTypeName}", 2848TypeId = "callback", 2863TypeId = AtsConstants.Void, 2870TypeId = AtsConstants.Void, 2897TypeId = AtsConstants.String, 2906TypeId = AtsConstants.Number, 2914TypeId = AtsConstants.Void,
Aspire.Hosting.RemoteHost (37)
Ats\AtsMarshaller.cs (1)
402TypeId = AtsTypeMapping.DeriveTypeId(type),
AtsCapabilityScanner.cs (34)
855TypeId = originalTarget, 885TypeId = typeInfo.AtsTypeId, 1097? new AtsTypeRef { TypeId = "callback", ClrType = prop.PropertyType, Category = AtsTypeCategory.Callback } 1617: new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive }; 1621TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 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 }; 2588TypeId = AtsConstants.Void, 2603TypeId = typeRef.TypeId, 2682return new AtsTypeRef { TypeId = primitiveTypeId, ClrType = type, Category = AtsTypeCategory.Primitive }; 2688return new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = type, Category = AtsTypeCategory.Primitive }; 2695TypeId = AtsConstants.DictTypeId(AtsConstants.String, AtsConstants.Any), 2698KeyType = new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive }, 2699ValueType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive }, 2708TypeId = AtsConstants.ListTypeId(AtsConstants.Any), 2711ElementType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive } 2723TypeId = AtsConstants.EnumTypeId(type.FullName ?? type.Name), 2746TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2769TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2791TypeId = AtsConstants.ListTypeId(elementTypeRef.TypeId), 2811TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 2856TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 2872TypeId = AtsTypeMapping.DeriveTypeId(type), 2884TypeId = AtsTypeMapping.DeriveTypeId(type), 2894TypeId = AtsTypeMapping.DeriveTypeId(type), 2989TypeId = ifaceTypeId, 3056TypeId = typeId, 3315TypeId = string.Join("|", unionTypes.Select(u => u.TypeId)),
AtsContextFilter.cs (2)
324TypeId = targetTypeId, 343TypeId = AtsConstants.Void,
Aspire.Hosting.RemoteHost.Tests (19)
AtsContextFilterTests.cs (17)
191TypeId = "Aspire.TypeSystem/AtsContext", 198TypeId = "Aspire.Hosting/Aspire.Hosting.DistributedApplication", 204TypeId = referencedHandleType.AtsTypeId, 276TypeId = foreignEnum.TypeId, 285Type = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }, 294TypeId = foreignCallbackEnum.TypeId, 434TypeId = AtsConstants.EnumTypeId(typeof(TestMode).FullName!), 487TypeId = exportedValueOnlyEnumType.TypeId, 507TypeId = selectedHandleType.AtsTypeId, 517TypeId = referencedCoreDtoType.TypeId, 527TypeId = referencedCoreEnumType.TypeId, 535TypeId = referencedCoreHandleType.AtsTypeId, 543TypeId = selectedHandleType.AtsTypeId, 560TypeId = unrelatedCoreHandleType.AtsTypeId, 578TypeId = "System/String", 591TypeId = exportedValueOnlyDtoType.TypeId, 604TypeId = "System/String",
AtsMarshallerTests.cs (2)
224TypeId = AtsConstants.CancellationToken, 886var typeRef = new AtsTypeRef { TypeId = "test/SelfReferencingDto", Category = AtsTypeCategory.Dto };
362 references to TypeId
Aspire.Hosting.CodeGeneration.Go (27)
AtsGoCodeGenerator.cs (27)
184if (!string.IsNullOrEmpty(expanded.TypeId)) 186expansionTargetIds.Add(expanded.TypeId); 315if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId 316|| IsCancellationTokenTypeId(typeRef.TypeId)) 322set.Add(typeRef.TypeId); 432if (string.IsNullOrEmpty(targetType.TypeId)) 438if (!_implNames.ContainsKey(targetType.TypeId)) 442if (!result.TryGetValue(targetType.TypeId, out var list)) 445result[targetType.TypeId] = list; 695AtsTypeCategory.Dto when value is JsonObject obj && dtoTypesById.TryGetValue(typeRef.TypeId, out var dtoInfo) 1090sb.Append(MapDtoType(directOptionsParam.Type!.TypeId)); 1136&& p.CallbackReturnType.TypeId != AtsConstants.Void; 1153var hasReturn = capability.ReturnType is not null && capability.ReturnType.TypeId != AtsConstants.Void; 1170if (IsSameType(returnType.TypeId, capability, currentTypeId)) 1266var isFluent = IsSameType(returnType.TypeId, capability, currentTypeId); 1280var childImplName = returnType.TypeId is not null && _implNames.TryGetValue(returnType.TypeId, out var implTarget) 1450var dtoType = MapDtoType(directOptionsParam.Type!.TypeId); 1541&& p.CallbackReturnType.TypeId != AtsConstants.Void; 1892var hasReturn = capability.ReturnType is not null && capability.ReturnType.TypeId != AtsConstants.Void; 2082if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 2089AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId), 2090AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 2091AtsTypeCategory.Handle => MapHandleType(typeRef.TypeId), 2092AtsTypeCategory.Dto => "*" + MapDtoType(typeRef.TypeId), 2120if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 2191IsCancellationTokenTypeId(parameter.Type?.TypeId);
Aspire.Hosting.CodeGeneration.Go.Tests (2)
AtsGoCodeGeneratorTests.cs (2)
101Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 219.Any(i => i.TypeId.Contains("IResourceWithEnvironment"));
Aspire.Hosting.CodeGeneration.Java (39)
AtsJavaCodeGenerator.cs (39)
865AtsTypeCategory.Dto when value is JsonObject obj && dtoTypesById.TryGetValue(typeRef.TypeId, out var dtoInfo) 998if (!string.Equals(left.Type?.TypeId, right.Type?.TypeId, StringComparison.Ordinal)) 1022if (!string.Equals(leftCallbackParameters[i].Type.TypeId, rightCallbackParameters[i].Type.TypeId, StringComparison.Ordinal)) 1028return string.Equals(left.CallbackReturnType?.TypeId, right.CallbackReturnType?.TypeId, StringComparison.Ordinal); 1866var returnsDifferentBuilder = capability.ReturnType?.TypeId is { } returnTypeId && 1871? new(MapHandleType(capability.ReturnType!.TypeId!), HasReturn: true, ReturnsCurrentBuilder: false) 1875var hasReturn = capability.ReturnType?.TypeId != AtsConstants.Void; 1887var hasReturnType = callbackReturnType != null && callbackReturnType.TypeId != AtsConstants.Void; 1921var hasReturnType = callbackParam.CallbackReturnType != null && callbackParam.CallbackReturnType.TypeId != AtsConstants.Void; 1967var hasReturnType = property.CallbackReturnType != null && property.CallbackReturnType.TypeId != AtsConstants.Void; 1997if (callbackParameter.Type?.TypeId == AtsConstants.CancellationToken) 2017if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 2022if (IsCancellationTokenTypeId(typeRef.TypeId)) 2030AtsTypeCategory.Primitive => RenderJavaPrimitiveTransportValueConversion(typeRef.TypeId, valueExpression, allowNull), 2031AtsTypeCategory.Enum => RenderJavaEnumTransportValueConversion(typeRef.TypeId, valueExpression, allowNull), 2032AtsTypeCategory.Dto => RenderJavaDtoTransportValueConversion(typeRef.TypeId, valueExpression, allowNull), 2147if (typeRef.TypeId == AtsConstants.CancellationToken) 2400.FirstOrDefault(baseType => !string.Equals(baseType.TypeId, typeId, StringComparison.Ordinal) 2401&& _classNames.ContainsKey(baseType.TypeId)); 2405baseClassName = _classNames[exportedBaseType.TypeId]; 2439if (targetType.TypeId is null) 2444if (!result.TryGetValue(targetType.TypeId, out var list)) 2447result[targetType.TypeId] = list; 2487if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 2494AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId, isOptional || useBoxedTypes), 2495AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 2496AtsTypeCategory.Handle => MapHandleType(typeRef.TypeId), 2497AtsTypeCategory.Dto => MapDtoType(typeRef.TypeId), 2519if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 2541if (IsCancellationTokenTypeId(typeRef.TypeId)) 2599IsCancellationTokenTypeId(parameter.Type?.TypeId); 2613if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId 2614|| IsCancellationTokenTypeId(typeRef.TypeId)) 2621handleTypeIds.Add(typeRef.TypeId); 2636typeIds[typeRef.TypeId] = false; // false = List 2643typeIds[typeRef.TypeId] = true; // true = Dict
Aspire.Hosting.CodeGeneration.Java.Tests (2)
AtsJavaCodeGeneratorTests.cs (2)
131Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 273.Any(i => i.TypeId.Contains("IResourceWithEnvironment"));
Aspire.Hosting.CodeGeneration.Python (49)
AtsPythonCodeGenerator.cs (49)
169if (capabilityTargetType.TypeId == builderTargetType.TypeId) 179if (capabilityTargetType.TypeId == currentBase.TypeId) 187if (currentBase.ImplementedInterfaces.Any(i => i.TypeId == capabilityTargetType.TypeId)) 211if (_wrapperClassNames.TryGetValue(typeRef.TypeId, out var wrapperClassName)) 218AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId), 219AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 220AtsTypeCategory.Handle => GetWrapperOrHandleName(typeRef.TypeId), 221AtsTypeCategory.Dto => GetDtoClassName(typeRef.TypeId), 242return typeRef.TypeId is AtsConstants.Void or AtsConstants.Any or AtsConstants.CancellationToken 273if (param.Type?.TypeId == AtsConstants.CancellationToken) 286if (param.Type?.TypeId == AtsConstants.CancellationToken) 435filtered = filtered.Where(p => p.Type?.TypeId != AtsConstants.CancellationToken); 447if (param.Type?.TypeId == AtsConstants.CancellationToken) 605if (param.Type?.TypeId == AtsConstants.CancellationToken) 630private static string? GetReturnTypeId(AtsCapabilityInfo capability) => capability.ReturnType?.TypeId; 728if (IsHandleType(cap.ReturnType) && !dtoTypeIds.Contains(cap.ReturnType!.TypeId)) 735if (IsHandleType(param.Type) && !dtoTypeIds.Contains(param.Type!.TypeId)) 737typeIds.Add(param.Type!.TypeId); 744if (IsHandleType(cbParam.Type) && !dtoTypeIds.Contains(cbParam.Type.TypeId)) 746typeIds.Add(cbParam.Type.TypeId); 926AtsTypeCategory.Dto when value is JsonObject obj && dtoTypesById.TryGetValue(typeRef.TypeId, out var dtoInfo) 1286var returnsSelf = isDistributedApplicationBuilder && capability.ReturnType?.TypeId == capability.TargetTypeId; 1389.Select(i => i.TypeId), 1392.Where(i => !transitivelyImplemented.Contains(i.TypeId)) 1394baseClass = string.Join(", ", implementedInterfaces.Select(i => DeriveClassName(i.TypeId))); 1454baseTypeInterfaces = baseType.ImplementedInterfaces.Select(i => i.TypeId).ToList(); 1463var implementedInterfaces = builder.TargetType?.ImplementedInterfaces.Where(i => !baseTypeInterfaces.Contains(i.TypeId)).ToList(); 1470.Select(i => i.TypeId), 1473.Where(i => !transitivelyImplemented.Contains(i.TypeId)) 1590var returnsBuilder = capability.ReturnsBuilder && capability.ReturnType!.TypeId == capability.TargetTypeId; 1591var returnsChildBuilder = capability.ReturnsBuilder && capability.ReturnType != null && IsHandleType(capability.ReturnType) && capability.ReturnType.TypeId != capability.TargetTypeId; 1868if (!capabilitiesByTypeId.TryGetValue(expandedType.TypeId, out var list)) 1871capabilitiesByTypeId[expandedType.TypeId] = list; 1872typeRefsByTypeId[expandedType.TypeId] = expandedType; 1968.Select(i => i.TypeId) 2095if (!string.IsNullOrEmpty(typeRef.TypeId) && typeRef.Category == AtsTypeCategory.Handle) 2097typeRefs.TryAdd(typeRef.TypeId, typeRef); 2099if (!string.IsNullOrEmpty(typeRef.TypeId) && typeRef.Category == AtsTypeCategory.Dict) 2101_moduleBuilder.HandleRegistrations.TryAdd(typeRef.TypeId, "AspireDict"); 2103if (!string.IsNullOrEmpty(typeRef.TypeId) && typeRef.Category == AtsTypeCategory.List) 2105_moduleBuilder.HandleRegistrations.TryAdd(typeRef.TypeId, "AspireList"); 2184return DeriveClassName(typeRef.TypeId); 2353var tickIndex = typeRef.TypeId.IndexOf('`'); 2356return typeRef.TypeId[..tickIndex] + "T"; 2359return typeRef.TypeId + "T"; 2362return typeRef.TypeId;
Aspire.Hosting.CodeGeneration.Python.Tests (10)
AtsPythonCodeGeneratorTests.cs (10)
99Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 217.Any(i => i.TypeId.Contains("IResourceWithEnvironment")); 421TargetTypeId = resourceType.TypeId, 433AtsTypeId = resourceType.TypeId, 477TargetTypeId = resourceType.TypeId, 489AtsTypeId = resourceType.TypeId, 548TargetTypeId = resourceType.TypeId, 559AtsTypeId = resourceType.TypeId, 566AtsTypeId = genericBaseTypeRef.TypeId, 571AtsTypeId = genericInterfaceTypeRef.TypeId,
Aspire.Hosting.CodeGeneration.Rust (30)
AtsRustCodeGenerator.cs (30)
375if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId 376|| IsCancellationTokenTypeId(typeRef.TypeId)) 386AtsTypeCategory.Dto => !dtoTypesById.TryGetValue(typeRef.TypeId, out var dto) 472var hasReturn = capability.ReturnType.TypeId != AtsConstants.Void; 605var wrappedType = MapHandleType(returnTypeRef.TypeId); 609else if (returnTypeRef?.TypeId == AtsConstants.CancellationToken) 858if (targetType.TypeId is null) 863if (!result.TryGetValue(targetType.TypeId, out var list)) 866result[targetType.TypeId] = list; 905if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 912AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId), 913AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 914AtsTypeCategory.Handle => MapHandleType(typeRef.TypeId), 915AtsTypeCategory.Dto => MapDtoType(typeRef.TypeId), 943if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 950AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId), 951AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 954AtsTypeCategory.Dto => MapDtoType(typeRef.TypeId), 983if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 990AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId), 991AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 992AtsTypeCategory.Dto => MapDtoType(typeRef.TypeId), 1035var baseType = typeRef.TypeId switch 1059&& typeRef.TypeId != AtsConstants.ReferenceExpressionTypeId 1060&& !IsCancellationTokenTypeId(typeRef.TypeId); 1074IsCancellationTokenTypeId(parameter.Type?.TypeId); 1088if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId 1089|| IsCancellationTokenTypeId(typeRef.TypeId)) 1096handleTypeIds.Add(typeRef.TypeId); 1111typeIds.Add(typeRef.TypeId);
Aspire.Hosting.CodeGeneration.Rust.Tests (2)
AtsRustCodeGeneratorTests.cs (2)
100Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 218.Any(i => i.TypeId.Contains("IResourceWithEnvironment"));
Aspire.Hosting.CodeGeneration.TypeScript (100)
AtsTypeScriptCodeGenerator.cs (46)
133capability.ReturnType.TypeId == AtsConstants.Void ? null : capability.Documentation?.Returns, 134suppressReturns: capability.ReturnType.TypeId == AtsConstants.Void, 374!_projector.DtoTypesById.TryGetValue(typeRef.TypeId, out var dtoType)) 389!_projector.DtoTypesById.TryGetValue(typeRef.TypeId, out var dtoType)) 395if (!visitedDtoTypeIds.Add(typeRef.TypeId)) 406visitedDtoTypeIds.Remove(typeRef.TypeId); 417private static string? GetReturnTypeId(AtsCapabilityInfo capability) => capability.ReturnType?.TypeId; 911var isVoid = capability.ReturnType == null || capability.ReturnType.TypeId == AtsConstants.Void; 914if (capability.ReturnType != null && _projector.TypesWithPromiseWrappers.Contains(capability.ReturnType.TypeId)) 916WriteLine($" {signature.MethodName}({signature.ParameterList}): {_projector.GetPublicPromiseInterfaceName(capability.ReturnType.TypeId)};"); 1102if (capability.ReturnsBuilder && capability.ReturnType?.TypeId != null && 1103!string.Equals(capability.ReturnType.TypeId, builder.TypeId, StringComparison.Ordinal) && 1104!string.Equals(capability.ReturnType.TypeId, capability.TargetTypeId, StringComparison.Ordinal)) 1106returnTypeId = capability.ReturnType.TypeId; 1122var wrappedReturnTypeId = capability.ReturnType!.TypeId; 1188if (capability.ReturnType?.TypeId == AtsConstants.CancellationToken) 1429if (param.Type is not { TypeId: var dtoTypeId }) 1499if (!visitedDtoTypeIds.Add(dtoProperty.Type.TypeId)) 1515visitedDtoTypeIds.Remove(dtoProperty.Type.TypeId); 1663if (capability.ReturnsBuilder && capability.ReturnType?.TypeId != null && 1664!string.Equals(capability.ReturnType.TypeId, builder.TypeId, StringComparison.Ordinal) && 1665!string.Equals(capability.ReturnType.TypeId, capability.TargetTypeId, StringComparison.Ordinal)) 1667var returnClass = _projector.WrapperClassNames.GetValueOrDefault(capability.ReturnType.TypeId) 1668?? TypeScriptApiProjector.DeriveClassName(capability.ReturnType.TypeId); 1817else if (capability.ReturnType?.TypeId == AtsConstants.CancellationToken) 1895&& callbackParam.CallbackReturnType.TypeId != AtsConstants.Void; 1930var cbTypeId = callbackParameter.Type.TypeId; 2269if (getter.ReturnType?.TypeId != null && _projector.WrapperClassNames.TryGetValue(getter.ReturnType.TypeId, out var wrapperClassName)) 2283if (getter.ReturnType?.TypeId == AtsConstants.CancellationToken) 2336if (getter.ReturnType?.TypeId != null && _projector.WrapperClassNames.TryGetValue(getter.ReturnType.TypeId, out var wrapperClassName)) 2363if (getter.ReturnType?.TypeId == AtsConstants.CancellationToken) 2384var handleType = _projector.GetConcreteHandleTypeName(getter.ReturnType!.TypeId); 2438var handleType = _projector.GetConcreteHandleTypeName(getter.ReturnType!.TypeId); 2661var returnTypeId = method.ReturnType!.TypeId; 2712else if (method.ReturnType?.TypeId == AtsConstants.CancellationToken) 2774var returnTypeId = capability.ReturnType!.TypeId; 2900var isVoid = capability.ReturnType == null || capability.ReturnType.TypeId == AtsConstants.Void; 2905var returnWrapperClass = _projector.WrapperClassNames.GetValueOrDefault(capability.ReturnType!.TypeId) 2906?? TypeScriptApiProjector.DeriveClassName(capability.ReturnType.TypeId); 2909var returnHandleType = _projector.GetConcreteHandleTypeName(capability.ReturnType.TypeId); 3042if (capability.ReturnType?.TypeId == AtsConstants.CancellationToken) 3152var isVoid = capability.ReturnType == null || capability.ReturnType.TypeId == AtsConstants.Void; 3157_projector.WrapperClassNames.GetValueOrDefault(capability.ReturnType!.TypeId) 3158?? TypeScriptApiProjector.DeriveClassName(capability.ReturnType.TypeId));
TypeScriptApiProjector.cs (54)
134.DistinctBy(typeRef => typeRef.TypeId, StringComparer.Ordinal) 135.GroupBy(typeRef => DeriveClassName(typeRef.TypeId), StringComparer.Ordinal) 222_typesWithPromiseWrappers.Add(alias.TypeId); 223_wrapperClassNames[alias.TypeId] = builder.BuilderClassName; 224_concreteTypeIds[alias.TypeId] = builder.TypeId; 225_typeRefsById[alias.TypeId] = builder.TargetType ?? alias; 407return capability.ReturnType is { TypeId: { } returnTypeId } 419if (capability.ReturnType is { } returnType && _typesWithPromiseWrappers.Contains(returnType.TypeId)) 421return GetPublicPromiseInterfaceName(returnType.TypeId); 424if (capability.ReturnType is null || capability.ReturnType.TypeId == AtsConstants.Void) 773AtsTypeCategory.Dto when value is JsonObject obj && _dtoTypesById.TryGetValue(typeRef.TypeId, out var dtoInfo) 1307var returnTypeId = capability.ReturnType?.TypeId; 1659if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 1664if (typeRef.TypeId == InputTypeTypeId) 1669if (typeRef.TypeId == InteractionInputTypeId) 1674if (typeRef.TypeId == InteractionInputCollectionTypeId) 1680if (_wrapperClassNames.TryGetValue(typeRef.TypeId, out var wrapperClassName)) 1687AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId), 1688AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 1689AtsTypeCategory.Handle => GetWrapperOrHandleName(typeRef.TypeId), 1690AtsTypeCategory.Dto => GetDtoInterfaceName(typeRef.TypeId), 1711return typeRef.TypeId is AtsConstants.Void or AtsConstants.Any or AtsConstants.CancellationToken 1863if (IsHandleType(typeRef) && _wrapperClassNames.TryGetValue(typeRef!.TypeId, out var className)) 1869if (typeRef?.TypeId == InteractionInputCollectionTypeId) 1947if (!IsAssignableToInterface(candidateTypeRef, typeRef.TypeId) || 1948!_wrapperClassNames.TryGetValue(candidateTypeRef.TypeId, out var wrapperClassName)) 1969if (string.Equals(candidateTypeRef.TypeId, interfaceTypeId, StringComparison.Ordinal)) 1999internal static bool IsCancellationTokenType(AtsTypeRef? typeRef) => typeRef?.TypeId == AtsConstants.CancellationToken; 2250var aTypeId = a.Type?.TypeId; 2251var bTypeId = b.Type?.TypeId; 2275if (!string.Equals(aCallbackParams[i].Type.TypeId, bCallbackParams[i].Type.TypeId, StringComparison.Ordinal)) 2282var aReturnTypeId = a.CallbackReturnType?.TypeId; 2283var bReturnTypeId = b.CallbackReturnType?.TypeId; 2409if (typeRef?.TypeId is { } typeId && _typesWithPromiseWrappers.Contains(typeId)) 2434if (capability.ReturnsBuilder && capability.ReturnType?.TypeId != null && 2435!string.Equals(capability.ReturnType.TypeId, builder.TypeId, StringComparison.Ordinal) && 2436!string.Equals(capability.ReturnType.TypeId, capability.TargetTypeId, StringComparison.Ordinal)) 2438return GetPublicPromiseInterfaceName(capability.ReturnType.TypeId); 2464if (IsHandleType(typeRef) && _wrapperClassNames.ContainsKey(typeRef.TypeId)) 2469if (typeRef.TypeId == InteractionInputCollectionTypeId) 2609if (!capabilitiesByTypeId.TryGetValue(expandedType.TypeId, out var list)) 2612capabilitiesByTypeId[expandedType.TypeId] = list; 2614typeRefsByTypeId[expandedType.TypeId] = expandedType; 2831return IsTypeInHierarchy(retainedType, candidateType.TypeId) || 2832IsTypeInHierarchy(candidateType, retainedType.TypeId); 2838string.Equals(interfaceType.TypeId, typeId, StringComparison.Ordinal) || 2845(string.Equals(baseType.TypeId, typeId, StringComparison.Ordinal) || 2865if (!string.IsNullOrEmpty(typeRef.TypeId) && typeRef.Category == AtsTypeCategory.Handle) 2867typeRefs.TryAdd(typeRef.TypeId, typeRef); 3008if (_typesWithPromiseWrappers.Contains(returnType.TypeId)) 3010var className = _wrapperClassNames.GetValueOrDefault(returnType.TypeId) 3011?? DeriveClassName(returnType.TypeId); 3034var returnType = callbackReturnType == null || callbackReturnType.TypeId == AtsConstants.Void
Aspire.Hosting.CodeGeneration.TypeScript.Tests (40)
AtsTypeScriptCodeGeneratorTests.cs (40)
160Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 306Assert.Equal("string", nameGetterCapability.ReturnType?.TypeId); 316Assert.Equal("Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestCallbackContext", nameSetterCapability.ReturnType?.TypeId); // Returns context for fluent chaining 324Assert.Equal("number", valueGetterCapability.ReturnType?.TypeId); 407t.TypeId == "Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestRedisResource"); 544Assert.Contains(withBrowserLogs.Parameters, p => p.Name == "browser" && p.Type?.TypeId == "string" && p.IsOptional); 545Assert.Contains(withBrowserLogs.Parameters, p => p.Name == "profile" && p.Type?.TypeId == "string" && p.IsOptional); 559c.ExpandedTargetTypes.Any(t => t.TypeId.Contains("ContainerResource"))) 564TargetType = c.TargetType != null ? new { c.TargetType.TypeId, c.TargetType.IsInterface } : null, 566.Where(t => t.TypeId.Contains("ContainerResource")) 567.Select(t => new { t.TypeId, t.IsInterface }) 607if (expandedType.TypeId.Contains("ContainerResource")) 610$"Capability '{cap.CapabilityId}' ExpandedTargetType '{expandedType.TypeId}' has IsInterface = true"); 633Assert.Equal("Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource", withBindMount.TargetType.TypeId); 662Assert.Contains("IResourceWithConnectionString", withConnectionStringDirect.TargetType.TypeId); 670.FirstOrDefault(t => t.TypeId.Contains("TestRedisResource")); 690Assert.Contains("TestRedisResource", withRedisSpecific.TargetType.TypeId); 698.FirstOrDefault(t => t.TypeId.Contains("TestRedisResource")); 716Assert.Contains("ContainerResource", withBindMount.TargetType.TypeId); 724.FirstOrDefault(t => t.TypeId.Contains("ContainerResource") && !t.TypeId.Contains("IContainer")); 841$"Expanded type '{expandedType.TypeId}' should be a concrete type, not an interface"); 865Assert.Contains("IResourceWithEnvironment", testWithEnvironmentCallback.TargetType.TypeId); 874.FirstOrDefault(t => t.TypeId.Contains("TestRedisResource")); 990.Any(i => i.TypeId.Contains("IResourceWithEnvironment")); 1102.ReturnType!.TypeId; 1625Assert.Equal(expectedTypes.Select(GetAtsTypeId), parameter.CallbackParameters.Select(p => p.Type?.TypeId)); 1635Assert.Equal(GetAtsTypeId(parameterType), parameter.Type?.TypeId); 1775Assert.Equal("any", valueParam.Type.TypeId); 1922Assert.Equal(AtsConstants.CancellationToken, ctParam.Type.TypeId); 1957Assert.Equal(AtsConstants.CancellationToken, operationParam.CallbackParameters[0].Type?.TypeId); 1976Assert.Equal(AtsConstants.TimeSpan, timeoutParam.Type?.TypeId); 1980Assert.Equal(AtsConstants.CancellationToken, ctParam.Type?.TypeId); 2259var expandedTypeIds = withNpm.ExpandedTargetTypes.Select(t => t.TypeId).ToList(); 2290var expandedTypeIds = capability.ExpandedTargetTypes.Select(t => t.TypeId).ToList(); 2437TargetTypeId = targetType.TypeId, 2449TargetTypeId = targetType.TypeId, 2461TargetTypeId = targetType.TypeId, 2473TargetTypeId = targetType.TypeId, 2873TargetTypeId = targetType.TypeId,
Aspire.Hosting.RemoteHost (40)
Ats\AtsMarshaller.cs (5)
140if (typeRef.TypeId == AtsConstants.CancellationToken && value is CancellationToken cancellationToken) 146if (typeRef.TypeId == TypeSystem.AtsConstants.Any) 153AtsTypeCategory.Handle => _handles.Marshal(value, typeRef.TypeId), 158AtsTypeCategory.List => _handles.Marshal(value, typeRef.TypeId), 159AtsTypeCategory.Dict => _handles.Marshal(value, typeRef.TypeId),
AtsCapabilityScanner.cs (26)
612enumTypes.TryAdd(typeRef.TypeId, typeRef.ClrType); 694if (typeRef.Category == AtsTypeCategory.Unknown && validTypes.Contains(typeRef.TypeId)) 791return typeRef.TypeId; 900AddToCompatibilityMap(typeToCompatibleTypes, iface.TypeId, concreteTypeRef); 906AddToCompatibilityMap(typeToCompatibleTypes, baseType.TypeId, concreteTypeRef); 939.SelectMany(c => c.ExpandedTargetTypes.Select(t => (Target: t.TypeId, Capability: c))) 1011.Where(t => !targetIds.Contains(t.TypeId)) 1312AtsTypeCategory.Primitive => typeRef.TypeId != AtsConstants.CancellationToken && typeRef.TypeId != AtsConstants.Void, 1335if (!visitedDtoTypeIds.Add(typeRef.TypeId)) 1365_ = visitedDtoTypeIds.Remove(typeRef.TypeId); 1621TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 1627propertyTypeId = propertyTypeRef.TypeId; 1640propertyTypeId = propertyTypeRef.TypeId; 1645propertyTypeId = propertyTypeRef.TypeId; 2029var firstParamTypeId = extendsTypeRef?.TypeId ?? MapToAtsTypeId(firstParamType, assemblyExportedTypeCache); 2603TypeId = typeRef.TypeId, 2746TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2769TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2791TypeId = AtsConstants.ListTypeId(elementTypeRef.TypeId), 2811TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 2856TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 3315TypeId = string.Join("|", unionTypes.Select(u => u.TypeId)),
AtsContextFilter.cs (8)
174yield return targetType.TypeId; 179yield return expandedTargetType.TypeId; 393if (typeRef.Category == AtsTypeCategory.Handle && !string.IsNullOrEmpty(typeRef.TypeId)) 395referencedHandleTypes.TryAdd(typeRef.TypeId, typeRef); 425if (handleTypesById.TryGetValue(typeRef.TypeId, out var handleType) && includedHandleTypeIds.Add(handleType.AtsTypeId)) 430if (dtoTypesById.TryGetValue(typeRef.TypeId, out var dtoType) && includedDtoTypeIds.Add(dtoType.TypeId)) 435if (enumTypesById.ContainsKey(typeRef.TypeId)) 437includedEnumTypeIds.Add(typeRef.TypeId);
CodeGeneration\CodeGenerationService.cs (1)
141TypeId = t.TypeId,
Aspire.Hosting.RemoteHost.Tests (21)
AtsCapabilityScannerTests.cs (19)
159Assert.Equal("string[]", itemsType.TypeId); 164Assert.Equal("string[]", enumerableReturnCapability.ReturnType.TypeId); 179Assert.Contains(parameter.Type.UnionTypes!, type => type.TypeId == AtsConstants.String); 310Assert.Contains(resourceParameter.Type!.UnionTypes!, type => type.TypeId == "string"); 311Assert.Contains(resourceParameter.Type.UnionTypes!, type => type.TypeId == "Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource"); 378Assert.Equal(AtsTypeMapping.DeriveTypeId(typeof(HttpCommandExportOptions)), optionsParameter.Type.TypeId); 393Assert.Equal(AtsTypeMapping.DeriveTypeId(typeof(HttpCommandPrepareRequestContext)), callbackParameter.Type.TypeId); 395Assert.Equal(AtsTypeMapping.DeriveTypeId(typeof(HttpCommandRequestExportData)), prepareRequestProperty.CallbackReturnType?.TypeId); 424t => t.TypeId == AtsTypeMapping.DeriveTypeId(typeof(DerivedExportedProperties))); 443Assert.Equal(AtsConstants.String, nameGetter.ReturnType.TypeId); 448Assert.Equal(AtsConstants.String, descriptionGetter.ReturnType.TypeId); 469Assert.Equal(AtsConstants.String, nullableString.Type.TypeId); 474Assert.Equal(AtsConstants.String, requiredString.Type.TypeId); 479Assert.Equal(AtsConstants.Number, nullableNumber.Type.TypeId); 484Assert.Equal(AtsConstants.Number, requiredNumber.Type.TypeId); 503Assert.DoesNotContain(genericCapability.ExpandedTargetTypes, t => t.TypeId == shadowedTypeId); 504Assert.Contains(genericCapability.ExpandedTargetTypes, t => t.TypeId == otherTypeId); 505Assert.Contains(specificCapability.ExpandedTargetTypes, t => t.TypeId == shadowedTypeId); 560Assert.Equal(AtsTypeMapping.DeriveTypeId(typeof(AssemblyLevelExportedTestType)), parameter.Type.TypeId);
AtsContextFilterTests.cs (2)
230Assert.Equal("Aspire.Hosting/Aspire.Hosting.DistributedApplication", supportParameter.Type?.TypeId); 231Assert.Equal(AtsConstants.Void, filteredSupport.ReturnType.TypeId);