Skip to content

Commit 14b52b8

Browse files
committed
chore: modify MaaAgentClient.ctor() accessibility
1 parent 13b0abb commit 14b52b8

2 files changed

Lines changed: 6 additions & 25 deletions

File tree

src/MaaFramework.Binding.Native/MaaAgentClient.cs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class MaaAgentClient : MaaDisposableHandle<MaaAgentClientHandle>, IMaaAge
2929
/// <remarks>
3030
/// Wrapper of <see cref="MaaAgentClientCreate"/>.
3131
/// </remarks>
32-
public MaaAgentClient(string identifier = "")
32+
protected MaaAgentClient(string identifier = "")
3333
: base(invalidHandleValue: MaaAgentClientHandle.Zero)
3434
{
3535
var handle = MaaAgentClientCreate();
@@ -40,35 +40,18 @@ public MaaAgentClient(string identifier = "")
4040
_ = Id.ThrowIfNotEquals(identifier);
4141
}
4242

43-
/// <param name="identifier">The unique identifier used to communicate with the agent server.</param>
44-
/// <param name="resource">The resource.</param>
45-
/// <inheritdoc cref="MaaAgentClient(string)"/>
46-
[SetsRequiredMembers]
47-
public MaaAgentClient(string identifier, MaaResource resource)
48-
: this(identifier)
49-
{
50-
Resource = resource;
51-
}
52-
53-
/// <inheritdoc cref="MaaAgentClient(string, MaaResource)"/>
54-
[SetsRequiredMembers]
55-
public MaaAgentClient(MaaResource resource)
56-
: this("", resource)
57-
{
58-
}
59-
6043
/// <summary>
6144
/// Creates a <see cref="MaaAgentClient"/> instance.
6245
/// </summary>
6346
/// <param name="identifier">The unique identifier used to communicate with the agent server.</param>
6447
/// <param name="resource">The resource.</param>
6548
/// <returns>The <see cref="MaaAgentClient"/> instance.</returns>
6649
public static MaaAgentClient Create(string identifier, MaaResource resource)
67-
=> new(identifier, resource);
50+
=> new(identifier) { Resource = resource, };
6851

6952
/// <inheritdoc cref="Create(string, MaaResource)"/>
7053
public static MaaAgentClient Create(MaaResource resource)
71-
=> new(resource);
54+
=> new() { Resource = resource, };
7255

7356
/// <inheritdoc/>
7457
public string Id { get; }

src/MaaFramework.Binding.UnitTests/Test_IMaaAgentClient.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class Test_IMaaAgentClient
1313
public static Dictionary<MaaTypes, object> NewData => new()
1414
{
1515
#if MAA_NATIVE
16-
{ MaaTypes.Native, new MaaAgentClient(new MaaResource()) },
16+
{ MaaTypes.Native, MaaAgentClient.Create(new MaaResource()) },
1717
#endif
1818
};
1919
public static Dictionary<MaaTypes, object> Data { get; private set; } = default!;
@@ -39,11 +39,9 @@ public void CreateInstances()
3939
{
4040
#if MAA_NATIVE
4141
var newId = Guid.NewGuid().ToString();
42-
using var native1 = new MaaAgentClient(/*identifier = string.Empty*/) { Resource = new MaaResource() };
43-
using var native2 = new MaaAgentClient(/*identifier = string.Empty*/ new MaaResource());
44-
// var native3 = new MaaAgentClient(newId, new MaaResource());
42+
using var native1 = MaaAgentClient.Create(new MaaResource());
43+
using var native2 = MaaAgentClient.Create(new MaaResource());
4544
using var native3 = MaaAgentClient.Create(newId, new MaaResource());
46-
using var native4 = MaaAgentClient.Create(new MaaResource());
4745

4846
Assert.AreNotEqual(native1.Id, native2.Id);
4947
Assert.AreEqual(newId, native3.Id);

0 commit comments

Comments
 (0)