231 writes to TypeId
Aspire.Hosting.CodeGeneration.Go.Tests (30)
AtsGoCodeGeneratorTests.cs (4)
2638TypeId = AtsConstants.String, 2644TypeId = AtsConstants.Number, 2648var voidType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }; 2734TypeId = AtsConstants.Number,
AtsGoDerivedBuilderTests.cs (10)
490private static readonly AtsTypeRef s_builder = new() { TypeId = AtsConstants.BuilderTypeId, Category = AtsTypeCategory.Handle, IsInterface = true }; 497private static readonly AtsTypeRef s_string = new() { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive }; 498private static readonly AtsTypeRef s_poolSettings = new() { TypeId = PoolSettingsId, Category = AtsTypeCategory.Dto }; 615private static AtsTypeRef Handle(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Handle }; 619TypeId = AtsConstants.ArrayTypeId(element.TypeId), 627TypeId = AtsConstants.ListTypeId(element.TypeId), 634TypeId = AtsConstants.DictTypeId(key.TypeId, value.TypeId), 643TypeId = string.Join("|", members.Select(member => member.TypeId)), 655Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback }, 658CallbackReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }
GoApiExportTests.cs (2)
334new AtsDtoPropertyInfo { Name = "Required", Type = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive } }, 335new AtsDtoPropertyInfo { Name = "Optional", Type = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive }, IsOptional = true }
GoDocCommentTests.cs (6)
451var resourceType = new AtsTypeRef { TypeId = ResourceTypeId, Category = AtsTypeCategory.Handle }; 452var settingsType = new AtsTypeRef { TypeId = SettingsTypeId, Category = AtsTypeCategory.Dto }; 453var statusType = new AtsTypeRef { TypeId = StatusTypeId, Category = AtsTypeCategory.Enum }; 454var tagsType = new AtsTypeRef { TypeId = "Tests/List<string>", Category = AtsTypeCategory.List, ElementType = stringType }; 565private static AtsTypeRef Primitive(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Primitive }; 586var resourceType = new AtsTypeRef { TypeId = ResourceTypeId, Category = AtsTypeCategory.Handle };
GoGeneratorEscapingTests.cs (8)
119var tagsType = new AtsTypeRef { TypeId = "Tests/List<string>", Category = AtsTypeCategory.List, ElementType = stringType }; 120var unionType = new AtsTypeRef { TypeId = "Tests/Union", Category = AtsTypeCategory.Union, UnionTypes = [stringType, numberType] }; 121var callbackType = new AtsTypeRef { TypeId = "Tests/Callback", Category = AtsTypeCategory.Callback }; 122var enumType = new AtsTypeRef { TypeId = StatusTypeId, Category = AtsTypeCategory.Enum }; 123var lookupType = new AtsTypeRef { TypeId = "Tests/Dict<string,string>", Category = AtsTypeCategory.Dict, KeyType = stringType, ValueType = stringType, IsReadOnly = true }; 124var unknownType = new AtsTypeRef { TypeId = "Tests/Unknown", Category = AtsTypeCategory.Unknown }; 223private static AtsTypeRef Primitive(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Primitive }; 225private static AtsTypeRef Handle(string typeId) => new() { TypeId = typeId, Category = AtsTypeCategory.Handle };
Aspire.Hosting.CodeGeneration.Java.Tests (46)
AtsJavaCodeGeneratorTests.cs (46)
719var numberType = new AtsTypeRef { TypeId = AtsConstants.Number, Category = AtsTypeCategory.Primitive }; 720var booleanType = new AtsTypeRef { TypeId = AtsConstants.Boolean, Category = AtsTypeCategory.Primitive }; 2920new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = MutableStringDict() }); 2935TypeId = "list", 2950var stringType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive }; 2951var innerArray = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = stringType }; 2954new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = innerArray }); 2997var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle }; 2998var stringType = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive }; 2999var innerArray = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = stringType }; 3000var matrixType = new AtsTypeRef { TypeId = "array", Category = AtsTypeCategory.Array, ElementType = innerArray }; 3005Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback }, 3007CallbackReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive } 3014ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }, 3035var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle }; 3039Type = new AtsTypeRef { TypeId = AtsConstants.CancellationToken, Category = AtsTypeCategory.Dto } 3046ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }, 3063var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle }; 3081TypeId = AtsConstants.Number, 3109TypeId = "Tests/ProbeResource", 3117new AtsTypeRef { TypeId = AtsConstants.Boolean, Category = AtsTypeCategory.Primitive, IsNullable = true }), 3121new AtsTypeRef { TypeId = AtsConstants.Number, Category = AtsTypeCategory.Primitive, IsNullable = true }), 3247var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle }; 3250TypeId = AtsConstants.Number, 3256TypeId = AtsConstants.Boolean, 3262TypeId = "numberArray", 3268TypeId = "booleanArray", 3274TypeId = "booleanMatrix", 3282Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback }, 3288CallbackReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive } 3295ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }, 3537var contextType = new AtsTypeRef { TypeId = "Tests/MutableContext", Category = AtsTypeCategory.Dto }; 3553Type = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive } 3566Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback }, 3574TypeId = AtsConstants.Void, 3628var resourceType = new AtsTypeRef { TypeId = "Tests/ProbeResource", Category = AtsTypeCategory.Handle }; 3629var contextType = new AtsTypeRef { TypeId = "Tests/MutableContext", Category = AtsTypeCategory.Dto }; 3634Type = new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback }, 3639CallbackReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive } 3646ReturnType = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }, 3668Type = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive } 3855Type = new AtsTypeRef { TypeId = "KeywordProbe", Category = AtsTypeCategory.Dto } 3914new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive }); 3945TypeId = "dict", 3948KeyType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive }, 3949ValueType = new AtsTypeRef { TypeId = "string", Category = AtsTypeCategory.Primitive }
Aspire.Hosting.CodeGeneration.Python.Tests (20)
AtsPythonCodeGeneratorTests.cs (20)
392TypeId = context.DtoTypes.Single(t => t.Name == "TerminalOptions").TypeId, 860TypeId = "Tests/KeywordResource", 885TypeId = AtsConstants.String, 916TypeId = "Tests/AcronymResource", 941TypeId = AtsConstants.String, 975TypeId = genericBaseType.AssemblyQualifiedName!, 982TypeId = genericInterfaceType.AssemblyQualifiedName!, 990TypeId = "Tests/GenericResource", 1015TypeId = AtsConstants.Void, 1055TypeId = "Tests/NullableUnion", 1061TypeId = "Tests/NestedNullableUnion", 1067TypeId = AtsConstants.Number, 1075TypeId = AtsConstants.String, 1110TypeId = "Tests/NullableItems", 1114TypeId = AtsConstants.Number, 1124TypeId = AtsConstants.Void, 1160TypeId = AtsConstants.String, 1166TypeId = AtsConstants.Boolean, 1172TypeId = "Tests/CollidingAlphaResource", 1179TypeId = "Tests/CollidingBetaResource",
Aspire.Hosting.CodeGeneration.TypeScript.Tests (30)
AtsTypeScriptCodeGeneratorTests.cs (30)
282TypeId = $"{ApiExportPackageName}/PropertyContext", 287TypeId = AtsConstants.String, 969TypeId = AtsConstants.Number, 975TypeId = $"{AtsConstants.Number}[]", 1026TypeId = "test/EmptyUnion", 1042TypeId = "string", 1047TypeId = "list", 1053TypeId = "dictionary", 1069TypeId = AtsConstants.Number, 1075TypeId = "dictionary", 1077KeyType = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive }, 1080TypeId = "list", 1819TypeId = $"{resourceType.Assembly.GetName().Name}/{resourceType.FullName}", 2103TypeId = GetAtsTypeId(typeof(TResource)), 2116TypeId = AtsConstants.Void, 2141TypeId = AtsConstants.Void, 3129TypeId = $"{ApiExportPackageName}/PromiseContext", 3134TypeId = AtsConstants.String, 3139TypeId = AtsConstants.Void, 3334TypeId = $"{eventHubsPackage}/AzureEventHubsEmulatorResource", 3342TypeId = $"{serviceBusPackage}/AzureServiceBusEmulatorResource", 3428TypeId = targetTypeId, 3443TypeId = AtsConstants.Void, 3546TypeId = $"Aspire.Hosting/{targetTypeName}", 3561TypeId = "callback", 3576TypeId = AtsConstants.Void, 3583TypeId = AtsConstants.Void, 3610TypeId = AtsConstants.String, 3619TypeId = AtsConstants.Number, 3627TypeId = AtsConstants.Void,
Aspire.Hosting.Native.CodeGeneration (34)
src\Aspire.Hosting.RemoteHost\AtsCapabilityScanner.cs (34)
935TypeId = originalTarget, 965TypeId = typeInfo.AtsTypeId, 1178? new AtsTypeRef { TypeId = "callback", ClrType = prop.PropertyType, Category = AtsTypeCategory.Callback } 1704: new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive }; 1708TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 1731propertyTypeRef = new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive }; 2244? new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback } 2301returnTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }; 2305returnTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }; 2313?? new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive } 2314: new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }; 2319?? new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive } 2347var voidTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }; 2682TypeId = AtsConstants.Void, 2718TypeId = typeRef.TypeId, 2798return new AtsTypeRef { TypeId = primitiveTypeId, ClrType = type, Category = AtsTypeCategory.Primitive }; 2804return new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = type, Category = AtsTypeCategory.Primitive }; 2811TypeId = AtsConstants.DictTypeId(AtsConstants.String, AtsConstants.Any), 2814KeyType = new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive }, 2815ValueType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive }, 2824TypeId = AtsConstants.ListTypeId(AtsConstants.Any), 2827ElementType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive } 2839TypeId = AtsConstants.EnumTypeId(type.FullName ?? type.Name), 2862TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2885TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2907TypeId = AtsConstants.ListTypeId(elementTypeRef.TypeId), 2927TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 2972TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 2988TypeId = AtsTypeMapping.DeriveTypeId(type), 3000TypeId = AtsTypeMapping.DeriveTypeId(type), 3010TypeId = AtsTypeMapping.DeriveTypeId(type), 3105TypeId = ifaceTypeId, 3172TypeId = typeId, 3431TypeId = string.Join("|", unionTypes.Select(u => u.TypeId)),
Aspire.Hosting.RemoteHost (39)
Ats\AtsMarshaller.cs (1)
426TypeId = AtsTypeMapping.DeriveTypeId(type),
Ats\ExternalCapabilityRegistry.cs (2)
796: new AtsTypeRef { TypeId = "unknown", Category = AtsTypeCategory.Unknown } 808TypeId = typeRef.TypeId,
AtsCapabilityScanner.cs (34)
935TypeId = originalTarget, 965TypeId = typeInfo.AtsTypeId, 1178? new AtsTypeRef { TypeId = "callback", ClrType = prop.PropertyType, Category = AtsTypeCategory.Callback } 1704: new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive }; 1708TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 1731propertyTypeRef = new AtsTypeRef { TypeId = AtsConstants.Any, Category = AtsTypeCategory.Primitive }; 2244? new AtsTypeRef { TypeId = "callback", Category = AtsTypeCategory.Callback } 2301returnTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }; 2305returnTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }; 2313?? new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive } 2314: new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }; 2319?? new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive } 2347var voidTypeRef = new AtsTypeRef { TypeId = AtsConstants.Void, Category = AtsTypeCategory.Primitive }; 2682TypeId = AtsConstants.Void, 2718TypeId = typeRef.TypeId, 2798return new AtsTypeRef { TypeId = primitiveTypeId, ClrType = type, Category = AtsTypeCategory.Primitive }; 2804return new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = type, Category = AtsTypeCategory.Primitive }; 2811TypeId = AtsConstants.DictTypeId(AtsConstants.String, AtsConstants.Any), 2814KeyType = new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive }, 2815ValueType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive }, 2824TypeId = AtsConstants.ListTypeId(AtsConstants.Any), 2827ElementType = new AtsTypeRef { TypeId = AtsConstants.Any, ClrType = typeof(object), Category = AtsTypeCategory.Primitive } 2839TypeId = AtsConstants.EnumTypeId(type.FullName ?? type.Name), 2862TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2885TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2907TypeId = AtsConstants.ListTypeId(elementTypeRef.TypeId), 2927TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 2972TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 2988TypeId = AtsTypeMapping.DeriveTypeId(type), 3000TypeId = AtsTypeMapping.DeriveTypeId(type), 3010TypeId = AtsTypeMapping.DeriveTypeId(type), 3105TypeId = ifaceTypeId, 3172TypeId = typeId, 3431TypeId = string.Join("|", unionTypes.Select(u => u.TypeId)),
AtsContextFilter.cs (2)
324TypeId = targetTypeId, 344TypeId = AtsConstants.Void,
Aspire.Hosting.RemoteHost.Tests (32)
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 (12)
171TypeId = "string|number|boolean", 175new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive }, 176new AtsTypeRef { TypeId = AtsConstants.Number, ClrType = typeof(int), Category = AtsTypeCategory.Primitive }, 177new AtsTypeRef { TypeId = AtsConstants.Boolean, ClrType = typeof(bool), Category = AtsTypeCategory.Primitive } 194TypeId = "string|resource", 198new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive }, 199new AtsTypeRef { TypeId = "test/IResource", ClrType = typeof(IResource), Category = AtsTypeCategory.Handle } 216TypeId = "string|boolean", 220new AtsTypeRef { TypeId = AtsConstants.String, ClrType = typeof(string), Category = AtsTypeCategory.Primitive }, 221new AtsTypeRef { TypeId = AtsConstants.Boolean, ClrType = typeof(bool), Category = AtsTypeCategory.Primitive } 293TypeId = AtsConstants.CancellationToken, 1021var typeRef = new AtsTypeRef { TypeId = "test/SelfReferencingDto", Category = AtsTypeCategory.Dto };
ExternalCapabilityRegistryTests.cs (3)
894ReturnType = new AtsTypeRef { TypeId = AtsConstants.Boolean, Category = AtsTypeCategory.Primitive } 920ReturnType = new AtsTypeRef { TypeId = AtsConstants.Boolean, Category = AtsTypeCategory.Primitive } 964Type = new AtsTypeRef { TypeId = AtsConstants.String, Category = AtsTypeCategory.Primitive },
481 references to TypeId
aspire-managed (6)
AppHostServerV2CodeGeneration.cs (2)
116handles.TryAdd(type.TypeId, new AtsTypeInfo { AtsTypeId = type.TypeId });
src\Shared\NativeProviderContractReader.cs (4)
43capability.Parameters is null || capability.ReturnType is null || string.IsNullOrWhiteSpace(capability.ReturnType.TypeId)) 50string.IsNullOrWhiteSpace(parameter.Type.TypeId)) 55string.IsNullOrWhiteSpace(parameter.CallbackReturnType.TypeId) || 56parameter.CallbackParameters.Any(value => value is null || value.Type is null || string.IsNullOrWhiteSpace(value.Type.TypeId))))
Aspire.Hosting.CodeGeneration.Go (40)
AtsGoCodeGenerator.ApiProjection.cs (5)
791.Select(implemented => _interfaceNames.GetValueOrDefault(implemented.TypeId)) 873var hasReturn = returnType is not null && returnType.TypeId != AtsConstants.Void; 894ReturnsReceiver = returnsHandle && IsSameType(returnType!.TypeId, capability, typeId) 1276_typeOwners.TryAdd(typeRef.TypeId, GetOwningAssemblyName(typeRef.TypeId, clrType.Assembly.GetName().Name));
AtsGoCodeGenerator.cs (35)
273requiredTypeIds.Add(type.TypeId); 446if (!string.IsNullOrEmpty(expanded.TypeId)) 448expansionTargetIds.Add(expanded.TypeId); 675.Select(baseType => baseType.TypeId) 718if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId 719|| IsCancellationTokenTypeId(typeRef.TypeId)) 725set.Add(typeRef.TypeId); 835if (string.IsNullOrEmpty(targetType.TypeId)) 841if (!_implNames.ContainsKey(targetType.TypeId)) 845if (!result.TryGetValue(targetType.TypeId, out var list)) 848result[targetType.TypeId] = list; 966var returnsValue = capability.ReturnType is not null && capability.ReturnType.TypeId != AtsConstants.Void; 1260AtsTypeCategory.Enum => $"{MapEnumType(typeRef.TypeId)}({RenderGoJsonValue(value)})", 1261AtsTypeCategory.Dto when value is JsonObject obj && dtoTypesById.TryGetValue(typeRef.TypeId, out var dtoInfo) 1277: MapEnumType(typeRef.TypeId); 1831&& p.CallbackReturnType.TypeId != AtsConstants.Void; 1848var hasReturn = capability.ReturnType is not null && capability.ReturnType.TypeId != AtsConstants.Void; 1865if (IsSameType(returnType.TypeId, capability, currentTypeId)) 1953var isFluent = IsSameType(returnType.TypeId, capability, currentTypeId); 1970var childImplName = returnType.TypeId is not null && _implNames.TryGetValue(returnType.TypeId, out var implTarget) 2222&& p.CallbackReturnType.TypeId != AtsConstants.Void; 2285if (clientExpression is not null && IsCancellationTokenTypeId(type.TypeId)) 2292&& _implNames.ContainsKey(type.TypeId)) 2294return $"callbackHandleArg({clientExpression}, args, {index}, new{_interfaceNames[type.TypeId]}FromHandle)"; 2535AtsTypeCategory.Primitive => type.TypeId is not (AtsConstants.Any or AtsConstants.ReferenceExpressionTypeId), 2840var hasReturn = capability.ReturnType is not null && capability.ReturnType.TypeId != AtsConstants.Void; 3065if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 3076AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 3077AtsTypeCategory.Handle => MapHandleType(typeRef.TypeId, asInput), 3078AtsTypeCategory.Dto => "*" + MapDtoType(typeRef.TypeId), 3106if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 3140&& typeRef.TypeId is not (AtsConstants.Void or AtsConstants.Any or AtsConstants.CancellationToken); 3166private static string MapPrimitiveType(AtsTypeRef typeRef) => typeRef.TypeId switch 3207IsCancellationTokenTypeId(parameter.Type?.TypeId);
Aspire.Hosting.CodeGeneration.Go.Tests (10)
AtsGoCodeGeneratorTests.cs (2)
1948Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 2066.Any(i => i.TypeId.Contains("IResourceWithEnvironment"));
AtsGoDerivedBuilderTests.cs (6)
619TypeId = AtsConstants.ArrayTypeId(element.TypeId), 627TypeId = AtsConstants.ListTypeId(element.TypeId), 634TypeId = AtsConstants.DictTypeId(key.TypeId, value.TypeId), 643TypeId = string.Join("|", members.Select(member => member.TypeId)), 676TargetTypeId = target.TypeId,
GoDocCommentTests.cs (1)
602ReturnsBuilder = returnType.TypeId == ResourceTypeId,
GoGeneratorEscapingTests.cs (1)
273ReturnsBuilder = returnType.TypeId == ResourceTypeId,
Aspire.Hosting.CodeGeneration.Java (39)
AtsJavaCodeGenerator.cs (39)
881AtsTypeCategory.Dto when value is JsonObject obj && dtoTypesById.TryGetValue(typeRef.TypeId, out var dtoInfo) 1014if (!string.Equals(left.Type?.TypeId, right.Type?.TypeId, StringComparison.Ordinal)) 1038if (!string.Equals(leftCallbackParameters[i].Type.TypeId, rightCallbackParameters[i].Type.TypeId, StringComparison.Ordinal)) 1044return string.Equals(left.CallbackReturnType?.TypeId, right.CallbackReturnType?.TypeId, StringComparison.Ordinal); 1886var returnsDifferentBuilder = capability.ReturnType?.TypeId is { } returnTypeId && 1891? new(MapHandleType(capability.ReturnType!.TypeId!), HasReturn: true, ReturnsCurrentBuilder: false) 1895var hasReturn = capability.ReturnType?.TypeId != AtsConstants.Void; 1910var hasReturnType = callbackReturnType != null && callbackReturnType.TypeId != AtsConstants.Void; 1944var hasReturnType = callbackParam.CallbackReturnType != null && callbackParam.CallbackReturnType.TypeId != AtsConstants.Void; 2000var hasReturnType = property.CallbackReturnType != null && property.CallbackReturnType.TypeId != AtsConstants.Void; 2030if (callbackParameter.Type?.TypeId == AtsConstants.CancellationToken) 2050if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 2055if (IsCancellationTokenTypeId(typeRef.TypeId)) 2063AtsTypeCategory.Primitive => RenderJavaPrimitiveTransportValueConversion(typeRef.TypeId, valueExpression, allowNull), 2064AtsTypeCategory.Enum => RenderJavaEnumTransportValueConversion(typeRef.TypeId, valueExpression, allowNull), 2065AtsTypeCategory.Dto => RenderJavaDtoTransportValueConversion(typeRef.TypeId, valueExpression, allowNull), 2229if (typeRef.TypeId == AtsConstants.CancellationToken) 2482.FirstOrDefault(baseType => !string.Equals(baseType.TypeId, typeId, StringComparison.Ordinal) 2483&& _classNames.ContainsKey(baseType.TypeId)); 2487baseClassName = _classNames[exportedBaseType.TypeId]; 2521if (targetType.TypeId is null) 2526if (!result.TryGetValue(targetType.TypeId, out var list)) 2529result[targetType.TypeId] = list; 2569if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 2576AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId, isOptional || useBoxedTypes), 2577AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 2578AtsTypeCategory.Handle => MapHandleType(typeRef.TypeId), 2579AtsTypeCategory.Dto => MapDtoType(typeRef.TypeId), 2601if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 2623if (IsCancellationTokenTypeId(typeRef.TypeId)) 2683IsCancellationTokenTypeId(parameter.Type?.TypeId); 2697if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId 2698|| IsCancellationTokenTypeId(typeRef.TypeId)) 2705handleTypeIds.Add(typeRef.TypeId); 2720typeIds[typeRef.TypeId] = false; // false = List 2727typeIds[typeRef.TypeId] = true; // true = Dict
Aspire.Hosting.CodeGeneration.Java.Tests (13)
AtsJavaCodeGeneratorTests.cs (13)
186Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 328.Any(i => i.TypeId.Contains("IResourceWithEnvironment")); 3015TargetTypeId = resourceType.TypeId, 3047TargetTypeId = resourceType.TypeId, 3089TargetTypeId = resourceType.TypeId, 3296TargetTypeId = resourceType.TypeId, 3310HandleTypes = [new AtsTypeInfo { AtsTypeId = resourceType.TypeId! }], 3547TypeId = contextType.TypeId!, 3647TargetTypeId = resourceType.TypeId, 3656HandleTypes = [new AtsTypeInfo { AtsTypeId = resourceType.TypeId! }], 3662TypeId = contextType.TypeId!, 3957HandleTypes = [new AtsTypeInfo { AtsTypeId = resourceType.TypeId! }], 3971TargetTypeId = resourceType.TypeId,
Aspire.Hosting.CodeGeneration.Python (53)
AtsPythonCodeGenerator.cs (53)
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) 297var writeback = parameter.CallbackReturnType?.TypeId == AtsConstants.Void && 298parameter.CallbackParameters?.Any(p => p.Type.Category == AtsTypeCategory.Dto && p.Type.TypeId != AtsConstants.CancellationToken) == true 310? JsonValue.Create(callbackParameter.Type.TypeId)!.ToJsonString() 459filtered = filtered.Where(p => p.Type?.TypeId != AtsConstants.CancellationToken); 471if (param.Type?.TypeId == AtsConstants.CancellationToken) 533if (typeRef.Category == AtsTypeCategory.Primitive && typeRef.TypeId == AtsConstants.Void) 666if (param.Type?.TypeId == AtsConstants.CancellationToken) 691private static string? GetReturnTypeId(AtsCapabilityInfo capability) => capability.ReturnType?.TypeId; 808if (IsHandleType(cap.ReturnType) && !dtoTypeIds.Contains(cap.ReturnType!.TypeId)) 815if (IsHandleType(param.Type) && !dtoTypeIds.Contains(param.Type!.TypeId)) 817typeIds.Add(param.Type!.TypeId); 824if (IsHandleType(cbParam.Type) && !dtoTypeIds.Contains(cbParam.Type.TypeId)) 826typeIds.Add(cbParam.Type.TypeId); 1016AtsTypeCategory.Dto when value is JsonObject obj && dtoTypesById.TryGetValue(typeRef.TypeId, out var dtoInfo) 1376var returnsSelf = isDistributedApplicationBuilder && capability.ReturnType?.TypeId == capability.TargetTypeId; 1480.Select(i => i.TypeId), 1483.Where(i => !transitivelyImplemented.Contains(i.TypeId)) 1485baseClass = string.Join(", ", implementedInterfaces.Select(i => DeriveClassName(i.TypeId))); 1545baseTypeInterfaces = baseType.ImplementedInterfaces.Select(i => i.TypeId).ToList(); 1554var implementedInterfaces = builder.TargetType?.ImplementedInterfaces.Where(i => !baseTypeInterfaces.Contains(i.TypeId)).ToList(); 1561.Select(i => i.TypeId), 1564.Where(i => !transitivelyImplemented.Contains(i.TypeId)) 1681var returnsBuilder = capability.ReturnsBuilder && capability.ReturnType!.TypeId == capability.TargetTypeId; 1682var returnsChildBuilder = capability.ReturnsBuilder && capability.ReturnType != null && IsHandleType(capability.ReturnType) && capability.ReturnType.TypeId != capability.TargetTypeId; 1962if (!capabilitiesByTypeId.TryGetValue(expandedType.TypeId, out var list)) 1965capabilitiesByTypeId[expandedType.TypeId] = list; 1966typeRefsByTypeId[expandedType.TypeId] = expandedType; 2062.Select(i => i.TypeId) 2189if (!string.IsNullOrEmpty(typeRef.TypeId) && typeRef.Category == AtsTypeCategory.Handle) 2191typeRefs.TryAdd(typeRef.TypeId, typeRef); 2193if (!string.IsNullOrEmpty(typeRef.TypeId) && typeRef.Category == AtsTypeCategory.Dict) 2195_moduleBuilder.HandleRegistrations.TryAdd(typeRef.TypeId, "AspireDict"); 2197if (!string.IsNullOrEmpty(typeRef.TypeId) && typeRef.Category == AtsTypeCategory.List) 2199_moduleBuilder.HandleRegistrations.TryAdd(typeRef.TypeId, "AspireList"); 2278return DeriveClassName(typeRef.TypeId); 2447var tickIndex = typeRef.TypeId.IndexOf('`'); 2450return typeRef.TypeId[..tickIndex] + "T"; 2453return typeRef.TypeId + "T"; 2456return typeRef.TypeId;
Aspire.Hosting.CodeGeneration.Python.Tests (14)
AtsPythonCodeGeneratorTests.cs (14)
102Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 220.Any(i => i.TypeId.Contains("IResourceWithEnvironment")); 891TargetTypeId = resourceType.TypeId, 903AtsTypeId = resourceType.TypeId, 947TargetTypeId = resourceType.TypeId, 959AtsTypeId = resourceType.TypeId, 1018TargetTypeId = resourceType.TypeId, 1029AtsTypeId = resourceType.TypeId, 1036AtsTypeId = genericBaseTypeRef.TypeId, 1041AtsTypeId = genericInterfaceTypeRef.TypeId, 1202TargetTypeId = projectType.TypeId, 1223TargetTypeId = containerType.TypeId, 1235AtsTypeId = projectType.TypeId, 1240AtsTypeId = containerType.TypeId,
Aspire.Hosting.CodeGeneration.Rust (31)
AtsRustCodeGenerator.cs (31)
378if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId 379|| IsCancellationTokenTypeId(typeRef.TypeId)) 389AtsTypeCategory.Dto => !dtoTypesById.TryGetValue(typeRef.TypeId, out var dto) 474var hasReturn = capability.ReturnType.TypeId != AtsConstants.Void; 607var wrappedType = MapHandleType(returnTypeRef.TypeId); 611else if (returnTypeRef?.TypeId == AtsConstants.CancellationToken) 860if (targetType.TypeId is null) 865if (!result.TryGetValue(targetType.TypeId, out var list)) 868result[targetType.TypeId] = list; 907if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 914AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId), 915AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 916AtsTypeCategory.Handle => MapHandleType(typeRef.TypeId), 917AtsTypeCategory.Dto => MapDtoType(typeRef.TypeId), 945if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 952AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId), 953AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 956AtsTypeCategory.Dto => MapDtoType(typeRef.TypeId), 985if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 992AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId), 993AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 994AtsTypeCategory.Dto => MapDtoType(typeRef.TypeId), 1039var baseType = typeRef.TypeId switch 1064&& typeRef.TypeId is not (AtsConstants.Void or AtsConstants.Any or AtsConstants.CancellationToken); 1068&& typeRef.TypeId != AtsConstants.ReferenceExpressionTypeId 1069&& !IsCancellationTokenTypeId(typeRef.TypeId); 1083IsCancellationTokenTypeId(parameter.Type?.TypeId); 1097if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId 1098|| IsCancellationTokenTypeId(typeRef.TypeId)) 1105handleTypeIds.Add(typeRef.TypeId); 1120typeIds.Add(typeRef.TypeId);
Aspire.Hosting.CodeGeneration.Rust.Tests (2)
AtsRustCodeGeneratorTests.cs (2)
260Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 378.Any(i => i.TypeId.Contains("IResourceWithEnvironment"));
Aspire.Hosting.CodeGeneration.TypeScript (101)
AtsTypeScriptCodeGenerator.cs (47)
136capability.ReturnType.TypeId == AtsConstants.Void ? null : capability.Documentation?.Returns, 137suppressReturns: capability.ReturnType.TypeId == AtsConstants.Void, 388!_projector.DtoTypesById.TryGetValue(typeRef.TypeId, out var dtoType)) 403!_projector.DtoTypesById.TryGetValue(typeRef.TypeId, out var dtoType)) 409if (!visitedDtoTypeIds.Add(typeRef.TypeId)) 420visitedDtoTypeIds.Remove(typeRef.TypeId); 431private static string? GetReturnTypeId(AtsCapabilityInfo capability) => capability.ReturnType?.TypeId; 452capability.ReturnType.TypeId != capability.TargetTypeId))) 950var isVoid = capability.ReturnType == null || capability.ReturnType.TypeId == AtsConstants.Void; 953if (capability.ReturnType != null && _projector.TypesWithPromiseWrappers.Contains(capability.ReturnType.TypeId)) 955WriteLine($" {signature.MethodName}({signature.ParameterList}): {_projector.GetPublicPromiseInterfaceName(capability.ReturnType.TypeId)};"); 1141if (capability.ReturnsBuilder && capability.ReturnType?.TypeId != null && 1142!string.Equals(capability.ReturnType.TypeId, builder.TypeId, StringComparison.Ordinal) && 1143!string.Equals(capability.ReturnType.TypeId, capability.TargetTypeId, StringComparison.Ordinal)) 1145returnTypeId = capability.ReturnType.TypeId; 1161var wrappedReturnTypeId = capability.ReturnType!.TypeId; 1227if (capability.ReturnType?.TypeId == AtsConstants.CancellationToken) 1468if (param.Type is not { TypeId: var dtoTypeId }) 1538if (!visitedDtoTypeIds.Add(dtoProperty.Type.TypeId)) 1554visitedDtoTypeIds.Remove(dtoProperty.Type.TypeId); 1638if (capability.ReturnsBuilder && capability.ReturnType?.TypeId != null && 1639!string.Equals(capability.ReturnType.TypeId, builder.TypeId, StringComparison.Ordinal) && 1640!string.Equals(capability.ReturnType.TypeId, capability.TargetTypeId, StringComparison.Ordinal)) 1642var returnClass = _projector.WrapperClassNames.GetValueOrDefault(capability.ReturnType.TypeId) 1643?? TypeScriptApiProjector.DeriveClassName(capability.ReturnType.TypeId); 1811else if (capability.ReturnType?.TypeId == AtsConstants.CancellationToken) 1889&& callbackParam.CallbackReturnType.TypeId != AtsConstants.Void; 1924var cbTypeId = callbackParameter.Type.TypeId; 2273if (getter.ReturnType?.TypeId != null && _projector.WrapperClassNames.TryGetValue(getter.ReturnType.TypeId, out var wrapperClassName)) 2287if (getter.ReturnType?.TypeId == AtsConstants.CancellationToken) 2340if (getter.ReturnType?.TypeId != null && _projector.WrapperClassNames.TryGetValue(getter.ReturnType.TypeId, out var wrapperClassName)) 2367if (getter.ReturnType?.TypeId == AtsConstants.CancellationToken) 2388var handleType = _projector.GetConcreteHandleTypeName(getter.ReturnType!.TypeId); 2442var handleType = _projector.GetConcreteHandleTypeName(getter.ReturnType!.TypeId); 2665var returnTypeId = method.ReturnType!.TypeId; 2716else if (method.ReturnType?.TypeId == AtsConstants.CancellationToken) 2778var returnTypeId = capability.ReturnType!.TypeId; 2904var isVoid = capability.ReturnType == null || capability.ReturnType.TypeId == AtsConstants.Void; 2909var returnWrapperClass = _projector.WrapperClassNames.GetValueOrDefault(capability.ReturnType!.TypeId) 2910?? TypeScriptApiProjector.DeriveClassName(capability.ReturnType.TypeId); 2913var returnHandleType = _projector.GetConcreteHandleTypeName(capability.ReturnType.TypeId); 3065if (capability.ReturnType?.TypeId == AtsConstants.CancellationToken) 3130var isVoid = capability.ReturnType == null || capability.ReturnType.TypeId == AtsConstants.Void; 3134_projector.WrapperClassNames.GetValueOrDefault(capability.ReturnType!.TypeId) 3135?? 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) 1311var returnTypeId = capability.ReturnType?.TypeId; 1663if (typeRef.TypeId == AtsConstants.ReferenceExpressionTypeId) 1668if (typeRef.TypeId == InputTypeTypeId) 1673if (typeRef.TypeId == InteractionInputTypeId) 1678if (typeRef.TypeId == InteractionInputCollectionTypeId) 1684if (_wrapperClassNames.TryGetValue(typeRef.TypeId, out var wrapperClassName)) 1691AtsTypeCategory.Primitive => MapPrimitiveType(typeRef.TypeId), 1692AtsTypeCategory.Enum => MapEnumType(typeRef.TypeId), 1693AtsTypeCategory.Handle => GetWrapperOrHandleName(typeRef.TypeId), 1694AtsTypeCategory.Dto => GetDtoInterfaceName(typeRef.TypeId), 1715return typeRef.TypeId is AtsConstants.Void or AtsConstants.Any or AtsConstants.CancellationToken 1875if (IsHandleType(typeRef) && _wrapperClassNames.TryGetValue(typeRef!.TypeId, out var className)) 1881if (typeRef?.TypeId == InteractionInputCollectionTypeId) 1959if (!IsAssignableToInterface(candidateTypeRef, typeRef.TypeId) || 1960!_wrapperClassNames.TryGetValue(candidateTypeRef.TypeId, out var wrapperClassName)) 1981if (string.Equals(candidateTypeRef.TypeId, interfaceTypeId, StringComparison.Ordinal)) 2011internal static bool IsCancellationTokenType(AtsTypeRef? typeRef) => typeRef?.TypeId == AtsConstants.CancellationToken; 2327var aTypeId = a.Type?.TypeId; 2328var bTypeId = b.Type?.TypeId; 2352if (!string.Equals(aCallbackParams[i].Type.TypeId, bCallbackParams[i].Type.TypeId, StringComparison.Ordinal)) 2359var aReturnTypeId = a.CallbackReturnType?.TypeId; 2360var bReturnTypeId = b.CallbackReturnType?.TypeId; 2486if (typeRef?.TypeId is { } typeId && _typesWithPromiseWrappers.Contains(typeId)) 2511if (capability.ReturnsBuilder && capability.ReturnType?.TypeId != null && 2512!string.Equals(capability.ReturnType.TypeId, builder.TypeId, StringComparison.Ordinal) && 2513!string.Equals(capability.ReturnType.TypeId, capability.TargetTypeId, StringComparison.Ordinal)) 2515return GetPublicPromiseInterfaceName(capability.ReturnType.TypeId); 2541if (IsHandleType(typeRef) && _wrapperClassNames.ContainsKey(typeRef.TypeId)) 2546if (typeRef.TypeId == InteractionInputCollectionTypeId) 2686if (!capabilitiesByTypeId.TryGetValue(expandedType.TypeId, out var list)) 2689capabilitiesByTypeId[expandedType.TypeId] = list; 2691typeRefsByTypeId[expandedType.TypeId] = expandedType; 2908return IsTypeInHierarchy(retainedType, candidateType.TypeId) || 2909IsTypeInHierarchy(candidateType, retainedType.TypeId); 2915string.Equals(interfaceType.TypeId, typeId, StringComparison.Ordinal) || 2922(string.Equals(baseType.TypeId, typeId, StringComparison.Ordinal) || 2942if (!string.IsNullOrEmpty(typeRef.TypeId) && typeRef.Category == AtsTypeCategory.Handle) 2944typeRefs.TryAdd(typeRef.TypeId, typeRef); 3085if (_typesWithPromiseWrappers.Contains(returnType.TypeId)) 3087var className = _wrapperClassNames.GetValueOrDefault(returnType.TypeId) 3088?? DeriveClassName(returnType.TypeId); 3112var returnType = callbackReturnType == null || callbackReturnType.TypeId == AtsConstants.Void
Aspire.Hosting.CodeGeneration.TypeScript.Tests (58)
AtsTypeScriptCodeGeneratorTests.cs (58)
172Assert.Contains(addTestRedis.Parameters, p => p.Name == "name" && p.Type?.TypeId == "string"); 298TargetTypeId = targetType.TypeId, 310TargetTypeId = targetType.TypeId, 421Assert.Equal("string", nameGetterCapability.ReturnType?.TypeId); 431Assert.Equal("Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestCallbackContext", nameSetterCapability.ReturnType?.TypeId); // Returns context for fluent chaining 439Assert.Equal("number", valueGetterCapability.ReturnType?.TypeId); 522t.TypeId == "Aspire.Hosting.CodeGeneration.TypeScript.Tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests.TestTypes.TestRedisResource"); 645Assert.Equal("Aspire.Hosting/Aspire.Hosting.ApplicationModel.EndpointReferenceExpression", endpointOrigins.ReturnType.TypeId); 651Assert.Equal(endpointOrigins.ReturnType.TypeId, primaryOrigin.ReturnType.TypeId); 677Assert.Equal(AtsConstants.Void, setValue.ReturnType.TypeId); 686Assert.Equal("string", valueParameter.Type.TypeId); 696Assert.Equal("string", tryGetCurrentValue.ReturnType.TypeId); 718Assert.Equal(typeId, capability.ReturnType.TypeId); 731Assert.Contains(withBrowserLogs.Parameters, p => p.Name == "browser" && p.Type?.TypeId == "string" && p.IsOptional); 732Assert.Contains(withBrowserLogs.Parameters, p => p.Name == "profile" && p.Type?.TypeId == "string" && p.IsOptional); 746c.ExpandedTargetTypes.Any(t => t.TypeId.Contains("ContainerResource"))) 751TargetType = c.TargetType != null ? new { c.TargetType.TypeId, c.TargetType.IsInterface } : null, 753.Where(t => t.TypeId.Contains("ContainerResource")) 754.Select(t => new { t.TypeId, t.IsInterface }) 794if (expandedType.TypeId.Contains("ContainerResource")) 797$"Capability '{cap.CapabilityId}' ExpandedTargetType '{expandedType.TypeId}' has IsInterface = true"); 820Assert.Equal("Aspire.Hosting/Aspire.Hosting.ApplicationModel.ContainerResource", withBindMount.TargetType.TypeId); 849Assert.Contains("IResourceWithConnectionString", withConnectionStringDirect.TargetType.TypeId); 857.FirstOrDefault(t => t.TypeId.Contains("TestRedisResource")); 877Assert.Contains("TestRedisResource", withRedisSpecific.TargetType.TypeId); 885.FirstOrDefault(t => t.TypeId.Contains("TestRedisResource")); 903Assert.Contains("ContainerResource", withBindMount.TargetType.TypeId); 911.FirstOrDefault(t => t.TypeId.Contains("ContainerResource") && !t.TypeId.Contains("IContainer")); 1140$"Expanded type '{expandedType.TypeId}' should be a concrete type, not an interface"); 1164Assert.Contains("IResourceWithEnvironment", testWithEnvironmentCallback.TargetType.TypeId); 1173.FirstOrDefault(t => t.TypeId.Contains("TestRedisResource")); 1339Assert.Equal(capability.TargetTypeId, capability.ReturnType.TypeId); 1344Assert.Equal(AtsConstants.String, image.Type?.TypeId); 1348capability.ExpandedTargetTypes.Select(t => t.TypeId).Order(StringComparer.Ordinal)); 1424Assert.Equal("string", capability.Parameters.Single().Type?.TypeId); 1458claimParameter.Type?.TypeId); 1544.Any(i => i.TypeId.Contains("IResourceWithEnvironment")); 1656.ReturnType!.TypeId; 2220Assert.Equal(expectedTypes.Select(GetAtsTypeId), parameter.CallbackParameters.Select(p => p.Type?.TypeId)); 2230Assert.Equal(GetAtsTypeId(parameterType), parameter.Type?.TypeId); 2370Assert.Equal("any", valueParam.Type.TypeId); 2518Assert.Equal(AtsConstants.CancellationToken, ctParam.Type.TypeId); 2553Assert.Equal(AtsConstants.CancellationToken, operationParam.CallbackParameters[0].Type?.TypeId); 2572Assert.Equal(AtsConstants.TimeSpan, timeoutParam.Type?.TypeId); 2576Assert.Equal(AtsConstants.CancellationToken, ctParam.Type?.TypeId); 2592Assert.Equal("Aspire.Hosting/Aspire.Hosting.ApplicationModel.ProjectResource", capability.ReturnType.TypeId); 2616Assert.Equal("Aspire.Hosting.Dotnet/Aspire.Hosting.Dotnet.DotnetProjectOptions", options.Type.TypeId); 2617var dto = Assert.Single(context.DtoTypes, dto => dto.TypeId == options.Type.TypeId); 2632Assert.Equal(legacyTypeId, legacyOptions.Type.TypeId); 2935var expandedTypeIds = withNpm.ExpandedTargetTypes.Select(t => t.TypeId).ToList(); 2966var expandedTypeIds = capability.ExpandedTargetTypes.Select(t => t.TypeId).ToList(); 3150TargetTypeId = targetType.TypeId, 3162TargetTypeId = targetType.TypeId, 3174TargetTypeId = targetType.TypeId, 3186TargetTypeId = targetType.TypeId, 3586TargetTypeId = targetType.TypeId,
Aspire.Hosting.Native.CodeGeneration (48)
NativeCSharpProjection.cs (7)
116callback.CallbackReturnType?.TypeId != "void") 162member.TypeId == "string" 237AtsTypeCategory.Handle when handles.TryGetValue(type.TypeId, out var handle) => handle, 238AtsTypeCategory.Dto when dtos.TryGetValue(type.TypeId, out var dto) => dto, 242AtsTypeCategory.Primitive => type.TypeId switch 249_ => throw new NotSupportedException($"Unsupported native primitive: {type.TypeId} ({type.ClrType}).") 251_ => throw new NotSupportedException($"Unsupported native C# type: {type.TypeId} ({type.Category}).")
NativeProviderTypeScriptProjection.cs (2)
27.Select(type => type.TypeId).Distinct(StringComparer.Ordinal).ToArray(); 89var id = type.TypeId;
Program.cs (9)
101if (handles.Contains(capability.ReturnType.TypeId)) 131if (handles.Contains(capability.ReturnType.TypeId)) 134$" return {(asynchronous ? "connection.PublishCoreHandle" : "handles.Add")}(result, {Literal(capability.ReturnType.TypeId)});"); 136else if (context.DtoTypes.Any(dto => dto.TypeId == capability.ReturnType.TypeId)) 434parameter.CallbackReturnType?.TypeId == "void" && type.IsGenericType && 437return $"connection.CreateAuthoringCallback<{type.GetGenericArguments()[0].Name}>(callbackConnection, RpcArguments.String({node}), {Literal(callbackParameter.Type.TypeId)})"; 440members.Any(member => member.TypeId == "string") && 441members.All(member => member.TypeId == "string" || member.Category == AtsTypeCategory.Handle)) 443return $"RpcArguments.Union({node}, handles, [{string.Join(", ", members.Where(member => member.Category == AtsTypeCategory.Handle).Select(member => Literal(member.TypeId)))}])";
src\Aspire.Hosting.RemoteHost\AtsCapabilityScanner.cs (26)
692enumTypes.TryAdd(typeRef.TypeId, typeRef.ClrType); 774if (typeRef.Category == AtsTypeCategory.Unknown && validTypes.Contains(typeRef.TypeId)) 871return typeRef.TypeId; 980AddToCompatibilityMap(typeToCompatibleTypes, iface.TypeId, concreteTypeRef); 986AddToCompatibilityMap(typeToCompatibleTypes, baseType.TypeId, concreteTypeRef); 1019.SelectMany(c => c.ExpandedTargetTypes.Select(t => (Target: t.TypeId, Capability: c))) 1091.Where(t => !targetIds.Contains(t.TypeId)) 1399AtsTypeCategory.Primitive => typeRef.TypeId != AtsConstants.CancellationToken && typeRef.TypeId != AtsConstants.Void, 1422if (!visitedDtoTypeIds.Add(typeRef.TypeId)) 1452_ = visitedDtoTypeIds.Remove(typeRef.TypeId); 1708TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 1714propertyTypeId = propertyTypeRef.TypeId; 1727propertyTypeId = propertyTypeRef.TypeId; 1732propertyTypeId = propertyTypeRef.TypeId; 2122var firstParamTypeId = extendsTypeRef?.TypeId ?? MapToAtsTypeId(firstParamType, assemblyExportedTypeCache); 2718TypeId = typeRef.TypeId, 2862TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2885TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2907TypeId = AtsConstants.ListTypeId(elementTypeRef.TypeId), 2927TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 2972TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 3431TypeId = string.Join("|", unionTypes.Select(u => u.TypeId)),
src\Shared\NativeProviderContractReader.cs (4)
43capability.Parameters is null || capability.ReturnType is null || string.IsNullOrWhiteSpace(capability.ReturnType.TypeId)) 50string.IsNullOrWhiteSpace(parameter.Type.TypeId)) 55string.IsNullOrWhiteSpace(parameter.CallbackReturnType.TypeId) || 56parameter.CallbackParameters.Any(value => value is null || value.Type is null || string.IsNullOrWhiteSpace(value.Type.TypeId))))
Aspire.Hosting.RemoteHost (42)
Ats\AtsMarshaller.cs (6)
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), 185$"Value of type '{value.GetType()}' does not match any member of union '{typeRef.TypeId}'.");
Ats\ExternalCapabilityRegistry.cs (1)
606.Where(parameter => parameter.Type?.TypeId == AtsConstants.CancellationToken)
AtsCapabilityScanner.cs (26)
692enumTypes.TryAdd(typeRef.TypeId, typeRef.ClrType); 774if (typeRef.Category == AtsTypeCategory.Unknown && validTypes.Contains(typeRef.TypeId)) 871return typeRef.TypeId; 980AddToCompatibilityMap(typeToCompatibleTypes, iface.TypeId, concreteTypeRef); 986AddToCompatibilityMap(typeToCompatibleTypes, baseType.TypeId, concreteTypeRef); 1019.SelectMany(c => c.ExpandedTargetTypes.Select(t => (Target: t.TypeId, Capability: c))) 1091.Where(t => !targetIds.Contains(t.TypeId)) 1399AtsTypeCategory.Primitive => typeRef.TypeId != AtsConstants.CancellationToken && typeRef.TypeId != AtsConstants.Void, 1422if (!visitedDtoTypeIds.Add(typeRef.TypeId)) 1452_ = visitedDtoTypeIds.Remove(typeRef.TypeId); 1708TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 1714propertyTypeId = propertyTypeRef.TypeId; 1727propertyTypeId = propertyTypeRef.TypeId; 1732propertyTypeId = propertyTypeRef.TypeId; 2122var firstParamTypeId = extendsTypeRef?.TypeId ?? MapToAtsTypeId(firstParamType, assemblyExportedTypeCache); 2718TypeId = typeRef.TypeId, 2862TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2885TypeId = AtsConstants.DictTypeId(keyTypeRef.TypeId, valueTypeRef.TypeId), 2907TypeId = AtsConstants.ListTypeId(elementTypeRef.TypeId), 2927TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 2972TypeId = AtsConstants.ArrayTypeId(elementTypeRef.TypeId), 3431TypeId = string.Join("|", unionTypes.Select(u => u.TypeId)),
AtsContextFilter.cs (8)
174yield return targetType.TypeId; 179yield return expandedTargetType.TypeId; 394if (typeRef.Category == AtsTypeCategory.Handle && !string.IsNullOrEmpty(typeRef.TypeId)) 396referencedHandleTypes.TryAdd(typeRef.TypeId, typeRef); 426if (handleTypesById.TryGetValue(typeRef.TypeId, out var handleType) && includedHandleTypeIds.Add(handleType.AtsTypeId)) 431if (dtoTypesById.TryGetValue(typeRef.TypeId, out var dtoType) && includedDtoTypeIds.Add(dtoType.TypeId)) 436if (enumTypesById.ContainsKey(typeRef.TypeId)) 438includedEnumTypeIds.Add(typeRef.TypeId);
CodeGeneration\CodeGenerationService.cs (1)
150TypeId = t.TypeId,
Aspire.Hosting.RemoteHost.Tests (24)
AtsCapabilityScannerTests.cs (20)
160Assert.Equal("string[]", itemsType.TypeId); 165Assert.Equal("string[]", enumerableReturnCapability.ReturnType.TypeId); 179Assert.Equal(expectedElementTypeId, typeRef.ElementType.TypeId); 194Assert.Contains(parameter.Type.UnionTypes!, type => type.TypeId == AtsConstants.String); 337Assert.Contains(resourceParameter.Type!.UnionTypes!, type => type.TypeId == "string"); 338Assert.Contains(resourceParameter.Type.UnionTypes!, type => type.TypeId == "Aspire.Hosting/Aspire.Hosting.ApplicationModel.IResource"); 426Assert.Equal(AtsTypeMapping.DeriveTypeId(typeof(HttpCommandExportOptions)), optionsParameter.Type.TypeId); 441Assert.Equal(AtsTypeMapping.DeriveTypeId(typeof(HttpCommandPrepareRequestContext)), callbackParameter.Type.TypeId); 443Assert.Equal(AtsTypeMapping.DeriveTypeId(typeof(HttpCommandRequestExportData)), prepareRequestProperty.CallbackReturnType?.TypeId); 472t => t.TypeId == AtsTypeMapping.DeriveTypeId(typeof(DerivedExportedProperties))); 491Assert.Equal(AtsConstants.String, nameGetter.ReturnType.TypeId); 496Assert.Equal(AtsConstants.String, descriptionGetter.ReturnType.TypeId); 517Assert.Equal(AtsConstants.String, nullableString.Type.TypeId); 522Assert.Equal(AtsConstants.String, requiredString.Type.TypeId); 527Assert.Equal(AtsConstants.Number, nullableNumber.Type.TypeId); 532Assert.Equal(AtsConstants.Number, requiredNumber.Type.TypeId); 627Assert.DoesNotContain(genericCapability.ExpandedTargetTypes, t => t.TypeId == shadowedTypeId); 628Assert.Contains(genericCapability.ExpandedTargetTypes, t => t.TypeId == otherTypeId); 629Assert.Contains(specificCapability.ExpandedTargetTypes, t => t.TypeId == shadowedTypeId); 684Assert.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);
ExternalCapabilityRegistryTests.cs (2)
543Assert.Equal("string", capability.ReturnType!.TypeId); 571Assert.Equal("string", capability.ReturnType!.TypeId);