From 1652bf554fb6c2c26b1505de829be201fc9dbcd1 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 10 Feb 2017 12:46:15 -0800 Subject: [PATCH] Workaround APICheck errors --- .../RazorPage.cs | 22 ++++++++++++------- .../RazorPageBase.cs | 11 +++++++++- .../Page.cs | 10 ++------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/RazorPage.cs b/src/Microsoft.AspNetCore.Mvc.Razor/RazorPage.cs index bab23fd534..6196e64b51 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor/RazorPage.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor/RazorPage.cs @@ -18,13 +18,21 @@ namespace Microsoft.AspNetCore.Mvc.Razor /// /// Represents properties and methods that are needed in order to render a view that uses Razor syntax. /// - public abstract class RazorPage : RazorPageBase, IRazorPage + public abstract class RazorPage : RazorPageBase { private readonly HashSet _renderedSections = new HashSet(StringComparer.OrdinalIgnoreCase); private bool _renderedBody; private bool _ignoreBody; private HashSet _ignoredSections; + /// + /// Initializes a new instance of . + /// + public RazorPage() + { + + } + /// /// Gets the to use when this /// handles non- C# expressions. @@ -49,12 +57,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor /// Returns null if is null. public ITempDataDictionary TempData => ViewContext?.TempData; - /// - public IHtmlContent BodyContent { get; set; } - - /// - public IDictionary PreviousSectionWriters { get; set; } - protected override HtmlEncoder Encoder => HtmlEncoder; /// @@ -289,7 +291,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor } /// - public void EnsureRenderedBodyOrSections() + public override void EnsureRenderedBodyOrSections() { // a) all sections defined for this page are rendered. // b) if no sections are defined, then the body is rendered if it's available. @@ -324,6 +326,10 @@ namespace Microsoft.AspNetCore.Mvc.Razor } } + // Working around an issue with ApiCheck tool + /// + public override Task FlushAsync() => base.FlushAsync(); + public override void BeginContext(int position, int length, bool isLiteral) { const string BeginContextEvent = "Microsoft.AspNetCore.Mvc.Razor.BeginInstrumentationContext"; diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/RazorPageBase.cs b/src/Microsoft.AspNetCore.Mvc.Razor/RazorPageBase.cs index 9f852567a7..89255284bc 100644 --- a/src/Microsoft.AspNetCore.Mvc.Razor/RazorPageBase.cs +++ b/src/Microsoft.AspNetCore.Mvc.Razor/RazorPageBase.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor /// /// Represents properties and methods that are needed in order to render a view that uses Razor syntax. /// - public abstract class RazorPageBase + public abstract class RazorPageBase : IRazorPage { private StringWriter _valueBuffer; private ITagHelperFactory _tagHelperFactory; @@ -73,8 +73,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor /// public dynamic ViewBag => ViewContext?.ViewBag; + /// public bool IsLayoutBeingRendered { get; set; } + /// + public IHtmlContent BodyContent { get; set; } + + /// + public IDictionary PreviousSectionWriters { get; set; } + protected virtual HtmlEncoder Encoder { get; set; } protected Stack TagHelperScopes { get; } = new Stack(); @@ -714,6 +721,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor (value is bool && (bool)value); } + public abstract void EnsureRenderedBodyOrSections(); + private struct AttributeInfo { public AttributeInfo( diff --git a/src/Microsoft.AspNetCore.Mvc.RazorPages/Page.cs b/src/Microsoft.AspNetCore.Mvc.RazorPages/Page.cs index 02d3e43077..488fd0ac70 100644 --- a/src/Microsoft.AspNetCore.Mvc.RazorPages/Page.cs +++ b/src/Microsoft.AspNetCore.Mvc.RazorPages/Page.cs @@ -21,12 +21,6 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages private IUrlHelper _urlHelper; private PageArgumentBinder _binder; - /// - public IHtmlContent BodyContent { get; set; } - - /// - public IDictionary PreviousSectionWriters { get; set; } - /// /// The . /// @@ -73,9 +67,9 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages } /// - public void EnsureRenderedBodyOrSections() + public override void EnsureRenderedBodyOrSections() { - throw new NotImplementedException(); + throw new NotSupportedException(); } public override void BeginContext(int position, int length, bool isLiteral)