Skip to content

Commit 825d4a2

Browse files
committed
Add global AnalyzerConfig for custom Roslyn analyzer
1 parent 343f277 commit 825d4a2

102 files changed

Lines changed: 7044 additions & 2913 deletions

File tree

Some content is hidden

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

.editorconfig

Lines changed: 364 additions & 0 deletions
Large diffs are not rendered by default.

.globalconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Top level global AnalyzerConfig file
2+
is_global = true
3+
4+
# Remove unused imports
5+
dotnet_diagnostic.IDE0005.severity = error
6+
7+
# Add braces
8+
dotnet_diagnostic.IDE0011.severity = error
9+
10+
# Inline variable declaration
11+
dotnet_diagnostic.IDE0018.severity = error
12+
13+
# Use collection initializers
14+
dotnet_diagnostic.IDE0028.severity = error
15+
16+
# Simplify default expression
17+
dotnet_diagnostic.IDE0034.severity = error
18+
19+
# Remove unused parameter
20+
dotnet_diagnostic.IDE0060.severity = error
21+
22+
# Simplify new expression
23+
dotnet_diagnostic.IDE0090.severity = error

Monero.Test/Monero.Test.csproj

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
77

8-
<IsPackable>false</IsPackable>
9-
<IsTestProject>true</IsTestProject>
10-
</PropertyGroup>
8+
<IsPackable>false</IsPackable>
9+
<IsTestProject>true</IsTestProject>
10+
</PropertyGroup>
1111

12-
<ItemGroup>
13-
<PackageReference Include="coverlet.collector" Version="6.0.0" />
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
15-
<PackageReference Include="xunit" Version="2.5.3" />
16-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
17-
</ItemGroup>
12+
<ItemGroup>
13+
<PackageReference Include="coverlet.collector" Version="6.0.4"/>
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0"/>
15+
<PackageReference Include="xunit" Version="2.9.3"/>
16+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4"/>
17+
</ItemGroup>
1818

19-
<ItemGroup>
20-
<ProjectReference Include="..\Monero\Monero.csproj" />
21-
</ItemGroup>
19+
<ItemGroup>
20+
<ProjectReference Include="..\Monero\Monero.csproj"/>
21+
</ItemGroup>
2222

23-
<ItemGroup>
24-
<Using Include="Xunit" />
25-
</ItemGroup>
23+
<ItemGroup>
24+
<Using Include="Xunit"/>
25+
</ItemGroup>
2626

2727
</Project>

Monero.Test/TestMoneroConnectionManager.cs

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ public void TestConnectionManager()
1515
try
1616
{
1717
// start monero-wallet-rpc instances as test server connections (can also use monerod servers)
18-
for (int i = 0; i < 5; i++) walletRpcs.Add(TestUtils.StartWalletRpcProcess());
18+
for (int i = 0; i < 5; i++)
19+
{
20+
walletRpcs.Add(TestUtils.StartWalletRpcProcess());
21+
}
1922

2023
// create connection manager
2124
connectionManager = new MoneroConnectionManager();
@@ -29,7 +32,8 @@ public void TestConnectionManager()
2932
connectionManager.AddConnection(walletRpcs[2].GetRpcConnection().SetPriority(2));
3033
connectionManager.AddConnection(walletRpcs[3].GetRpcConnection().SetPriority(2));
3134
connectionManager.AddConnection(walletRpcs[0].GetRpcConnection()); // default priority is lowest
32-
connectionManager.AddConnection(new MoneroRpcConnection(walletRpcs[1].GetRpcConnection().GetUri())); // test unauthenticated
35+
connectionManager.AddConnection(
36+
new MoneroRpcConnection(walletRpcs[1].GetRpcConnection().GetUri())); // test unauthenticated
3337

3438
// test connections and order
3539
List<MoneroRpcConnection> orderedConnections = connectionManager.GetRpcConnections();
@@ -38,11 +42,15 @@ public void TestConnectionManager()
3842
Assert.True(orderedConnections[2] == walletRpcs[3].GetRpcConnection());
3943
Assert.True(orderedConnections[3] == walletRpcs[0].GetRpcConnection());
4044
Assert.True(orderedConnections[4].GetUri() == walletRpcs[1].GetRpcConnection().GetUri());
41-
foreach (MoneroRpcConnection c in orderedConnections) Assert.NotNull(c.IsOnline());
45+
foreach (MoneroRpcConnection c in orderedConnections)
46+
{
47+
Assert.NotNull(c.IsOnline());
48+
}
4249

4350
// test getting connection by uri
4451
Assert.True(connectionManager.HasConnection(walletRpcs[0].GetRpcConnection().GetUri()));
45-
Assert.True(connectionManager.GetConnection(walletRpcs[0].GetRpcConnection().GetUri()) == walletRpcs[0].GetRpcConnection());
52+
Assert.True(connectionManager.GetConnection(walletRpcs[0].GetRpcConnection().GetUri()) ==
53+
walletRpcs[0].GetRpcConnection());
4654

4755
// test unknown connection
4856
int numExpectedChanges = 0;
@@ -66,7 +74,7 @@ public void TestConnectionManager()
6674
Assert.True(listener.ChangedConnections[listener.ChangedConnections.Count - 1] == null);
6775

6876
// start periodically checking connection without auto switch
69-
connectionManager.StartPolling((ulong)TestUtils.SYNC_PERIOD_IN_MS, false, null, null, null);
77+
connectionManager.StartPolling((ulong)TestUtils.SYNC_PERIOD_IN_MS, false);
7078

7179
// connect to best available connection in order of priority and response time
7280
connection = connectionManager.GetBestAvailableConnection();
@@ -84,7 +92,10 @@ public void TestConnectionManager()
8492
Assert.True(orderedConnections[2] == walletRpcs[3].GetRpcConnection());
8593
Assert.True(orderedConnections[3] == walletRpcs[0].GetRpcConnection());
8694
Assert.True(orderedConnections[4].GetUri() == walletRpcs[1].GetRpcConnection().GetUri());
87-
for (int i = 1; i < orderedConnections.Count; i++) Assert.Null(orderedConnections[i].IsOnline());
95+
for (int i = 1; i < orderedConnections.Count; i++)
96+
{
97+
Assert.Null(orderedConnections[i].IsOnline());
98+
}
8899

89100
// shut down prioritized servers
90101
TestUtils.StopWalletRpcProcess(walletRpcs[2]);
@@ -95,7 +106,8 @@ public void TestConnectionManager()
95106
Assert.False(connectionManager.GetConnection().IsOnline());
96107
Assert.Null(connectionManager.GetConnection().IsAuthenticated());
97108
Assert.True(++numExpectedChanges == listener.ChangedConnections.Count);
98-
Assert.True(listener.ChangedConnections[listener.ChangedConnections.Count - 1] == connectionManager.GetConnection());
109+
Assert.True(listener.ChangedConnections[listener.ChangedConnections.Count - 1] ==
110+
connectionManager.GetConnection());
99111

100112
// test connection order
101113
orderedConnections = connectionManager.GetRpcConnections();
@@ -121,11 +133,27 @@ public void TestConnectionManager()
121133
{
122134
bool? IsOnline = orderedConnections[i].IsOnline();
123135
bool? IsAuthenticated = orderedConnections[i].IsAuthenticated();
124-
if (i == 1 || i == 2) Assert.True(IsOnline);
125-
else Assert.False(IsOnline);
126-
if (i == 1) Assert.True(IsAuthenticated);
127-
else if (i == 2) Assert.False(IsAuthenticated);
128-
else Assert.Null(IsAuthenticated);
136+
if (i == 1 || i == 2)
137+
{
138+
Assert.True(IsOnline);
139+
}
140+
else
141+
{
142+
Assert.False(IsOnline);
143+
}
144+
145+
if (i == 1)
146+
{
147+
Assert.True(IsAuthenticated);
148+
}
149+
else if (i == 2)
150+
{
151+
Assert.False(IsAuthenticated);
152+
}
153+
else
154+
{
155+
Assert.Null(IsAuthenticated);
156+
}
129157
}
130158

131159
// test auto switch when disconnected
@@ -171,7 +199,12 @@ public void TestConnectionManager()
171199
Assert.True(orderedConnections[2] == walletRpcs[4].GetRpcConnection());
172200
Assert.True(orderedConnections[3] == walletRpcs[2].GetRpcConnection());
173201
Assert.True(orderedConnections[4] == walletRpcs[3].GetRpcConnection());
174-
for (int i = 0; i < orderedConnections.Count - 1; i++) Assert.True(i <= 1 ? orderedConnections[i].IsOnline() == true : orderedConnections[i].IsOnline() != true);
202+
for (int i = 0; i < orderedConnections.Count - 1; i++)
203+
{
204+
Assert.True(
205+
i <= 1 ? orderedConnections[i].IsOnline() == true : orderedConnections[i].IsOnline() != true);
206+
}
207+
175208
Assert.False(orderedConnections[4].IsOnline());
176209

177210
// set connection to existing uri
@@ -184,13 +217,14 @@ public void TestConnectionManager()
184217

185218
if (rpcConnection.GetType().IsInstanceOfType(currentConnection))
186219
{
187-
rpcConnection = (MoneroRpcConnection)currentConnection;
220+
rpcConnection = currentConnection;
188221
Assert.True(TestUtils.WALLET_RPC_USERNAME == rpcConnection.GetUsername());
189222
Assert.True(TestUtils.WALLET_RPC_PASSWORD == rpcConnection.GetPassword());
190223
}
191224

192225
Assert.True(++numExpectedChanges == listener.ChangedConnections.Count);
193-
Assert.True(listener.ChangedConnections[listener.ChangedConnections.Count - 1] == walletRpcs[0].GetRpcConnection());
226+
Assert.True(listener.ChangedConnections[listener.ChangedConnections.Count - 1] ==
227+
walletRpcs[0].GetRpcConnection());
194228

195229
// set connection to new uri
196230
connectionManager.StopPolling();
@@ -222,22 +256,28 @@ public void TestConnectionManager()
222256
connectionManager.SetConnection(null);
223257
Assert.False(connectionManager.IsConnected());
224258
Assert.True(++numExpectedChanges == listener.ChangedConnections.Count);
225-
connectionManager.StartPolling((ulong)TestUtils.SYNC_PERIOD_IN_MS, null, null, MoneroConnectionManager.PollType.CURRENT, null);
259+
connectionManager.StartPolling((ulong)TestUtils.SYNC_PERIOD_IN_MS, null, null,
260+
MoneroConnectionManager.PollType.CURRENT);
226261
Thread.Sleep(TestUtils.AUTO_CONNECT_TIMEOUT_MS);
227262
Assert.True(connectionManager.IsConnected());
228263
Assert.True(++numExpectedChanges == listener.ChangedConnections.Count);
229264

230265
// test polling all connections
231266
connectionManager.SetConnection(null);
232267
Assert.True(++numExpectedChanges == listener.ChangedConnections.Count);
233-
connectionManager.StartPolling((ulong)TestUtils.SYNC_PERIOD_IN_MS, null, null, MoneroConnectionManager.PollType.ALL, null);
268+
connectionManager.StartPolling((ulong)TestUtils.SYNC_PERIOD_IN_MS, null, null,
269+
MoneroConnectionManager.PollType.ALL);
234270
Thread.Sleep(TestUtils.AUTO_CONNECT_TIMEOUT_MS);
235271
Assert.True(connectionManager.IsConnected());
236272
Assert.True(++numExpectedChanges == listener.ChangedConnections.Count);
237273

238274
// shut down all connections
239275
connection = connectionManager.GetConnection();
240-
foreach (MoneroWalletRpc walletRpc in walletRpcs) TestUtils.StopWalletRpcProcess(walletRpc);
276+
foreach (MoneroWalletRpc walletRpc in walletRpcs)
277+
{
278+
TestUtils.StopWalletRpcProcess(walletRpc);
279+
}
280+
241281
Thread.Sleep(TestUtils.SYNC_PERIOD_IN_MS + 100);
242282
Assert.False(connection.IsOnline());
243283
Assert.True(++numExpectedChanges == listener.ChangedConnections.Count);

0 commit comments

Comments
 (0)