Commit Graph

1238 Commits

Author SHA1 Message Date
Ryan Nowak faaba481e8 Adding an 'AddMinimalMvc()' for Mvc.Core and sample
This adds the ability to configure Mvc.Core for a project; MVC with
minimal services and dependencies.
2015-06-12 11:29:47 -07:00
Ryan Nowak 0861612779 A new pattern for adding multi-registration services
This is some cleanup of how we add multi-registration services to avoid
duplication when calling AddMvcServices multiple times. Also improved
tests to be more clear, and to verify all of our special cases
explicitly.
2015-06-12 11:23:51 -07:00
Hisham Abdullah Bin Ateya 1f9a451e2f Using 'nameof' operator instead of margic strings 2015-06-12 02:26:34 +03:00
Ajay Bhargav Baaskaran a3c593bda9 [Fixes #2409] Return EmptyResult for void actions 2015-06-11 11:51:51 -07:00
N. Taylor Mullen 31aa51ba49 React to aspnet/Razor#172. 2015-06-10 14:43:08 -07:00
Doug Bunting 3f6ab3bb03 Add `ModelMetadata.ElementMetadata`
- #2664
- use new property to correctly determine `isTargetEnum` in `GetCurrentValues()`
 - avoid `ArgumentNullException` in all cases where raw values are `enum` but target is not
- stop skipping tests blocked by #2664, exposing a couple more #1487 issues
- use new property instead of private `GetElementType()` methods where possible
 - cleans up some duplicate code
 - also remove redundant use of `IsCollectionType` and `ElementMetadata`

nits:
- move properties above methods in `ModelMetadata`
- avoid accidentally-incorrect "Remove Unnecessary Usings"
2015-06-10 12:02:50 -07:00
Doug Bunting afd5b4f2a6 Demonstrate #1485, #1487, #2662, #2664 in functional and unit tests
- test additional cases _close_ to these bugs as well

for #1485
- show odd `@Html.CheckBox()`, `@Html.Hidden()` behaviour in unit tests
- show odd `@Html.TextBox()` behaviour in functional tests (templates)

for #1487
- show odd `@Html.Value()` behaviour in unit tests
- show odd `@Html.RadioButton()`, `@Html.TextArea()` behaviour in functional tests
- show lack of validation attributes for `@Html.RadioButton()`, `<select>` tag helper

for #2662
- show odd `@Html.RadioButton(string.Empty)` behaviour in functional tests

for #2664
- show failures with `@Html.ListBox()` in unit tests

nits:
- test `IHtmlHelper` methods, not extensions
- use `ViewData`, not `ViewBag` in `HtmlGeneration_FormController`
- name test methods a bit more consistently
- rename `HtmlHelperValueExtensionsTest` to `HtmlHelperValueTest`
2015-06-10 10:22:40 -07:00
Ajay Bhargav Baaskaran 37d1881dad [Fixes #2609] Support for binding all integer types to enums 2015-06-09 16:08:38 -07:00
Ajay Bhargav Baaskaran a40d4aef2b React to aspnet/Diagnostics#140 change 2015-06-09 15:57:09 -07:00
Ryan Nowak a679e87a9b Split Mvc.Core
This is the first step is some more refactorings to come in the future
with the goal of making MVC less monolythic. This makes the core of MVC
more reusable and more in line with the design of other vNext platform
components.

With this change, Mvc.Core contains just the minimal guts needed to build
a working app.
- Action Discovery
- Action Invoker
- Filters
- ObjectResult
- Model Metadata
- Model Binding
- Formatters
- Validation System

And yes, we are aware of the irony of 'minimal MVC' not including the view
system. The idea is that this is the kernel of an MVC app, and anything
real is layered on top.

The most noticable impact of this change is that MvcOptions has been blown
apart into more managable chunks. See the various ConfigureMvc*** methods.

The new Mvc.Extensions package is a placeholder while we evaluate and tune
the new definitions. Expect more changes as features are move to their own
packages, and in some case their own repositories.

For now there is no experience to bootstrap an Mvc.Core app. That's coming
next.
2015-06-09 02:12:13 -07:00
Ryan Nowak 03571cc27b Event Notification for MVC Prototype
Here's a first take on the pattern for publishing notifications from MVC.
2015-06-08 17:49:33 -07:00
Ryan Nowak a452b10ba4 Fix #2278 - Only activate public properties 2015-06-08 15:54:16 -07:00
Ajay Bhargav Baaskaran f5cabf2029 [Fixes #2564] Support comma separated string include in BindAttribute
This reverts commit 7746d0f451.
2015-06-08 14:30:10 -07:00
Ajay Bhargav Baaskaran 7746d0f451 Revert "[Fixes #2609] Support comma separated string include in BindAttribute"
This reverts commit eba352166d.
2015-06-08 14:29:59 -07:00
Ajay Bhargav Baaskaran eba352166d [Fixes #2609] Support comma separated string include in BindAttribute 2015-06-08 14:02:26 -07:00
Kirthi Krishnamraju 12ed69e72a Fix build break: Add HelloWorld.htm to LocalizationWebSite 2015-06-08 12:49:22 -07:00
Kirthi Krishnamraju 74b193b15d Added configurable option for LanguageViewLocationExpander to use subfolder or suffix 2015-06-08 12:07:49 -07:00
Harsh Gupta 67d0bf880a Fixing 2340: ModelMetadata should recompute localizable properties. 2015-06-08 11:07:59 -07:00
Kiran Challa 0469103683 React to Session api review changes 2015-06-08 09:44:05 -07:00
Ryan Nowak 6cd277e8aa Refactor I***ModelBuilder extensibility
Combining IControllerModelBuilder and IActionModelBuilder into a pipeline
of IApplicationModelBuilders. Extensibility for framework features (Auth,
Cors, etc) should implement an IApplicationModelBuilder to add data to
models before IApplicationModelConventions have a chance to run.

Also deleting IGlobalFilterProvider while touching this code, this should
have been removed a while ago when we removed other options facades.
2015-06-07 18:07:41 -07:00
Doug Bunting 261975b0bc Rename `MvcTagHelpersWebSite` to `HtmlGenerationsWebSite`
- name was too specific and I am about to add another HTML helper scenario
2015-06-05 20:30:17 -07:00
Doug Bunting eefa582069 Address #2526; remove use of a required validator when validating `[BindRequired]`
- only use MVC error message when `[BindRequired]` is violated
- update that error message to more clearly describe the problem
- enable all tests skipped due to dupe bug #2493
- update expectations of a few tests using the old messages

nits:
- rename `ModelBinding_MissingRequiredMember` to `ModelBinding_MissingBindRequiredMember`
- remove `<param>` description of removed `requiredValidator` parameter
- remove unused `MutableObjectModelBinderTest.GetRequiredValidator()`
2015-06-05 16:56:05 -07:00
Doug Bunting cda2c6781c Use stable locale when testing date/time formats
- `CultureReplacerMiddleware` no longer helping `RazorWebSite`
 - regressed with @30d11a8
- `[ReplaceCulture]` sets up the correct culture early enough for consistent formatting
- remove `CultureReplacerMiddleware` from `RazorWebSite`
 - only `Startup` class we have that used this with `RequestLocalizationMiddleware`
 - testing `RequestLocalizationMiddleware`; so remove the confusing extra middleware
2015-06-05 14:25:51 -07:00
Kiran Challa bd035714d0 [Fixes #2648]: Fix registration of MVC services 2015-06-05 09:43:40 -07:00
Kirthi Krishnamraju 30d11a8227 Added LanguageViewLocationExpander into framework and removed it from samples 2015-06-04 14:06:08 -07:00
Doug Bunting ffd1dc1fb0 Add support for generating baseline output files while testing
- baselines include both expected output and design-time line mappings
- controlled by GENERATE_BASELINES
 - assertions related to file content are not checked in this mode
- add design-time test of Basic.cshtml to `MvcRazorHostTest`
- regenerate all files to avoid BOM and blank line noise in future PRs
 - update out-of-date design-time Basic.cs file

nits:
- make a few variable names more consistent
- make `Assembly` fields `static`
- remove unused `_resourcesAssembly` field from `ErrorPageTests`
- remove `ResourceHelpers` which was specific to functional tests
2015-06-01 13:13:39 -07:00
Harsh Gupta 386562c269 Enabling test for 2447, CancellationToken does not gets validated. 2015-06-01 12:41:34 -07:00
Doug Bunting e31eab0391 `ByteArrayModelBinder` should return `null` only when type is not matched
- #2456
- visible behaviours now match MVC 5
- prevent `CollectionModelBinder` from converting no value to `byte[0]`
- prevent `TypeConverterModelBinder` from converting empty value to `byte[] { '\0' }`

nit:
- remove additional delegates `ModelBindingTestHelper.GetOperationBindingContext()` calls
 - a few left despite #2625 cleanup
2015-06-01 12:20:17 -07:00
Doug Bunting 26795bd4b5 Correct test expectations
- use valid `multipart/form-data` content type; include a `boundary`
- correct expectations of `FormCollection` model binder's operation
 - restore tests actually skipped for either of the above reasons
- add more tests with `ModelBindingResult.Model==null` and both `IsModelSet` values

#### Remove test references to Won't Fix bug #2473
- restore #2473 tests; update test expectations
- expect `null` composite results whenever binding fails

#### Restore test skipped due to "#2646"
- that issue does not exist; was likely #2466 or similar fixed bug

#### Rename model binding tests that still mention ReturnsFalse or ReturnsTrue

#### Minor src changes
- remove unused variable and unnecessary nesting in `DefaultControllerActionArgumentBinder`
- remove dangling mention of `[DefaultValue]` in `ComplexModelDtoModelBinder`

#### nits:
- remove empty delegates from some `GetOperationBindingContext` calls; `null` fine
- do some `using` cleanup
- combine two test methods in `KeyValuePairModelBinderTest`
- name a few more arguments
2015-06-01 12:15:39 -07:00
N. Taylor Mullen e0b8532735 Update names and spacing of some missed ChunkTree renames. 2015-05-29 23:07:55 -07:00
N. Taylor Mullen 94553703a2 React to aspnet/Razor#140
- ICodeTreeCache => IChunkTreeCache
- ModelCodeGenerator => ModelChunkGenerator
- MvcCSharpCodeBuilder => MvcCSharpCodeGenerator
- Updated files that used Razor resources that are now in different namespaces.
- Updated variable names to account for Razor renames.

aspnet/Razor#140
2015-05-29 14:21:35 -07:00
CodingGorilla 70b56f157c Updated the ResponseCacheFilter class to store a reference to the CacheProfile passed into the contructor
Updated the ResponseCacheFilter Duration, Location, NoStore, and VaryByHeader properties to return one of 3 values: the specific setting applied to the instance, the setting supplied by the CachePolicy (from the constructor), or a default value.  The emphasis being not to change the outward function of these properties to consumers, but to defer the evaluation of these properties until the OnActionExecuting method.
Updated the ResponseCacheFilter to check whether a cache duration has been supplied when the NoStore property is false and throw an InvalidOperationException when a duration has not been provided.
Updated ResponseCacheFilterTest to reflect the changes in behavior in the ResponseCacheFilter
Updated the ResponseCacheFilterAttributeTest to reflect the change in the behavior of the ResponseCacheFilter

Added unit tests to ResponseCacheFilterTest.cs to verify that the CachePolicy properties are properly overriden with the properties set directly on the ResponseCacheFilter.

Added functional tests to test the ability to override CacheProfile settings with properties on the ResponseCacheAttribute
2015-05-29 12:28:14 -07:00
Harsh Gupta 4f419eee55 Removing creating ModelValidationNode by default in CompositeModelBinder.
This moves the responsibility of of MVN creation to individual model binders if they want the individual models to be validated.
2015-05-29 09:21:11 -07:00
David Paquette 3fe0490b99 Renamed FileVersion to AppendVersion in tag helpers that support cache busting
FileVersion property renamed to AppendVersion in ImageTagHelper,
LinkTagHelper and ScriptTagHelper.

asp-file-version attribute renamed to asp-append-version.

Resolves issue #2540
2015-05-28 17:56:19 -07:00
Ryan Nowak 6e1226bfe4 Enable tests for #2470
This was very likely fixed as part of
22f1881cc6
2015-05-28 14:57:50 -07:00
Ryan Nowak 144c1d3cf4 Fix #2151 - Part 4 remove [Activate] support from controllers.
This change completely removes [Activate]. In a controller, you should
constructor injection or [FromServices] to access services.

To access context items (ActionContext, ActionBindingContext, root
ViewDataDictionary) you should use the respected attribute class.

We'd like to consider streamlining this further in the future by getting
down to a single injectable context for controllers, but for now this will
have to do.
2015-05-21 22:57:56 -07:00
Ryan Nowak af5322e2ce Part of #2151 - Remove [Activate] from TagHelpers
This change removes [Activate] support from TagHelpers. TagHelpers which
need access to context should use [ViewContext] to have it injected. To
access services, use constructor injection.
2015-05-21 22:57:51 -07:00
Ryan Nowak b393191cff Part of #2151 - Remove [Activate] from ViewComponents
This change removes [Activate] from ViewComponents. Accessing context
should be done through [ViewComponentContext]. Accessing services should
be done though constructor injection.
2015-05-21 22:57:45 -07:00
Ryan Nowak 92dbd8923b Fix #2582 - Remove @inject dependency on [Activate]
Removes usage of [Activate] in razor code generation. Razor will now use
it's own special attribute recognized by the Razor activator.
2015-05-21 22:57:39 -07:00
Ryan Nowak 8f38650d1f Fix #1579 - Bind top-level collections as an empty collection
This change treats 'top-level' collection-type models similarly to
top-level POCO model - namely that they will always be instantiated even
if there's no data to put inside.
2015-05-21 22:46:04 -07:00
Ryan Nowak b64fd7ae39 Fix #2407 - Add back the implicit [Required] for value types
This change adds a [Required] client validator when
ModelMetadata.IsRequired == true. The bulk of the changes here are
mechanical updates to test files.
2015-05-21 17:52:25 -07:00
N. Taylor Mullen e689863461 Add required attributes to AnchorTagHelper and FormTagHelper.
- This involved also adding required attributes with wildcards.
- With this change AnchorTagHelpers and FormTagHelpers should no longer light up on every `<form>` or `<a>` tag.

#2581
2015-05-21 16:42:45 -07:00
Kiran Challa 2a321fd622 React to Caching api review changes 2015-05-21 14:44:27 -07:00
Doug Bunting 8a701726b3 Rename _GlobalImport.cshtml files to _ViewImports.cshtml
- also rename files and directories with "GlobalImport" in name
 - nearly blind but avoid "ViewImportss" in new names
- public API change: `ViewHierarchyUtility.GetGlobalImportLocations()` -> `GetViewImportsLocations()`
 - primary source updates were comments, tests, and implementation details

nit:
- rename NestedGlobalImports.cs file to NestedViewImportsController.cs, matching class
2015-05-21 12:27:08 -07:00
Kirthi Krishnamraju 78033fda1f fix build break 2015-05-21 11:25:03 -07:00
Doug Bunting 517c013882 React to aspnet/Razor#89 fix
- use `IDictionary<string, TValue>` support in `<a/>` and `<form/>` tag helpers
 - make `RouteValues` dictionaries `IDictionary<string, string>` for ease of use
- remove `TagHelperOutputExtensions.FindPrefixedAttributes()`
- set all `GeneratedTagHelperContext` properties
- add error for tag helper dictionary properties where `TValue` is `ModelExpression`
- add new `RazorPage.InvalidTagHelperIndexerAssignment()` method and resource

tests
- use new `isIndexer` argument when creating `TagHelperAttributeDescriptor`
- arrange `AnchorTagHelper` and `FormTagHelper` correctly
 - also expect `routeValues != null` in calls to `IHtmlGenerator`

nits:
- get rid of some `foo` and `bar` gunk in tests
- remove unused variable to cleanup a test compilation warning
2015-05-20 22:07:19 -07:00
Kirthi Krishnamraju 337bbad51d React to aspnet/Configuration #195,#198 and fix few minor build break issues 2015-05-20 20:01:23 -07:00
Ryan Nowak fa56df93c3 Fix #2407 - Part 1 - Make model binding behavior for [Required] compatible
with MVC5.

This change removes the behavior in model binding to validate values 'on
the wire' for requiredness instead of the looking at the model. This
restores the behavior of [Required] for model binding to the MVC5
semantics.
2015-05-19 15:57:56 -07:00
Ajay Bhargav Baaskaran 48e0b3261c [Fixes #2547] Fixed attribute value prefix with dynamic content being ignored 2015-05-18 17:15:38 -07:00
N. Taylor Mullen a0813faa48 React to default hosting environment change.
- Default hosting environment was changed from Development to Production, modified EnvironmentTagHelper functional test.
2015-05-18 16:16:17 -07:00
Ajay Bhargav Baaskaran 47bfba11b9 React to aspnet/Razor#217 fix 2015-05-15 12:28:43 -07:00
Harsh Gupta d0927bdc75 Fixes #2464 - Does not add extra skipped entries for model bound from services.
Also ensures that when a type is marked as skipped, any sub property which is model bound (and hence a modelstate un validated entry),
is marked as skipped (otherwise it would cause the ModelState to be invalid).
Also fixing a bug in model state dictionary FindKeyWithPrefix was not considering [0] & [0][0] as a valid prefix.
2015-05-15 12:27:43 -07:00
Harsh Gupta 88ac4b94e4 Fixing #2466, #2446.
The assumption is ModelState should have entries if
1. An error is explicitly added by a model binder.
2. There is validation error reported while validating the model.
3. There is value bound by the model binder.

With this change there should be no extra entry other than for the cases mentioned above.

Also enabling the integration test cases.
2015-05-15 12:27:41 -07:00
N. Taylor Mullen 12e4307f3a Add tests to account for aspnet/Razor#220.
- Added unit and functional test.
2015-05-15 12:13:15 -07:00
Kiran Challa 6ef8be92ff [Fixes #2541] Use custom stream writer for Xml output formatters 2015-05-15 12:12:11 -07:00
Harsh Gupta 22f1881cc6 Restoring modelvalidation node. 2015-05-14 18:38:26 -07:00
Kirthi Krishnamraju 8b5223518f Fix 2224: [Jsonpatch]Added tests for custom converters on properties 2015-05-14 17:18:42 -07:00
Ajay Bhargav Baaskaran 39642761b1 Added overload to ViewComponent.Json to accept JsonSerializerSettings 2015-05-14 15:45:41 -07:00
Ryan Nowak 7767251dad Adding some deserialization to a test for SerializableError 2015-05-14 15:38:50 -07:00
Ryan Nowak cc4ee1068d Fix #2414 Part 2 - Add [DefaultValue(...)] support to the invoker for
action parameters
2015-05-14 13:58:02 -07:00
Ryan Nowak 2fc983b23a Fix for #2414 - Remove [DefaultValue] support from ModelBinding
This part of the change removes default value support from ModelBinding.

Updated some unit tests to verify that it does nothing in that case.
Deleted a functional test as it was pure duplication of another
(supported) case where the property has a pre-initialized value.
2015-05-13 20:03:23 -07:00
Hao Kung 1ea1cc4338 AuthorizeFilter should always set default identity 2015-05-13 16:39:35 -07:00
Ryan Nowak 90805fa827 Pass InputFormatters in OBC
This removes the need to use IScopedInstance<ActionBindingContext> to get
access to the formatters.
2015-05-13 16:02:34 -07:00
Kiran Challa 4bed2e6f2b [Fixes #2545] RedirectToRouteResult doesn't use RouteName property when calculating destination URL 2015-05-13 12:35:25 -07:00
Kirthi Krishnamraju da740cd6a8 fix #2535: Timezone test failure in Microsoft.AspNet.Mvc.Core.Tests 2015-05-13 10:06:26 -07:00
Hao Kung b2318bc471 React to security API changes 2015-05-12 15:12:06 -07:00
Kirthi Krishnamraju caa8ea44fb Fix #448: Support app-wide defaults for HTML helpers 2015-05-12 14:10:59 -07:00
Ryan Nowak 4939181075 Fix #2528 - Revert formatter behavior for [Required]
This change removes the support in the DCS formatter to issue an error
message when [Required] is used on a value type.
2015-05-12 11:17:31 -07:00
Ryan Nowak 39fe063aee Fix #2330 - Reimagine *FormatterContext
This change simplifies InputFormatterContext/OutputFormatterContext by
swapping ActionContext for HttpContext.

This change is important especially for InputFormatterContext as it
decouples ModelState from ActionContext - allowing us to fix a
related bug where the _wrong_ ModelState can be passed in for a
TryUpdateModel operation.
2015-05-12 11:05:56 -07:00
Doug Bunting fcf7b15c64 Remove `FromBodyOnProperty_RequiredOnValueTypeSubProperty_AddsModelStateError`
- this integration test depends on the old `[Required]` special case
- #2388 explicitly removes that bahaviour so the test goes with it
2015-05-11 17:18:52 -07:00
James Newton-King de630754bf SerializerSettings refactor
Add SerializerSettings to MvcOptions and pass those options to the JsonInputFormatter and JsonOutputFormatter.
Remove custom contract resolver.

PR feedback
Pass JsonSerializerSettings to JsonPatchInputFormatter

PR feedback
Make DI JsonOutputFormatter formatter use MvcOptions SerializerSettings

Fix JsonPatchInputFormatter using null ContractResolver

Fix tests
2015-05-11 16:43:17 -07:00
James Newton-King ab4cd5c4c4 Add JsonHelper for serializing JSON in views
- remove NotNull from JsonHelper Serialize
2015-05-11 16:01:08 -07:00
Kiran Challa 40794fcc33 Custom stream writer which avoids writing the BOM and does not flush or close the stream. 2015-05-11 13:27:05 -07:00
Ajay Bhargav Baaskaran d6012d4297 [Fixes #2506] Added overload to Controller.Json to accept JsonSerializerSettings 2015-05-11 12:36:45 -07:00
Pranav K 131096ff61 Adding relevant unit tests for MvcRazorCodeParser property name trimming 2015-05-11 12:20:49 -07:00
David Paquette ab4d2eec31 ImageTagHelper
An ImageTagHelper that supports cache busting by appending a file
version hash to the image src attribute
[Resolves #2249]

Code cleanup
2015-05-11 13:41:10 -05:00
Pranav K 320507604a Removing superfluous types and methods from Common. 2015-05-09 08:04:28 -07:00
Harsh Gupta 583277cceb Adding tests for ActionParameters and TryUpdateModel 2015-05-08 19:11:03 -07:00
Ryan Nowak 8a476b56d8 Part 2 of fix for #2248 - Support 'override' of attribute routes on action
methods

This change applies the 'override' semantic to attribute routes on virtual
methods.

A method override can either inherit attribute routes from a base
definition, or can replace them. It's not possible to inherit routes and
also add to them.
2015-05-08 17:05:50 -07:00
Ryan Nowak 46db71cfce Part 1 of fix for #2248 - Ambiguity when inheriting attribute routes
The change here is to make an attribute route defined on a base class
inherited only if no other routes were defined 'closer' to the controller
class.

To put another way, attribute routes can either be inherited or
overridden, you can't inherit + add your own.
2015-05-08 17:05:45 -07:00
Ryan Nowak 0f6b2331ce Fix #2378 - Fully expand models in ApiExplorer
This change dramatically simplifies the parameter discovery logic in
DefaultApiDescriptionProvider. Instead of surfacing POCO objects as
parameters, we now fully expand every model.

The rationale is that we want to show every key/value that can be set by
the user and not force consumers of ApiDescription to do that themselves.

Tests are cleaned up to match the new behavior.
2015-05-08 11:53:38 -07:00
Chris R bd03142dab React to Http namespace changes. 2015-05-07 15:19:10 -07:00
Troy Dai ea717729c1 React to common package name change 2015-05-07 09:39:08 -07:00
Hao Kung 5804856fe2 React to security changes 2015-05-06 22:24:08 -07:00
Chris R 7f737246b1 React to QueryString API changes. 2015-05-06 15:20:40 -07:00
David Fowler 5cec601abe Fix MVC packages being broken on CoreCLR
- Mvc is currently broken on CoreCLR because it is
inheriting dependencies from Microsoft.AspNet.Mvc.Common but the resulting
dependency to Microsoft.AspNet.Mvc.Common is then erased at pack time.
This change moves the dependencies down and makes the shared package
only depend on System.Runtime.

#2507
2015-05-05 23:26:45 -07:00
Ajay Bhargav Baaskaran 0a7b2ac821 [Fixes #2491] RemoveRange handles attributes parameter safely 2015-05-05 14:14:23 -07:00
Kiran Challa c0ca6214c2 React to Caching api changes 2015-05-05 10:08:50 -07:00
Kiran Challa 7e623258c0 Use strongly typed MediaTypeHeaderValue for content type in action results. 2015-05-04 14:06:58 -07:00
Doug Bunting 584015c79b A few quick cleanups
- in .kproj files, let VS mark a couple more test projects as such
- remove duplicate `ModelExpression` class
 - not necessary now that test project references MVC Core project
 - follow up to 9fded74
- avoid `resources` warning in project.json files
2015-05-04 11:55:24 -07:00
Ryan Nowak a5df6679f9 More model binding integration tests
Includes tests for a ValidationAttribute other than RequiredAttribute on
complex models using POCOs and collections
2015-05-04 11:20:52 -07:00
Kiran Challa 284c899233 Register default services directly in AddMvc and remove MvcServices 2015-05-04 10:53:34 -07:00
Harsh Gupta f37f2ae352 Validations with BindRequired on properties. 2015-05-04 10:32:35 -07:00
Harsh Gupta 502b832d17 Integration tests for
Collection Model Binder -> MutableObject(POCO) Model Binder – With-Data/Fallback-to-empty-prefix/Without-Data
2015-05-04 09:52:15 -07:00
Ryan Nowak 1ee5238709 Another batch of ModelBinding integration tests
Includes tests for [Required] on properties with various levels of nesting
inside complex model binders.
2015-05-01 14:22:44 -07:00
N. Taylor Mullen 64e726d2b2 Update LICENSE.txt and license header on files. 2015-05-01 13:55:25 -07:00
Pranav K 124496a12f Use DateTimeOffset with fixed time zone in tests to allow it to work in
non-PST timezones.
2015-04-30 21:40:20 -07:00
Harsh Gupta 3a3acde904 Simple ModelBinders and Simple ModelBinder Poco-2
Covers simple scenario for each model binder.
Covers scenarios mixing a POCO model binder -> Simple Model binder.

This contains tests for
FormCollectionModelBinder
BinderTypeBasedModelBinder
TypeConverterModelBinder

Remainging:
TypeMatchModelBinder

This also adds missing unit test for TypeMatchModelBinder as well.
2015-04-30 13:43:02 -07:00
Ryan Nowak 95feb5a3ec ModelBinding Integration tests part 3 2015-04-30 12:45:10 -07:00
Brennan 44bcd36256 React to interface renames 2015-04-30 09:46:13 -07:00
Ryan Nowak 4b686b1234 Part 2 of integration tests for GenericModelBinder
This includes a random sampling of combinations where a collection model
binder is binding another collection as an element type.
2015-04-29 16:52:52 -07:00
Chris R b455724859 Remove redundant Http.Core and Http.Interfaces dependencies. 2015-04-29 15:59:52 -07:00
Ajay Bhargav Baaskaran 89ebce0289 [Fixes #2336] Generate some input elements without value attribute 2015-04-29 13:47:17 -07:00
Kiran Challa 0a1918acac Cleanup logging in tag helpers 2015-04-29 09:41:51 -07:00
Ryan Nowak f77bb0ed2f GenericModelBinder integration tests part 1
- Covers simple scenario for each model binder.
- Covers scenarios mixing a generic model binder with a greedy model
  binder.
2015-04-28 17:43:29 -07:00
Harsh Gupta b5b37265e1 Simple ModelBinders and Simple ModelBinder Poco - 1
Covers simple scenario for each model binder.
Covers scenarios mixing a POCO model binder -> Simple Model binder.

This contains tests for
HeaderModel
ServicesModelBinder
CancellationTokenModelBinder
ByteArrayModelBinder
FormFileModelBinder

Part 2 Will contain similar tests for
FormCollectionModelBinder
BinderTypeBasedModelBinder
TypeConverterModelBinder
TypeMatchModelBinder
Any leftovers for BodyModelBinder
2015-04-28 14:13:36 -07:00
Kirthi Krishnamraju 30e54609cc Fix #1911 : Create a separate package for ApiExplorer 2015-04-28 13:13:20 -07:00
Ajay Bhargav Baaskaran 3ca018375a Issue #1885 - Updated startup code in few websites 2015-04-28 10:42:01 -07:00
Youngjune Hong 3ea7daabfe Added the default constructor to ViewContext 2015-04-27 15:30:18 -07:00
N. Taylor Mullen f152ea7004 React to aspnet/Razor#279 changes.
- Updated all tests and TagHelpers to utilize the new TagHelperOutput.Attributes and TagHelperContext.AllAttribute types.

aspnet/Razor#279
2015-04-27 14:30:30 -07:00
Doug Bunting 05ac641f9a PR comment on c162209
- place `[HtmlAttributeNotBound]` on its own line
 - don't use (wonderful) shortcut syntax
- @Eilon's comment https://github.com/aspnet/Mvc/pull/2452/files#r29162068
2015-04-27 13:32:19 -07:00
Kirthi Krishnamraju 3c9456e2a3 AntiForgery: Add documentation and update variable names for readability 2015-04-27 11:40:59 -07:00
Doug Bunting c1622096b9 React to aspnet/Razor#182 fix
- use `[HtmlAttributeNotBound]` to make tag helper properties `public`
- properties remain invisible in Razor
2015-04-27 08:17:40 -07:00
Doug Bunting 838f672b10 Clean up .xproj files added with HttpAbstractions 2015-04-27 08:12:22 -07:00
Ryan Nowak 9fded74b15 Merging ModelBinding into Mvc.Core 2015-04-27 02:10:37 -07:00
Ryan Nowak 572e57e25c Create Mvc.Abstractions
Creates a new package 'Microsoft.AspNet.Mvc.Abstractions' which defines
APIs and contracts for core concepts and extensibility points in MVC.

Includes:
- ModelBinding
- Validation
- Model State
- Model Metadata
- Action Descriptors
- IActionResult
- Filters
- IActionConstraint
2015-04-27 00:49:14 -07:00
Henk Mollema 955b45f995 Utilized `nameof()` for `ArgumentNullException`s
Utilized the use of nameof() operator for ArgumentNullExceptions.
2015-04-24 14:00:34 -07:00
Chris Ross 98614736a7 React to authentication API changes. 2015-04-24 10:53:50 -07:00
Hao Kung 60fd1f28b9 React to security changes 2015-04-23 23:00:20 -07:00
Doug Bunting 3fd4991959 Bind to readonly non-`null` collections
- part 1/2 of #2294
- handle readonly non-`null` collections in relevant binders
 - `CollectionModelBinder.CopyToModel()` and `MutableObjectModelBinder.AddToProperty()` methods
 - handle read-only controller properties in `DefaultControllerActionArgumentBinder`
 - do not copy into arrays e.g. add `CopyToModel()` override in `ArrayModelBinder`
- remove ability to set a private controller property
 - confirm `SetMethod.IsPublic` in `DefaultControllerActionArgumentBinder`
- avoid NREs in `GetModel()` overrides

Test handling of readonly collections
- previous tests barely touched this scenario
- also add more tests setting controller properties

nits:
- add missing `[NotNull]` attributes
- add missing doc comments
- consolidate a few `[Fact]`s into `[Theory]`s
- simplify some wrapping; shorten a few lines
- remove dead code in `DefaultControllerActionArgumentBinder` and `ControllerActionArgumentBinderTests`
2015-04-23 20:11:09 -07:00
Ajay Bhargav Baaskaran a80a333fea [Fixes #1489] Support for named route in form tag helper 2015-04-23 17:08:38 -07:00
Ajay Bhargav Baaskaran 37e819ce85 [Fixes #2085] Using custom HtmlEncoder in unit tests - part 2 2015-04-23 13:36:54 -07:00
Ajay Bhargav Baaskaran 5da8ba7769 [Fixes #2085] Using custom HtmlEncoder in unit tests 2015-04-23 13:16:27 -07:00
Chris Ross 017e44ae95 Handle FileProviders package changes. 2015-04-23 12:56:10 -07:00
Kiran Challa 687ab258a1 Logging for filters 2015-04-23 06:38:45 -07:00
Ajay Bhargav Baaskaran 1511ea34a8 [Fixes #662] Throw if controller cannot be activated 2015-04-22 16:15:48 -07:00
Harsh Gupta 4df7d52210 PR Comments 2015-04-22 14:40:16 -07:00
Harsh Gupta 86fcacea92 Fix for #2357 : We prevent assigining null values to non nullable controller properties. 2015-04-22 14:40:14 -07:00
Harsh Gupta 53ef8258bb The model state keys for body bound models which are bound at property will use the entire model name with this change for example
Consider

public class Person
{
    [FromBody]
    public Address Address { get; set; }
}

public class Address
{
   [Required]
   public string Street { get; set; }

   public int Zip { get; set; }
}

Request body { "Zip" : 12345 }
In this case the error key would be "prefix.Address.Street" (assuming there is a prefix because of additional metadata/positioning for/of the Person model).

public class Person
{
       [Required]
       public string Name { get; set; }
}

public void Action([FromBody]Person p)
{
}
Request body { }
In this case the prefix gets ignored and the error key is Name.
Please note this is so that we are compatible with MVC 5.0

public class Person
{
       [Required]
       public string Name { get; set; }
}

public void Action([FromBody][ModelBinder(Name = "prefix")] Person p)
{
}

public void Action2([FromBody][Bind(Name = "prefix")] Person p)
{
}
Request body { }
In both these cases (Action and Action2) the prefix gets ignored and the error key is Name.
This is a slight improvement from mvc, as in MVC the action parameter would be null.

The followup for this would be to fix #2416 -
This PR ignores the validation assuming that #2416 will address the issues and update the test.

NOTE: previous versions of mvc did not have property binding and hence there is no precedence in this case. For MVC and Web API it was possible to body bind an action parameter which used an empty prefix instead of a parameter name for adding errors to model state (In case of MVC if a custom prefix was provided, it failed binding from body i.e the parameter was null).
2015-04-22 14:02:08 -07:00
Kirthi Krishnamraju 924d50bd8f Added functionaltests for JsonPatchDocument 2015-04-22 13:44:25 -07:00
Kirthi Krishnamraju bf712263fc Fix for #2280 - Cannot do an "add" patch to IList<Anything>
Added unit tests
2015-04-22 13:44:14 -07:00
Kirthi Krishnamraju e48565dcd8 Adding errors in ModelState 2015-04-22 13:44:09 -07:00
Kirthi Krishnamraju 9f97d25e02 Moved exception messages to resource file and updated tests to validate exception messages 2015-04-22 13:44:04 -07:00
Hao Kung a001cd4f2a React to Security logging change 2015-04-22 12:51:19 -07:00
Ryan Nowak f3679f214e Fix #1712 - remove reflection from validation code in MutableObjectModelBinder
This change moves [BindingBehavior(...)] and friends into the model
metadata layer, and removes the reflection code from
MutableObjectModelBinder that was looking for them previously.
2015-04-22 12:10:45 -07:00
Kirthi Krishnamraju 9d2b1822d9 Fix for #819 : Attribute Routing: Resolve Name + Token Replacement 2015-04-22 11:47:23 -07:00
Henk Mollema 323ec2fdc7 Throw exception with unknown attributeName
Throw a meaningful exception if the attribute to copy does not exists
in the attributes of the TagHelperContext rather than:
`System.InvalidOperationException : Sequence contains no matching
element`.

Added test too.
2015-04-21 14:49:14 -07:00
Kiran Challa 162c4709c1 Refactor attribute route 2015-04-21 11:02:05 -07:00
sornaks 064c01cf2b #2267 - Moving responsibility for setting ModelState.MaxAllowedErrors into a more appropriate location. 2015-04-20 14:31:04 -07:00
Ryan Nowak 8bae02928d Fix build break 2015-04-20 12:44:30 -07:00
Ryan Nowak 2719111453 Add more details to ModelAttributes
This change adds more information to ModelAttributes, so that metadata
providers can look at the attributes on the property and type separately
if so desired
2015-04-17 17:35:20 -07:00
Ajay Bhargav Baaskaran a4fd51772f [Fixes #2276] Serialize only simple types to session in TempData 2015-04-17 14:30:47 -07:00
Pranav K fb451b51e5 Added SourceLocation to inherited chunks \ tag helpers
Updated CompilationResult to support compilation failures from multiple
files.

Fixes #2321
2015-04-17 11:23:38 -07:00
Ajay Bhargav Baaskaran f878ca5b15 [Fixes #1919] Added path info to RazorPage exceptions 2015-04-17 10:30:37 -07:00
ianhong 21031a3aa8 Add sample and functional test for custom inline constraints 2015-04-17 08:42:20 -07:00
Kiran Challa e7728dde3f Log view discovery 2015-04-17 04:23:45 -07:00
Chris Ross 6223aac9be Handle Http.Core rename. 2015-04-16 15:48:27 -07:00
Ryan Nowak f77493dffe Part 1 of #1712 - Remove reflection in MutableObjectModelBinder
This change introduces a new property to ModelMetadata called
IsBindingRequired, which specifies whether or not a model value must be
present on the wire during model binding.

[DataMember(IsRequired = true)] is currently the only thing that will set
this property.

Updated tests and documentation for clarity on the difference in meaning
between MM.IsRequired and MM.IsBindingRequired. Moved setting for
IsRequired to ValidationMetadata which is a better fit.

Also added functional tests for [BindingBehavior] and [DataMember] in
model binding because they were totally missing.
2015-04-16 12:07:33 -07:00
Kiran Challa c3f10f4a0f Logging for content-negotiation 2015-04-16 12:02:55 -07:00
Kiran Challa 7576116969 Removed test code related to logging and instead used Testing repo's logging helpers. 2015-04-16 11:19:24 -07:00
Kiran Challa 65bd8c448a Removed Logging related ILogValues types and cleaned up tests. 2015-04-16 11:19:20 -07:00
Kiran Challa 20daab2fb5 Removed direct dependency on Framework.Logging and instead used Framework.Logging.Interfaces.
Fixed breaking code which additionally cleans up start-up logging which we wanted to do.
2015-04-16 11:19:17 -07:00
Henk Mollema 9eb87d4676 Removed htmlAttributes null check in GenerateForm
The null check caused the form not to use the default url generation
behavior when html attributes were specified.
2015-04-16 16:29:27 +02:00
Harsh Gupta c67236141b Fixes 2304:
The fix splits client validation and model validation into two separate hierarchies.
Introduced ClientModelValidatorProvider in MvcOptions, which can be iterated to produce IClientModelValidators.
As a result of this, HtmlGenerator code can be free of ActionBindingContext and directly consumes options.
This also means that we do not modify the client validations during resource filters.
2015-04-15 14:30:46 -07:00
N. Taylor Mullen eaa58bc913 Change inject directive to format correctly after newline during design time.
- Also modified existing tests to account for aspnet/Razor#332 which fixed models formatting after newline.
- Updated tests for inject to understand new formatting parsing.

aspnet/Razor#332
2015-04-15 12:18:45 -07:00
Ajay Bhargav Baaskaran 4951235eef [Fixes #2337] Added support for file types in input taghelper and
htmlhelper
2015-04-15 11:58:40 -07:00
Ajay Bhargav Baaskaran a9f2c937df React to Cookie changes 2015-04-15 11:50:11 -07:00
Hao Kung bee20973c7 React to http challenge changes 2015-04-15 11:39:12 -07:00
Youngjune Hong 9daf6b48a1 Update ModelBinderAttribute not throw exceptions from BinderType property setter 2015-04-14 17:31:50 -07:00
Youngjune Hong 852d6402eb Remove an unecessary test from DefaultAssemblyProviderTests 2015-04-14 16:00:10 -07:00
N. Taylor Mullen 2c4c35e126 Add rendering logic for PreElement and PostElement on TagHelperOutput.
- Added unit tests to validate that the properties were rendered correctly.
- Modified functional tests to utilize PreElement and PostElement.

aspnet/Razor#341
2015-04-14 12:01:20 -07:00
Ryan Nowak d0e5118741 Delay Attribute Route initialization to the first request 2015-04-13 16:16:27 -07:00
Kiran Challa 24b930fa7c Clean up logging.
- Removing scopes as we want to limit the number of scopes being created.
- Added new log statements using the new log format string.
2015-04-13 15:59:38 -07:00
sornaks 7ea467f73d Adding functional test for CacheTagHelper's enabled property. 2015-04-09 13:21:47 -07:00
Doug Bunting 8965ac96c0 Add more functional tests of cache profiles 2015-04-08 22:37:45 -07:00
Harsh Gupta 58a5ad2279 Adding Outputformatter in resource filters. 2015-04-08 16:46:46 -07:00
Ajay Bhargav Baaskaran f60896bd90 [Fixes #2259] Use fast property setter in MutableObjectModelBinder 2015-04-08 16:44:30 -07:00
Victor Hurdugaci 5164d647c5 React to resource renames 2015-04-08 15:27:51 -07:00
sornaks 645b82d194 Fixing the build break. 2015-04-08 14:30:19 -07:00
sornaks b08a2154c1 #2142: Introducing enabled attribute for CacheTagHelper. 2015-04-08 13:27:03 -07:00
Pranav K 43e24b2aad Removing IInputFormatterSelector
Follow up work item to #2269
2015-04-08 07:35:48 -07:00
Doug Bunting cef32d4098 React to aspnet/razor#320 fix
- Razor PR aspnet/Razor#350
2015-04-07 17:50:58 -07:00
Doug Bunting 73e8fc10e4 Automatically use `type="number"` for expressions of more types
- #2261
- include `short`, `ushort`, `float`, `double`

- correct typo in `<input/>` tag helper; ignored calculated format
 - only one test for `<input/>`'s calculated format 😦
- fill some `Editor*()` and `<input/>` tag helper test gaps

nit: clean up some trailing whitespace
2015-04-07 17:19:08 -07:00
Pranav K f9d53e341c * Simplify MvcOptions
* Remove facades for accessing Options<T> and pass options to the invoker

Fixes #2266
Fixes #2269
2015-04-07 14:45:53 -07:00
Doug Bunting 689f5bfa79 Use `XmlAssert` to avoid functional test failures
- #2311

nit: rewrap lines for consistency and to remove orphans
2015-04-07 11:46:38 -07:00
Doug Bunting 94721f09a9 Remove duplicate tests
- duplication in data sets confuses xUnit
2015-04-07 11:00:45 -07:00
Kiran Challa 9330789fe3 Reacting to ILogger api changes 2015-04-04 02:52:43 -07:00
Doug Bunting f3ec6f33ae Merge remote-tracking branch 'origin/release' into dev 2015-04-03 12:08:11 -07:00
Doug Bunting 7916cb9c68 Add a few more `<Service/>` items 2015-04-02 22:55:21 -07:00
N. Taylor Mullen 88dc5f73ac Update project.json, code=>compile. Also remove **/*.cs and **/*.vs from compile section. These are now defaulted to on. 2015-04-02 16:17:54 -07:00
Doug Bunting 393aa54545 Update .xproj files for Microsoft.Web.AspNet.* -> Microsoft.DNX.* rename 2015-04-02 13:49:27 -07:00
Pranav K 6058ad084e Reacting to diagnostics error page changes 2015-04-02 12:42:17 -07:00
N. Taylor Mullen 2de7c173ab Add travis and appveyor CI support. 2015-04-01 15:53:39 -07:00
Pranav K a4f3b86865 Prevent RazorErrorExtensions.ToDiagnostics from throwing when it
encounters SourceLocation.Undefined \ negative error lengths
2015-04-01 13:51:29 -07:00
Ryan Nowak acb657d951 [Perf] Fully cache model metadata
This change caches the actual model metadata instances. Some profiling
showed we didn't go far enough, we were allocating a lot of ModelMetadata
+ ModelPropertyCollection instances.
2015-04-01 11:44:17 -07:00
Hao Kung 08f0e1055b React to hosting changes 2015-03-30 18:20:33 -07:00
sornaks f640744f85 Merge branch 'release' into dev 2015-03-30 16:39:41 -07:00
sornaks 6e9533ce9c #2295 - Disposing the read stream after computing file hash. 2015-03-30 16:23:55 -07:00
Wei Wang 1fe0983845 Merge remote-tracking branch 'origin/release' into dev 2015-03-30 15:31:12 -07:00
Wei Wang 50ea1fb3d2 Rename "dnu bundle" to "dnu publish" 2015-03-30 15:29:48 -07:00
Pranav K 9dc8ecac8a Cleanup: Moving files from src/Microsoft.AspNet.Mvc.Razor/Razor/PreCompileViews ->
src/Microsoft.AspNet.Mvc.Razor/Precompilation
2015-03-30 14:51:11 -07:00
Doug Bunting 36bd387686 Merge remote-tracking branch 'origin/release' into dev 2015-03-30 11:44:35 -07:00
Doug Bunting 5882cdb03f MVC portion of aspnet/Razor#335
- set correct `MarkAsHtmlEncodedMethodName` value in `MvcRazorHost`
- handle `HtmlString` values in `TagHelperOutput.Attributes` in `RazorPage`
 - special-case double-quotes in `HtmlString` values
 - add `static WriteTo()` method for use in tag helpers
- handle non-`string` `output.Attributes` values in tag helpers
- make `TagHelperContentWrapperTextWriter` a `public` class
- provide a `TagHelperContent.Append(object, ...)` extension method
- add `LinkTagHelper.Href` and `ScriptTagHelper.Src` properties
 - avoid Razor HTML-encoding these attribute values before their use
- add `JavaScriptEncoder` properties in `LinkTagHelper` and `ScriptTagHelper`
 - allow encoding testing without unit testing the default encoder
- handle MVC and Razor changes for this bug in existing tests
- add functional tests of encodings
- add test encoders to TestCommon project

nits:
- correct `InputTagHelper` to pass `type=""` through unchanged
- set correct `TagHelperContentTypeName` value in `MvcRazorHost`
- remove unnecessary `FormTagHelper.Method` and `OptionTagHelper.Selected` properties
- remove complex ternaries and `ShouldAddFileVersion()` methods
- add a few debug assertions
- fix some odd wrapping
- remove or `#if`-out unused `using`s
- remove trailing whitespace
2015-03-30 10:54:00 -07:00
Pranav K 60381c415e Unrendered sections does not throw when redefined and rendered in nested
layout.

Fixes #2252
2015-03-30 09:33:09 -07:00
Doug Bunting 4d4686147f Let VS do its thing
- newline after BOM and slight reordering of Mvc.sln
- add `Service/Include` properties to some test .xproj files
 - also add BOM in a few cases
2015-03-28 14:41:40 -07:00
Kiran Challa e571f401c3 Enable a skipped test to run on coreclr 2015-03-26 23:57:35 -07:00
Kiran Challa e9d7bb2230 React to ElmLogger extension changes 2015-03-26 23:46:15 -07:00
anurse 5477458781 fix tests 2015-03-26 22:30:46 -07:00
Victor Hurdugaci 38eff2ddbc Change casing of the "compiler" folder 2015-03-26 16:39:35 -07:00
N. Taylor Mullen b0b0836395 Merge branch 'release' into dev 2015-03-26 15:02:53 -07:00