1 write to Type
System.Text.Json (1)
System\Text\Json\Serialization\Metadata\JsonTypeInfo.cs (1)
44
Type
= type;
148 references to Type
Microsoft.AspNetCore.Http.Extensions (3)
src\Shared\Json\JsonSerializerExtensions.cs (3)
14
=> jsonTypeInfo.
Type
.IsSealed || jsonTypeInfo.
Type
.IsValueType || jsonTypeInfo.PolymorphismOptions is not null;
17
=> runtimeType is null || jsonTypeInfo.
Type
== runtimeType || jsonTypeInfo.HasKnownPolymorphism();
Microsoft.AspNetCore.Http.Results (5)
HttpResultsHelper.cs (1)
43
Log.WritingResultAsJson(logger, jsonTypeInfo.
Type
.Name);
JsonHttpResultOfT.cs (1)
110
HttpResultsHelper.Log.WritingResultAsJson(logger, JsonTypeInfo.
Type
.Name);
src\Shared\Json\JsonSerializerExtensions.cs (3)
14
=> jsonTypeInfo.
Type
.IsSealed || jsonTypeInfo.
Type
.IsValueType || jsonTypeInfo.PolymorphismOptions is not null;
17
=> runtimeType is null || jsonTypeInfo.
Type
== runtimeType || jsonTypeInfo.HasKnownPolymorphism();
Microsoft.AspNetCore.Mvc.Core (3)
src\Shared\Json\JsonSerializerExtensions.cs (3)
14
=> jsonTypeInfo.
Type
.IsSealed || jsonTypeInfo.
Type
.IsValueType || jsonTypeInfo.PolymorphismOptions is not null;
17
=> runtimeType is null || jsonTypeInfo.
Type
== runtimeType || jsonTypeInfo.HasKnownPolymorphism();
Microsoft.AspNetCore.OpenApi (5)
Extensions\JsonNodeSchemaExtensions.cs (3)
190
var type = context.TypeInfo.
Type
;
419
return !context.TypeInfo.
Type
.IsAbstract
421
&& !polymorphismOptions.DerivedTypes.Any(type => type.DerivedType == context.TypeInfo.
Type
);
Extensions\JsonTypeInfoExtensions.cs (1)
55
var type = jsonTypeInfo.
Type
;
Services\Schemas\OpenApiSchemaService.cs (1)
61
var type = context.TypeInfo.
Type
;
Microsoft.AspNetCore.OpenApi.Microbenchmarks (2)
TransformersBenchmark.cs (2)
105
if (context.JsonTypeInfo.
Type
== typeof(Todo) && context.ParameterDescription != null)
178
if (context.JsonTypeInfo.
Type
== typeof(Todo) && context.ParameterDescription != null)
Microsoft.AspNetCore.OpenApi.Tests (38)
Services\CreateSchemaReferenceIdTests.cs (8)
22
return jsonTypeInfo.
Type
.Name switch
27
_ => jsonTypeInfo.
Type
.Name,
68
var options = new OpenApiOptions { CreateSchemaReferenceId = (type) => type.
Type
.Name == "Todo" ? $"{type.
Type
.Name}Schema" : OpenApiOptions.CreateDefaultSchemaReferenceId(type) };
117
var options = new OpenApiOptions { CreateSchemaReferenceId = (type) => type.
Type
.Name == "Todo" ? null : OpenApiOptions.CreateDefaultSchemaReferenceId(type) };
169
if (type.
Type
.Name == "Todo")
212
if (type.
Type
.Name == "TodoWithDueDate" || type.
Type
.Name == "Todo")
Transformers\Implementations\OpenApiSchemaReferenceTransformerTests.cs (2)
279
if (context.JsonTypeInfo.
Type
== typeof(Todo) && context.ParameterDescription is not null)
464
if (context.JsonTypeInfo.
Type
== typeof(Todo))
Transformers\SchemaTransformerTests.cs (27)
33
Assert.Equal(typeof(Todo), context.JsonTypeInfo.
Type
);
47
Assert.Equal(typeof(Todo), context.JsonTypeInfo.
Type
);
52
Assert.Equal(typeof(int), context.JsonTypeInfo.
Type
);
56
Assert.Equal(typeof(string), context.JsonTypeInfo.
Type
);
60
Assert.Equal(typeof(bool), context.JsonTypeInfo.
Type
);
64
Assert.Equal(typeof(DateTime), context.JsonTypeInfo.
Type
);
81
Assert.Equal(typeof(Todo), context.JsonTypeInfo.
Type
);
85
Assert.Equal(typeof(int), context.JsonTypeInfo.
Type
);
89
Assert.Equal(typeof(string), context.JsonTypeInfo.
Type
);
93
Assert.Equal(typeof(bool), context.JsonTypeInfo.
Type
);
97
Assert.Equal(typeof(DateTime), context.JsonTypeInfo.
Type
);
184
if (context.JsonTypeInfo.
Type
== typeof(Todo))
214
if (context.JsonTypeInfo.
Type
== typeof(Todo) && context.ParameterDescription is not null)
418
if (context.JsonTypeInfo.
Type
== typeof(int))
451
if (context.JsonTypeInfo.
Type
== typeof(int))
486
if (context.JsonTypeInfo.
Type
== typeof(Triangle))
521
if (context.JsonTypeInfo.
Type
== typeof(int))
556
if (context.JsonTypeInfo.
Type
== typeof(Triangle))
560
if (context.JsonTypeInfo.
Type
== typeof(Square))
597
if (context.JsonTypeInfo.
Type
== typeof(Triangle))
601
if (context.JsonTypeInfo.
Type
== typeof(Square))
638
if (context.JsonTypeInfo.
Type
== typeof(Triangle))
642
if (context.JsonTypeInfo.
Type
== typeof(Square))
679
if (context.JsonTypeInfo.
Type
== typeof(int))
714
if (context.JsonTypeInfo.
Type
== typeof(Todo))
718
if (context.JsonTypeInfo.
Type
== typeof(Triangle))
850
if (context.JsonTypeInfo.
Type
== typeof(Todo))
Transformers\TypeBasedTransformerLifetimeTests.cs (1)
349
if (context.JsonTypeInfo.
Type
== typeof(Todo))
Microsoft.AspNetCore.Routing (3)
src\Shared\Json\JsonSerializerExtensions.cs (3)
14
=> jsonTypeInfo.
Type
.IsSealed || jsonTypeInfo.
Type
.IsValueType || jsonTypeInfo.PolymorphismOptions is not null;
17
=> runtimeType is null || jsonTypeInfo.
Type
== runtimeType || jsonTypeInfo.HasKnownPolymorphism();
Microsoft.Extensions.AI.Abstractions (2)
Utilities\AIJsonSchemaCreateContext.cs (1)
100
GetCustomAttr(TypeInfo.
Type
);
Utilities\AIJsonUtilities.Schema.cs (1)
273
if (key.IncludeTypeInEnumSchemas && ctx.TypeInfo.
Type
.IsEnum && objSchema.ContainsKey(EnumPropertyName) && !objSchema.ContainsKey(TypePropertyName))
Microsoft.Extensions.AI.Abstractions.Tests (2)
test\Shared\JsonSchemaExporter\TestTypes.cs (1)
1310
GetAttrs(ctx.TypeInfo.
Type
);
Utilities\AIJsonUtilitiesTests.cs (1)
157
return context.TypeInfo.
Type
== typeof(int) && context.GetCustomAttribute<DescriptionAttribute>() is DescriptionAttribute attr
Microsoft.Extensions.AI.Tests (1)
ChatCompletion\DistributedCachingChatClientTest.cs (1)
632
if (typeInfo.
Type
== typeof(AIContent))
Shared (17)
JsonSchemaExporter\JsonSchemaExporter.cs (16)
133
if (!typeInfo.
Type
.IsAbstract && !derivedTypes.Any(derived => derived.DerivedType == typeInfo.
Type
))
137
derivedTypes.Add(new JsonDerivedType(typeInfo.
Type
));
222
if (Nullable.GetUnderlyingType(typeInfo.
Type
) is Type nullableElementType)
230
Debug.Assert(elementTypeInfo.
Type
.IsEnum, "The enum keyword should only be populated by schemas for enum types.");
262
ReflectionHelpers.ResolveJsonConstructorParameterMapper(typeInfo.
Type
, typeInfo);
276
ICustomAttributeProvider? attributeProvider = ReflectionHelpers.ResolveAttributeProvider(typeInfo.
Type
, property);
311
parentType: typeInfo.
Type
,
428
if (_simpleTypeSchemaFactories.TryGetValue(typeInfo.
Type
, out Func<JsonNumberHandling, JsonSchema>? simpleTypeSchemaFactory))
432
else if (typeInfo.
Type
.IsEnum)
465
return ReflectionHelpers.CanBeNull(typeInfo.
Type
) &&
708
Debug.Assert(parameterTypeInfo.
Type
== parameter.ParameterType, "The typeInfo type must match the ParameterInfo type.");
732
Debug.Assert(typeInfo.
Type
.IsEnum && ReflectionHelpers.IsBuiltInConverter(converter), "must be using a built-in enum converter.");
736
converter = factory.CreateConverter(typeInfo.
Type
, typeInfo.Options)!;
746
if (typeInfo.
Type
.GetCustomAttribute<FlagsAttribute>() is not null)
753
foreach (string name in Enum.GetNames(typeInfo.
Type
))
JsonSchemaExporter\JsonSchemaExporter.ReflectionHelpers.cs (1)
147
Debug.Assert(type == typeInfo.
Type
, "The declaring type must match the typeInfo type.");
System.Net.Http.Json (3)
System\Net\Http\Json\JsonContent.cs (3)
19
public Type ObjectType => _typeInfo.
Type
;
28
Debug.Assert(inputValue is null || jsonTypeInfo.
Type
.IsAssignableFrom(inputValue.GetType()));
99
EnsureTypeCompatibility(inputValue, jsonTypeInfo.
Type
);
System.Text.Json (64)
System\Text\Json\Schema\JsonSchemaExporter.cs (4)
104
if (!typeInfo.
Type
.IsAbstract && !IsPolymorphicTypeThatSpecifiesItselfAsDerivedType(typeInfo))
108
derivedTypes.Add(new JsonDerivedType(typeInfo.
Type
));
197
Debug.Assert(elementTypeInfo.
Type
.IsEnum, "The enum keyword should only be populated by schemas for enum types.");
399
if (derivedType.DerivedType == typeInfo.
Type
)
System\Text\Json\Serialization\Converters\Collection\ListOfTConverter.cs (1)
30
ThrowHelper.ThrowNotSupportedException_SerializationNotSupported(state.Current.JsonTypeInfo.
Type
);
System\Text\Json\Serialization\Converters\Collection\QueueOfTConverter.cs (1)
28
ThrowHelper.ThrowNotSupportedException_SerializationNotSupported(state.Current.JsonTypeInfo.
Type
);
System\Text\Json\Serialization\Converters\Collection\StackOfTConverter.cs (1)
29
ThrowHelper.ThrowNotSupportedException_SerializationNotSupported(state.Current.JsonTypeInfo.
Type
);
System\Text\Json\Serialization\Converters\Object\ObjectWithParameterizedConstructorConverter.Large.cs (1)
27
ThrowHelper.ThrowJsonException_ConstructorParameterDisallowNull(jsonParameterInfo.Name, state.Current.JsonTypeInfo.
Type
);
System\Text\Json\Serialization\Converters\Object\ObjectWithParameterizedConstructorConverter.Small.cs (1)
80
ThrowHelper.ThrowJsonException_ConstructorParameterDisallowNull(info.Name, state.Current.JsonTypeInfo.
Type
);
System\Text\Json\Serialization\JsonConverter.MetadataHandling.cs (3)
33
Debug.Assert(Type!.IsAssignableFrom(resolvedType.
Type
));
38
ThrowHelper.ThrowNotSupportedException_DerivedConverterDoesNotSupportMetadata(resolvedType.
Type
);
104
ThrowHelper.ThrowNotSupportedException_DerivedConverterDoesNotSupportMetadata(derivedJsonTypeInfo.
Type
);
System\Text\Json\Serialization\JsonConverterOfT.cs (2)
235
Debug.Assert(Type == state.Current.JsonTypeInfo.
Type
);
415
Debug.Assert(Type == state.Current.JsonTypeInfo.
Type
);
System\Text\Json\Serialization\JsonConverterOfT.ReadCore.cs (1)
40
bool success = TryRead(ref reader, state.Current.JsonTypeInfo.
Type
, options, ref state, out value, out _);
System\Text\Json\Serialization\JsonSerializer.Read.HandleMetadata.cs (2)
155
ThrowHelper.ThrowJsonException_MetadataInvalidPropertyInArrayMetadata(ref state, jsonTypeInfo.
Type
, reader);
176
ThrowHelper.ThrowJsonException_MetadataInvalidPropertyInArrayMetadata(ref state, jsonTypeInfo.
Type
, reader);
System\Text\Json\Serialization\JsonSerializer.Read.HandlePropertyName.cs (1)
48
ThrowHelper.ThrowJsonException_UnmappedJsonProperty(jsonTypeInfo.
Type
, stringPropertyName);
System\Text\Json\Serialization\JsonSerializerOptions.Caching.cs (1)
157
if (jsonTypeInfo?.
Type
!= type)
System\Text\Json\Serialization\JsonSerializerOptions.cs (2)
996
if (info.
Type
!= type)
998
ThrowHelper.ThrowInvalidOperationException_ResolverTypeNotCompatible(type, info.
Type
);
System\Text\Json\Serialization\Metadata\DefaultJsonTypeInfoResolver.Helpers.cs (5)
50
if (GetNumberHandlingForType(typeInfo.
Type
) is { } numberHandling)
55
if (GetObjectCreationHandlingForType(typeInfo.
Type
) is { } creationHandling)
60
if (GetUnmappedMemberHandling(typeInfo.
Type
) is { } unmappedMemberHandling)
108
foreach (Type currentType in typeInfo.
Type
.GetSortedTypeHierarchy())
148
Debug.Assert(currentType.IsAssignableFrom(typeInfo.
Type
));
System\Text\Json\Serialization\Metadata\JsonMetadataServices.Helpers.cs (1)
138
Debug.Assert(typeInfo.
Type
!= JsonTypeInfo.ObjectType);
System\Text\Json\Serialization\Metadata\JsonPropertyInfo.cs (1)
376
Debug.Assert(declaringTypeInfo is null || declaringType.IsAssignableFrom(declaringTypeInfo.
Type
));
System\Text\Json\Serialization\Metadata\JsonPropertyInfoOfT.cs (4)
214
ThrowHelper.ThrowJsonException_PropertyGetterDisallowNull(Name, state.Current.JsonTypeInfo.
Type
);
298
ThrowHelper.ThrowJsonException_PropertySetterDisallowNull(Name, state.Current.JsonTypeInfo.
Type
);
321
ThrowHelper.ThrowJsonException_PropertySetterDisallowNull(Name, state.Current.JsonTypeInfo.
Type
);
350
ThrowHelper.ThrowJsonException_PropertySetterDisallowNull(Name, state.Current.JsonTypeInfo.
Type
);
System\Text\Json\Serialization\Metadata\JsonTypeInfo.cs (10)
194
ThrowHelper.ThrowInvalidOperationException_JsonTypeInfoOnDeserializingCallbacksNotSupported(
Type
);
376
ThrowHelper.ThrowInvalidOperationException_NoMetadataForTypeProperties(Options.TypeInfoResolver,
Type
);
401
Debug.Assert(value is null || value.
Type
== ElementType);
427
Debug.Assert(value is null || value.
Type
== KeyType);
441
/// Gets the <see cref="
Type
"/> for which the JSON serialization contract is being defined.
751
PolymorphicTypeResolver = new PolymorphicTypeResolver(Options, PolymorphismOptions,
Type
, Converter.CanHaveMetadata);
791
Debug.Assert(
Type
!= typeof(object));
979
Debug.Assert(jsonTypeInfo.
Type
== type);
1008
ThrowHelper.ThrowArgumentException_CannotSerializeInvalidType(nameof(propertyType), propertyType,
Type
, name);
1038
parameters: new object[] { declaringType ??
Type
, this, Options })!;
System\Text\Json\Serialization\Metadata\JsonTypeInfoOfT.cs (2)
75
ThrowHelper.ThrowInvalidOperationException_CreateObjectConverterNotCompatible(
Type
);
152
return new JsonPropertyInfo<T>(declaringType ?? declaringTypeInfo.
Type
, declaringTypeInfo, options)
System\Text\Json\Serialization\Metadata\PolymorphicTypeResolver.cs (7)
104
ThrowHelper.ThrowInvalidOperationException_PropertyConflictsWithMetadataPropertyName(derivedTypeInfo.JsonTypeInfo.
Type
, propertyName);
239
ThrowHelper.ThrowNotSupportedException_RuntimeTypeDiamondAmbiguity(BaseType, type, result.JsonTypeInfo.
Type
, interfaceResult.JsonTypeInfo.
Type
);
267
for (Type? candidate = typeInfo.
Type
.BaseType; candidate != null; candidate = candidate.BaseType)
279
foreach (Type interfaceType in typeInfo.
Type
.GetInterfaces())
287
if (matchingResult.
Type
.IsAssignableFrom(interfaceType))
292
else if (interfaceType.IsAssignableFrom(matchingResult.
Type
))
System\Text\Json\Serialization\ReadStack.cs (1)
399
private string DebuggerDisplay => $"Path = {JsonPath()}, Current = ConverterStrategy.{Current.JsonTypeInfo?.Converter.ConverterStrategy}, {Current.JsonTypeInfo?.
Type
.Name}";
System\Text\Json\Serialization\ReadStackFrame.cs (1)
166
private string DebuggerDisplay => $"ConverterStrategy.{JsonTypeInfo?.Converter.ConverterStrategy}, {JsonTypeInfo?.
Type
.Name}";
System\Text\Json\Serialization\WriteStack.cs (2)
167
rootValueBoxed is not null && jsonTypeInfo.
Type
.IsValueType)
446
private string DebuggerDisplay => $"Path = {PropertyPath()} Current = ConverterStrategy.{Current.JsonPropertyInfo?.EffectiveConverter.ConverterStrategy}, {Current.JsonTypeInfo?.
Type
.Name}";
System\Text\Json\Serialization\WriteStackFrame.cs (2)
124
if (PolymorphicTypeInfo?.
Type
!= runtimeType)
169
private readonly string DebuggerDisplay => $"ConverterStrategy.{JsonTypeInfo?.Converter.ConverterStrategy}, {JsonTypeInfo?.
Type
.Name}";
System\Text\Json\ThrowHelper.Serialization.cs (7)
323
throw new JsonException(SR.Format(SR.JsonRequiredPropertiesMissing, parent.
Type
, listOfMissingPropertiesBuilder.ToString()));
407
SR.Format(SR.ObjectWithParameterizedCtorRefMetadataNotSupported, jsonTypeInfo.
Type
));
481
Type propertyType = state.Current.JsonPropertyInfo?.PropertyType ?? state.Current.JsonTypeInfo.
Type
;
575
Type propertyType = state.Current.JsonPropertyInfo?.PropertyType ?? state.Current.JsonTypeInfo.
Type
;
603
Type propertyType = state.Current.JsonPropertyInfo?.PropertyType ?? state.Current.JsonTypeInfo.
Type
;
623
Type type = typeInfo.
Type
;
791
throw new InvalidOperationException(SR.Format(SR.JsonPropertyInfoBoundToDifferentParent, propertyInfo.Name, propertyInfo.DeclaringTypeInfo.
Type
.FullName));