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