140 writes to TypeId
Aspire.Hosting.CodeGeneration.Java.Tests (44)
AtsJavaCodeGeneratorTests.cs (44)
2646new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = MutableStringDict() }); 2661TypeId = "list", 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 }; 2807TypeId = AtsConstants.Number, 2833TypeId = "Tests/ProbeResource", 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 }; 2966TypeId = AtsConstants.Number, 2972TypeId = AtsConstants.Boolean, 2978TypeId = "numberArray", 2984TypeId = "booleanArray", 2990TypeId = "booleanMatrix", 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 }, 3256TypeId = AtsConstants.Void, 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 }); 3627TypeId = "dict", 3630KeyType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive }, 3631ValueType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive }
Aspire.Hosting.CodeGeneration.Python.Tests (19)
AtsPythonCodeGeneratorTests.cs (19)
498TypeId = "Tests/KeywordResource", 523TypeId = AtsConstants.String, 554TypeId = "Tests/AcronymResource", 579TypeId = AtsConstants.String, 613TypeId = genericBaseType.AssemblyQualifiedName!, 620TypeId = genericInterfaceType.AssemblyQualifiedName!, 628TypeId = "Tests/GenericResource", 653TypeId = AtsConstants.Void, 693TypeId = "Tests/NullableUnion", 699TypeId = "Tests/NestedNullableUnion", 705TypeId = AtsConstants.Number, 713TypeId = AtsConstants.String, 748TypeId = "Tests/NullableItems", 752TypeId = AtsConstants.Number, 762TypeId = AtsConstants.Void, 798TypeId = AtsConstants.String, 804TypeId = AtsConstants.Boolean, 810TypeId = "Tests/CollidingAlphaResource", 817TypeId = "Tests/CollidingBetaResource",
Aspire.Hosting.CodeGeneration.TypeScript.Tests (21)
AtsTypeScriptCodeGeneratorTests.cs (21)
784TypeId = AtsConstants.Number, 790TypeId = $"{AtsConstants.Number}[]", 841TypeId = "test/EmptyUnion", 1380TypeId = $"{resourceType.Assembly.GetName().Name}/{resourceType.FullName}", 1626TypeId = GetAtsTypeId(typeof(TResource)), 1639TypeId = AtsConstants.Void, 1662TypeId = AtsConstants.Void, 2565TypeId = $"{ApiExportPackageName}/PromiseContext", 2570TypeId = AtsConstants.String, 2575TypeId = AtsConstants.Void, 2770TypeId = $"{eventHubsPackage}/AzureEventHubsEmulatorResource", 2778TypeId = $"{serviceBusPackage}/AzureServiceBusEmulatorResource", 2864TypeId = targetTypeId, 2879TypeId = AtsConstants.Void, 2982TypeId = $"Aspire.Hosting/{targetTypeName}", 2997TypeId = "callback", 3012TypeId = AtsConstants.Void, 3019TypeId = AtsConstants.Void, 3046TypeId = AtsConstants.String, 3055TypeId = AtsConstants.Number, 3063TypeId = AtsConstants.Void,
Aspire.Hosting.RemoteHost (37)
Ats\AtsMarshaller.cs (1)
443TypeId = 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, 2683return new AtsTypeRef { TypeId = primitiveTypeId, ClrType = type, Category = AtsTypeCategory.Primitive }; 2689return new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = type, Category = AtsTypeCategory.Primitive }; 2696TypeId = AtsConstants.DictTypeId(AtsConstants.String, AtsConstants.Any), 2699KeyType = new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive }, 2700ValueType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive }, 2709TypeId = AtsConstants.ListTypeId(AtsConstants.Any), 2712ElementType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive } 2724TypeId = AtsConstants.EnumTypeId(type.FullName ?? type.Name), 2747TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2770TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2792TypeId = AtsConstants.ListTypeId(elementTypeRef.TypeId), 2812TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 2857TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 2873TypeId = AtsTypeMapping.DeriveTypeId(type), 2885TypeId = AtsTypeMapping.DeriveTypeId(type), 2895TypeId = AtsTypeMapping.DeriveTypeId(type), 2990TypeId = ifaceTypeId, 3057TypeId = typeId, 3316TypeId = 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)
225TypeId = AtsConstants.CancellationToken, 953var typeRef = new AtsTypeRef { TypeId = "test/SelfReferencingDto", Category = AtsTypeCategory.Dto };
385 references to TypeId
Aspire.Hosting.CodeGeneration.Go (31)
AtsGoCodeGenerator.cs (31)
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; 694AtsTypeCategory.Enum => $"{MapEnumType(typeRef.TypeId)}({value.ToRelaxedJsonString()})", 695AtsTypeCategory.Dto when value is JsonObject obj && dtoTypesById.TryGetValue(typeRef.TypeId, out var dtoInfo) 710? MapPrimitiveType(typeRef.TypeId) 711: MapEnumType(typeRef.TypeId); 1101sb.Append(MapDtoType(directOptionsParam.Type!.TypeId)); 1147&& p.CallbackReturnType.TypeId != AtsConstants.Void; 1164var hasReturn = capability.ReturnType is not null && capability.ReturnType.TypeId != AtsConstants.Void; 1181if (IsSameType(returnType.TypeId, capability, currentTypeId)) 1277var isFluent = IsSameType(returnType.TypeId, capability, currentTypeId); 1291var childImplName = returnType.TypeId is not null && _implNames.TryGetValue(returnType.TypeId, out var implTarget) 1466var dtoType = MapDtoType(directOptionsParam.Type!.TypeId); 1557&& p.CallbackReturnType.TypeId != AtsConstants.Void; 1908var hasReturn = capability.ReturnType is not null && capability.ReturnType.TypeId != AtsConstants.Void; 2098if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 2105AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId), 2106AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 2107AtsTypeCategory.Handle => MapHandleType(typeRef.TypeId), 2108AtsTypeCategory.Dto => "*" + MapDtoType(typeRef.TypeId), 2136if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 2166&& typeRef.TypeId is not (AtsConstants.Void or AtsConstants.Any or AtsConstants.CancellationToken); 2212IsCancellationTokenTypeId(parameter.Type?.TypeId);
Aspire.Hosting.CodeGeneration.Go.Tests (2)
AtsGoCodeGeneratorTests.cs (2)
164Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 282.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; 1890var hasReturnType = callbackReturnType != null && callbackReturnType.TypeId != AtsConstants.Void; 1924var hasReturnType = callbackParam.CallbackReturnType != null && callbackParam.CallbackReturnType.TypeId != AtsConstants.Void; 1980var hasReturnType = property.CallbackReturnType != null && property.CallbackReturnType.TypeId != AtsConstants.Void; 2010if (callbackParameter.Type?.TypeId == AtsConstants.CancellationToken) 2030if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 2035if (IsCancellationTokenTypeId(typeRef.TypeId)) 2043AtsTypeCategory.Primitive => RenderJavaPrimitiveTransportValueConversion(typeRef.TypeId, valueExpression, allowNull), 2044AtsTypeCategory.Enum => RenderJavaEnumTransportValueConversion(typeRef.TypeId, valueExpression, allowNull), 2045AtsTypeCategory.Dto => RenderJavaDtoTransportValueConversion(typeRef.TypeId, valueExpression, allowNull), 2209if (typeRef.TypeId == AtsConstants.CancellationToken) 2462.FirstOrDefault(baseType => !string.Equals(baseType.TypeId, typeId, StringComparison.Ordinal) 2463&& _classNames.ContainsKey(baseType.TypeId)); 2467baseClassName = _classNames[exportedBaseType.TypeId]; 2501if (targetType.TypeId is null) 2506if (!result.TryGetValue(targetType.TypeId, out var list)) 2509result[targetType.TypeId] = list; 2549if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 2556AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId, isOptional || useBoxedTypes), 2557AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 2558AtsTypeCategory.Handle => MapHandleType(typeRef.TypeId), 2559AtsTypeCategory.Dto => MapDtoType(typeRef.TypeId), 2581if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 2603if (IsCancellationTokenTypeId(typeRef.TypeId)) 2663IsCancellationTokenTypeId(parameter.Type?.TypeId); 2677if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId 2678|| IsCancellationTokenTypeId(typeRef.TypeId)) 2685handleTypeIds.Add(typeRef.TypeId); 2700typeIds[typeRef.TypeId] = false; // false = List 2707typeIds[typeRef.TypeId] = true; // true = Dict
Aspire.Hosting.CodeGeneration.Java.Tests (13)
AtsJavaCodeGeneratorTests.cs (13)
132Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 274.Any(i => i.TypeId.Contains("IResourceWithEnvironment")); 2741TargetTypeId = resourceType.TypeId, 2773TargetTypeId = resourceType.TypeId, 2815TargetTypeId = resourceType.TypeId, 3012TargetTypeId = resourceType.TypeId, 3026HandleTypes = [new AtsTypeInfo { AtsTypeId = resourceType.TypeId! }], 3229TypeId = contextType.TypeId!, 3329TargetTypeId = resourceType.TypeId, 3338HandleTypes = [new AtsTypeInfo { AtsTypeId = resourceType.TypeId! }], 3344TypeId = contextType.TypeId!, 3639HandleTypes = [new AtsTypeInfo { AtsTypeId = resourceType.TypeId! }], 3653TargetTypeId = resourceType.TypeId,
Aspire.Hosting.CodeGeneration.Python (51)
AtsPythonCodeGenerator.cs (51)
173if (capabilityTargetType.TypeId == builderTargetType.TypeId) 183if (capabilityTargetType.TypeId == currentBase.TypeId) 191if (currentBase.ImplementedInterfaces.Any(i => i.TypeId == capabilityTargetType.TypeId)) 215if (_wrapperClassNames.TryGetValue(typeRef.TypeId, out var wrapperClassName)) 222AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId), 223AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 224AtsTypeCategory.Handle => GetWrapperOrHandleName(typeRef.TypeId), 225AtsTypeCategory.Dto => GetDtoClassName(typeRef.TypeId), 247&& typeRef.TypeId is not (AtsConstants.Void or AtsConstants.Any or AtsConstants.CancellationToken); 275if (param.Type?.TypeId == AtsConstants.CancellationToken) 288if (param.Type?.TypeId == AtsConstants.CancellationToken) 305? JsonValue.Create(callbackParameter.Type.TypeId)!.ToJsonString() 454filtered = filtered.Where(p => p.Type?.TypeId != AtsConstants.CancellationToken); 466if (param.Type?.TypeId == AtsConstants.CancellationToken) 528if (typeRef.Category == AtsTypeCategory.Primitive && typeRef.TypeId == AtsConstants.Void) 661if (param.Type?.TypeId == AtsConstants.CancellationToken) 686private static string? GetReturnTypeId(AtsCapabilityInfo capability) => capability.ReturnType?.TypeId; 803if (IsHandleType(cap.ReturnType) && !dtoTypeIds.Contains(cap.ReturnType!.TypeId)) 810if (IsHandleType(param.Type) && !dtoTypeIds.Contains(param.Type!.TypeId)) 812typeIds.Add(param.Type!.TypeId); 819if (IsHandleType(cbParam.Type) && !dtoTypeIds.Contains(cbParam.Type.TypeId)) 821typeIds.Add(cbParam.Type.TypeId); 1001AtsTypeCategory.Dto when value is JsonObject obj && dtoTypesById.TryGetValue(typeRef.TypeId, out var dtoInfo) 1361var returnsSelf = isDistributedApplicationBuilder && capability.ReturnType?.TypeId == capability.TargetTypeId; 1465.Select(i => i.TypeId), 1468.Where(i => !transitivelyImplemented.Contains(i.TypeId)) 1470baseClass = string.Join(", ", implementedInterfaces.Select(i => DeriveClassName(i.TypeId))); 1530baseTypeInterfaces = baseType.ImplementedInterfaces.Select(i => i.TypeId).ToList(); 1539var implementedInterfaces = builder.TargetType?.ImplementedInterfaces.Where(i => !baseTypeInterfaces.Contains(i.TypeId)).ToList(); 1546.Select(i => i.TypeId), 1549.Where(i => !transitivelyImplemented.Contains(i.TypeId)) 1666var returnsBuilder = capability.ReturnsBuilder && capability.ReturnType!.TypeId == capability.TargetTypeId; 1667var returnsChildBuilder = capability.ReturnsBuilder && capability.ReturnType != null && IsHandleType(capability.ReturnType) && capability.ReturnType.TypeId != capability.TargetTypeId; 1947if (!capabilitiesByTypeId.TryGetValue(expandedType.TypeId, out var list)) 1950capabilitiesByTypeId[expandedType.TypeId] = list; 1951typeRefsByTypeId[expandedType.TypeId] = expandedType; 2047.Select(i => i.TypeId) 2174if (!string.IsNullOrEmpty(typeRef.TypeId) && typeRef.Category == AtsTypeCategory.Handle) 2176typeRefs.TryAdd(typeRef.TypeId, typeRef); 2178if (!string.IsNullOrEmpty(typeRef.TypeId) && typeRef.Category == AtsTypeCategory.Dict) 2180_moduleBuilder.HandleRegistrations.TryAdd(typeRef.TypeId, "AspireDict"); 2182if (!string.IsNullOrEmpty(typeRef.TypeId) && typeRef.Category == AtsTypeCategory.List) 2184_moduleBuilder.HandleRegistrations.TryAdd(typeRef.TypeId, "AspireList"); 2263return DeriveClassName(typeRef.TypeId); 2432var tickIndex = typeRef.TypeId.IndexOf('`'); 2435return typeRef.TypeId[..tickIndex] + "T"; 2438return typeRef.TypeId + "T"; 2441return typeRef.TypeId;
Aspire.Hosting.CodeGeneration.Python.Tests (14)
AtsPythonCodeGeneratorTests.cs (14)
101Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 219.Any(i => i.TypeId.Contains("IResourceWithEnvironment")); 529TargetTypeId = resourceType.TypeId, 541AtsTypeId = resourceType.TypeId, 585TargetTypeId = resourceType.TypeId, 597AtsTypeId = resourceType.TypeId, 656TargetTypeId = resourceType.TypeId, 667AtsTypeId = resourceType.TypeId, 674AtsTypeId = genericBaseTypeRef.TypeId, 679AtsTypeId = genericInterfaceTypeRef.TypeId, 840TargetTypeId = projectType.TypeId, 861TargetTypeId = containerType.TypeId, 873AtsTypeId = projectType.TypeId, 878AtsTypeId = containerType.TypeId,
Aspire.Hosting.CodeGeneration.Rust (31)
AtsRustCodeGenerator.cs (31)
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), 1037var baseType = typeRef.TypeId switch 1062&& typeRef.TypeId is not (AtsConstants.Void or AtsConstants.Any or AtsConstants.CancellationToken); 1066&& typeRef.TypeId != AtsConstants.ReferenceExpressionTypeId 1067&& !IsCancellationTokenTypeId(typeRef.TypeId); 1081IsCancellationTokenTypeId(parameter.Type?.TypeId); 1095if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId 1096|| IsCancellationTokenTypeId(typeRef.TypeId)) 1103handleTypeIds.Add(typeRef.TypeId); 1118typeIds.Add(typeRef.TypeId);
Aspire.Hosting.CodeGeneration.Rust.Tests (2)
AtsRustCodeGeneratorTests.cs (2)
160Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 278.Any(i => i.TypeId.Contains("IResourceWithEnvironment"));
Aspire.Hosting.CodeGeneration.TypeScript (100)
AtsTypeScriptCodeGenerator.cs (46)
134capability.ReturnType.TypeId == AtsConstants.Void ? null : capability.Documentation?.Returns, 135suppressReturns: capability.ReturnType.TypeId == AtsConstants.Void, 375!_projector.DtoTypesById.TryGetValue(typeRef.TypeId, out var dtoType)) 390!_projector.DtoTypesById.TryGetValue(typeRef.TypeId, out var dtoType)) 396if (!visitedDtoTypeIds.Add(typeRef.TypeId)) 407visitedDtoTypeIds.Remove(typeRef.TypeId); 418private static string? GetReturnTypeId(AtsCapabilityInfo capability) => capability.ReturnType?.TypeId; 914var isVoid = capability.ReturnType == null || capability.ReturnType.TypeId == AtsConstants.Void; 917if (capability.ReturnType != null && _projector.TypesWithPromiseWrappers.Contains(capability.ReturnType.TypeId)) 919WriteLine($" {signature.MethodName}({signature.ParameterList}): {_projector.GetPublicPromiseInterfaceName(capability.ReturnType.TypeId)};"); 1105if (capability.ReturnsBuilder && capability.ReturnType?.TypeId != null && 1106!string.Equals(capability.ReturnType.TypeId, builder.TypeId, StringComparison.Ordinal) && 1107!string.Equals(capability.ReturnType.TypeId, capability.TargetTypeId, StringComparison.Ordinal)) 1109returnTypeId = capability.ReturnType.TypeId; 1125var wrappedReturnTypeId = capability.ReturnType!.TypeId; 1191if (capability.ReturnType?.TypeId == AtsConstants.CancellationToken) 1432if (param.Type is not { TypeId: var dtoTypeId }) 1502if (!visitedDtoTypeIds.Add(dtoProperty.Type.TypeId)) 1518visitedDtoTypeIds.Remove(dtoProperty.Type.TypeId); 1602if (capability.ReturnsBuilder && capability.ReturnType?.TypeId != null && 1603!string.Equals(capability.ReturnType.TypeId, builder.TypeId, StringComparison.Ordinal) && 1604!string.Equals(capability.ReturnType.TypeId, capability.TargetTypeId, StringComparison.Ordinal)) 1606var returnClass = _projector.WrapperClassNames.GetValueOrDefault(capability.ReturnType.TypeId) 1607?? TypeScriptApiProjector.DeriveClassName(capability.ReturnType.TypeId); 1775else if (capability.ReturnType?.TypeId == AtsConstants.CancellationToken) 1853&& callbackParam.CallbackReturnType.TypeId != AtsConstants.Void; 1888var cbTypeId = callbackParameter.Type.TypeId; 2227if (getter.ReturnType?.TypeId != null && _projector.WrapperClassNames.TryGetValue(getter.ReturnType.TypeId, out var wrapperClassName)) 2241if (getter.ReturnType?.TypeId == AtsConstants.CancellationToken) 2294if (getter.ReturnType?.TypeId != null && _projector.WrapperClassNames.TryGetValue(getter.ReturnType.TypeId, out var wrapperClassName)) 2321if (getter.ReturnType?.TypeId == AtsConstants.CancellationToken) 2342var handleType = _projector.GetConcreteHandleTypeName(getter.ReturnType!.TypeId); 2396var handleType = _projector.GetConcreteHandleTypeName(getter.ReturnType!.TypeId); 2619var returnTypeId = method.ReturnType!.TypeId; 2670else if (method.ReturnType?.TypeId == AtsConstants.CancellationToken) 2732var returnTypeId = capability.ReturnType!.TypeId; 2858var isVoid = capability.ReturnType == null || capability.ReturnType.TypeId == AtsConstants.Void; 2863var returnWrapperClass = _projector.WrapperClassNames.GetValueOrDefault(capability.ReturnType!.TypeId) 2864?? TypeScriptApiProjector.DeriveClassName(capability.ReturnType.TypeId); 2867var returnHandleType = _projector.GetConcreteHandleTypeName(capability.ReturnType.TypeId); 3000if (capability.ReturnType?.TypeId == AtsConstants.CancellationToken) 3065var isVoid = capability.ReturnType == null || capability.ReturnType.TypeId == AtsConstants.Void; 3069_projector.WrapperClassNames.GetValueOrDefault(capability.ReturnType!.TypeId) 3070?? 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 1871if (IsHandleType(typeRef) && _wrapperClassNames.TryGetValue(typeRef!.TypeId, out var className)) 1877if (typeRef?.TypeId == InteractionInputCollectionTypeId) 1955if (!IsAssignableToInterface(candidateTypeRef, typeRef.TypeId) || 1956!_wrapperClassNames.TryGetValue(candidateTypeRef.TypeId, out var wrapperClassName)) 1977if (string.Equals(candidateTypeRef.TypeId, interfaceTypeId, StringComparison.Ordinal)) 2007internal static bool IsCancellationTokenType(AtsTypeRef? typeRef) => typeRef?.TypeId == AtsConstants.CancellationToken; 2323var aTypeId = a.Type?.TypeId; 2324var bTypeId = b.Type?.TypeId; 2348if (!string.Equals(aCallbackParams[i].Type.TypeId, bCallbackParams[i].Type.TypeId, StringComparison.Ordinal)) 2355var aReturnTypeId = a.CallbackReturnType?.TypeId; 2356var bReturnTypeId = b.CallbackReturnType?.TypeId; 2482if (typeRef?.TypeId is { } typeId && _typesWithPromiseWrappers.Contains(typeId)) 2507if (capability.ReturnsBuilder && capability.ReturnType?.TypeId != null && 2508!string.Equals(capability.ReturnType.TypeId, builder.TypeId, StringComparison.Ordinal) && 2509!string.Equals(capability.ReturnType.TypeId, capability.TargetTypeId, StringComparison.Ordinal)) 2511return GetPublicPromiseInterfaceName(capability.ReturnType.TypeId); 2537if (IsHandleType(typeRef) && _wrapperClassNames.ContainsKey(typeRef.TypeId)) 2542if (typeRef.TypeId == InteractionInputCollectionTypeId) 2682if (!capabilitiesByTypeId.TryGetValue(expandedType.TypeId, out var list)) 2685capabilitiesByTypeId[expandedType.TypeId] = list; 2687typeRefsByTypeId[expandedType.TypeId] = expandedType; 2904return IsTypeInHierarchy(retainedType, candidateType.TypeId) || 2905IsTypeInHierarchy(candidateType, retainedType.TypeId); 2911string.Equals(interfaceType.TypeId, typeId, StringComparison.Ordinal) || 2918(string.Equals(baseType.TypeId, typeId, StringComparison.Ordinal) || 2938if (!string.IsNullOrEmpty(typeRef.TypeId) && typeRef.Category == AtsTypeCategory.Handle) 2940typeRefs.TryAdd(typeRef.TypeId, typeRef); 3081if (_typesWithPromiseWrappers.Contains(returnType.TypeId)) 3083var className = _wrapperClassNames.GetValueOrDefault(returnType.TypeId) 3084?? DeriveClassName(returnType.TypeId); 3107var returnType = callbackReturnType == null || callbackReturnType.TypeId == AtsConstants.Void
Aspire.Hosting.CodeGeneration.TypeScript.Tests (40)
AtsTypeScriptCodeGeneratorTests.cs (40)
163Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 309Assert.Equal("string", nameGetterCapability.ReturnType?.TypeId); 319Assert.Equal("Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestCallbackContext", nameSetterCapability.ReturnType?.TypeId); // Returns context for fluent chaining 327Assert.Equal("number", valueGetterCapability.ReturnType?.TypeId); 410t.TypeId == "Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestRedisResource"); 546Assert.Contains(withBrowserLogs.Parameters, p => p.Name == "browser" && p.Type?.TypeId == "string" && p.IsOptional); 547Assert.Contains(withBrowserLogs.Parameters, p => p.Name == "profile" && p.Type?.TypeId == "string" && p.IsOptional); 561c.ExpandedTargetTypes.Any(t => t.TypeId.Contains("ContainerResource"))) 566TargetType = c.TargetType != null ? new { c.TargetType.TypeId, c.TargetType.IsInterface } : null, 568.Where(t => t.TypeId.Contains("ContainerResource")) 569.Select(t => new { t.TypeId, t.IsInterface }) 609if (expandedType.TypeId.Contains("ContainerResource")) 612$"Capability '{cap.CapabilityId}' ExpandedTargetType '{expandedType.TypeId}' has IsInterface = true"); 635Assert.Equal("Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource", withBindMount.TargetType.TypeId); 664Assert.Contains("IResourceWithConnectionString", withConnectionStringDirect.TargetType.TypeId); 672.FirstOrDefault(t => t.TypeId.Contains("TestRedisResource")); 692Assert.Contains("TestRedisResource", withRedisSpecific.TargetType.TypeId); 700.FirstOrDefault(t => t.TypeId.Contains("TestRedisResource")); 718Assert.Contains("ContainerResource", withBindMount.TargetType.TypeId); 726.FirstOrDefault(t => t.TypeId.Contains("ContainerResource") && !t.TypeId.Contains("IContainer")); 899$"Expanded type '{expandedType.TypeId}' should be a concrete type, not an interface"); 923Assert.Contains("IResourceWithEnvironment", testWithEnvironmentCallback.TargetType.TypeId); 932.FirstOrDefault(t => t.TypeId.Contains("TestRedisResource")); 1105.Any(i => i.TypeId.Contains("IResourceWithEnvironment")); 1217.ReturnType!.TypeId; 1741Assert.Equal(expectedTypes.Select(GetAtsTypeId), parameter.CallbackParameters.Select(p => p.Type?.TypeId)); 1751Assert.Equal(GetAtsTypeId(parameterType), parameter.Type?.TypeId); 1891Assert.Equal("any", valueParam.Type.TypeId); 2039Assert.Equal(AtsConstants.CancellationToken, ctParam.Type.TypeId); 2074Assert.Equal(AtsConstants.CancellationToken, operationParam.CallbackParameters[0].Type?.TypeId); 2093Assert.Equal(AtsConstants.TimeSpan, timeoutParam.Type?.TypeId); 2097Assert.Equal(AtsConstants.CancellationToken, ctParam.Type?.TypeId); 2376var expandedTypeIds = withNpm.ExpandedTargetTypes.Select(t => t.TypeId).ToList(); 2407var expandedTypeIds = capability.ExpandedTargetTypes.Select(t => t.TypeId).ToList(); 2586TargetTypeId = targetType.TypeId, 2598TargetTypeId = targetType.TypeId, 2610TargetTypeId = targetType.TypeId, 2622TargetTypeId = targetType.TypeId, 3022TargetTypeId = targetType.TypeId,
Aspire.Hosting.RemoteHost (40)
Ats\AtsMarshaller.cs (5)
144if (typeRef.TypeId == AtsConstants.CancellationToken && value is CancellationToken cancellationToken) 150if (typeRef.TypeId == TypeSystem.AtsConstants.Any) 157AtsTypeCategory.Handle => _handles.Marshal(value, typeRef.TypeId), 162AtsTypeCategory.List => _handles.Marshal(value, typeRef.TypeId), 163AtsTypeCategory.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, 2747TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2770TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2792TypeId = AtsConstants.ListTypeId(elementTypeRef.TypeId), 2812TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 2857TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 3316TypeId = 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 (22)
AtsCapabilityScannerTests.cs (20)
159Assert.Equal("string[]", itemsType.TypeId); 164Assert.Equal("string[]", enumerableReturnCapability.ReturnType.TypeId); 178Assert.Equal(expectedElementTypeId, typeRef.ElementType.TypeId); 193Assert.Contains(parameter.Type.UnionTypes!, type => type.TypeId == AtsConstants.String); 324Assert.Contains(resourceParameter.Type!.UnionTypes!, type => type.TypeId == "string"); 325Assert.Contains(resourceParameter.Type.UnionTypes!, type => type.TypeId == "Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource"); 392Assert.Equal(AtsTypeMapping.DeriveTypeId(typeof(HttpCommandExportOptions)), optionsParameter.Type.TypeId); 407Assert.Equal(AtsTypeMapping.DeriveTypeId(typeof(HttpCommandPrepareRequestContext)), callbackParameter.Type.TypeId); 409Assert.Equal(AtsTypeMapping.DeriveTypeId(typeof(HttpCommandRequestExportData)), prepareRequestProperty.CallbackReturnType?.TypeId); 438t => t.TypeId == AtsTypeMapping.DeriveTypeId(typeof(DerivedExportedProperties))); 457Assert.Equal(AtsConstants.String, nameGetter.ReturnType.TypeId); 462Assert.Equal(AtsConstants.String, descriptionGetter.ReturnType.TypeId); 483Assert.Equal(AtsConstants.String, nullableString.Type.TypeId); 488Assert.Equal(AtsConstants.String, requiredString.Type.TypeId); 493Assert.Equal(AtsConstants.Number, nullableNumber.Type.TypeId); 498Assert.Equal(AtsConstants.Number, requiredNumber.Type.TypeId); 517Assert.DoesNotContain(genericCapability.ExpandedTargetTypes, t => t.TypeId == shadowedTypeId); 518Assert.Contains(genericCapability.ExpandedTargetTypes, t => t.TypeId == otherTypeId); 519Assert.Contains(specificCapability.ExpandedTargetTypes, t => t.TypeId == shadowedTypeId); 574Assert.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);