Skip to content

Commit 3ff4447

Browse files
Add XML docs to core packages
1 parent 3b91ad9 commit 3ff4447

24 files changed

+448
-10
lines changed

src/Microsoft.AspNetCore.AngularServices/PrimeCacheHelper.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,31 @@
99

1010
namespace Microsoft.AspNetCore.AngularServices
1111
{
12+
/// <summary>
13+
/// Helpers for prepopulating Angular 2's 'http' service with data.
14+
/// </summary>
1215
public static class PrimeCacheHelper
1316
{
17+
/// <summary>
18+
/// Performs an HTTP GET request to the specified URL and adds the resulting JSON data
19+
/// to the Angular 'http' service cache.
20+
/// </summary>
21+
/// <param name="html">The <see cref="IHtmlHelper"/>.</param>
22+
/// <param name="url">The URL to be requested.</param>
23+
/// <returns>A task representing the HTML content to be rendered into the document.</returns>
1424
[Obsolete("Use PrimeCacheAsync instead")]
1525
public static Task<IHtmlContent> PrimeCache(this IHtmlHelper html, string url)
1626
{
1727
return PrimeCacheAsync(html, url);
1828
}
1929

30+
/// <summary>
31+
/// Performs an HTTP GET request to the specified URL and adds the resulting JSON data
32+
/// to the Angular 'http' service cache.
33+
/// </summary>
34+
/// <param name="html">The <see cref="IHtmlHelper"/>.</param>
35+
/// <param name="url">The URL to be requested.</param>
36+
/// <returns>A task representing the HTML content to be rendered into the document.</returns>
2037
public static async Task<IHtmlContent> PrimeCacheAsync(this IHtmlHelper html, string url)
2138
{
2239
// TODO: Consider deduplicating the PrimeCacheAsync calls (that is, if there are multiple requests to precache

src/Microsoft.AspNetCore.AngularServices/project.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
},
1515
"buildOptions": {
1616
"warningsAsErrors": true,
17-
"keyFile": "../../tools/Key.snk"
17+
"keyFile": "../../tools/Key.snk",
18+
"xmlDoc": true
1819
},
1920
"dependencies": {
2021
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.1",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
namespace Microsoft.AspNetCore.NodeServices
22
{
3+
/// <summary>
4+
/// Represents a way of creating and invoking code in a Node.js environment.
5+
/// </summary>
36
public enum NodeHostingModel
47
{
8+
/// <summary>
9+
/// An out-of-process Node.js instance where RPC calls are made via HTTP.
10+
/// </summary>
511
Http,
12+
13+
/// <summary>
14+
/// An out-of-process Node.js instance where RPC calls are made over binary sockets.
15+
/// </summary>
616
Socket,
717
}
818
}

src/Microsoft.AspNetCore.NodeServices/Configuration/NodeServicesFactory.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@
33

44
namespace Microsoft.AspNetCore.NodeServices
55
{
6+
/// <summary>
7+
/// Supplies INodeServices instances.
8+
/// </summary>
69
public static class NodeServicesFactory
710
{
11+
/// <summary>
12+
/// Create an <see cref="INodeServices"/> instance according to the supplied options.
13+
/// </summary>
14+
/// <param name="options">Options for creating the <see cref="INodeServices"/> instance.</param>
15+
/// <returns>An <see cref="INodeServices"/> instance.</returns>
816
public static INodeServices CreateNodeServices(NodeServicesOptions options)
917
{
1018
if (options == null)

src/Microsoft.AspNetCore.NodeServices/Configuration/NodeServicesOptions.cs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,25 @@
88

99
namespace Microsoft.AspNetCore.NodeServices
1010
{
11+
/// <summary>
12+
/// Describes options used to configure an <see cref="INodeServices"/> instance.
13+
/// </summary>
1114
public class NodeServicesOptions
1215
{
16+
/// <summary>
17+
/// Defines the default <see cref="NodeHostingModel"/>.
18+
/// </summary>
1319
public const NodeHostingModel DefaultNodeHostingModel = NodeHostingModel.Http;
20+
1421
internal const string TimeoutConfigPropertyName = nameof(InvocationTimeoutMilliseconds);
1522
private const int DefaultInvocationTimeoutMilliseconds = 60 * 1000;
1623
private const string LogCategoryName = "Microsoft.AspNetCore.NodeServices";
1724
private static readonly string[] DefaultWatchFileExtensions = { ".js", ".jsx", ".ts", ".tsx", ".json", ".html" };
1825

26+
/// <summary>
27+
/// Creates a new instance of <see cref="NodeServicesOptions"/>.
28+
/// </summary>
29+
/// <param name="serviceProvider">The <see cref="IServiceProvider"/>.</param>
1930
public NodeServicesOptions(IServiceProvider serviceProvider)
2031
{
2132
if (serviceProvider == null)
@@ -44,14 +55,49 @@ public NodeServicesOptions(IServiceProvider serviceProvider)
4455
: new ConsoleLogger(LogCategoryName, null, false);
4556
}
4657

58+
/// <summary>
59+
/// Specifies which <see cref="NodeHostingModel"/> should be used.
60+
/// </summary>
4761
public NodeHostingModel HostingModel { get; set; }
62+
63+
/// <summary>
64+
/// If set, this callback function will be invoked to supply the <see cref="INodeServices"/> instance.
65+
/// </summary>
4866
public Func<INodeInstance> NodeInstanceFactory { get; set; }
67+
68+
/// <summary>
69+
/// If set, overrides the path to the root of your application. This path is used when locating Node.js modules relative to your project.
70+
/// </summary>
4971
public string ProjectPath { get; set; }
72+
73+
/// <summary>
74+
/// If set, the Node.js instance should restart when any matching file on disk within your project changes.
75+
/// </summary>
5076
public string[] WatchFileExtensions { get; set; }
77+
78+
/// <summary>
79+
/// The Node.js instance's stdout/stderr will be redirected to this <see cref="ILogger"/>.
80+
/// </summary>
5181
public ILogger NodeInstanceOutputLogger { get; set; }
82+
83+
/// <summary>
84+
/// If true, the Node.js instance will accept incoming V8 debugger connections (e.g., from node-inspector).
85+
/// </summary>
5286
public bool LaunchWithDebugging { get; set; }
53-
public IDictionary<string, string> EnvironmentVariables { get; set; }
87+
88+
/// <summary>
89+
/// If <see cref="LaunchWithDebugging"/> is true, the Node.js instance will listen for V8 debugger connections on this port.
90+
/// </summary>
5491
public int DebuggingPort { get; set; }
92+
93+
/// <summary>
94+
/// If set, starts the Node.js instance with the specified environment variables.
95+
/// </summary>
96+
public IDictionary<string, string> EnvironmentVariables { get; set; }
97+
98+
/// <summary>
99+
/// Specifies the maximum duration, in milliseconds, that your .NET code should wait for Node.js RPC calls to return.
100+
/// </summary>
55101
public int InvocationTimeoutMilliseconds { get; set; }
56102
}
57103
}

src/Microsoft.AspNetCore.NodeServices/Configuration/NodeServicesServiceCollectionExtensions.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@ namespace Microsoft.Extensions.DependencyInjection
88
/// </summary>
99
public static class NodeServicesServiceCollectionExtensions
1010
{
11+
/// <summary>
12+
/// Adds NodeServices support to the <paramref name="serviceCollection"/>.
13+
/// </summary>
14+
/// <param name="serviceCollection">The <see cref="IServiceCollection"/>.</param>
1115
public static void AddNodeServices(this IServiceCollection serviceCollection)
1216
=> AddNodeServices(serviceCollection, _ => {});
1317

18+
/// <summary>
19+
/// Adds NodeServices support to the <paramref name="serviceCollection"/>.
20+
/// </summary>
21+
/// <param name="serviceCollection">The <see cref="IServiceCollection"/>.</param>
22+
/// <param name="options">Options for configuring the <see cref="INodeServices"/> instances.</param>
1423
[Obsolete("Use the AddNodeServices(Action<NodeServicesOptions> setupAction) overload instead.")]
1524
public static void AddNodeServices(this IServiceCollection serviceCollection, NodeServicesOptions options)
1625
{
@@ -20,6 +29,11 @@ public static void AddNodeServices(this IServiceCollection serviceCollection, No
2029
});
2130
}
2231

32+
/// <summary>
33+
/// Adds NodeServices support to the <paramref name="serviceCollection"/>.
34+
/// </summary>
35+
/// <param name="serviceCollection">The <see cref="IServiceCollection"/>.</param>
36+
/// <param name="setupAction">A callback that will be invoked to populate the <see cref="NodeServicesOptions"/>.</param>
2337
public static void AddNodeServices(this IServiceCollection serviceCollection, Action<NodeServicesOptions> setupAction)
2438
{
2539
if (setupAction == null)

src/Microsoft.AspNetCore.NodeServices/HostingModels/INodeInstance.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,20 @@
44

55
namespace Microsoft.AspNetCore.NodeServices.HostingModels
66
{
7+
/// <summary>
8+
/// Represents an instance of Node.js to which Remote Procedure Calls (RPC) may be sent.
9+
/// </summary>
710
public interface INodeInstance : IDisposable
811
{
12+
/// <summary>
13+
/// Asynchronously invokes code in the Node.js instance.
14+
/// </summary>
15+
/// <typeparam name="T">The JSON-serializable data type that the Node.js code will asynchronously return.</typeparam>
16+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that can be used to cancel the invocation.</param>
17+
/// <param name="moduleName">The path to the Node.js module (i.e., JavaScript file) relative to your project root that contains the code to be invoked.</param>
18+
/// <param name="exportNameOrNull">If set, specifies the CommonJS export to be invoked. If not set, the module's default CommonJS export itself must be a function to be invoked.</param>
19+
/// <param name="args">Any sequence of JSON-serializable arguments to be passed to the Node.js function.</param>
20+
/// <returns>A <see cref="Task{TResult}"/> representing the completion of the RPC call.</returns>
921
Task<T> InvokeExportAsync<T>(CancellationToken cancellationToken, string moduleName, string exportNameOrNull, params object[] args);
1022
}
1123
}

src/Microsoft.AspNetCore.NodeServices/HostingModels/NodeInvocationException.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,33 @@
22

33
namespace Microsoft.AspNetCore.NodeServices.HostingModels
44
{
5+
/// <summary>
6+
/// Represents an exception caused by invoking Node.js code.
7+
/// </summary>
58
public class NodeInvocationException : Exception
69
{
10+
/// <summary>
11+
/// If true, indicates that the invocation failed because the Node.js instance could not be reached. For example,
12+
/// it might have already shut down or previously crashed.
13+
/// </summary>
714
public bool NodeInstanceUnavailable { get; private set; }
815

16+
/// <summary>
17+
/// Creates a new instance of <see cref="NodeInvocationException"/>.
18+
/// </summary>
19+
/// <param name="message">A description of the exception.</param>
20+
/// <param name="details">Additional information, such as a Node.js stack trace, representing the exception.</param>
921
public NodeInvocationException(string message, string details)
1022
: base(message + Environment.NewLine + details)
1123
{
1224
}
1325

26+
/// <summary>
27+
/// Creates a new instance of <see cref="NodeInvocationException"/>.
28+
/// </summary>
29+
/// <param name="message">A description of the exception.</param>
30+
/// <param name="details">Additional information, such as a Node.js stack trace, representing the exception.</param>
31+
/// <param name="nodeInstanceUnavailable">Specifies a value for the <see cref="NodeInstanceUnavailable"/> flag.</param>
1432
public NodeInvocationException(string message, string details, bool nodeInstanceUnavailable)
1533
: this(message, details)
1634
{
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
namespace Microsoft.AspNetCore.NodeServices.HostingModels
22
{
3+
/// <summary>
4+
/// Describes an RPC call sent from .NET code to Node.js code.
5+
/// </summary>
36
public class NodeInvocationInfo
47
{
8+
/// <summary>
9+
/// Specifies the path to the Node.js module (i.e., .js file) relative to the project root.
10+
/// </summary>
511
public string ModuleName { get; set; }
12+
13+
/// <summary>
14+
/// If set, specifies the name of CommonJS function export to be invoked.
15+
/// If not set, the Node.js module's default export must itself be a function to be invoked.
16+
/// </summary>
617
public string ExportedFunctionName { get; set; }
18+
19+
/// <summary>
20+
/// A sequence of JSON-serializable arguments to be passed to the Node.js function being invoked.
21+
/// </summary>
722
public object[] Args { get; set; }
823
}
924
}

src/Microsoft.AspNetCore.NodeServices/HostingModels/OutOfProcessNodeInstance.cs

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ namespace Microsoft.AspNetCore.NodeServices.HostingModels
2121
/// <seealso cref="Microsoft.AspNetCore.NodeServices.HostingModels.INodeInstance" />
2222
public abstract class OutOfProcessNodeInstance : INodeInstance
2323
{
24+
/// <summary>
25+
/// The <see cref="ILogger"/> to which the Node.js instance's stdout/stderr is being redirected.
26+
/// </summary>
2427
protected readonly ILogger OutputLogger;
28+
2529
private const string ConnectionEstablishedMessage = "[Microsoft.AspNetCore.NodeServices:Listening]";
2630
private const string DebuggingStartedMessageFormat = @"-----
2731
*** Node.js debugging is enabled ***
@@ -43,6 +47,18 @@ npm install -g node-inspector
4347
private bool _nodeProcessNeedsRestart;
4448
private readonly string[] _watchFileExtensions;
4549

50+
/// <summary>
51+
/// Creates a new instance of <see cref="OutOfProcessNodeInstance"/>.
52+
/// </summary>
53+
/// <param name="entryPointScript">The path to the entry point script that the Node instance should load and execute.</param>
54+
/// <param name="projectPath">The root path of the current project. This is used when resolving Node.js module paths relative to the project root.</param>
55+
/// <param name="watchFileExtensions">The filename extensions that should be watched within the project root. The Node instance will automatically shut itself down if any matching file changes.</param>
56+
/// <param name="commandLineArguments">Additional command-line arguments to be passed to the Node.js instance.</param>
57+
/// <param name="nodeOutputLogger">The <see cref="ILogger"/> to which the Node.js instance's stdout/stderr (and other log information) should be written.</param>
58+
/// <param name="environmentVars">Environment variables to be set on the Node.js process.</param>
59+
/// <param name="invocationTimeoutMilliseconds">The maximum duration, in milliseconds, to wait for RPC calls to complete.</param>
60+
/// <param name="launchWithDebugging">If true, passes a flag to the Node.js process telling it to accept V8 debugger connections.</param>
61+
/// <param name="debuggingPort">If debugging is enabled, the Node.js process should listen for V8 debugger connections on this port.</param>
4662
public OutOfProcessNodeInstance(
4763
string entryPointScript,
4864
string projectPath,
@@ -71,6 +87,15 @@ public OutOfProcessNodeInstance(
7187
ConnectToInputOutputStreams();
7288
}
7389

90+
/// <summary>
91+
/// Asynchronously invokes code in the Node.js instance.
92+
/// </summary>
93+
/// <typeparam name="T">The JSON-serializable data type that the Node.js code will asynchronously return.</typeparam>
94+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that can be used to cancel the invocation.</param>
95+
/// <param name="moduleName">The path to the Node.js module (i.e., JavaScript file) relative to your project root that contains the code to be invoked.</param>
96+
/// <param name="exportNameOrNull">If set, specifies the CommonJS export to be invoked. If not set, the module's default CommonJS export itself must be a function to be invoked.</param>
97+
/// <param name="args">Any sequence of JSON-serializable arguments to be passed to the Node.js function.</param>
98+
/// <returns>A <see cref="Task{TResult}"/> representing the completion of the RPC call.</returns>
7499
public async Task<T> InvokeExportAsync<T>(
75100
CancellationToken cancellationToken, string moduleName, string exportNameOrNull, params object[] args)
76101
{
@@ -154,21 +179,41 @@ public async Task<T> InvokeExportAsync<T>(
154179
}
155180
}
156181

182+
/// <summary>
183+
/// Disposes this instance.
184+
/// </summary>
157185
public void Dispose()
158186
{
159187
Dispose(true);
160188
GC.SuppressFinalize(this);
161189
}
162190

191+
/// <summary>
192+
/// Asynchronously invokes code in the Node.js instance.
193+
/// </summary>
194+
/// <typeparam name="T">The JSON-serializable data type that the Node.js code will asynchronously return.</typeparam>
195+
/// <param name="invocationInfo">Specifies the Node.js function to be invoked and arguments to be passed to it.</param>
196+
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that can be used to cancel the invocation.</param>
197+
/// <returns>A <see cref="Task{TResult}"/> representing the completion of the RPC call.</returns>
163198
protected abstract Task<T> InvokeExportAsync<T>(
164199
NodeInvocationInfo invocationInfo,
165200
CancellationToken cancellationToken);
166201

167-
// This method is virtual, as it provides a way to override the NODE_PATH or the path to node.exe
202+
/// <summary>
203+
/// Configures a <see cref="ProcessStartInfo"/> instance describing how to launch the Node.js process.
204+
/// </summary>
205+
/// <param name="entryPointFilename">The entrypoint JavaScript file that the Node.js process should execute.</param>
206+
/// <param name="projectPath">The root path of the project. This is used when locating Node.js modules relative to the project root.</param>
207+
/// <param name="commandLineArguments">Command-line arguments to be passed to the Node.js process.</param>
208+
/// <param name="environmentVars">Environment variables to be set on the Node.js process.</param>
209+
/// <param name="launchWithDebugging">If true, passes a flag to the Node.js process telling it to accept V8 debugger connections.</param>
210+
/// <param name="debuggingPort">If debugging is enabled, the Node.js process should listen for V8 debugger connections on this port.</param>
211+
/// <returns></returns>
168212
protected virtual ProcessStartInfo PrepareNodeProcessStartInfo(
169213
string entryPointFilename, string projectPath, string commandLineArguments,
170214
IDictionary<string, string> environmentVars, bool launchWithDebugging, int debuggingPort)
171215
{
216+
// This method is virtual, as it provides a way to override the NODE_PATH or the path to node.exe
172217
string debuggingArgs;
173218
if (launchWithDebugging)
174219
{
@@ -217,16 +262,28 @@ protected virtual ProcessStartInfo PrepareNodeProcessStartInfo(
217262
return startInfo;
218263
}
219264

265+
/// <summary>
266+
/// Virtual method invoked whenever the Node.js process emits a line to its stdout.
267+
/// </summary>
268+
/// <param name="outputData">The line emitted to the Node.js process's stdout.</param>
220269
protected virtual void OnOutputDataReceived(string outputData)
221270
{
222271
OutputLogger.LogInformation(outputData);
223272
}
224273

274+
/// <summary>
275+
/// Virtual method invoked whenever the Node.js process emits a line to its stderr.
276+
/// </summary>
277+
/// <param name="errorData">The line emitted to the Node.js process's stderr.</param>
225278
protected virtual void OnErrorDataReceived(string errorData)
226279
{
227280
OutputLogger.LogError(errorData);
228281
}
229282

283+
/// <summary>
284+
/// Disposes the instance.
285+
/// </summary>
286+
/// <param name="disposing">True if the object is disposing or false if it is finalizing.</param>
230287
protected virtual void Dispose(bool disposing)
231288
{
232289
if (!_disposed)
@@ -403,6 +460,9 @@ private void RestartDueToFileChange(string fullPath)
403460
EnsureFileSystemWatcherIsDisposed();
404461
}
405462

463+
/// <summary>
464+
/// Implements the finalization part of the IDisposable pattern by calling Dispose(false).
465+
/// </summary>
406466
~OutOfProcessNodeInstance()
407467
{
408468
Dispose(false);

0 commit comments

Comments
 (0)