Workaround APICheck errors

This commit is contained in:
Pranav K 2017-02-10 12:46:15 -08:00
parent bc3a741eee
commit 1652bf554f
3 changed files with 26 additions and 17 deletions

View File

@ -18,13 +18,21 @@ namespace Microsoft.AspNetCore.Mvc.Razor
/// <summary> /// <summary>
/// Represents properties and methods that are needed in order to render a view that uses Razor syntax. /// Represents properties and methods that are needed in order to render a view that uses Razor syntax.
/// </summary> /// </summary>
public abstract class RazorPage : RazorPageBase, IRazorPage public abstract class RazorPage : RazorPageBase
{ {
private readonly HashSet<string> _renderedSections = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private readonly HashSet<string> _renderedSections = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
private bool _renderedBody; private bool _renderedBody;
private bool _ignoreBody; private bool _ignoreBody;
private HashSet<string> _ignoredSections; private HashSet<string> _ignoredSections;
/// <summary>
/// Initializes a new instance of <see cref="RazorPage"/>.
/// </summary>
public RazorPage()
{
}
/// <summary> /// <summary>
/// Gets the <see cref="System.Text.Encodings.Web.HtmlEncoder"/> to use when this <see cref="RazorPage"/> /// Gets the <see cref="System.Text.Encodings.Web.HtmlEncoder"/> to use when this <see cref="RazorPage"/>
/// handles non-<see cref="IHtmlContent"/> C# expressions. /// handles non-<see cref="IHtmlContent"/> C# expressions.
@ -49,12 +57,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor
/// <remarks>Returns null if <see cref="ViewContext"/> is null.</remarks> /// <remarks>Returns null if <see cref="ViewContext"/> is null.</remarks>
public ITempDataDictionary TempData => ViewContext?.TempData; public ITempDataDictionary TempData => ViewContext?.TempData;
/// <inheritdoc />
public IHtmlContent BodyContent { get; set; }
/// <inheritdoc />
public IDictionary<string, RenderAsyncDelegate> PreviousSectionWriters { get; set; }
protected override HtmlEncoder Encoder => HtmlEncoder; protected override HtmlEncoder Encoder => HtmlEncoder;
/// <summary> /// <summary>
@ -289,7 +291,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
} }
/// <inheritdoc /> /// <inheritdoc />
public void EnsureRenderedBodyOrSections() public override void EnsureRenderedBodyOrSections()
{ {
// a) all sections defined for this page are rendered. // a) all sections defined for this page are rendered.
// b) if no sections are defined, then the body is rendered if it's available. // 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
/// <inheritdoc />
public override Task<HtmlString> FlushAsync() => base.FlushAsync();
public override void BeginContext(int position, int length, bool isLiteral) public override void BeginContext(int position, int length, bool isLiteral)
{ {
const string BeginContextEvent = "Microsoft.AspNetCore.Mvc.Razor.BeginInstrumentationContext"; const string BeginContextEvent = "Microsoft.AspNetCore.Mvc.Razor.BeginInstrumentationContext";

View File

@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
/// <summary> /// <summary>
/// Represents properties and methods that are needed in order to render a view that uses Razor syntax. /// Represents properties and methods that are needed in order to render a view that uses Razor syntax.
/// </summary> /// </summary>
public abstract class RazorPageBase public abstract class RazorPageBase : IRazorPage
{ {
private StringWriter _valueBuffer; private StringWriter _valueBuffer;
private ITagHelperFactory _tagHelperFactory; private ITagHelperFactory _tagHelperFactory;
@ -73,8 +73,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor
/// </summary> /// </summary>
public dynamic ViewBag => ViewContext?.ViewBag; public dynamic ViewBag => ViewContext?.ViewBag;
/// <inheritdoc />
public bool IsLayoutBeingRendered { get; set; } public bool IsLayoutBeingRendered { get; set; }
/// <inheritdoc />
public IHtmlContent BodyContent { get; set; }
/// <inheritdoc />
public IDictionary<string, RenderAsyncDelegate> PreviousSectionWriters { get; set; }
protected virtual HtmlEncoder Encoder { get; set; } protected virtual HtmlEncoder Encoder { get; set; }
protected Stack<TagHelperScopeInfo> TagHelperScopes { get; } = new Stack<TagHelperScopeInfo>(); protected Stack<TagHelperScopeInfo> TagHelperScopes { get; } = new Stack<TagHelperScopeInfo>();
@ -714,6 +721,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor
(value is bool && (bool)value); (value is bool && (bool)value);
} }
public abstract void EnsureRenderedBodyOrSections();
private struct AttributeInfo private struct AttributeInfo
{ {
public AttributeInfo( public AttributeInfo(

View File

@ -21,12 +21,6 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
private IUrlHelper _urlHelper; private IUrlHelper _urlHelper;
private PageArgumentBinder _binder; private PageArgumentBinder _binder;
/// <inheritdoc />
public IHtmlContent BodyContent { get; set; }
/// <inheritdoc />
public IDictionary<string, RenderAsyncDelegate> PreviousSectionWriters { get; set; }
/// <summary> /// <summary>
/// The <see cref="PageContext"/>. /// The <see cref="PageContext"/>.
/// </summary> /// </summary>
@ -73,9 +67,9 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
} }
/// <inheritdoc /> /// <inheritdoc />
public void EnsureRenderedBodyOrSections() public override void EnsureRenderedBodyOrSections()
{ {
throw new NotImplementedException(); throw new NotSupportedException();
} }
public override void BeginContext(int position, int length, bool isLiteral) public override void BeginContext(int position, int length, bool isLiteral)