Skip to content

Commit cc03d72

Browse files
authored
Merge pull request #25 from Cysharp/feature/DocComments
Add XML documentation comments.
2 parents 158dbe2 + b5bd885 commit cc03d72

23 files changed

+212
-29
lines changed

Multicaster.sln

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Microsoft Visual Studio Solution File, Format Version 12.00
32
# Visual Studio Version 17
43
VisualStudioVersion = 17.10.34916.146
@@ -9,7 +8,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Multicaster.Tests", "test\M
98
EndProject
109
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7ED9EEF8-6BF3-4F69-BD7E-D1B25905BD30}"
1110
ProjectSection(SolutionItems) = preProject
12-
Directory.Build.props = Directory.Build.props
11+
src\Directory.Build.props = src\Directory.Build.props
1312
Directory.Packages.props = Directory.Packages.props
1413
README.md = README.md
1514
EndProjectSection

Directory.Build.props renamed to src/Directory.Build.props

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<LangVersion>12</LangVersion>
88

99
<SignAssembly>true</SignAssembly>
10-
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\src\Multicaster\opensource.snk</AssemblyOriginatorKeyFile>
10+
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\Multicaster\opensource.snk</AssemblyOriginatorKeyFile>
1111
</PropertyGroup>
1212

1313
<!-- Prevent local path leakage by artifacts -->
@@ -30,17 +30,18 @@
3030
<PackageReadmeFile>README.md</PackageReadmeFile>
3131
<IncludeSymbols>true</IncludeSymbols>
3232
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
33+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
3334
<ContinuousIntegrationBuild Condition="'$(CI)' == 'true'">true</ContinuousIntegrationBuild>
3435
</PropertyGroup>
3536

3637
<ItemGroup>
37-
<None Include="$(MSBuildThisFileDirectory)\README.md" Pack="true" PackagePath="/" />
38-
<None Include="$(MSBuildThisFileDirectory)\src\Multicaster\Icon.png" Pack="true" PackagePath="/" />
38+
<None Include="$(MSBuildThisFileDirectory)\..\README.md" Pack="true" PackagePath="/" />
39+
<None Include="$(MSBuildThisFileDirectory)\Multicaster\Icon.png" Pack="true" PackagePath="/" />
3940
</ItemGroup>
4041

4142
<!--
4243
<ItemGroup>
4344
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="all"/>
4445
</ItemGroup>
4546
-->
46-
</Project>
47+
</Project>

src/Multicaster.Distributed.Nats/NatsGroupProvider.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
namespace Cysharp.Runtime.Multicast.Distributed.Nats;
1212

13+
/// <summary>
14+
/// Provides functionality for managing multicast groups over a NATS (NATS.io) connection.
15+
/// </summary>
1316
public class NatsGroupProvider : IMulticastGroupProvider
1417
{
1518
private readonly ConcurrentDictionary<(string Name, Type KeyType, Type ReceiverType), object> _groups = new();
@@ -18,10 +21,16 @@ public class NatsGroupProvider : IMulticastGroupProvider
1821
private readonly IRemoteSerializer _serializer;
1922
private readonly MessagePackSerializerOptions _messagePackSerializerOptionsForKey;
2023

24+
/// <summary>
25+
/// Initializes a new instance of the <see cref="NatsGroupProvider"/> class with the specified proxy factory, serializer, and configuration options.
26+
/// </summary>
2127
public NatsGroupProvider(IRemoteProxyFactory proxyFactory, IRemoteSerializer serializer, IOptions<NatsGroupOptions> options)
2228
: this(proxyFactory, serializer, options.Value)
2329
{}
2430

31+
/// <summary>
32+
/// Initializes a new instance of the <see cref="NatsGroupProvider"/> class, which provides functionality for managing groups using NATS messaging.
33+
/// </summary>
2534
public NatsGroupProvider(IRemoteProxyFactory proxyFactory, IRemoteSerializer serializer, NatsGroupOptions options)
2635
{
2736
_connection = new NatsConnection(NatsOpts.Default with { Url = options.Url });
@@ -34,10 +43,12 @@ public NatsGroupProvider(IRemoteProxyFactory proxyFactory, IRemoteSerializer ser
3443
);
3544
}
3645

46+
/// <inheritdoc />
3747
public IMulticastAsyncGroup<TKey, TReceiver> GetOrAddGroup<TKey, TReceiver>(string name)
3848
where TKey : IEquatable<TKey>
3949
=> (IMulticastAsyncGroup<TKey, TReceiver>)_groups.GetOrAdd((name, typeof(TKey), typeof(TReceiver)), _ => new NatsGroup<TKey, TReceiver>(name, _connection, _proxyFactory, _serializer, _messagePackSerializerOptionsForKey, Remove));
4050

51+
/// <inheritdoc />
4152
public IMulticastSyncGroup<TKey, TReceiver> GetOrAddSynchronousGroup<TKey, TReceiver>(string name)
4253
where TKey : IEquatable<TKey>
4354
=> (IMulticastSyncGroup<TKey, TReceiver>)_groups.GetOrAdd((name, typeof(TKey), typeof(TReceiver)), _ => new NatsGroup<TKey, TReceiver>(name, _connection, _proxyFactory, _serializer, _messagePackSerializerOptionsForKey, Remove));
@@ -49,6 +60,9 @@ private void Remove<TKey, TReceiver>(NatsGroup<TKey, TReceiver> group)
4960
}
5061
}
5162

63+
/// <summary>
64+
/// Represents configuration options for a NATS group, including server connection details and serialization settings.
65+
/// </summary>
5266
public class NatsGroupOptions
5367
{
5468
/// <summary>
@@ -60,4 +74,4 @@ public class NatsGroupOptions
6074
/// Gets or sets a MessagePackSerializerOptions used for serializing the key.
6175
/// </summary>
6276
public MessagePackSerializerOptions MessagePackSerializerOptionsForKey { get; set; } = MessagePackSerializer.DefaultOptions;
63-
}
77+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
namespace Cysharp.Runtime.Multicast.Distributed;
22

3+
/// <summary>
4+
/// Represents a marker interface for a group that utilizes a distributed backplane.
5+
/// </summary>
36
public interface IDistributedGroup;

src/Multicaster/IMulticastGroup.cs

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,88 @@
11
namespace Cysharp.Runtime.Multicast;
22

3+
/// <summary>
4+
/// Represents a multicast group that allows sending messages to multiple receivers based on specified inclusion or
5+
/// exclusion criteria.
6+
/// </summary>
7+
/// <typeparam name="TKey">The type of the key used to identify receivers. Must implement <see cref="IEquatable{T}"/>.</typeparam>
8+
/// <typeparam name="TReceiver">The type of the receiver that messages are sent to.</typeparam>
39
public interface IMulticastGroup<TKey, TReceiver>
410
where TKey : IEquatable<TKey>
511
{
12+
/// <summary>
13+
/// Gets a receiver that processes all messages without filtering.
14+
/// </summary>
615
TReceiver All { get; }
16+
17+
/// <summary>
18+
/// Returns a new instance of the receiver with elements excluded based on the specified keys.
19+
/// </summary>
720
TReceiver Except(IEnumerable<TKey> excludes);
21+
22+
/// <summary>
23+
/// Filters the current set of targets to include only the specified ones.
24+
/// </summary>
825
TReceiver Only(IEnumerable<TKey> targets);
26+
27+
/// <summary>
28+
/// Retrieves a single instance of <typeparamref name="TReceiver"/> associated with the specified <typeparamref name="TKey"/>.
29+
/// </summary>
930
TReceiver Single(TKey target);
1031
}
1132

33+
/// <summary>
34+
/// Represents a multicast group that supports asynchronous operations for managing receivers.
35+
/// </summary>
1236
public interface IMulticastAsyncGroup<TKey, TReceiver> : IMulticastGroup<TKey, TReceiver>, IDisposable
1337
where TKey : IEquatable<TKey>
1438
{
39+
/// <summary>
40+
/// Adds a key and its associated receiver to the group asynchronously.
41+
/// </summary>
1542
ValueTask AddAsync(TKey key, TReceiver receiver, CancellationToken cancellationToken = default);
43+
44+
/// <summary>
45+
/// Removes the item associated with the specified key from the group asynchronously.
46+
/// </summary>
1647
ValueTask RemoveAsync(TKey key, CancellationToken cancellationToken = default);
48+
49+
/// <summary>
50+
/// Counts the total number of items in the group asynchronously.
51+
/// </summary>
1752
ValueTask<int> CountAsync(CancellationToken cancellationToken = default);
1853
}
1954

55+
/// <summary>
56+
/// Represents a multicast group that supports synchronous operations for managing receivers.
57+
/// </summary>
2058
public interface IMulticastSyncGroup<TKey, TReceiver> : IMulticastGroup<TKey, TReceiver>, IDisposable
2159
where TKey : IEquatable<TKey>
2260
{
61+
/// <summary>
62+
/// Adds a key and its associated receiver to the group.
63+
/// </summary>
2364
void Add(TKey key, TReceiver receiver);
65+
66+
/// <summary>
67+
/// Removes the item associated with the specified key from the group.
68+
/// </summary>
2469
void Remove(TKey key);
70+
71+
/// <summary>
72+
/// Counts the total number of items in the group.
73+
/// </summary>
2574
int Count();
2675
}
2776

77+
/// <summary>
78+
/// Provides extension methods for working with multicast groups.
79+
/// </summary>
2880
public static class MulticastGroupExtensions
2981
{
82+
/// <summary>
83+
/// Returns a new instance of the receiver with elements excluded based on the specified key.
84+
/// </summary>
3085
public static TReceiver Except<TKey, TReceiver>(this IMulticastGroup<TKey, TReceiver> group, TKey exclude)
3186
where TKey : IEquatable<TKey>
3287
=> group.Except([exclude]);
33-
}
88+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
namespace Cysharp.Runtime.Multicast;
22

3+
/// <summary>
4+
/// Provides functionality to manage and retrieve multicast groups, supporting both asynchronous and synchronous communication patterns.
5+
/// </summary>
36
public interface IMulticastGroupProvider
47
{
8+
/// <summary>
9+
/// Retrieves an existing multicast group by name or creates a new one if it does not exist.
10+
/// </summary>
511
IMulticastAsyncGroup<TKey, TReceiver> GetOrAddGroup<TKey, TReceiver>(string name)
612
where TKey : IEquatable<TKey>;
13+
14+
/// <summary>
15+
/// Retrieves an existing synchronous multicast group by name or creates a new one if it does not exist.
16+
/// </summary>
717
IMulticastSyncGroup<TKey, TReceiver> GetOrAddSynchronousGroup<TKey, TReceiver>(string name)
818
where TKey : IEquatable<TKey>;
919
}

src/Multicaster/InMemory/DynamicInMemoryProxyFactory.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
using System.Reflection;
33
using System.Reflection.Emit;
44

5+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
6+
57
namespace Cysharp.Runtime.Multicast.InMemory;
68

9+
/// <summary>
10+
/// Provides a factory for dynamically creating in-memory proxy instances for a specified interface type.
11+
/// </summary>
712
public class DynamicInMemoryProxyFactory : IInMemoryProxyFactory
813
{
914
public static IInMemoryProxyFactory Instance { get; } = new DynamicInMemoryProxyFactory();
@@ -227,4 +232,4 @@ static Core()
227232
public static T Create(IReceiverHolder<TKey, T> receivers, ImmutableArray<TKey> excludes, ImmutableArray<TKey>? targets)
228233
=> _factory(receivers, excludes, targets);
229234
}
230-
}
235+
}

src/Multicaster/InMemory/InMemoryGroupProvider.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System.Collections.Concurrent;
22
using System.Collections.Immutable;
33

4+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
5+
46
namespace Cysharp.Runtime.Multicast.InMemory;
57

68
public class InMemoryGroupProvider : IMulticastGroupProvider
@@ -13,10 +15,12 @@ public InMemoryGroupProvider(IInMemoryProxyFactory proxyFactory)
1315
_proxyFactory = proxyFactory;
1416
}
1517

18+
/// <inheritdoc />
1619
public IMulticastAsyncGroup<TKey, T> GetOrAddGroup<TKey, T>(string name)
1720
where TKey : IEquatable<TKey>
1821
=> (IMulticastAsyncGroup<TKey, T>)_groups.GetOrAdd((typeof(TKey), typeof(T), name), _ => new InMemoryGroup<TKey, T>(name, _proxyFactory, Remove));
1922

23+
/// <inheritdoc />
2024
public IMulticastSyncGroup<TKey, T> GetOrAddSynchronousGroup<TKey, T>(string name)
2125
where TKey : IEquatable<TKey>
2226
=> (IMulticastSyncGroup<TKey, T>)_groups.GetOrAdd((typeof(TKey), typeof(T), name), _ => new InMemoryGroup<TKey, T>(name, _proxyFactory, Remove));
@@ -108,4 +112,4 @@ private void ThrowIfDisposed()
108112
{
109113
if (_disposed) throw new ObjectDisposedException(nameof(InMemoryGroup<TKey, T>));
110114
}
111-
}
115+
}

src/Multicaster/InMemory/InMemoryProxyBase.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Cysharp.Runtime.Multicast.InMemory;
66

7+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
8+
79
public abstract class InMemoryProxyBase<TKey, T>
810
where TKey : IEquatable<TKey>
911
{
@@ -566,4 +568,4 @@ private void ThrowIfNotSingle()
566568
[MethodImpl(MethodImplOptions.AggressiveInlining)]
567569
private bool CanInvoke(ReceiverRegistration<TKey, T> r)
568570
=> !r.HasKey || r.Key is null || (!_excludes.Contains(r.Key) && (_targets is null || _targets.Value.Contains(r.Key)));
569-
}
571+
}

src/Multicaster/InMemory/InMemoryProxyFactory.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
using System;
2-
using System.Collections;
3-
using System.Collections.Concurrent;
4-
using System.Collections.Immutable;
1+
using System.Collections.Immutable;
52
using System.Runtime.InteropServices;
63

4+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
5+
76
namespace Cysharp.Runtime.Multicast.InMemory;
87

98
public interface IInMemoryProxyFactory
@@ -153,4 +152,4 @@ public void Dispose()
153152
{
154153
_onDispose(_state);
155154
}
156-
}
155+
}

0 commit comments

Comments
 (0)