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