Skip to content

Commit fba9301

Browse files
committed
chore: fix code quality analysis warnings
1 parent bb67eb4 commit fba9301

13 files changed

Lines changed: 70 additions & 52 deletions

File tree

src/MaaFramework.Binding.Native/Buffers/MaaStringListBuffer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public override bool TryIndexOf(MaaStringBuffer item, out MaaSize index)
153153
for (MaaSize tmpIndex = 0; tmpIndex < count; tmpIndex++)
154154
{
155155
if (MaaStringBuffer.TryGetValue(MaaStringListBufferAt(Handle, tmpIndex), out var stringInList)
156-
&& stringInList.Equals(stringInItem))
156+
&& stringInList.Equals(stringInItem, StringComparison.Ordinal))
157157
{
158158
index = tmpIndex;
159159
return true;

src/MaaFramework.Binding.Native/MaaAgentClient.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public static MaaAgentClient Create(MaaResource resource)
6161
/// <returns>The <see cref="MaaAgentClient"/> instance.</returns>
6262
public static MaaAgentClient Create(string identifier, MaaTasker maa)
6363
{
64+
ArgumentNullException.ThrowIfNull(maa);
65+
6466
var client = new MaaAgentClient(identifier) { Resource = maa.Resource, };
6567
_ = MaaAgentClientRegisterTaskerSink(client.Handle, maa.Handle);
6668
_ = MaaAgentClientRegisterResourceSink(client.Handle, maa.Resource.Handle);
@@ -179,6 +181,8 @@ public bool LinkStart(ProcessStartInfo info, CancellationToken cancellationToken
179181
/// </remarks>
180182
public bool LinkStart(IMaaAgentClient.AgentServerStartupMethod method, CancellationToken cancellationToken = default)
181183
{
184+
ArgumentNullException.ThrowIfNull(method);
185+
182186
if (_agentServerProcess is null or { HasExited: true })
183187
{
184188
ArgumentException.ThrowIfNullOrEmpty(Id);
@@ -213,7 +217,7 @@ public async Task<bool> LinkStartUnlessProcessExit(Process process, Cancellation
213217
cts.Token.ThrowIfCancellationRequested();
214218

215219
return completedTask != serverExitTask
216-
&& linkStartTask.Result;
220+
&& await linkStartTask;
217221
}
218222
finally
219223
{

src/MaaFramework.Binding.Native/MaaAgentServer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ public MaaAgentServer Detach()
172172
}
173173
}
174174

175+
#pragma warning disable CA1707 // 标识符不应包含下划线
176+
175177
/// <summary>
176178
/// A static class providing extension methods for <see cref="MaaAgentServer"/>.
177179
/// </summary>

src/MaaFramework.Binding.Native/MaaController/MaaAdbController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class MaaAdbController : MaaController
3131
/// <exception cref="MaaJobStatusException"/>
3232
public MaaAdbController(AdbDeviceInfo info, LinkOption link = LinkOption.Start, CheckStatusOption check = CheckStatusOption.ThrowIfNotSucceeded)
3333
{
34+
ArgumentNullException.ThrowIfNull(info);
3435
ArgumentException.ThrowIfNullOrEmpty(info.AdbPath);
3536
ArgumentException.ThrowIfNullOrEmpty(info.AdbSerial);
3637
ArgumentException.ThrowIfNullOrEmpty(info.Config);

src/MaaFramework.Binding.Native/MaaController/MaaWin32Controller.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class MaaWin32Controller : MaaController
3131
/// <exception cref="MaaJobStatusException"/>
3232
public MaaWin32Controller(DesktopWindowInfo info, LinkOption link = LinkOption.Start, CheckStatusOption check = CheckStatusOption.ThrowIfNotSucceeded)
3333
{
34+
ArgumentNullException.ThrowIfNull(info);
3435
if (info.Handle == nint.Zero) throw new ArgumentException("Value cannot be zero.", "info.Handle");
3536

3637
var handle = MaaWin32ControllerCreate(info.Handle, (MaaWin32ScreencapMethod)info.ScreencapMethod, (MaaWin32InputMethod)info.MouseMethod, (MaaWin32InputMethod)info.KeyboardMethod);

src/MaaFramework.Binding.Native/MaaTasker.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@ public bool SetOption<T>(TaskerOption opt, T value)
143143
#pragma warning restore
144144
}
145145

146+
#pragma warning disable CA2213 // 应释放可释放的字段
146147
private MaaResource _resource = null!;
147148
private MaaController _controller = null!;
149+
#pragma warning restore CA2213 // 应释放可释放的字段
148150

149151
IMaaResource IMaaTasker.Resource
150152
{

src/MaaFramework.Binding.UnitTests/.editorconfig

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,50 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<ItemGroup>
4-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
5-
<PackageReference Include="MSTest.TestAdapter" />
6-
<PackageReference Include="MSTest.TestFramework" />
7-
<PackageReference Include="SixLabors.ImageSharp" />
8-
9-
<ProjectReference Include="..\MaaFramework\MaaFramework.csproj" Private="false" />
10-
<ProjectReference Include="..\MaaFramework.Binding.Extensions\MaaFramework.Binding.Extensions.csproj" />
11-
12-
<None Include="..\Common\TestParam.runsettings" />
13-
<None Include="SampleResource\**">
14-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
15-
</None>
16-
</ItemGroup>
17-
18-
<PropertyGroup>
19-
<GenerateProgramFile>false</GenerateProgramFile>
20-
21-
<NoWarn>$(NoWarn);S1121,S1656,S1199,IDE0022,IDE0060,IDE0072</NoWarn>
22-
</PropertyGroup>
23-
24-
<!-- Maa Test Constants -->
25-
<PropertyGroup>
26-
<DefineConstants>$(DefineConstants);MAA_NATIVE;</DefineConstants>
27-
</PropertyGroup>
28-
29-
<Choose>
30-
<When Condition="$([System.OperatingSystem]::IsOSPlatform('WINDOWS'))">
31-
<PropertyGroup>
32-
<DefineConstants>$(DefineConstants);MAA_WIN32;</DefineConstants>
33-
</PropertyGroup>
34-
</When>
35-
<Otherwise>
36-
</Otherwise>
37-
</Choose>
38-
39-
<Choose>
40-
<When Condition="$([System.Environment]::GetEnvironmentVariable('GITHUB_ACTIONS')) == 'true'">
41-
<PropertyGroup>
42-
<DefineConstants>$(DefineConstants);GITHUB_ACTIONS;</DefineConstants>
43-
</PropertyGroup>
44-
</When>
45-
<Otherwise>
46-
</Otherwise>
47-
</Choose>
3+
<ItemGroup>
4+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
5+
<PackageReference Include="MSTest.TestAdapter" />
6+
<PackageReference Include="MSTest.TestFramework" />
7+
<PackageReference Include="SixLabors.ImageSharp" />
8+
9+
<ProjectReference Include="..\MaaFramework\MaaFramework.csproj" Private="false" />
10+
<ProjectReference Include="..\MaaFramework.Binding.Extensions\MaaFramework.Binding.Extensions.csproj" />
11+
12+
<None Include="..\Common\TestParam.runsettings" />
13+
<None Include="SampleResource\**">
14+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
15+
</None>
16+
</ItemGroup>
17+
18+
<PropertyGroup>
19+
<GenerateProgramFile>false</GenerateProgramFile>
20+
21+
<AnalysisMode>Default</AnalysisMode>
22+
<NoWarn>$(NoWarn),S1121,S1656,S1199,CS1591</NoWarn>
23+
</PropertyGroup>
24+
25+
<!-- Maa Test Constants -->
26+
<PropertyGroup>
27+
<DefineConstants>$(DefineConstants);MAA_NATIVE;</DefineConstants>
28+
</PropertyGroup>
29+
30+
<Choose>
31+
<When Condition="$([System.OperatingSystem]::IsOSPlatform('WINDOWS'))">
32+
<PropertyGroup>
33+
<DefineConstants>$(DefineConstants);MAA_WIN32;</DefineConstants>
34+
</PropertyGroup>
35+
</When>
36+
<Otherwise>
37+
</Otherwise>
38+
</Choose>
39+
40+
<Choose>
41+
<When Condition="$([System.Environment]::GetEnvironmentVariable('GITHUB_ACTIONS')) == 'true'">
42+
<PropertyGroup>
43+
<DefineConstants>$(DefineConstants);GITHUB_ACTIONS;</DefineConstants>
44+
</PropertyGroup>
45+
</When>
46+
<Otherwise>
47+
</Otherwise>
48+
</Choose>
4849

4950
</Project>

src/MaaFramework.Binding/Buffers/MaaListBuffer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public abstract class MaaListBuffer<THandle, T>(THandle invalidHandleValue)
3535
/// which may cause the underlying std::vector storage to change,
3636
/// it is necessary to dispose T and increment _version by 1.
3737
/// </remarks>
38-
protected internal int _version;
38+
internal int _version;
3939
/// <inheritdoc/>
4040
public abstract bool TryAdd(T item);
4141
/// <inheritdoc/>

src/MaaFramework.Binding/Enums/Binding/ApiInfoFlags.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace MaaFramework.Binding;
22

33
#pragma warning disable S2344 // Enumeration type names should not have "Flags" or "Enum" suffixes
4+
#pragma warning disable CA1711 // 标识符应采用正确的后缀
45

56
/// <summary>
67
/// Represents information about binding interoperable API.

0 commit comments

Comments
 (0)