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