254 references to ModelType
HtmlGenerationWebSite (3)
Components\CheckViewData - LackModel.cs (2)
18writer.WriteLine($"<div class=\"col-md-3\">ModelType: '{ metadata.ModelType.Name }'</div>"); 31writer.WriteLine($"<div class=\"col-md-3\">ModelType: '{ metadata.ModelType.Name }'</div>");
Components\CheckViewData.cs (1)
17writer.WriteLine($"<div class=\"col-md-3\">ModelType: '{ metadata.ModelType.Name }'</div>");
Microsoft.AspNetCore.Mvc.Abstractions (43)
Formatters\InputFormatterContext.cs (1)
80ModelType = metadata.ModelType;
ModelBinding\ModelBindingContext.cs (1)
90public virtual Type ModelType => ModelMetadata.ModelType;
ModelBinding\ModelMetadata.cs (41)
147&& p.ModelType == metadata.ModelType)) 223/// Gets the name of the model's datatype. Overrides <see cref="ModelType"/> in some 251/// Gets the <see cref="ModelMetadata"/> for elements of <see cref="ModelType"/> if that <see cref="Type"/> 255/// <see cref="ModelMetadata"/> for <c>T</c> if <see cref="ModelType"/> implements 256/// <see cref="IEnumerable{T}"/>. <see cref="ModelMetadata"/> for <c>object</c> if <see cref="ModelType"/> 449/// Gets the <see cref="Type"/> for elements of <see cref="ModelType"/> if that <see cref="Type"/> 471/// Gets a value indicating whether <see cref="ModelType"/> is a complex type. 489/// Gets a value indicating whether or not <see cref="ModelType"/> is a <see cref="Nullable{T}"/>. 496/// Gets a value indicating whether or not <see cref="ModelType"/> is a collection type. 520/// Gets a value indicating whether or not <see cref="ModelType"/> is an enumerable type. 529/// Gets a value indicating whether or not <see cref="ModelType"/> allows <c>null</c> values. 534/// Gets the underlying type argument if <see cref="ModelType"/> inherits from <see cref="Nullable{T}"/>. 535/// Otherwise gets <see cref="ModelType"/>. 538/// Identical to <see cref="ModelType"/> unless <see cref="IsNullableValueType"/> is <c>true</c>. 545/// Gets a value indicating whether or not <see cref="ModelType"/> has a TryParse method. 568/// Gets a value indicating whether or not <see cref="ModelType"/> has a <see cref="TypeConverter"/> 674p.ModelType == parameter.ModelType); 688Resources.FormatRecordTypeHasValidationOnProperties(ModelType, property.Name)); 708return DisplayName ?? Name ?? ModelType.Name; 749Debug.Assert(ModelType != null); 751IsNullableValueType = Nullable.GetUnderlyingType(ModelType) != null; 752IsReferenceOrNullableType = !ModelType.IsValueType || IsNullableValueType; 753UnderlyingOrModelType = Nullable.GetUnderlyingType(ModelType) ?? ModelType; 765if (ModelType.IsArray) 768ElementType = ModelType.GetElementType()!; 776Debug.Assert(ModelType != null); 777IsConvertibleType = TypeDescriptor.GetConverter(ModelType).CanConvertFrom(typeof(string)); 778IsParseableType = FindTryParseMethod(ModelType) is not null; 780var collectionType = ClosedGenericMatcher.ExtractGenericInterface(ModelType, typeof(ICollection<>)); 783if (ModelType != typeof(string) && !ModelType.IsArray && typeof(IEnumerable).IsAssignableFrom(ModelType)) 786var enumerableType = ClosedGenericMatcher.ExtractGenericInterface(ModelType, typeof(IEnumerable<>)); 792$"Unable to find element type for '{ModelType.FullName}' though IsEnumerableType is true."); 801return $"ModelMetadata (Parameter: '{ParameterName}' Type: '{ModelType.Name}')"; 803return $"ModelMetadata (Property: '{ContainerType!.Name}.{PropertyName}' Type: '{ModelType.Name}')"; 805return $"ModelMetadata (Type: '{ModelType.Name}')"; 807return $"ModelMetadata (Constructor: '{ModelType.Name}')";
Microsoft.AspNetCore.Mvc.ApiExplorer (2)
DefaultApiDescriptionProvider.cs (2)
674return EndpointModelMetadata.GetDisplayType(metadata.ModelType); 677return metadata.ModelType;
Microsoft.AspNetCore.Mvc.ApiExplorer.Test (44)
EndpointMetadataApiDescriptionProviderTest.cs (44)
140Assert.Equal(expectedType, responseType.ModelMetadata?.ModelType); 159Assert.Equal(typeof(string), responseType.ModelMetadata?.ModelType); 174Assert.Equal(typeof(void), responseType.ModelMetadata?.ModelType); 198Assert.Equal(typeof(InferredJsonClass), inferredResponseType.ModelMetadata?.ModelType); 206Assert.Equal(typeof(TimeSpan), annotatedResponseType.ModelMetadata?.ModelType); 225Assert.Equal(typeof(InferredJsonClass), rdfInferredResponseType.ModelMetadata?.ModelType); 234Assert.Equal(typeof(TimeSpan), createdResponseType.ModelMetadata?.ModelType); 243Assert.Equal(typeof(InferredJsonClass), badRequestResponseType.ModelMetadata?.ModelType); 263Assert.Equal(typeof(InferredJsonClass), createdResponseType.ModelMetadata?.ModelType); 272Assert.Equal(typeof(void), badRequestResponseType.ModelMetadata?.ModelType); 289Assert.Equal(typeof(InferredJsonClass), createdResponseType.ModelMetadata?.ModelType); 298Assert.Equal(typeof(void), badRequestResponseType.ModelMetadata?.ModelType); 314Assert.Equal(typeof(InferredJsonClass), createdResponseType.ModelMetadata?.ModelType); 332Assert.Equal(typeof(void), responseType.ModelMetadata?.ModelType); 347Assert.Equal(typeof(InferredJsonClass), createdResponseType.ModelMetadata?.ModelType); 368Assert.Equal(typeof(InferredJsonClass), createdResponseType.ModelMetadata?.ModelType); 377Assert.Equal(typeof(void), badRequestResponseType.ModelMetadata?.ModelType); 402Assert.Equal(typeof(InferredJsonClass), createdResponseType.ModelMetadata?.ModelType); 411Assert.Equal(typeof(void), badRequestResponseType.ModelMetadata?.ModelType); 423Assert.Equal(typeof(int), param.ModelMetadata.ModelType); 438Assert.Equal(typeof(string), param.ModelMetadata.ModelType); 452Assert.Equal(typeof(int), param.ModelMetadata.ModelType); 466Assert.Equal(expectedTYpe, param.ModelMetadata.ModelType); 487Assert.Equal(expectedTYpe, param.ModelMetadata.ModelType); 508Assert.Equal(typeof(int?), param.ModelMetadata.ModelType); 522Assert.Equal(typeof(string), param.ModelMetadata.ModelType); 536Assert.Equal(typeof(T), param.ModelMetadata.ModelType); 558Assert.Equal(typeof(T), param.ModelMetadata.ModelType); 574Assert.Equal(typeof(int), param.ModelMetadata.ModelType); 600Assert.Equal(expectedType, param.ModelMetadata.ModelType); 626Assert.Equal(typeof(int), fooParam.ModelMetadata.ModelType); 633Assert.Equal(typeof(int), barParam.ModelMetadata.ModelType); 640Assert.Equal(typeof(InferredJsonClass), fromBodyParam.ModelMetadata.ModelType); 656Assert.Equal(typeof(int), param.ModelMetadata.ModelType); 663Assert.Equal(typeof(int), param.ModelMetadata.ModelType); 671Assert.Equal(typeof(InferredJsonClass), param.ModelMetadata.ModelType); 747Assert.Equal(typeof(int), fooParam.ModelMetadata.ModelType); 753Assert.Equal(typeof(int?), barParam.ModelMetadata.ModelType); 792Assert.Equal(typeof(string), fooParam.ModelMetadata.ModelType); 798Assert.Equal(typeof(int), barParam.ModelMetadata.ModelType); 811Assert.Equal(typeof(string), nameParam.ModelMetadata.ModelType); 1296Assert.Equal(typeof(IFormFile), fromFileParam0.ModelMetadata.ModelType); 1302Assert.Equal(typeof(IFormFile), fromFileParam1.ModelMetadata.ModelType); 1314Assert.Equal(expectedType, param.ModelMetadata.ModelType);
Microsoft.AspNetCore.Mvc.Core (49)
ModelBinding\Binders\ArrayModelBinderProvider.cs (2)
22if (context.Metadata.ModelType.IsArray) 24var elementType = context.Metadata.ElementMetadata!.ModelType;
ModelBinding\Binders\ByteArrayModelBinderProvider.cs (1)
21if (context.Metadata.ModelType == typeof(byte[]))
ModelBinding\Binders\CancellationTokenModelBinderProvider.cs (1)
22if (context.Metadata.ModelType == typeof(CancellationToken))
ModelBinding\Binders\CollectionModelBinderProvider.cs (1)
23var modelType = context.Metadata.ModelType;
ModelBinding\Binders\ComplexObjectModelBinder.cs (2)
427return CanUpdateReadOnlyProperty(propertyMetadata.ModelType); 449!property.ModelType.IsArray)
ModelBinding\Binders\ComplexTypeModelBinder.cs (2)
269!property.ModelType.IsArray) 425return !propertyMetadata.IsReadOnly || CanUpdateReadOnlyProperty(propertyMetadata.ModelType);
ModelBinding\Binders\DictionaryModelBinderProvider.cs (1)
23var modelType = context.Metadata.ModelType;
ModelBinding\Binders\FormCollectionModelBinderProvider.cs (1)
23var modelType = context.Metadata.ModelType;
ModelBinding\Binders\FormFileModelBinderProvider.cs (1)
24var modelType = context.Metadata.ModelType;
ModelBinding\Binders\HeaderModelBinderProvider.cs (2)
34Log.CannotCreateHeaderModelBinder(logger, modelMetadata.ModelType); 47modelMetadata.GetMetadataForType(modelMetadata.ModelType),
ModelBinding\Binders\KeyValuePairModelBinderProvider.cs (1)
21var modelType = context.Metadata.ModelType;
ModelBinding\Binders\ServicesModelBinderProvider.cs (1)
31!context.Metadata.ModelType.IsValueType &&
ModelBinding\Binders\SimpleTypeModelBinderProvider.cs (1)
24return new SimpleTypeModelBinder(context.Metadata.ModelType, loggerFactory);
ModelBinding\Binders\TryParseModelBinderProvider.cs (1)
22return new TryParseModelBinder(context.Metadata.ModelType, loggerFactory);
ModelBinding\DefaultModelBindingContext.cs (1)
288var rootModelType = states[states.Length - 1].ModelMetadata.ModelType;
ModelBinding\Metadata\DefaultModelMetadata.cs (2)
366var properties = _provider.GetMetadataForProperties(ModelType); 388_constructorMetadata = modelMetadataProvider.GetMetadataForConstructor(BindingMetadata.BoundConstructor, ModelType);
ModelBinding\ModelBinderFactory.cs (4)
75var message = Resources.FormatCouldNotCreateIModelBinder(providerContext.Metadata.ModelType); 311return $"{_token} (Parameter: '{_metadata.ParameterName}' Type: '{_metadata.ModelType.Name}')"; 314$"Type: '{_metadata.ModelType.Name}')"; 316return $"{_token} (Type: '{_metadata.ModelType.Name}')";
ModelBinding\ParameterBinder.Log.cs (16)
28AttemptingToBindParameter(logger, modelMetadata.ParameterName, modelMetadata.ModelType); 35modelMetadata.ModelType); 43modelMetadata.ModelType); 49AttemptingToBindParameter(logger, parameter.Name, modelMetadata.ModelType); 74DoneAttemptingToBindParameter(logger, modelMetadata.ParameterName, modelMetadata.ModelType); 81modelMetadata.ModelType); 89modelMetadata.ModelType); 95DoneAttemptingToBindParameter(logger, parameter.Name, modelMetadata.ModelType); 120AttemptingToValidateParameter(logger, modelMetadata.ParameterName, modelMetadata.ModelType); 127modelMetadata.ModelType); 135modelMetadata.ModelType); 142AttemptingToValidateParameter(logger, parameter.Name, modelMetadata.ModelType); 170modelMetadata.ModelType); 177modelMetadata.ModelType); 185modelMetadata.ModelType); 192DoneAttemptingToValidateParameter(logger, parameter.Name, modelMetadata.ModelType);
ModelBinding\PropertyValueSetter.cs (2)
31if (metadata.ModelType.IsArray) 53metadata.ElementMetadata!.ModelType);
ModelBinding\Validation\DefaultComplexObjectValidationStrategy.cs (1)
99Resources.FormatValidationStrategy_MappedPropertyNotFound(parameterName, _modelMetadata.ModelType));
ModelBinding\Validation\ValidationVisitor.cs (1)
307message = Resources.FormatValidationVisitor_ExceededMaxDepth(nameof(ValidationVisitor), MaxValidationDepth, metadata.ModelType);
MvcCoreLoggerExtensions.cs (4)
182modelMetadata.ModelType, 190modelMetadata.ModelType, 222modelMetadata.ModelType); 229modelMetadata.ModelType);
Microsoft.AspNetCore.Mvc.Core.Test (45)
ModelBinding\Binders\ArrayModelBinderProviderTest.cs (3)
40Assert.Equal(modelType.GetElementType(), m.ModelType); 60Assert.Equal(typeof(int), m.ModelType); 90Assert.Equal(typeof(int), m.ModelType);
ModelBinding\Binders\CollectionModelBinderProviderTest.cs (3)
53Assert.Equal(typeof(int), m.ModelType); 54elementType = m.ModelType; 75Assert.Equal(typeof(int), m.ModelType);
ModelBinding\Binders\ComplexObjectModelBinderProviderTest.cs (4)
37if (m.ModelType == typeof(int) || m.ModelType == typeof(string)) 64if (m.ModelType == typeof(int) || m.ModelType == typeof(string))
ModelBinding\Binders\ComplexObjectModelBinderTest.cs (1)
423var canUpdate = ComplexObjectModelBinder.CanUpdateReadOnlyProperty(metadata.ModelType);
ModelBinding\Binders\ComplexTypeModelBinderProviderTest.cs (4)
37if (m.ModelType == typeof(int) || m.ModelType == typeof(string)) 64if (m.ModelType == typeof(int) || m.ModelType == typeof(string))
ModelBinding\Binders\DictionaryModelBinderProviderTest.cs (3)
40if (m.ModelType == typeof(KeyValuePair<string, int>) || 41m.ModelType == typeof(int) || 42m.ModelType == typeof(string))
ModelBinding\Binders\KeyValuePairModelBinderProviderTest.cs (2)
38if (m.ModelType == typeof(string) || m.ModelType == typeof(int))
ModelBinding\Metadata\DefaultModelMetadataProviderTest.cs (5)
76Assert.Equal(modelType, propertyMetadata.ContainerMetadata.ModelType); 82Assert.Equal(modelType, propertyMetadata.ContainerMetadata.ModelType); 179Assert.Equal(typeof(string), propertyMetadata.ModelType); 278Assert.Equal(typeof(DerivedModelType), metadata.ModelType); 362Assert.Equal(typeof(DerivedModelType), metadata.ModelType);
ModelBinding\Metadata\DefaultModelMetadataTest.cs (4)
32Assert.Equal(typeof(string), metadata.ModelType); 90Assert.Equal(typeof(Exception), metadata.ModelType); 109Assert.Equal(typeof(string), metadata.ModelType); 273Assert.Equal(elementType, elementMetadata.ModelType);
ModelBinding\ModelBinderFactoryTest.cs (16)
72if (c.Metadata.ModelType == typeof(Widget)) 112if (c.Metadata.ModelType == typeof(WidgetId)) 147if (c.Metadata.ModelType == typeof(Widget)) 152else if (c.Metadata.ModelType == typeof(WidgetId)) 189Assert.Equal(typeof(Employee), c.Metadata.ModelType); 226Assert.Equal(typeof(Employee), c.Metadata.ModelType); 257Assert.Equal(typeof(Employee), c.Metadata.ModelType); 358Assert.Equal(typeof(Employee), context.Metadata.ModelType); 401if (c.Metadata.ModelType == typeof(Widget)) 421Assert.Equal(typeof(WidgetId), c.Metadata.ModelType); 462if (c.Metadata.ModelType == typeof(Widget)) 483Assert.Equal(typeof(WidgetId), c.Metadata.ModelType); 526if (c.Metadata.ModelType == typeof(Widget)) 537Assert.Equal(typeof(WidgetId), c.Metadata.ModelType); 589if (c.Metadata.ModelType == typeof(Widget)) 600Assert.Equal(typeof(WidgetId), c.Metadata.ModelType);
Microsoft.AspNetCore.Mvc.DataAnnotations (3)
DataAnnotationsClientModelValidatorProvider.cs (1)
54context.ModelMetadata.ContainerType ?? context.ModelMetadata.ModelType,
DataAnnotationsModelValidatorProvider.cs (2)
50context.ModelMetadata.ContainerType ?? context.ModelMetadata.ModelType, 87if (typeof(IValidatableObject).IsAssignableFrom(context.ModelMetadata.ModelType))
Microsoft.AspNetCore.Mvc.IntegrationTests (4)
ExcludeBindingMetadataProviderIntegrationTest.cs (1)
135if (context.Metadata.ModelType == typeof(Type))
ValidationIntegrationTests.cs (3)
2552v => Assert.Equal(typeof(ModelWithNonNullableReferenceTypeProperties), v.ModelType), 2553v => Assert.Equal(typeof(string), v.ModelType), 2554v => Assert.Equal(typeof(Delegate), v.ModelType));
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (1)
JsonPatchOperationsArrayProviderTests.cs (1)
46Assert.Equal(typeof(Operation[]), description.ModelMetadata.ModelType);
Microsoft.AspNetCore.Mvc.Razor.Test (9)
RazorPageCreateModelExpressionTest.cs (9)
124Assert.Equal(expectedType, modelExpression.Metadata.ModelType); 142Assert.Equal(typeof(int), result.Metadata.ModelType); 160Assert.Equal(typeof(int), result.Metadata.ModelType); 178Assert.Equal(typeof(int), result.Metadata.ModelType); 196Assert.Equal(typeof(int), result.Metadata.ModelType); 215Assert.Equal(typeof(string), result.Metadata.ModelType); 233Assert.Equal(typeof(string), result.Metadata.ModelType); 251Assert.Equal(typeof(string), result.Metadata.ModelType); 269Assert.Equal(typeof(string), result.Metadata.ModelType);
Microsoft.AspNetCore.Mvc.TagHelpers (1)
InputTagHelper.cs (1)
280/// <see cref="ModelMetadata.ModelType"/> base class, used to determine this method's return value.</param>
Microsoft.AspNetCore.Mvc.ViewFeatures (17)
DefaultDisplayTemplates.cs (1)
96if (elementMetadata.ModelType == typeof(object))
DefaultEditorTemplates.cs (1)
78if (elementMetadata.ModelType == typeof(object))
ExpressionMetadataProvider.cs (1)
201if (viewData.ModelMetadata.ModelType == typeof(object))
HtmlHelper.cs (2)
1365/// Thrown if <paramref name="metadata"/>'s <see cref="ModelMetadata.ModelType"/> is not an <see cref="Enum"/> 1375metadata.ModelType.FullName,
HtmlHelperOfT.cs (1)
70var runtimeType = viewContext.ViewData.ModelMetadata.ModelType;
ModelExplorer.cs (3)
151return Metadata.ModelType; 157return Metadata.ModelType; 402if (Metadata.ModelType != ModelType)
RemoteAttributeBase.cs (1)
187context.ModelMetadata.ContainerType ?? context.ModelMetadata.ModelType,
TemplateInfo.cs (1)
117return _visitedObjects.Contains(modelExplorer.Model ?? modelExplorer.Metadata.ModelType);
ViewDataDictionary.cs (6)
198source.ModelMetadata.ModelType == typeof(object) && 205else if (!declaredModelType.IsAssignableFrom(source.ModelMetadata.ModelType)) 210else if (modelType != null && !source.ModelMetadata.ModelType.IsAssignableFrom(modelType)) 444ModelMetadata.ModelType == typeof(object) && 452else if (modelType != null && !ModelMetadata.ModelType.IsAssignableFrom(modelType)) 465_declaredModelType != ModelMetadata.ModelType)
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (30)
ControllerTest.cs (1)
425Assert.Equal(expectedType, controller.ViewData.ModelMetadata.ModelType);
ModelExplorerTest.cs (3)
52Assert.Equal(typeof(int), baseProperty.Metadata.ModelType); 57Assert.Equal(typeof(string), derivedProperty.Metadata.ModelType); 76Assert.Equal(typeof(int), baseProperty.Metadata.ModelType);
Rendering\DefaultTemplatesUtilities.cs (2)
341metadata.ModelType == null ? "(null)" : metadata.ModelType.FullName,
Rendering\HtmlHelperSelectTest.cs (4)
1336Assert.Equal(metadata.ModelType, htmlHelper.Metadata.ModelType); 1396Assert.Equal(metadata.ModelType, htmlHelper.Metadata.ModelType);
ViewComponents\ViewComponentContextTest.cs (1)
108Assert.Equal(expectedType, viewComponentContext.ViewData.ModelMetadata.ModelType);
ViewDataDictionaryOfTModelTest.cs (15)
53Assert.Equal(typeof(TestModel), viewData1.ModelMetadata.ModelType); 65Assert.Equal(typeof(TestModel), viewData2.ModelMetadata.ModelType); 92Assert.Equal(typeof(TestModel), viewData1.ModelMetadata.ModelType); 104Assert.Equal(typeof(TestModel), viewData2.ModelMetadata.ModelType); 128Assert.Equal(typeof(SupremeTestModel), viewData.ModelMetadata.ModelType); 149Assert.Equal(typeof(SupremeTestModel), viewData.ModelMetadata.ModelType); 172Assert.Equal(typeof(int), viewData.ModelMetadata.ModelType); 194Assert.Equal(expectedType, viewData1.ModelMetadata.ModelType); 199Assert.Equal(expectedType, viewData2.ModelMetadata.ModelType); 258Assert.Equal(expectedType, viewData.ModelMetadata.ModelType); 280Assert.Equal(typeof(int?), viewData.ModelMetadata.ModelType); 299Assert.NotEqual(source.ModelMetadata.ModelType, viewData.ModelMetadata.ModelType); 300Assert.Equal(typeof(int?), viewData.ModelMetadata.ModelType); 321Assert.Equal(typeof(TestModel), viewData.ModelMetadata.ModelType);
ViewDataDictionaryTest.cs (4)
207Assert.Equal(typeof(TestModel), viewData.ModelMetadata.ModelType); 264Assert.Equal(typeof(object), viewData.ModelMetadata.ModelType); 292Assert.Equal(expectedType, viewData.ModelMetadata.ModelType); 363Assert.Equal(typeof(bool), viewData.ModelMetadata.ModelType);
Microsoft.AspNetCore.OpenApi (3)
Services\OpenApiDocumentService.cs (3)
692&& parameter.ModelMetadata.ModelType != parameter.Type 693&& parameter.ModelMetadata.ModelType.IsEnum; 699? parameter.ModelMetadata.ModelType