Skip to content

Commit 09cfdf6

Browse files
authored
Added triple slash XML comments for public-facing Aspire.Hosting APIs. (dotnet#622)
* Added triple slash XML comments for public-facing APIs.
1 parent fa9293a commit 09cfdf6

File tree

54 files changed

+618
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+618
-28
lines changed

src/Aspire.Hosting/ApplicationModel/AllocatedEndpointAnnotation.cs

+19
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,20 @@
66

77
namespace Aspire.Hosting.ApplicationModel;
88

9+
/// <summary>
10+
/// Represents an endpoint allocated for a service instance.
11+
/// </summary>
912
[DebuggerDisplay("Type = {GetType().Name,nq}, Name = {Name}, UriString = {UriString}, BindingNameQualifiedUriString = {BindingNameQualifiedUriString}")]
1013
public class AllocatedEndpointAnnotation : IResourceAnnotation
1114
{
15+
/// <summary>
16+
/// Initializes a new instance of the <see cref="AllocatedEndpointAnnotation"/> class.
17+
/// </summary>
18+
/// <param name="name">The name of the endpoint.</param>
19+
/// <param name="protocol">The protocol used by the endpoint.</param>
20+
/// <param name="address">The IP address of the endpoint.</param>
21+
/// <param name="port">The port number of the endpoint.</param>
22+
/// <param name="scheme">The URI scheme used by the endpoint.</param>
1223
public AllocatedEndpointAnnotation(string name, ProtocolType protocol, string address, int port, string scheme)
1324
{
1425
ArgumentNullException.ThrowIfNullOrEmpty(name);
@@ -48,6 +59,9 @@ public AllocatedEndpointAnnotation(string name, ProtocolType protocol, string ad
4859
/// </summary>
4960
public string UriScheme { get; private set; }
5061

62+
/// <summary>
63+
/// Endpoint in string representation formatted as <c>"Address:Port"</c>.
64+
/// </summary>
5165
public string EndPointString => $"{Address}:{Port}";
5266

5367
/// <summary>
@@ -59,5 +73,10 @@ public AllocatedEndpointAnnotation(string name, ProtocolType protocol, string ad
5973
/// URI in string representation.
6074
/// </summary>
6175
public string UriString => $"{UriScheme}://{EndPointString}";
76+
77+
/// <summary>
78+
/// Returns a string representation of the allocated endpoint URI.
79+
/// </summary>
80+
/// <returns>The URI string, <see cref="UriString"/>.</returns>
6281
public override string ToString() => UriString;
6382
}

src/Aspire.Hosting/ApplicationModel/ContainerImageAnnotation.cs

+14
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,24 @@
55

66
namespace Aspire.Hosting.ApplicationModel;
77

8+
/// <summary>
9+
/// Represents an annotation for a container image.
10+
/// </summary>
811
[DebuggerDisplay("Type = {GetType().Name,nq}, Image = {Image}, Tag = {Tag}")]
912
public sealed class ContainerImageAnnotation : IResourceAnnotation
1013
{
14+
/// <summary>
15+
/// Gets or sets the registry for the container image.
16+
/// </summary>
1117
public string? Registry { get; set; }
18+
19+
/// <summary>
20+
/// Gets or sets the image for the container.
21+
/// </summary>
1222
public required string Image { get; set; }
23+
24+
/// <summary>
25+
/// Gets or sets the tag for the container image.
26+
/// </summary>
1327
public required string Tag { get; set; }
1428
}

src/Aspire.Hosting/ApplicationModel/ContainerResource.cs

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
namespace Aspire.Hosting.ApplicationModel;
55

6+
/// <summary>
7+
/// Represents a container resource that implements <see cref="IResourceWithEnvironment"/>
8+
/// and <see cref="IResourceWithBindings"/>.
9+
/// </summary>
610
public class ContainerResource(string name) : Resource(name), IResourceWithEnvironment, IResourceWithBindings
711
{
812
}

src/Aspire.Hosting/ApplicationModel/DistributedApplicationModel.cs

+10
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@
55

66
namespace Aspire.Hosting.ApplicationModel;
77

8+
/// <summary>
9+
/// Represents a distributed application.
10+
/// </summary>
11+
/// <param name="resources">The resource collection used to initiate the model.</param>
812
[DebuggerDisplay("Name = {Name}, Resources = {Resources.Count}")]
913
public class DistributedApplicationModel(IResourceCollection resources)
1014
{
15+
/// <summary>
16+
/// Gets the collection of resources associated with the distributed application.
17+
/// </summary>
1118
public IResourceCollection Resources { get; } = resources;
1219

20+
/// <summary>
21+
/// Gets or sets the name of the distributed application.
22+
/// </summary>
1323
public string? Name { get; set; }
1424
}

src/Aspire.Hosting/ApplicationModel/EndpointReference.cs

+15
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,26 @@
33

44
namespace Aspire.Hosting.ApplicationModel;
55

6+
/// <summary>
7+
/// Represents an endpoint reference for a resource with bindings.
8+
/// </summary>
9+
/// <param name="owner">The resource with bindings that owns the endpoint reference.</param>
10+
/// <param name="bindingName">The name of the binding.</param>
611
public sealed class EndpointReference(IResourceWithBindings owner, string bindingName)
712
{
13+
/// <summary>
14+
/// Gets the owner of the endpoint reference.
15+
/// </summary>
816
public IResourceWithBindings Owner { get; } = owner;
17+
18+
/// <summary>
19+
/// Gets the name of the binding associated with the endpoint reference.
20+
/// </summary>
921
public string BindingName { get; } = bindingName;
1022

23+
/// <summary>
24+
/// Gets the URI string for the endpoint reference.
25+
/// </summary>
1126
public string UriString
1227
{
1328
get

src/Aspire.Hosting/ApplicationModel/EnvironmentCallbackAnnotation.cs

+19
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,41 @@
33

44
namespace Aspire.Hosting.ApplicationModel;
55

6+
/// <summary>
7+
/// Represents an annotation that provides a callback to modify the environment variables of an application.
8+
/// </summary>
69
public class EnvironmentCallbackAnnotation : IResourceAnnotation
710
{
11+
/// <summary>
12+
/// Initializes a new instance of the <see cref="EnvironmentCallbackAnnotation"/> class with the specified name and callback function.
13+
/// </summary>
14+
/// <param name="name">The name of the environment variable to set.</param>
15+
/// <param name="callback">The callback function that returns the value to set the environment variable to.</param>
816
public EnvironmentCallbackAnnotation(string name, Func<string> callback)
917
{
1018
Callback = (c) => c.EnvironmentVariables[name] = callback();
1119
}
1220

21+
/// <summary>
22+
/// Initializes a new instance of the <see cref="EnvironmentCallbackAnnotation"/> class with the specified callback action.
23+
/// </summary>
24+
/// <param name="callback">The callback action to be executed.</param>
1325
public EnvironmentCallbackAnnotation(Action<Dictionary<string, string>> callback)
1426
{
1527
Callback = (c) => callback(c.EnvironmentVariables);
1628
}
1729

30+
/// <summary>
31+
/// Initializes a new instance of the <see cref="EnvironmentCallbackAnnotation"/> class with the specified callback.
32+
/// </summary>
33+
/// <param name="callback">The callback to be invoked.</param>
1834
public EnvironmentCallbackAnnotation(Action<EnvironmentCallbackContext> callback)
1935
{
2036
Callback = callback;
2137
}
2238

39+
/// <summary>
40+
/// Gets or sets the callback action to be executed when the environment is being built.
41+
/// </summary>
2342
public Action<EnvironmentCallbackContext> Callback { get; private set; }
2443
}

src/Aspire.Hosting/ApplicationModel/EnvironmentCallbackContext.cs

+12
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,20 @@
33

44
namespace Aspire.Hosting.ApplicationModel;
55

6+
/// <summary>
7+
/// Represents a callback context for environment variables associated with a publisher.
8+
/// </summary>
9+
/// <param name="publisherName">The name of the publisher.</param>
10+
/// <param name="environmentVariables">The environment variables associated with the publisher.</param>
611
public class EnvironmentCallbackContext(string publisherName, Dictionary<string, string>? environmentVariables = null)
712
{
13+
/// <summary>
14+
/// Gets the environment variables associated with the callback context.
15+
/// </summary>
816
public Dictionary<string, string> EnvironmentVariables { get; } = environmentVariables ?? new();
17+
18+
/// <summary>
19+
/// Gets the name of the publisher associated with the callback context.
20+
/// </summary>
921
public string PublisherName { get; } = publisherName;
1022
}

src/Aspire.Hosting/ApplicationModel/ExecutableArgsCallbackAnnotation.cs

+9-7
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33

44
namespace Aspire.Hosting.ApplicationModel;
55

6-
public class ExecutableArgsCallbackAnnotation : IResourceAnnotation
6+
/// <summary>
7+
/// Represents an annotation that provides a callback to be executed with a list of command-line arguments when an executable resource is started.
8+
/// </summary>
9+
/// <param name="callback">The callback action to be executed.</param>
10+
public class ExecutableArgsCallbackAnnotation(Action<IList<string>> callback) : IResourceAnnotation
711
{
8-
public ExecutableArgsCallbackAnnotation(Action<IList<string>> callback)
9-
{
10-
Callback = callback;
11-
}
12-
13-
public Action<IList<string>> Callback { get; private set; }
12+
/// <summary>
13+
/// Gets the callback action to be executed when the executable arguments are parsed.
14+
/// </summary>
15+
public Action<IList<string>> Callback { get; } = callback;
1416
}

src/Aspire.Hosting/ApplicationModel/ExecutableResource.cs

+18
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,27 @@
33

44
namespace Aspire.Hosting.ApplicationModel;
55

6+
/// <summary>
7+
/// Represents a resource that can be executed as a standalone process.
8+
/// </summary>
9+
/// <param name="name">The name of the resource.</param>
10+
/// <param name="command">The command to execute.</param>
11+
/// <param name="workingDirectory">The working directory of the executable.</param>
12+
/// <param name="args">The arguments to pass to the executable.</param>
613
public class ExecutableResource(string name, string command, string workingDirectory, string[]? args) : Resource(name), IResourceWithEnvironment, IResourceWithBindings
714
{
15+
/// <summary>
16+
/// Gets the command associated with this executable resource.
17+
/// </summary>
818
public string Command { get; } = command;
19+
20+
/// <summary>
21+
/// Gets the working directory for the executable resource.
22+
/// </summary>
923
public string WorkingDirectory { get; } = workingDirectory;
24+
25+
/// <summary>
26+
/// Gets the command line arguments passed to the executable resource.
27+
/// </summary>
1028
public string[]? Args { get; } = args;
1129
}

src/Aspire.Hosting/ApplicationModel/IResource.cs

+10
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@
33

44
namespace Aspire.Hosting.ApplicationModel;
55

6+
/// <summary>
7+
/// Represents a resource that can be hosted by an application.
8+
/// </summary>
69
public interface IResource
710
{
11+
/// <summary>
12+
/// Gets the name of the resource.
13+
/// </summary>
814
string Name { get; }
15+
16+
/// <summary>
17+
/// Gets the annotations associated with the resource.
18+
/// </summary>
919
ResourceMetadataCollection Annotations { get; }
1020
}

src/Aspire.Hosting/ApplicationModel/IResourceAnnotation.cs

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace Aspire.Hosting.ApplicationModel;
55

6+
/// <summary>
7+
/// Represents an annotation for a resource.
8+
/// </summary>
69
public interface IResourceAnnotation
710
{
811
}

src/Aspire.Hosting/ApplicationModel/IResourceBuilder.cs

+24
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,34 @@
33

44
namespace Aspire.Hosting.ApplicationModel;
55

6+
/// <summary>
7+
/// Defines a builder for creating resources of type <typeparamref name="T"/>.
8+
/// </summary>
9+
/// <typeparam name="T">The type of resource to build.</typeparam>
610
public interface IResourceBuilder<out T> where T : IResource
711
{
12+
/// <summary>
13+
/// Gets the distributed application builder associated with this resource builder.
14+
/// </summary>
815
IDistributedApplicationBuilder ApplicationBuilder { get; }
16+
17+
/// <summary>
18+
/// Gets the resource of type <typeparamref name="T"/> that is being built.
19+
/// </summary>
920
T Resource { get; }
21+
22+
/// <summary>
23+
/// Adds an annotation to the resource being built.
24+
/// </summary>
25+
/// <typeparam name="TAnnotation">The type of the annotation to add.</typeparam>
26+
/// <returns>The resource builder instance.</returns>
1027
IResourceBuilder<T> WithAnnotation<TAnnotation>() where TAnnotation : IResourceAnnotation, new() => WithAnnotation(new TAnnotation());
28+
29+
/// <summary>
30+
/// Adds an annotation to the resource being built.
31+
/// </summary>
32+
/// <typeparam name="TAnnotation">The type of the annotation to add.</typeparam>
33+
/// <param name="annotation">The annotation to add.</param>
34+
/// <returns>The resource builder instance.</returns>
1135
IResourceBuilder<T> WithAnnotation<TAnnotation>(TAnnotation annotation) where TAnnotation : IResourceAnnotation;
1236
}

src/Aspire.Hosting/ApplicationModel/IResourceCollection.cs

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace Aspire.Hosting.ApplicationModel;
55

6+
/// <summary>
7+
/// Represents a collection of resources.
8+
/// </summary>
69
public interface IResourceCollection : IList<IResource>
710
{
811
}

src/Aspire.Hosting/ApplicationModel/IResourceWithBindings.cs

+9
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33

44
namespace Aspire.Hosting.ApplicationModel;
55

6+
/// <summary>
7+
/// Represents a resource that has bindings associated with it.
8+
/// </summary>
69
public interface IResourceWithBindings : IResource
710
{
11+
/// <summary>
12+
/// Gets an endpoint reference for the specified binding.
13+
/// </summary>
14+
/// <param name="bindingName">The name of the binding.</param>
15+
/// <returns>An <see cref="EndpointReference"/> object representing the endpoint reference
16+
/// for the specified binding.</returns>
817
public EndpointReference GetEndpoint(string bindingName)
918
{
1019
return new EndpointReference(this, bindingName);

src/Aspire.Hosting/ApplicationModel/IResourceWithConnectionString.cs

+7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33

44
namespace Aspire.Hosting.ApplicationModel;
55

6+
/// <summary>
7+
/// Represents a resource that has a connection string associated with it.
8+
/// </summary>
69
public interface IResourceWithConnectionString : IResource
710
{
11+
/// <summary>
12+
/// Gets the connection string associated with the resource.
13+
/// </summary>
14+
/// <returns>The connection string associated with the resource, when one is available.</returns>
815
public string? GetConnectionString();
916
}

src/Aspire.Hosting/ApplicationModel/IResourceWithEnvironment.cs

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace Aspire.Hosting.ApplicationModel;
55

6+
/// <summary>
7+
/// Represents a resource that is associated with an environment.
8+
/// </summary>
69
public interface IResourceWithEnvironment : IResource
710
{
811
}

src/Aspire.Hosting/ApplicationModel/IResourceWithParentOfT.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33

44
namespace Aspire.Hosting.ApplicationModel;
55

6+
/// <summary>
7+
/// Represents a resource that has a parent resource of type <typeparamref name="T"/>.
8+
/// </summary>
9+
/// <typeparam name="T">The type of the parent resource.</typeparam>
610
public interface IResourceWithParent<T> : IResource where T : IResource
711
{
8-
public T Parent { get; }
12+
/// <summary>
13+
/// Gets the parent resource of type <typeparamref name="T"/>.
14+
/// </summary>
15+
T Parent { get; }
916
}

src/Aspire.Hosting/ApplicationModel/ManifestPublishingCallbackAnnotation.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@
55

66
namespace Aspire.Hosting.ApplicationModel;
77

8+
/// <summary>
9+
/// Represents an annotation that provides a callback to be executed during manifest publishing.
10+
/// </summary>
811
public class ManifestPublishingCallbackAnnotation(Action<Utf8JsonWriter>? callback) : IResourceAnnotation
912
{
13+
/// <summary>
14+
/// Gets the callback action for publishing the manifest.
15+
/// </summary>
1016
public Action<Utf8JsonWriter>? Callback { get; } = callback;
11-
public static ManifestPublishingCallbackAnnotation Ignore { get; } = new ManifestPublishingCallbackAnnotation(null);
17+
18+
/// <summary>
19+
/// Represents a <see langword="null"/>-based callback annotation for manifest
20+
/// publishing used in scenarios where it's ignored.
21+
/// </summary>
22+
public static ManifestPublishingCallbackAnnotation Ignore { get; } = new(null);
1223
}

0 commit comments

Comments
 (0)