Commit Graph

1832 Commits

Author SHA1 Message Date
Ryan Nowak 950b8b41a8 Rename IFilter -> IFilterMetadata 2015-07-06 23:40:43 -07:00
sornaks 57f1ae755f Optimizing TagBuilder.CreateSanitizedId to create buffer only when needed.
- Tested with a page containing 33% of invalid Ids which go through TagBuilder.CreateSanitizedId.
- Ran 10,000 requests with 20 in parallel and measured perf.
- Data before the change:
System.String allocated by CreateSanitizedId: 1.84 mb
System.Text.StringBuilder allocated by CreateSanitizedId: 1.68 mb
- Data after the change:
System.String allocated by CreateSanitizedId: 0.720 mb
System.Text.StringBuilder allocated by CreateSanitizedId: 0.560 mb

Around 60% improvement from the original case.
2015-07-06 17:19:38 -07:00
Eilon Lipton 4b18bfb494 Rename builder extension types to have more specific names 2015-07-06 16:35:44 -07:00
N. Taylor Mullen fc2019c973 Modify `TypeConverterModelBinder`'s `ModelBindingResult.IsModelSet` to be false when model value is `null` for non-null accepting types.
- Previously `ModelBindingResult.IsModelSet` would be set to true if type conversions resulted in empty => `null` values for ValueTypes. This resulted in improper usage of `ModelBindingResult`s creating null ref exceptions in certain cases.
- Updated existing functional test to account for new behavior. Previously it was handling the null ref exception by stating that errors were simply invalid; now we can provide a more distinct error.
- Added unit test to validate `TypeConverterModelBinder` does what it's supposed to when conversions result in null values.
- Added additional integration tests for `TypeConverterModelBinder`.

#2720
2015-07-02 20:03:32 -07:00
sornaks 68523a3550 Fixing tests in Mono.
- Disabling tests which have corresponding bugs in mono.
- Fixing a few tests which do not handle *nix file system.
- Updating Travis configuration to use mono's alpha bits.
- Introducing PlatformNormalizer to normalize content across multiple platforms.
2015-07-02 17:24:14 -07:00
sornaks 7606c81482 Renaming - file case. 2015-07-02 14:20:10 -07:00
Kirthi Krishnamraju 38748b54eb [JsonPatch]: Added NotNull attribute to parameters and updated comments 2015-07-02 12:19:38 -07:00
Victor Hurdugaci c2952f26fa Add repository information to project files 2015-07-01 20:18:53 -07:00
Hao Kung ec582d4512 React to security changes 2015-07-01 12:54:09 -07:00
Kiran Challa 406a3853af React to newly added api MediaTypeHeaderValue.Clone() #2569 2015-06-30 15:40:34 -07:00
Ajay Bhargav Baaskaran d2d4d1d1d3 [Fixes #2715] Using default SerializerSettings from MvcJsonOptions 2015-06-30 14:49:42 -07:00
N. Taylor Mullen 15cb2ce709 React to aspnet/Razor#382 2015-06-30 12:49:48 -07:00
Ajay Bhargav Baaskaran 6213354b85 Fixes for FileVersionProvider
- Path with query string works
 - No exception is thrown for absolute path
2015-06-30 11:25:32 -07:00
Doug Bunting 4d5604690d Add or update sample `readme.md` files
- #2731
2015-06-26 21:15:18 -07:00
Hao Kung 7c426f7835 React to Http/AuthNZ changes 2015-06-25 17:30:09 -07:00
Ajay Bhargav Baaskaran a3cbb1f378 [Fixes #2684] Removed Mvc.Common
- Removed TaskHelper and refactored with ClosedGenericMatcher
 - Removed TypeHelper
 - Moved custom encodings to InputFormatter
 - Moved ObjectToDictionary to PropertyHelper
 - Removed respective tests and test projects
2015-06-25 16:02:07 -07:00
Ryan Nowak 9e68537649 Add Minimal sample to Mvc.sln 2015-06-25 15:57:46 -07:00
N. Taylor Mullen 02a3ca8abb React to aspnet/Razor#352.
- Moved initialization of TagHelperDescriptorResolver to be Lazy so DesignTimeMode can be set.
2015-06-25 15:50:19 -07:00
Ryan Nowak 2f554c4b29 Use new antiforgery package 2015-06-25 14:45:00 -07:00
Ajay Bhargav Baaskaran e2787b3b84 [Fixes #2715] Removed formatter dependency from JsonResult and JsonViewComponentResult 2015-06-25 14:09:32 -07:00
Ryan Nowak d2908e7b7b Tweak lifetimes for a few commonly resolved services
This is some low hanging fruit for reducing the number of resolves we have
per request.

DefaultHtmlGenerator: Lots of these are created by RazorPage. It needs
IUrlHelper, so scoped is the best we can do for now. For an example, on
the front page of our sample, 48 of these are created for each request.
48! This takes it down to 1-per-request.

JsonResult: Again, multiple created per request (12 for the sample). This
class is totally stateless, so we can get down to 0-per-request.

DefaultViewComponentInvokerFactory: Same story as JsonResult.

DefaultObjectValidator/MvcMarkerService/DefaultFilterProvider:
these are stateless and pretty much guaranteed to be used by every request.
Getting them off the table.
2015-06-25 12:52:15 -07:00
Ryan Nowak 08068a85be Make use of concise 'TryAdd***' overloads where possible 2015-06-25 12:08:58 -07:00
Ryan Nowak f055618c8c Update MVC Enumerable service registrations
Updates MVC service registration code to use the new TryAddEnumerable
overload (idempotence++).

Some other misc cleanup to improve idempotence.
2015-06-24 18:44:36 -07:00
Doug Bunting 37f056ce2b [quick fixes] Cleanup a few things StyleCop found ages ago
- was trying out rules matching frequest PR comments (then)
 - did a manual scan to find new instances of same issues
- "" -> `string.Empty`
- `String` -> `string` and similar
- fill empty XML doc elements
 - ignored `JsonPatchDocument<TModel>`; just too many empty elements
- corrected missing / extra / out-of-order `<param>` descriptions
 - `xml-docs-test` detects incorrect external references but not these local issues
2015-06-24 16:37:39 -07:00
Doug Bunting 9c63d1d842 Get tests working with `core.autocrlf=false`
- #1514
- refactor `RazorCompilationService` to allow a test subclass that normalizes Razor file line endings
 - add `TestRazorCompilationService` to `RazorPageExecutionInstrumentationWebSite`
 - adjust line endings to match in `RazorPageExecutionInstrumentationTest`
- add `ignoreLineEndingDifferences: true` to `Assert.Equal()` calls
 - responses on Windows can have a mix of line endings
  - `git config` setting affects line endings in .cshtml (and baseline) files
  - however MVC and Razor mix `Environment.NewLine`s into HTTP responses
- update `PrecompilationTest` to split response regardless of line endings
- update `ResourceFile` to normalize all source file streams to LF only
 - ensures consistent checksums and line mappings
 - change `MvcRazorHostTest` to expect new line mappings
 - recreate baseline files to expect new checksums and literal line endings
- use verbatim strings in affected tests
 - careful use of `Environment.NewLine` in expectations is now just noise

nits:
- add doc comments in `RazorCompilationService`
- correct `TagHelpersTest` name to match containing file
- avoid incorrect `using` removal when `GENERATE_BASELINES` is not defined
- remove unnecessary `ResourceFile` normalization of output files
2015-06-24 14:53:07 -07:00
Harsh Gupta 09838fb45a Fixing Tests 2015-06-24 09:56:31 -07:00
Doug Bunting a170a4e1e4 Add `ModelBindingContext.IsFirstChanceBinding` and `IsTopLevelObject`
- cleanup duplicate code now that #2445 is fixed
- update unit tests using old `ModelBindingContext` setups
- fix (just) one integration test where `MutableObjectModelBinder` incorrectly calculated
  `isTopLevelObject` and returned a non-`null` model
- undo temporary changes in `BodyModelBinderTests` due to increased reliance on incorrect
  `isTopLevelObject` in #2445 fix

nits:
- combine tests that are now duplicates
- beef up coverage of some `MutableObjectModelBinderTest` cases
- remove unused `using`s
2015-06-24 09:17:29 -07:00
Doug Bunting a8c37e57de Fix build break: React to aspnet/EventNotification#11
- also aspnet/EventNotification@14e8e85
- `NotifierMethodAdapter` was renamed to `ProxyNotifierMethodAdapter`
2015-06-24 09:02:58 -07:00
Doug Bunting 715a0b6021 Add `ModelState` entries for greedy and type-matching model binders
- part II of II for #2445
- `FormCollectionModelBinder` is an exception because container is not user-provided
 - no `ModelState` entry added
- enable tests that #2445 was blocking
 - fix these and other tests expecting different `ModelState` entries
- simplify logic in `FormFileModelBinder`

`ValueProviderResult`
- remove `protected` setters and parameterless constructor
 - no scenario for their use in subclasses; however `ConvertTo()` remains `virtual`
- add single-parameter constructor
 - use in most of the greedy and type-matching model binders
- add doc comments throughout class

nits:
- use new `ValueProviderResult` constructor in many existing tests
- `""` -> `string.Empty` and `vpr` -> `valueProviderResult` in `ValueProviderResultTest`
- improve some test names in `BodyValidationIntegrationTests`
- do not check `Message` of a Json.NET `Exception`
2015-06-23 22:34:55 -07:00
Ajay Bhargav Baaskaran 4a4b8ec87e Made JsonOutputFormatter consistent with JsonInputFormatter 2015-06-23 11:39:59 -07:00
Ajay Bhargav Baaskaran f206cf6759 Removed IJsonOutputFormatter 2015-06-23 11:39:53 -07:00
Ajay Bhargav Baaskaran 5632a33098 Removed unnecessary log statement 2015-06-23 11:12:06 -07:00
Doug Bunting a29188444e Change hardcoded `bash` shebang to `env`
- aspnet/Home#695
- support various `bash` installation locations
- in particular, enable building on FreeBSD
2015-06-23 11:02:33 -07:00
Doug Bunting c4fa402105 Add `ModelBindingResult.IsFatalError` and make body binding more consistent
- part I of II for #2445 (with a duplicate code PR to follow)
- needed for #2445 because new `ModelState` entries for values will make inconsisteny worse
- change `BodyModelBinder` to use same keys for all `ModelBindingResult`s and `ModelState` entries
 - return fatal error result if formatter adds an error to `ModelState`
 - update potential callers to avoid avoid ignoring `IsFatalError`
- fix test attempting to serialize all of `ModelState`
 - will be borked with additional `RawValue`s in state
- fix two other tests that serialized `ModelState` but checked only `IsValid`

nits:
- address minor inconsistencies in `ModelBindingContext`
- use `System.Reflection.Extensions` package a bit more, where it's already referenced
- remove some unused resources
2015-06-18 16:19:01 -07:00
Ajay Bhargav Baaskaran b245996949 [Fixes #2700] Added HttpHeadAttribute 2015-06-17 12:58:02 -07:00
Doug Bunting 27283ec098 Make `string`-based expression evaluations behave consistently
- #1485, #1487
 - handle `TemplateInfo.HtmlFieldPrefix` in `ViewDataEvaluator.Eval()`
  - attempt lookup in the `ViewDataDictionary` using full name then evaluate
    relative `expression` against `viewData.Model`
  - handle `null` or empty `expression` special case in this method (remove `throw`s)
 - always pass relative `expression` name into `Eval()`
  - remove `null` or empty `expression` handling from higher-level code
  - in a couple of cases, special-case returned `ViewDataInfo`
- #2662
 - remove incorrect guard from `DefaultHtmlGenerator.GenerateRadioButtion()`
- add doc comments for the core methods that have changed
- enable unit tests skipped due to one of above bugs
 - fix one (yeah, just one) other test with incorrect expectations
- remove functional test comments about the above bugs and update expectations

nits:
- move some comments describing `ViewDataEvaluator` methods above the methods
2015-06-16 21:54:56 -07:00
Doug Bunting 8b5931d758 Add `Encode()` and `Raw()` overrides to `IHtmlHelper<TModel>`
- #2392
- `dynamic` does not work correctly when inherited from a base `interface`
2015-06-16 18:48:07 -07:00
Ajay Bhargav Baaskaran 4fe3fbabf0 React to aspnet/Diagnostics#142 changes 2015-06-16 11:27:33 -07:00
Ajay Bhargav Baaskaran 69e051dab7 Removed Cors.Core dependency from Mvc.Core 2015-06-16 10:25:27 -07:00
Ajay Bhargav Baaskaran fcdbd17e58 Removed Diagnostics.Abstractions dependency from Mvc.Razor 2015-06-16 10:25:26 -07:00
Ajay Bhargav Baaskaran 6fd8465402 Removed unnecessary cors dependency 2015-06-16 10:25:25 -07:00
Chris R a668f4e1c0 React to HttpResponse.HeadersSent rename. 2015-06-15 18:29:20 -07:00
Doug Bunting 296ec7736e Go one less step when resolving `[ModelMetadataType]`
- #2610
- make MVC 6's attribute consistent with data annotation's `[MetadataType]`, used in MVC 5
2015-06-14 18:02:10 -07:00
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 a665e48826 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:29:42 -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