Skip to content

Commit 5f4f422

Browse files
committed
Add global AnalyzerConfig for custom Roslyn analyzer
1 parent 343f277 commit 5f4f422

108 files changed

Lines changed: 7036 additions & 2959 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.

.gitattributes

Lines changed: 7 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,9 @@
1-
###############################################################################
2-
# Set default behavior to automatically normalize line endings.
3-
###############################################################################
4-
* text=auto
1+
# Windows CRLF endings expected on server
2+
* text eol=crlf
53

6-
###############################################################################
7-
# Set default behavior for command prompt diff.
8-
#
9-
# This is need for earlier builds of msysgit that does not have it on by
10-
# default for csharp files.
11-
# Note: This is only used by command line
12-
###############################################################################
13-
#*.cs diff=csharp
4+
# Explicitly set Unix LF endings for .sh files
5+
*.sh text eol=lf
146

15-
###############################################################################
16-
# Set the merge driver for project and solution files
17-
#
18-
# Merging from the command prompt will add diff markers to the files if there
19-
# are conflicts (Merging from VS is not affected by the settings below, in VS
20-
# the diff markers are never inserted). Diff markers may cause the following
21-
# file extensions to fail to load in VS. An alternative would be to treat
22-
# these files as binary and thus will always conflict and require user
23-
# intervention with every merge. To do so, just uncomment the entries below
24-
###############################################################################
25-
#*.sln merge=binary
26-
#*.csproj merge=binary
27-
#*.vbproj merge=binary
28-
#*.vcxproj merge=binary
29-
#*.vcproj merge=binary
30-
#*.dbproj merge=binary
31-
#*.fsproj merge=binary
32-
#*.lsproj merge=binary
33-
#*.wixproj merge=binary
34-
#*.modelproj merge=binary
35-
#*.sqlproj merge=binary
36-
#*.wwaproj merge=binary
37-
38-
###############################################################################
39-
# behavior for image files
40-
#
41-
# image files are treated as binary by default.
42-
###############################################################################
43-
#*.jpg binary
44-
#*.png binary
45-
#*.gif binary
46-
47-
###############################################################################
48-
# diff behavior for common document formats
49-
#
50-
# Convert binary document formats to text before diffing them. This feature
51-
# is only available from the command line. Turn it on by uncommenting the
52-
# entries below.
53-
###############################################################################
54-
#*.doc diff=astextplain
55-
#*.DOC diff=astextplain
56-
#*.docx diff=astextplain
57-
#*.DOCX diff=astextplain
58-
#*.dot diff=astextplain
59-
#*.DOT diff=astextplain
60-
#*.pdf diff=astextplain
61-
#*.PDF diff=astextplain
62-
#*.rtf diff=astextplain
63-
#*.RTF diff=astextplain
7+
# Denote all files that are truly binary and should not be modified.
8+
*.png binary
9+
*.jpg binary

.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: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<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: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Monero.Common;
1+
using Monero.Common;
22
using Monero.Test.Utils;
33
using Monero.Wallet;
44

@@ -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)