Enable GenerateDocumentationFile. Add/fix XML docs.

This commit is contained in:
Steve Sanderson 2018-04-13 14:33:04 +01:00
parent 2f792cf53b
commit 4cbf6cc64b
25 changed files with 161 additions and 29 deletions

View File

@ -0,0 +1,8 @@
<Project>
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
</Project>

View File

@ -29,6 +29,10 @@ namespace Microsoft.AspNetCore.Blazor.Browser.Http
static IDictionary<int, TaskCompletionSource<HttpResponseMessage>> _pendingRequests
= new Dictionary<int, TaskCompletionSource<HttpResponseMessage>>();
/// <summary>
/// The name of a well-known property that can be added to <see cref="HttpRequestMessage.Properties"/>
/// to control the arguments passed to the underlying JavaScript <code>fetch</code> API.
/// </summary>
public const string FetchArgs = "BrowserHttpMessageHandler.FetchArgs";
/// <inheritdoc />

View File

@ -5,6 +5,9 @@ using System;
namespace Microsoft.AspNetCore.Blazor.Browser.Interop
{
/// <summary>
/// Represents errors that occur during an interop call from .NET to JavaScript.
/// </summary>
public class JavaScriptException : Exception
{
internal JavaScriptException(string message) : base(message)

View File

@ -1,11 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNetCore.Blazor.Razor
{
public static class BlazorCodeDocItems
{
public static object ClassName = new object();
public static object Namespace = new object();
}
}

View File

@ -3,16 +3,24 @@
using System;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Extensions;
namespace Microsoft.AspNetCore.Blazor.Razor
{
/// <summary>
/// Initializes the Blazor extension.
/// </summary>
public class BlazorExtensionInitializer : RazorExtensionInitializer
{
/// <summary>
/// Specifies the declaration configuration.
/// </summary>
public static readonly RazorConfiguration DeclarationConfiguration;
/// <summary>
/// Specifies the default configuration.
/// </summary>
public static readonly RazorConfiguration DefaultConfiguration;
static BlazorExtensionInitializer()
@ -29,6 +37,10 @@ namespace Microsoft.AspNetCore.Blazor.Razor
Array.Empty<RazorExtension>());
}
/// <summary>
/// Registers the Blazor extension.
/// </summary>
/// <param name="builder">The <see cref="RazorProjectEngineBuilder"/>.</param>
public static void Register(RazorProjectEngineBuilder builder)
{
if (builder == null)
@ -71,6 +83,10 @@ namespace Microsoft.AspNetCore.Blazor.Razor
}
}
/// <summary>
/// Initializes the Blazor extension.
/// </summary>
/// <param name="builder">The <see cref="RazorProjectEngineBuilder"/>.</param>
public override void Initialize(RazorProjectEngineBuilder builder)
{
if (builder == null)

View File

@ -11,32 +11,48 @@ using Microsoft.AspNetCore.Razor.Language.Intermediate;
namespace Microsoft.AspNetCore.Blazor.Razor
{
/// <summary>
/// A <see cref="DocumentClassifierPassBase"/> that recognizes Blazor components.
/// </summary>
public class ComponentDocumentClassifierPass : DocumentClassifierPassBase, IRazorDocumentClassifierPass
{
/// <summary>
/// The component document kind.
/// </summary>
public static readonly string ComponentDocumentKind = "Blazor.Component";
private static readonly char[] PathSeparators = new char[] { '/', '\\' };
/// <summary>
/// The base namespace.
/// </summary>
// This is a fallback value and will only be used if we can't compute
// a reasonable namespace.
public string BaseNamespace { get; set; } = "__BlazorGenerated";
// Set to true in the IDE so we can generated mangled class names. This is needed
// to avoid conflicts between generated design-time code and the code in the editor.
//
// A better workaround for this would be to create a singlefilegenerator that overrides
// the codegen process when a document is open, but this is more involved, so hacking
// it for now.
/// <summary>
/// Gets or sets whether to mangle class names.
///
/// Set to true in the IDE so we can generated mangled class names. This is needed
/// to avoid conflicts between generated design-time code and the code in the editor.
///
/// A better workaround for this would be to create a singlefilegenerator that overrides
/// the codegen process when a document is open, but this is more involved, so hacking
/// it for now.
/// </summary>
public bool MangleClassNames { get; set; } = false;
/// <inheritdoc />
protected override string DocumentKind => ComponentDocumentKind;
/// <inheritdoc />
protected override bool IsMatch(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode)
{
// Treat everything as a component by default if Blazor is part of the configuration.
return true;
}
/// <inheritdoc />
protected override void OnDocumentStructureCreated(
RazorCodeDocument codeDocument,
NamespaceDeclarationIntermediateNode @namespace,
@ -145,6 +161,7 @@ namespace Microsoft.AspNetCore.Blazor.Razor
documentNode.Target = new BlazorCodeTarget(documentNode.Options, _targetExtensions);
}
/// <inheritdoc />
protected override void OnInitialized()
{
base.OnInitialized();

View File

@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Razor.Language.Intermediate;
namespace Microsoft.AspNetCore.Blazor.Razor
{
public class PageDirective
internal class PageDirective
{
public static readonly DirectiveDescriptor Directive = DirectiveDescriptor.CreateDirective(
"page",

View File

@ -12,11 +12,18 @@ namespace Microsoft.AspNetCore.Blazor.Razor
/// </summary>
public class RazorCompilerException : Exception
{
/// <summary>
/// Constructs an instance of <see cref="RazorCompilerException"/>.
/// </summary>
/// <param name="diagnostic"></param>
public RazorCompilerException(RazorDiagnostic diagnostic)
{
Diagnostic = diagnostic;
}
/// <summary>
/// Gets the diagnostic value.
/// </summary>
public RazorDiagnostic Diagnostic { get; }
}
}

View File

@ -11,6 +11,9 @@ using System.Net.Mime;
namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Provides extension methods that add Blazor-related middleware to the ASP.NET pipeline.
/// </summary>
public static class BlazorAppBuilderExtensions
{
/// <summary>

View File

@ -3,6 +3,10 @@
namespace Microsoft.AspNetCore.Builder
{
/// <summary>
/// Provides configuration options to the <see cref="BlazorAppBuilderExtensions.UseBlazor(IApplicationBuilder, BlazorOptions)"/>
/// middleware.
/// </summary>
public class BlazorOptions
{
/// <summary>

View File

@ -5,9 +5,19 @@ using System;
namespace Microsoft.AspNetCore.Blazor.Components
{
/// <summary>
/// Configures options for binding specific element types.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class BindElementAttribute : Attribute
{
/// <summary>
/// Constructs an instance of <see cref="BindElementAttribute"/>.
/// </summary>
/// <param name="element">The tag name of the element.</param>
/// <param name="suffix">The suffix value. For example, set this to <code>value</code> for <code>bind-value</code>, or set this to <code>null</code> for <code>bind</code>.</param>
/// <param name="valueAttribute">The name of the value attribute to be bound.</param>
/// <param name="changeAttribute">The name of an attribute that will register an associated change event.</param>
public BindElementAttribute(string element, string suffix, string valueAttribute, string changeAttribute)
{
if (element == null)
@ -30,13 +40,25 @@ namespace Microsoft.AspNetCore.Blazor.Components
ChangeAttribute = changeAttribute;
}
/// <summary>
/// Gets the tag name of the element.
/// </summary>
public string Element { get; }
// Set this to `value` for `bind-value` - set this to null for `bind`
/// <summary>
/// Gets the suffix value.
/// For example, this will be <code>value</code> to mean <code>bind-value</code>, or <code>null</code> to mean <code>bind</code>.
/// </summary>
public string Suffix { get; }
/// <summary>
/// Gets the name of the value attribute to be bound.
/// </summary>
public string ValueAttribute { get; }
/// <summary>
/// Gets the name of an attribute that will register an associated change event.
/// </summary>
public string ChangeAttribute { get; }
}
}

View File

@ -5,9 +5,19 @@ using System;
namespace Microsoft.AspNetCore.Blazor.Components
{
/// <summary>
/// Configures options for binding subtypes of an HTML <code>input</code> element.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class BindInputElementAttribute : Attribute
{
/// <summary>
/// Constructs an instance of <see cref="BindInputElementAttribute"/>.
/// </summary>
/// <param name="type">The value of the element's <code>type</code> attribute.</param>
/// <param name="suffix">The suffix value.</param>
/// <param name="valueAttribute">The name of the value attribute to be bound.</param>
/// <param name="changeAttribute">The name of an attribute that will register an associated change event.</param>
public BindInputElementAttribute(string type, string suffix, string valueAttribute, string changeAttribute)
{
if (valueAttribute == null)
@ -25,13 +35,25 @@ namespace Microsoft.AspNetCore.Blazor.Components
ValueAttribute = valueAttribute;
ChangeAttribute = changeAttribute;
}
/// <summary>
/// Gets the value of the element's <code>type</code> attribute.
/// </summary>
public string Type { get; }
/// <summary>
/// Gets the suffix value.
/// </summary>
public string Suffix { get; }
/// <summary>
/// Gets the name of the value attribute to be bound.
/// </summary>
public string ValueAttribute { get; }
/// <summary>
/// Gets the name of an attribute that will register an associated change event.
/// </summary>
public string ChangeAttribute { get; }
}
}

View File

@ -25,6 +25,9 @@ namespace Microsoft.AspNetCore.Blazor.Components
/// </summary>
public abstract class BlazorComponent : IComponent, IHandleEvent
{
/// <summary>
/// Specifies the name of the <see cref="RenderTree"/>-building method.
/// </summary>
public const string BuildRenderTreeMethodName = nameof(BuildRenderTree);
private readonly RenderFragment _renderFragment;
@ -33,6 +36,9 @@ namespace Microsoft.AspNetCore.Blazor.Components
private bool _hasNeverRendered = true;
private bool _hasPendingQueuedRender;
/// <summary>
/// Constructs an instance of <see cref="BlazorComponent"/>.
/// </summary>
public BlazorComponent()
{
_renderFragment = BuildRenderTree;

View File

@ -5,9 +5,17 @@ using System;
namespace Microsoft.AspNetCore.Blazor.Components
{
/// <summary>
/// Associates an event argument type with an event attribute name.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class EventHandlerAttribute : Attribute
{
/// <summary>
/// Constructs an instance of <see cref="EventHandlerAttribute"/>.
/// </summary>
/// <param name="attributeName"></param>
/// <param name="eventArgsType"></param>
public EventHandlerAttribute(string attributeName, Type eventArgsType)
{
if (attributeName == null)
@ -24,8 +32,14 @@ namespace Microsoft.AspNetCore.Blazor.Components
EventArgsType = eventArgsType;
}
/// <summary>
/// Gets the attribute name.
/// </summary>
public string AttributeName { get; }
/// <summary>
/// Gets the event argument type.
/// </summary>
public Type EventArgsType { get; }
}
}

View File

@ -5,6 +5,10 @@ using System;
namespace Microsoft.AspNetCore.Blazor.Components
{
/// <summary>
/// Holds <see cref="EventHandler"/> attributes to configure the mappings between event names and
/// event argument types.
/// </summary>
[EventHandler("onchange", typeof(UIChangeEventArgs))]
[EventHandler("onclick", typeof(UIMouseEventArgs))]
public static class EventHandlers

View File

@ -5,9 +5,16 @@ using System;
namespace Microsoft.AspNetCore.Blazor.Components
{
/// <summary>
/// Indicates that the associated component should match the specified route template pattern.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public class RouteAttribute : Attribute
{
/// <summary>
/// Constructs an instance of <see cref="RouteAttribute"/>.
/// </summary>
/// <param name="template">The route template.</param>
public RouteAttribute(string template)
{
if (template == null)
@ -18,6 +25,9 @@ namespace Microsoft.AspNetCore.Blazor.Components
Template = template;
}
/// <summary>
/// Gets the route template.
/// </summary>
public string Template { get; }
}
}

View File

@ -30,7 +30,6 @@ namespace Microsoft.AspNetCore.Blazor
/// Sends a POST request to the specified URI, including the specified <paramref name="content"/>
/// in JSON-encoded format, and parses the JSON response body to create an object of the generic type.
/// </summary>
/// <typeparam name="T">A type into which the response body can be JSON-deserialized.</typeparam>
/// <param name="httpClient">The <see cref="HttpClient"/>.</param>
/// <param name="requestUri">The URI that the request will be sent to.</param>
/// <param name="content">Content for the request body. This will be JSON-encoded and sent as a string.</param>

View File

@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Blazor.RenderTree
/// <summary>
/// Marks a previously appended element frame as closed. Calls to this method
/// must be balanced with calls to <see cref="OpenElement(string)"/>.
/// must be balanced with calls to <see cref="OpenElement(int, string)"/>.
/// </summary>
public void CloseElement()
{
@ -157,7 +157,6 @@ namespace Microsoft.AspNetCore.Blazor.RenderTree
/// current element is not a component, the frame will be omitted.
/// </para>
/// </summary>
/// <param name="builder">The <see cref="RenderTreeBuilder"/>.</param>
/// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
/// <param name="name">The name of the attribute.</param>
/// <param name="value">The value of the attribute.</param>
@ -175,7 +174,6 @@ namespace Microsoft.AspNetCore.Blazor.RenderTree
/// current element is not a component, the frame will be omitted.
/// </para>
/// </summary>
/// <param name="builder">The <see cref="RenderTreeBuilder"/>.</param>
/// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
/// <param name="name">The name of the attribute.</param>
/// <param name="value">The value of the attribute.</param>
@ -271,8 +269,7 @@ namespace Microsoft.AspNetCore.Blazor.RenderTree
/// </para>
/// </summary>
/// <param name="sequence">An integer that represents the position of the instruction in the source code.</param>
/// <param name="name">The name of the attribute.</param>
/// <param name="value">The value of the attribute.</param>
/// <param name="frame">A <see cref="RenderTreeFrame"/> holding the name and value of the attribute.</param>
public void AddAttribute(int sequence, RenderTreeFrame frame)
{
if (frame.FrameType != RenderTreeFrameType.Attribute)

View File

@ -225,6 +225,7 @@ namespace Microsoft.AspNetCore.Blazor.RenderTree
internal RenderTreeFrame WithRegionSubtreeLength(int regionSubtreeLength)
=> new RenderTreeFrame(Sequence, regionSubtreeLength: regionSubtreeLength);
/// <inheritdoc />
// Just to be nice for debugging and unit tests.
public override string ToString()
{

View File

@ -73,6 +73,7 @@ namespace Microsoft.AspNetCore.Blazor.Routing
_renderHandle.Render(Render);
}
/// <inheritdoc />
public void Dispose()
{
// To avoid leaking memory, it's important to detach any event handlers in Dispose()

View File

@ -65,6 +65,7 @@ namespace Microsoft.AspNetCore.Blazor.Routing
/// * For literals with different values (case insensitive) we choose the lexical order
/// * For parameters with different numbers of constraints, the one with more wins
/// If we get to the end of the comparison routing we've detected an ambiguous pair of routes.
/// </summary>
internal static int RouteComparison(RouteEntry x, RouteEntry y)
{
var xTemplate = x.Template;

View File

@ -65,6 +65,7 @@ namespace Microsoft.AspNetCore.Blazor.Routing
: str.Substring(0, firstIndex);
}
/// <inheritdoc />
protected virtual void Render(RenderTreeBuilder builder, Type handler, IDictionary<string, object> parameters)
{
builder.OpenComponent(0, typeof(LayoutDisplay));

View File

@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Blazor.Services
/// Converts a relative URI into an absolute one (by resolving it
/// relative to the current absolute URI).
/// </summary>
/// <param name="relativeUri">The relative URI.</param>
/// <param name="href">The relative URI.</param>
/// <returns>The absolute URI.</returns>
Uri ToAbsoluteUri(string href);
@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.Blazor.Services
/// converts an absolute URI into one relative to the base URI prefix.
/// </summary>
/// <param name="baseUriPrefix">The base URI prefix (e.g., previously returned by <see cref="GetBaseUriPrefix"/>).</param>
/// <param name="absoluteUri">An absolute URI that is within the space of the base URI prefix.</param>
/// <param name="locationAbsolute">An absolute URI that is within the space of the base URI prefix.</param>
/// <returns>A relative URI path.</returns>
string ToBaseRelativePath(string baseUriPrefix, string locationAbsolute);

View File

@ -1,6 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Blazor.RenderTree;
namespace Microsoft.AspNetCore.Blazor
{
/// <summary>

View File

@ -4,6 +4,7 @@
<TargetFramework>netcoreapp2.0</TargetFramework>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>