Commit Graph

979 Commits

Author SHA1 Message Date
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