Commit Graph

1541 Commits

Author SHA1 Message Date
Stefán Jökull Sigurðarson c713aa92ca Making the HtmlHelper.GetEnumSelectList take DisplayAttribute.GroupName into account to create select groups. 2015-09-29 09:53:48 -07:00
Ryan Nowak d37f5aeb31 Fix #3217 - Optimize IList.GetEnumerator allocations
This change fixes call sites on the main request path for a simple site
(model binding, validation, views) that allocate boxed list enumerators.

Some cases aren't addressed by this change because the fix is too invasive
or requires changing an important contract to take IList instead of
IEnumerable. Will follow up on those case by case in order of importance.
2015-09-28 16:17:48 -07:00
Doug Bunting 28aec3f5cc Support user overrides of system-provided `ModelError` messages
- #2969
- add `ModelBindingMessages` for configuration and `IBindingMetadataProvider` overrides
  - use `interface` to avoid `new` oddities when adding a setter to an `abstract` property
- add `IModelBindingMessages` to `ModelMetadata` for use in rest of the product code
- plumb the various bits through the system
- add integration tests using a custom `IBindingMetadataProvider`s to override messages

nits:
- remove unused resources
- use `AttemptedValue` and not `model` in `SimpleTypeModelBinder`
2015-09-28 15:50:21 -07:00
Ryan Nowak 0d6edf240a Move ModelExplorer to ViewFeatures 2015-09-28 14:14:40 -07:00
Søren Kruse ec18b35123 Add FormatterCollection<T>
#2945
2015-09-28 13:23:19 -07:00
Ryan Nowak 67b43b4cfe Workaround Mono bugs to fix travis
This change works around two mono issues that are blocking travis. I'd
like to have tests skip instead, but unfortunately that would mean not
running any validation tests on mono so this seems better.

- RuntimeHelpers.GetHashCode will sometimes crash the runtime
- PropertyHelper sometimes returns throws null-ref
2015-09-28 12:58:45 -07:00
Pranav K 18c80d156c Replace NotNullAttribute with thrown exceptions 2015-09-26 23:48:43 -07:00
Doug Bunting eff10cdd66 Move `ModelStateDictionaryExtensions` into `Microsoft.AspNet.Mvc.ModelBinding` namespace
- missed the inconsistency when reviewing
- kept class in ViewFeatures assembly because it depends on `ExpressionHelper`

nit: wrap some long lines
2015-09-26 18:15:04 -07:00
Muchiachio b28debf442 Generic ModelStateDictionary add and remove extensions
- Added generic add model error and remove extensions for
ModelStateDictionary, to avoid using hard coded strings then specifying
model state dictionary keys.
- Added generic removal all  extension for ModelStateDictionary, to
support removing all the model state keys for given expression.

aspnet/Mvc#3164
2015-09-26 18:14:58 -07:00
Pranav K 6a0a24481a Asynchronously flush the HttpResponseStreamWriter after a view has been rendered.
This solves a perf issue for views which produce content that is smaller
than the buffer size of HttpResponseStreamWriter. In this case, the writer
ends up synchronously writing to the Response as part of Dispose which
affects perf.
2015-09-25 21:07:15 -07:00
Ryan Nowak 8a502dbe5d Rewrite of validation 2015-09-25 16:56:42 -07:00
Kirthi Krishnamraju 0889b18f95 Add localizers to validation attributes 2015-09-25 16:13:21 -07:00
Nero Sule 49acfd562e Adds common interfaces around Models (Implements #3158) 2015-09-25 11:10:59 -07:00
Ajay Bhargav Baaskaran 9c81b95d1b Renamed Controller.Context to Controller.HttpContext
- #3165
2015-09-25 11:01:30 -07:00
Ryan Nowak 5a80435534 API Review - Move ModelBindingHelper 2015-09-25 09:59:56 -07:00
Kirthi Krishnamraju ed509f65a2 fix #2747: Fix Mvc localization test once dnx support reading resources 2015-09-24 12:53:20 -07:00
Pranav K 1833e06984 TModel substitution in Razor pages has broken intellisense
Fixes #3185
2015-09-23 17:47:52 -07:00
Pranav K ff4100e292 Generate an expression to create line mappings for ModelChunk directives 2015-09-23 16:14:29 -07:00
Pranav K 89f58aa49f Allow @model specified in a page work with @inherits directive in
_ViewImports

Fixes #3144
2015-09-23 12:10:10 -07:00
Ryan Nowak 80add92de8 React to removal of TagHelperContent.ToString()
Avoid calling ToString on a TagHelperContent.

Also react to new properties on TagHelperCodeGenerationContext
2015-09-23 11:09:27 -07:00
Doug Bunting d8d0a1ab89 Rename `ModelMetadata.IsCollectionType` and add "real" `ModelMetadata.IsCollectionType`
- #3022
- existing `IsCollectionType` -> `IsEnumerableType`
- use new `IsCollectionType` in a few places
2015-09-22 19:05:40 -07:00
Pranav K 1574637a6a Reacting to Microsoft.AspNet.Cors version change 2015-09-22 11:26:04 -07:00
Pranav K 9eb2c5b810 Reacting to IExpirationTrigger -> IChangeToken rename 2015-09-22 08:14:34 -07:00
Ryan Nowak b544aabfdb Fix #3111 - Don't trounce content-type in VCR
This change makes ViewComponentResult respect an existing Content-Type
setting on the HttpResponse. Code is very similar to the code in
ViewExector, and includes the same quirks.
2015-09-21 23:20:20 -07:00
Ryan Nowak a318c4599a API Review - Split up .Actions
Abstractions - Core MVC extensibility

Controllers - MVC implementations of .Abstractions and supporting
contracts

Infrastructure - General purpose support APIs. Metadata APIs that don't
fit clearly with a feature or with .Abstraction
2015-09-21 21:54:02 -07:00
Pranav K 00b6e71e31 Changes per NotNull PR comments 2015-09-21 17:22:27 -07:00
Pranav K 498d209949 Remove chaining from HashCodeCombiner.
Reacting to https://github.com/aspnet/Common/issues/40
2015-09-21 17:11:08 -07:00
Pranav K f045c6792b Allow _ViewImports to remove default inherited tag helpers.
Additionally simplifying the contract for
ChunkInheritaceUtility\IChunkMerger so we don't have to understand the
order in which CodeTrees appear.
2015-09-21 14:53:24 -07:00
Ryan Nowak b95dcd5f1c Fix #3102 - Add an AddMvcOptions to builders
This makes it easier/possible for any third party code that extends
IMvcBuilder to set options.
2015-09-21 12:54:59 -07:00
Ryan Nowak f4c5e31ec1 Remove JsonPatch from MVC
JsonPatch is moving to https://github.com/aspnet/JsonPatch
2015-09-21 11:14:40 -07:00
Pranav K 66a04c2fd6 Replacing NotNullAttribute with thrown exceptions 2015-09-21 10:26:14 -07:00
Ryan Nowak 00c436b0e1 [Perf] Remove use of [FromServices] on Controller
[FromServices] requires modelbinding to run for each of these four
properties, which allocates a lot, and ultimately just ends up calling
GetRequiredService in the end.

Also, retrieving these services is now lazy, which should be very
beneficial as few of them aren't used often.
2015-09-21 08:53:12 -07:00
Ryan Nowak 9badd9386e API-Review Strongly-typed collections for a few options types.
We don't want these extensions methods defined in a wierd namespace, it's
straightforward and future-proof to just make these strongly-typed
collections.
2015-09-20 22:11:22 -07:00
Ryan Nowak 10ec9144ca Remove extra registration of TelemetrySource
This is now provided by hosting.
2015-09-20 21:16:01 -07:00
Ryan Nowak 4d55a6e62d API review - remove DefaultOrder
No change in behavior intended, removing this from our public API.
2015-09-20 21:11:57 -07:00
Ryan Nowak ccb5ead450 Api-Review - put uri complexity in CreatedResult 2015-09-20 19:44:32 -07:00
Doug Bunting 42017faa21 Add `InputFormatterResult` and `InputFormatterContext.ModelName`
- #2722
- make communication of errors from formatters to `BodyModelBinder` explicit
  - `JsonInputFormatter` now adds errors to `ModelStateDictionary` with correct key
- change `InputFormatter.SelectCharacterEncoding()` to add an error and return `null` when it fails
  - one less `Exception` case and removes some duplicate code

nits:
- improve some doc comments (more `<inheritdoc/>`, `<paramref/>` and `<see/>`)
- add another two `BodyValidationIntegrationTests` tests
2015-09-19 21:36:38 -07:00
Doug Bunting 0fb09908d3 [Build break] Correct doc comment references to match current namespaces
- local command line builds fail consistently during `xml-docs-test`
- bit buried on the CI machine but repo is not testing successfully there
2015-09-17 23:12:26 -07:00
Pranav K 7b433820b1 Changes per PR comments
Reformatting parameter identation
2015-09-17 15:42:58 -07:00
Pranav K a68d9e4cb1 Replace NotNullAttribute with thrown exceptions 2015-09-17 11:56:44 -07:00
Ryan Nowak 538cd9c191 Move less-commonly used types out of .Rendering 2015-09-16 23:52:29 -07:00
Ryan Nowak 046cb976b3 Move ActionResult classes back to main namespace 2015-09-16 21:42:31 -07:00
Pranav K 1c4614c219 Avoid allocating strings in DefaultViewLocationCache
Fixes #3135
2015-09-16 17:28:40 -07:00
Pranav K 00075520b4 Razor CompilerCache allocates too much in NormalizePath
Fixes #3035
2015-09-16 16:55:51 -07:00
Ryan Nowak 9a15b54d30 Flow IHtmlContent through to the razor buffer 2015-09-16 16:17:40 -07:00
Ryan Nowak a707311d9e Fix #3087 - use IHtmlContentBuilder in TagBuilder
Improves authoring experience when using TagBuilder by taking advantage of
IHtmlContentBuilder an its extension methods.

TagBuilder.InnerHtml is no longer settable.
2015-09-16 10:03:03 -07:00
Pranav K 887ab64d75 Throw an exception if layouts have circular references.
Fixes #3100
2015-09-14 12:57:06 -07:00
Doug Bunting 29a25b2ed1 No need to add an instance in `WebApiCompatShimMvcBuilderExtensions`
- DI has changed since this class was written
2015-09-13 22:25:04 -07:00
N. Taylor Mullen 93735a5be6 React to Razor `TargetElementAttribute` rename.
aspnet/Razor#516
2015-09-13 19:14:30 -07:00
Ryan Nowak 94388a8804 React to BufferedHtmlContent changes 2015-09-13 13:51:53 -07:00