Commit Graph

92 Commits

Author SHA1 Message Date
Doug Bunting 809d2bf7ec Add `ValidationHtmlAttributeProvider` to make `AddValidationAttributes()` available
- #5028
- helpers similar to our HTML or tag helpers can use the new singleton to examine or add validation attributes
 - in the most common case, helpers add validation attributes to a `TagBuilder`
- separate `DefaultValidationHtmlAttributeProvider` from `DefaultHtmlGenerator`
 - avoids creating two instances of the `DefaultHtmlGenerator` singleton
 - would be even uglier to require callers to cast an `IHtmlGenerator` to `ValidationHtmlAttributeProvider`
- `[Obsolete]` old `DefaultHtmlGenerator` constructor
2016-09-13 21:07:18 -07:00
Doug Bunting eee1a9fef4 Do not generate a validation summary when `excludePropertyErrors` unless specific model has an error
- #5209
- update affected `HtmlHelperValiationSummaryTest` and functional tests
- add `ValidationSummaryTagHelperTest` tests to cover related scenarios

##### Behaviour changes when no errors exist for the model:
###### Tag helper
``` html
<div asp-validation-summary="ModelOnly" class="order"><h3>Oopsie<h3></div>
```
previously generated
``` html
<div class="order validation-summary-errors"><h3>Oopsie</h3><ul><li style="display:none"></li>
</ul></div>
```
and now generates
``` html
<div class="order"><h3>Oopsie</h3></div>
```
###### HTML helper
``` c#
@Html.ValidationSummary(excludePropertyErrors: true, message: "Oopsie")
```
previously generated
``` html
<div class=\"validation-summary-errors\"><span>Oopsie</span>
<ul><li style=\"display:none\"></li>
</ul></div>
```
and now generates nothing (`@HtmlString.Empty`).
2016-09-08 15:36:47 -07:00
Ryan Brandenburg 830983a477 Fixes #5198 Stops caching of Enum display values (#5185)
Fixes #5197 GetEnumSelectList uses IStringLocalizer
Fixes #4215 Html.DisplayFor now checks DisplayAttributes on enums
2016-09-07 16:00:17 -07:00
Ajay Bhargav Baaskaran a6a4b5369a [Fixes #5166] Support passing instance directly when invoking ViewComponents with single parameter 2016-08-26 16:33:42 -07:00
N. Taylor Mullen 7036e2b0f5 Change `ViewComponent.View()` to flow the `ViewData.Model`.
- This is more consistent with how controllers work.

#4882
2016-08-25 10:22:23 -07:00
Pranav K 67dce322df Updating to Moq \ Castle.Core that does not require imports 2016-08-08 12:20:14 -07:00
Doug Bunting 8a6e99c7c0 Always render antiforgery tokens if `!CanRenderAtEndOfForm`
- #5005
- also add `FormContext` doc comments
2016-07-20 15:25:08 -07:00
ivano scifoni 581a5ea573 column attribute for <textarea> is incorrect (#5049)
- Modify tagBuilder.MergeAttribute key to cols
2016-07-20 09:22:39 -07:00
Doug Bunting e5cb6f9595 Add `null` check for `ModelStateEntry.Children`
- #4989
2016-07-18 14:02:17 -07:00
Ryan Brandenburg 310ab25347 Make tests resilient to Localization (#5011) 2016-07-14 09:28:01 -07:00
Doug Bunting 7430efa8cc One build to rule them all
- well, at least VS and command-line builds will share output
- part of aspnet/Coherence-Signed#277
2016-07-06 16:21:18 -07:00
Ajay Bhargav Baaskaran e7de647c10 [Fixes #453] Added unit tests for Display and Value Extensions
- Added more HtmlHelper tests
- Added some tests to cover complex expressions
2016-07-06 15:39:26 -07:00
Pranav K 222165e145 Updating to RTM builds of xunit and Moq (#4946) 2016-07-05 20:58:16 -07:00
Medeni Baykal 4fe758240f Added `ViewResultTest`s. (#4939)
* Added `ViewResultTest`s.
* Fixed the namespace and folder of `PartialViewResultTest `; and some minor fixes.
2016-07-05 15:25:20 -07:00
Doug Bunting 42cea41737 Fail more gracefully when option collections cleared
- #4690
- move `ModelBindingMessageProvider` init from `DefaultBindingMetadataProvider` to `DefaultModelMetadata`
 - in addition to avoiding error cases, this removes some boilerplate
- add specific errors to `BodyModelBinderProvider`, `CompilerCache`, `CompositeViewEngine`, `ModelBinderFactory`,
  and `ObjectResultExecutor`
 - `DefaultRazorViewEngineFileProviderAccessor.FileProvider` now a `NullFileProvider` in empty case
2016-06-30 14:52:50 -07:00
Medeni Baykal a852352223 Fix for https://github.com/aspnet/Mvc/issues/4903. (#4907)
Fix for https://github.com/aspnet/Mvc/issues/4903.
- `HtmlHelperTextAreaTest` added
- fix up `HtmlHelperTextBoxTest`
2016-06-29 10:11:54 -07:00
Crystal Qian e51a118a9d Added consistent model property to view result variants (#4901)
* Added consistent model property/tests to ViewResult, PartialViewResult, ViewComponentResult. This resolves #4813.

* Removed unnecessary model asserts

* Removed redundant model checking
2016-06-28 09:38:37 -07:00
Doug Bunting f8c7f1ab78 Add more tests using `[ViewComponent(Name = "...")]`
- #4851
2016-06-19 13:52:59 -07:00
Shahriar Gholami 94fa34ca41 TempData convenience property added to ViewComponent (#4873)
* TempData convenience property added to ViewComponent

 #4728

* PR feedback
2016-06-17 10:15:50 -07:00
Pranav K cd7954a164 Updating to dev versions 2016-06-16 10:40:11 -07:00
N. Taylor Mullen 8499e3d6bb Remove direct Microsoft.NETCore.Platforms dependency.
- Microsoft.NETCore.App now pulls this package in.

aspnet/Coherence-Signed#344
2016-06-13 15:30:27 -07:00
jacalvar 4b5df98bc3 [Fixes #4224] Remove use of service locator on ViewExecutor 2016-05-31 23:39:22 -07:00
jacalvar 6a6d2e0d9f [Fixes #4506] Move and rename ActionDescriptor.Name to ControllerActionDescriptor.ActionName 2016-05-31 23:13:20 -07:00
jacalvar 5f4ca4fa66 [Fixes #4223] Added a facade for ViewComponentResult 2016-05-31 22:47:33 -07:00
Shahriar Gholami 42dd4499e0 Fixed a bug in TagBuilder when attribute value is null
#4710
2016-05-26 11:04:32 -07:00
John Luo ff534da70f React to adding IsAvailable to ISession 2016-05-23 15:17:30 -07:00
Kiran Challa 93be3dee6e Fix FormTagHelper to set flag indicating generation of AntiforgeryToken
[Fixes #4595] Better error message with extraneous @Html.AntiforgeryToken
2016-05-20 04:29:01 -07:00
Kiran Challa 20a2e748ec Added ValueProviderFactories to ResourceFilterExecutingContext
This enables removing value provider factories from model binding(which is needed in some scenarios like large file uploads)
2016-05-20 04:15:07 -07:00
N. Taylor Mullen 55922d68d4 React to `HtmlEncodedString` rename to `HtmlString`.
- Removed the Mvc instance of `HtmlString` since it now exists in `HtmlAbstractions`.

#4558
aspnet/HtmlAbstractions#25
2016-05-17 11:02:10 -07:00
Ryan Nowak 4d63ffa879 Make ValueProvider creation lazy
We want this change to avoid MVC eagerly reading the form. This is good
for general perf and also for scenarios where you want read the body
yourself (large file uploads).

We DO have scenarios where you want to configure the value providers
per-request or also to change the limits on the value providers (form) so
it's worth keeping these around on the context.
2016-05-13 08:11:21 -07:00
Pranav K 3d494fd732 Merge branch 'release' into dev 2016-05-02 14:58:54 -07:00
Pranav K 36146a6139 Fix build warnings 2016-05-02 14:52:02 -07:00
Ryan Nowak 756cd2dab8 Remove OperationBindingContext
This change trims a few concepts that aren't really needed inside
ModelBinders anymore, and removes the OperationBindingContext class.
2016-04-25 09:29:03 -07:00
jacalvar 683356ea59 Merge branch 'release' into dev 2016-04-21 10:39:45 -07:00
jacalvar d9aacd0f87 [Fixes 4509] Stop registering disposable objects in our controller helper methods 2016-04-20 17:00:34 -07:00
Pranav K a9f8c166a6 Merge branch 'release' into dev 2016-04-19 14:54:08 -07:00
Pranav K d87d8283d0 Use latest build of dotnet-test-xunit 2016-04-19 14:54:07 -07:00
Pavel Krymets 1f93977729 Migrate tests, tools and samples to portable 2016-04-19 10:43:11 -07:00
Pavel Krymets e6ffb060f7 Bring Microsoft.NETCore.Platforms dependency back 2016-04-18 17:20:15 -07:00
Pavel Krymets 42c3397b6e Migrate tests, tools and samples to portable 2016-04-18 17:20:15 -07:00
Doug Bunting 1492db35fa Merge branch 'release' into dev 2016-04-16 13:07:08 -07:00
Doug Bunting 7a1ac034f9 Special-case use of `razorPage.Model` property in `ExpressionMetadataProvider`
- #3978
- better-aligns `ExpressionMetadataProvider` with `ExpressionHelper`

nit: mock less in `RazorPageCreateModelExpressionTest`
2016-04-15 17:15:33 -07:00
Doug Bunting 82fd17d050 Merge branch 'release' into dev 2016-04-08 16:06:59 -07:00
Doug Bunting a0c8834c70 Preserve existing metadata in `ViewDataDictionary` where possible
- #4116
- generalize rules for `ModelMetadata` creation; minimize metadata changes when Model is updated
 - down to a single special case in VDD for `Nullable<T>`
 - note existing functional tests did not need to change
- remove `ViewDataDictionary(ViewDataDictionary, object)` constructor; use `new VDD<object>(source, model)`
- allow all `Model` assignments in a view component
 - copy-constructed VDD in `ViewComponentContext` previously preserved the source's declared type

nits:
- do not call `virtual SetModel()` method from constructor; now mostly redundant
 - logic in copy constructor and `SetModel()` is consistent but different enough to keep code separate
- add some missing doc comments
- fix doc comment property versus type confusion; never need to specify `ViewDataDictionary.` prefix
- fix a few `TemplateBuilder` comments and remove unnecessary `model: null` argument to VDD constructor
2016-04-08 14:44:36 -07:00
mnltejaswini f4e35f5ba0 [Perf] Remove the validations in ControllerActivator and ViewComponentActivator which are redundant. These
validations are already done when selecting a controller and view component
Fixes #4367
2016-04-08 10:07:33 -07:00
ryanbrandenburg 906ac728c7 Null-check PagedBufferedStringWriter 2016-04-01 11:50:46 -07:00
jacalvar 5246125cb7 [Fixes #4087] Add AddViewComponentsAsServices() and ServiceBasedViewComponentActivator
* Added ViewComponentFeture and ViewComponentFeatureProvider to perform view component discovery.
* Changed view component discovery to use application parts.
* Changed ViewComponentDescriptorProvider to make use of Application parts.
* Added AddViewComponentsAsServices method on IMvcBuilder that performs view component
  discovery through the ApplicationPartManager and registers those view components as
  services in the service collection. Assemblies should be added to the ApplicationPartManager
  in order to discover view components in them in them.
2016-04-01 10:55:04 -07:00
mnltejaswini 7fbd407ad5 [Perf] Rewrite ExpressionHelper.GetExpressionText using StringBuilder 2016-03-31 11:26:37 -07:00
Doug Bunting 6bf25cecec React to HttpAbstractions namespace changes
- aspnet/HttpAbstractions#549 and aspnet/HttpAbstractions#592
- clean up `using`s
2016-03-30 16:19:42 -07:00
Ryan Nowak fb81a5e11e Introducing ModelBinderFactory
This change separates model binding into IModelBinderProvider (decides
which binder to use) and IModelBinder (does binding). The
IModelBinderFactory is a new services with coordinates the creation of
model binders.
2016-03-29 15:45:14 -07:00