Commit Graph

634 Commits

Author SHA1 Message Date
dougbu f4d53a0045 Prefer `IHtmlHelper` methods elsewhere in our code
- #847 line 7 sub-bullets
- don't call extension methods from our templates
 - partially addressed in PR #934 (for methods changed there)
- don't reference extension methods from XML comments
2014-08-06 16:08:17 -07:00
dougbu 4c5aa15f0b Call `IHtmlHelper` methods from extension methods
- don't call other extension methods
- #847 line 7
- remove extension methods that do nothing but pass through to the interface method
 - weren't exactly ambiguous (interface method wins) but were useless
2014-08-06 16:08:14 -07:00
dougbu 56d66c090e Make HTML helper `null` handling consistent
- #874 lines 3, 4, and 6
- correct `Value()` to treat a `null` expression name the same as `string.Empty`
- add missing `[NotNull]` attributes in `EditorExtensions` and for `GenerateIdFromName()`
- consistently pass `null` for default expression names to the helpers
 - for example, from extension methods
- add test cases using `null` for expression name

nits:
- correct summary XML comment for `HtmlHelper` class
- use named parameters and prefer interface (not extension) methods in changed calls
- use `string.Empty` instead of `""` in a few tests
2014-08-06 16:04:56 -07:00
Pranav K 4bf078269f Updating dev Nuget.config 2014-08-06 12:30:48 -07:00
Pranav K 4642d3968d Updating release Nuget.config 2014-08-05 15:50:05 -07:00
dougbu 8ab11bc073 Correct XML comment syntax
- fix problems at least with Roslyn compiler and VS IntelliSense or the Object Browser
 - `<see langref="keyword"/>` generates nothing
 - `<example>` at top level (outside `<summary>`) generates nothing
 - curly braces don't become angle brackets outside `<see cref="reference"/>` references
  - yeah, a point @yishaigalatzer asked about in a previous PR
- `<see href="reference"/>` is not valid
- correct some invalid use of angle brackets and remove useless empty elements
- correct unresolved XML comment references; generally, add namespace prefix

Symptoms for some of the above issues included
- generated XML comments such as `<!-- Badly formed XML comment ... -->`, usually indicating an unclosed element
- generated XML attributes such as `cref="!:..."`, indicating a broken reference
 - in a couple of cases we had `<typeparamref cref="TOption"/>`; attribute should be `"name"`

Few wording changes beyond
- `"opening </form> tag"` -> `"<form> start tag"`
- `"closing </form> tag"` -> `"</form> end tag"`

Also correct two typos in `HtmlHelper`

Will create a unit test to ensure XML syntax doesn't degrade going forward.  Separate PR.
- for now, check using `dir -r *.xml | sls '!'`
2014-08-05 14:24:48 -07:00
Pranav K eaee27756c Updating project.json to use frameworks token 2014-08-05 12:15:11 -07:00
Pranav K 5168808906 Introducing RazorTextWriter
RazorTextWriter represents the result of rendering a page as a sequence of
strings rather than a concatenated string. This avoids building up large
strings in memory.
2014-08-05 10:09:04 -07:00
dougbu dc58eb297d Remove unused `using`s from 3db0a80306 change
- see 3db0a80306
2014-08-04 18:10:50 -07:00
Pranav K 9d36a45f38 Updating tests using Moq to workaround Roslyn changes
https://roslyn.codeplex.com/workitem/246 affects usage of code with the
latest build of Roslyn with Moq v4.2. The workaround involves ensuring a
closure is created. Updating affected tests to make ToString() calls on
local variables to create these closures.
2014-08-04 17:13:19 -07:00
Ryan Nowak 383c6305e1 Fix for issue #349 2014-08-04 16:49:24 -07:00
dougbu 3db0a80306 Remove HTML helpers with `IDictionary<string, object>` parameters
- see line 2 of #874
- focus on `TextBox[For]()` and `ValidationSummary()`

related fixes included here:
- `TextArea[For]()` documentation incorrectly indicated their `htmlAttributes` parameters were dictionaries
- handle `htmlAttributes` parameters more consistently; create a dictionary only when necessary
2014-08-03 22:37:42 -07:00
dougbu c9b2323592 Move web site projects back where they belong
- solution corrupted in a recent checkin
2014-08-02 14:42:42 -07:00
dougbu d0d7c6aef8 Add `HtmlHelperDisplayTextTest` and `HtmlHelperValueExtensionsTest` classes 2014-08-01 21:06:28 -07:00
dougbu 126ee116cf Remove useless `.ToString()` calls in tests 2014-08-01 21:06:23 -07:00
dougbu 7845a8fbe1 `@Html.DisplayName()`, `.DisplayText()`, `.Id()`, `.Name()`, `.Value()` return `string`
- fixes #566 and part of #847
- allows compositions such as `@Html.Label("property", Html.Id("property"))`
  and `@Html.Raw(Html.DisplayText("property"))` (this one is not recommended)
- adjust XML comments to match
- add missing XML comments to `HtmlHelperValueExtensions`
- nit: `TInnerModel` -> `TModelItem`

- increase XML comment consistency for changed methods
 - generally make wording more consistent e.g. how we use words such as
   "returns"
 - use `<see langref="string|true|false|null"/>` more
2014-08-01 21:06:20 -07:00
Ben Brown 01f5fec210 Added Logging to Mvc 2014-08-01 15:33:47 -07:00
harshgMSFT 11d6c507f9 Stylecop fixes 2014-08-01 14:21:00 -07:00
harshgMSFT 19f3f78b3e Adding TextPlainFormatter to always handle returning strings as text\plain format.
Conflicts:
	src/Microsoft.AspNet.Mvc.Common/Encodings.cs
	src/Microsoft.AspNet.Mvc.Core/Formatters/JsonOutputFormatter.cs
	src/Microsoft.AspNet.Mvc/MvcOptionsSetup.cs
	test/Microsoft.AspNet.Mvc.Core.Test/ActionResults/ObjectContentResultTests.cs
	test/Microsoft.AspNet.Mvc.Test/MvcOptionSetupTest.cs
2014-08-01 13:47:23 -07:00
David Fowler 5708f7592b Changing GetLibraryExport to GetAllExports 2014-07-31 16:55:01 -07:00
Ryan Nowak 99d053ef81 Return a copy of the route values in functional tests.
This is a workaround for a Json.Net + CoreCLR issue.
2014-07-31 15:09:47 -07:00
dougbu 7ec4ab021e Make longest `@Html.DisplayForModel()` overload an extension method
- consistent with @Html.EditorForModel()` overloads
2014-07-31 12:01:28 -07:00
dougbu 40eb05f7e4 Improve `HtmlHelper` extension points
- address all of #659 and a bit of #874 (avoid `public virtual` methods in
  `HtmlHelper`)

- make `MetadataProvider` and `GetClientValidationRules()` `public` and
  therefore available to extension methods
- remove unused `GetValidationAttributes()` overload
- make remaining `GetValidationAttributes()` overload (and not
  `GetClientValidationRules()`) `virtual`, allowing derived classes to
  change the attributes without overriding all callers
- reverse `GetValidationAttributes()` and `GetClientValidationRules()`
  parameter order to match precedence
- add `GenerateName()` and `GenerateValidationSummary()` to make
  `protected virtual` method names consistent
- `Name()`, `ValidationSummary()` and `TextArea()` are no longer `virtual`
  because `protected virtual Generate*()` methods exist for all
2014-07-31 12:01:09 -07:00
dougbu b8960219b4 Fix Stylecop failure
- long line
2014-07-30 23:02:44 -07:00
harshgMSFT 8f00b9a7b4 Removing a stale proj reference in .sln 2014-07-30 14:53:04 -07:00
Pranav K 9c545aa343 Updating System.Xml.ReaderWriter to 4.0.10.0 2014-07-29 22:11:50 -07:00
harshgMSFT 01260515f1 Responding to comments 2014-07-29 18:25:34 -07:00
harshgMSFT 2fe2efa94a Moving to the latest pattern of Specifying formatters using options 2014-07-29 18:02:10 -07:00
harshgMSFT 307c191c17 Adding support for content negotiation.
This change consists of :
1. Conneg based on request headers, supports the following 3 scenarios:
	a. ContentType property on ObjectResult set to null or is empty.
	b. ContentType property on ObjectResult set to a single content type.
	c. ContentType property on ObjectResult set to multiple content types.

2. Parsing Helpers, comparers and extensions for comparing various http headers.
3. Tests.

Open workitems:
1. Remodel JsonResult and ContentResult to be a derivation of ObjectResult.
2. Populate DeclaredType.

Conflicts:
	src/Microsoft.AspNet.Mvc.Core/Formatters/OutputFormatterDescriptor.cs
	src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj
	src/Microsoft.AspNet.Mvc.Core/OptionDescriptors/OutputFormatterDescriptorExtensions.cs
	src/Microsoft.AspNet.Mvc.Core/Properties/Resources.Designer.cs
	src/Microsoft.AspNet.Mvc.Core/Resources.resx
	src/Microsoft.AspNet.Mvc.HeaderValueAbstractions/MediaTypeHeaderValue.cs
	src/Microsoft.AspNet.Mvc.HeaderValueAbstractions/MediaTypeWithQualityHeaderValue.cs
	src/Microsoft.AspNet.Mvc/MvcOptionsSetup.cs
	src/Microsoft.AspNet.Mvc/MvcServices.cs
	test/Microsoft.AspNet.Mvc.Core.Test/Microsoft.AspNet.Mvc.Core.Test.kproj
	test/Microsoft.AspNet.Mvc.Core.Test/OptionDescriptors/OutputFormatterDescriptorExtensionTest.cs
	test/Microsoft.AspNet.Mvc.HeaderValueAbstractions.Test/MediaTypeHeaderValueParsingTests.cs
	test/Microsoft.AspNet.Mvc.Test/MvcOptionSetupTest.cs
2014-07-29 17:26:56 -07:00
Pranav K 225b4903cf Reacting to Roslyn package changes 2014-07-29 16:50:19 -07:00
Ryan Nowak 2987f98283 Adding parameter replacement 2014-07-29 16:14:57 -07:00
Ryan Nowak 96c759e25c Add friendly name to action descriptor. Issue 820
Used in error messages for various attribute routing pieces, and anywhere
that you need a display name for an AD.
2014-07-29 15:21:34 -07:00
Ryan Nowak 2f9501458f Add friendly name to action descriptor. Issue 820
Used in error messages for various attribute routing pieces, and anywhere
that you need a display name for an AD.
2014-07-29 15:14:59 -07:00
sornaks cee73c0af3 1. Introducing XML Input Formatters.
2. Adding DelegatingStream class
3. Unit + Functional tests for formatters.
2014-07-29 15:04:23 -07:00
dougbu 43d1253936 Cleanup unused `FormContext` members due to legacy validation removal
- provide new property back for customer use
- remove unused FieldValidationMetadataClass
2014-07-29 10:44:12 -07:00
dougbu b5dcc9895d Fix #620, Remove legacy / non-unobtrusive client side validation
- remove `ViewContext.UnobtrusiveJavaScriptEnabled` property and all references
- avoid `ViewContext.GetFormContextForClientValidation()` calls since
  ternary expression is more explicit and we were inconsistent
- improve `ValidationMessage()` comments
- don't treat `ModelState.IsValid` as if it were still nullable
2014-07-29 10:43:19 -07:00
Javier Calvarro Nelson b0d52f73fd [Issue #527] Revive common ActionResults - Part 1.
1. Added HttpNotFound() to Controller.
2. Updated HttpStatusCodeResult to expose the StatusCode as a property.
3. Added unit tests for HttpNotFound() and for HttpStatusCodeResult.
4. Updated the MvcSample to add an action that uses HttpNotFound().
5. Brought back HttpNotFoundResult and added unit tests for it.
2014-07-25 13:04:59 -07:00
dougbu cd0285183e Fix StyleCop issues 2014-07-25 10:51:40 -07:00
Pranav K 24f74222f5 Introducing Controller.TryUpdateModel
This changeset reintroduces some of the overloads for
Controller.TryUpdateModel.

Fixes #415
2014-07-25 10:08:44 -07:00
Pranav K da0bf6f7d8 Commonizing code in option provider
* Adding ValueProviderFactoryProvider and CompositeValueProviderFactory to
  maintain parity in pattern with other option types.

Fixes #818
2014-07-25 06:52:00 -07:00
Pranav K 92e26cf8e0 RazorView should not create new ViewContext when rendering pages.
For pages that can pop back (e.g. Partial pages \ View Components), the
invoking component already creates a new ViewContext. ViewStart, Pages
and Layouts need to share the same Layout. This is required for sharing
ViewData values (such as title).

Fixes #861
2014-07-25 06:37:53 -07:00
dougbu 3746e44dc3 Add more `ModelMetadata` and HTML helper tests
- add `CachedDataAnnotationsMetadataAttributesTest`
- add `CachedDataAnnotationsModelMetadataTest`
- confirm more default property values in `ModelMetadataTest`
- confirm use of `DisplayName` in `ModelMetadataTest`
- add `HtmlHelperDisplayNameExtensionsTest`
- add `HtmlHelperLabelExtensionsTest`
- add `HtmlHelperNameExtensionsTest`
2014-07-24 18:32:35 -07:00
dougbu 48085eea08 Correct `ModelMetadata.IsRequired` to honour overrides
- subclasses would not calculate a value because `ModelMetadata` constructor
  set this property
- meant presence of a `[Required]` attribute in the model was ignored
2014-07-24 18:32:13 -07:00
dougbu 80a27c6f3b Add `ModelMetadata.DisplayName` property
- value comes from `Name` property of `[Display]` attribute
- use new property in `@Html.DisplayName()` and `@Html.Label()`; remove associated TODO comments
2014-07-24 18:31:48 -07:00
dougbu f4b582f654 Remove incorrect override of `ModelMetadata.GetDisplayName()`
- this method delegates to a number of `ModelMetadata` properties
- no use cases for overriding; should not be `virtual`
- `ModelMetadata.DisplayName` override using `DisplayAttribute.GetName()` coming in next commit
2014-07-24 16:49:02 -07:00
harshgMSFT b1912d799c Moving to RandomNumberGenerator as CryptRandom is not supported in Mono 2014-07-24 14:07:58 -07:00
Pranav K 47d227cbf2 Modify FindView and FindPartialView to accept ActionContext
Fixes #787
2014-07-24 11:48:23 -07:00
harshgMSFT a2561281b7 Adding MvcOptions.OutputFormatters property. 2014-07-23 17:46:17 -07:00
harshgMSFT 8ed7dadfd8 Fixing project.json in Mvc 2014-07-23 17:22:46 -07:00
harshgMSFT 1df4738a19 Adding OutputFormatter base class 2014-07-23 16:50:22 -07:00