diff --git a/samples/TagHelperSample.Web/Startup.cs b/samples/TagHelperSample.Web/Startup.cs index ad1086689e..0b26939810 100644 --- a/samples/TagHelperSample.Web/Startup.cs +++ b/samples/TagHelperSample.Web/Startup.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Microsoft.AspNet.Builder; +using Microsoft.AspNet.Mvc; using Microsoft.Framework.DependencyInjection; namespace TagHelperSample.Web @@ -10,7 +11,14 @@ namespace TagHelperSample.Web { public void Configure(IApplicationBuilder app) { - app.UseServices(services => services.AddMvc()); + app.UseServices(services => + { + services.AddMvc(); + + // Setup services with a test AssemblyProvider so that only the sample's assemblies are loaded. This + // prevents loading controllers from other assemblies when the sample is used in functional tests. + services.AddTransient>(); + }); app.UseMvc(); } } diff --git a/samples/TagHelperSample.Web/TestAssemblyProvider.cs b/samples/TagHelperSample.Web/TestAssemblyProvider.cs new file mode 100644 index 0000000000..d44fbdca47 --- /dev/null +++ b/samples/TagHelperSample.Web/TestAssemblyProvider.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Reflection; +using Microsoft.AspNet.Mvc; + +namespace TagHelperSample.Web +{ + /// + /// Limits MVC to use a single Assembly for controller discovery. This is used by the functional test to limit the + /// Controller discovery to TagHelperSample.Web Assembly alone. The sample should work in the absence of this file + /// when not run from a functional test. + /// + /// + /// This is a generic type because it needs to instantiated by a service provider to replace a built-in MVC + /// service. + /// + public class TestAssemblyProvider : IAssemblyProvider + { + public TestAssemblyProvider() + { + CandidateAssemblies = new Assembly[] { typeof(T).GetTypeInfo().Assembly }; + } + + public IEnumerable CandidateAssemblies { get; private set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/AnchorTagHelper.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/AnchorTagHelper.cs index f6771160e7..f4d7f58211 100644 --- a/src/Microsoft.AspNet.Mvc.TagHelpers/AnchorTagHelper.cs +++ b/src/Microsoft.AspNet.Mvc.TagHelpers/AnchorTagHelper.cs @@ -93,7 +93,6 @@ namespace Microsoft.AspNet.Mvc.TagHelpers routePrefixedAttributes.Any()) { // User specified an href and one of the bound attributes; can't determine the href attribute. - // Reviewers: Should this instead ignore the helper-specific attributes? throw new InvalidOperationException( Resources.FormatAnchorTagHelper_CannotOverrideHref( "", diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/FormTagHelper.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/FormTagHelper.cs index 573b074bb3..ca9246bf3d 100644 --- a/src/Microsoft.AspNet.Mvc.TagHelpers/FormTagHelper.cs +++ b/src/Microsoft.AspNet.Mvc.TagHelpers/FormTagHelper.cs @@ -55,7 +55,10 @@ namespace Microsoft.AspNet.Mvc.TagHelpers public bool? AntiForgery { get; set; } /// - /// At most adds an anti-forgery token if user provides an action attribute. + /// + /// Does nothing if user provides an action attribute and is null or + /// false. + /// /// /// Thrown if action attribute is provided and or are /// non-null or if the user provided asp-route-* attributes. @@ -71,8 +74,6 @@ namespace Microsoft.AspNet.Mvc.TagHelpers if (Action != null || Controller != null || routePrefixedAttributes.Any()) { // User also specified bound attributes we cannot use. - // Reviewers: Should this instead ignore the helper-specific attributes -- only change - // antiForgeryDefault? throw new InvalidOperationException( Resources.FormatFormTagHelper_CannotOverrideAction( "
", diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/InputTagHelper.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/InputTagHelper.cs index 4e64bf71d9..04578ed591 100644 --- a/src/Microsoft.AspNet.Mvc.TagHelpers/InputTagHelper.cs +++ b/src/Microsoft.AspNet.Mvc.TagHelpers/InputTagHelper.cs @@ -125,7 +125,6 @@ namespace Microsoft.AspNet.Mvc.TagHelpers if (For == null) { // Regular HTML element. Just make sure Format wasn't specified. - // Reviewers: Should this instead ignore the unused helper-specific attribute? if (Format != null) { throw new InvalidOperationException(Resources.FormatInputTagHelper_UnableToFormat( diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/SelectTagHelper.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/SelectTagHelper.cs index 60838fcdd9..2648b7c16a 100644 --- a/src/Microsoft.AspNet.Mvc.TagHelpers/SelectTagHelper.cs +++ b/src/Microsoft.AspNet.Mvc.TagHelpers/SelectTagHelper.cs @@ -72,7 +72,6 @@ namespace Microsoft.AspNet.Mvc.TagHelpers if (For == null) { // Regular HTML