Skip to content

Commit 9d77f1e

Browse files
napolyeveroddandeven
authored andcommitted
Add default .NET SDK code formatting
1 parent 67060b1 commit 9d77f1e

103 files changed

Lines changed: 15913 additions & 15965 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.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Code format check
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
pull_request:
8+
branches:
9+
- "master"
10+
workflow_dispatch:
11+
12+
jobs:
13+
lint:
14+
runs-on: windows-latest
15+
steps:
16+
17+
- uses: actions/checkout@v5
18+
with:
19+
submodules: recursive
20+
21+
- name: Setup .NET
22+
uses: actions/setup-dotnet@v5
23+
with:
24+
dotnet-version: 8.0.x
25+
26+
- name: Restore dependencies
27+
run: dotnet restore
28+
29+
- name: Code format check
30+
run: |
31+
dotnet tool install -g dotnet-format
32+
dotnet format monero-csharp.sln --no-restore --verify-no-changes --verbosity diagnostic

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/checkout@v5
1717

1818
- name: Setup .NET
19-
uses: actions/setup-dotnet@v4
19+
uses: actions/setup-dotnet@v5
2020
with:
2121
dotnet-version: 8.0.x
2222

Monero.Test/TestMoneroConnectionManager.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ namespace Monero.Test;
66

77
public class TestMoneroConnectionManager
88
{
9-
10-
11-
public TestMoneroConnectionManager() { }
12-
139
[Fact]
1410
public void TestConnectionManager()
1511
{
@@ -51,7 +47,7 @@ public void TestConnectionManager()
5147
// test unknown connection
5248
int numExpectedChanges = 0;
5349
connectionManager.SetConnection(orderedConnections[0]);
54-
Assert.Null( connectionManager.IsConnected());
50+
Assert.Null(connectionManager.IsConnected());
5551
Assert.True(++numExpectedChanges == listener.ChangedConnections.Count);
5652

5753
// auto connect to best available connection
@@ -206,7 +202,7 @@ public void TestConnectionManager()
206202

207203
// set connection to empty string
208204
connectionManager.SetConnection("");
209-
Assert.Null( connectionManager.GetConnection());
205+
Assert.Null(connectionManager.GetConnection());
210206
Assert.True(++numExpectedChanges == listener.ChangedConnections.Count);
211207

212208
// check all connections and test auto switch
@@ -250,7 +246,7 @@ public void TestConnectionManager()
250246
// reset
251247
connectionManager.Reset();
252248
Assert.True(0 == connectionManager.GetConnections().Count);
253-
Assert.Null( connectionManager.GetConnection());
249+
Assert.Null(connectionManager.GetConnection());
254250
}
255251
catch (Exception ex)
256252
{

Monero.Test/TestMoneroDaemonRpc.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
using Monero.Common;
1+
using System.Collections.ObjectModel;
2+
3+
using Monero.Common;
24
using Monero.Daemon;
35
using Monero.Daemon.Common;
46
using Monero.Test.Utils;
57
using Monero.Wallet;
68
using Monero.Wallet.Common;
7-
using System.Collections.ObjectModel;
89

910
namespace Monero.Test;
1011

@@ -1103,7 +1104,7 @@ public void TestGetMiningStatus()
11031104
}
11041105
catch (MoneroError e)
11051106
{
1106-
throw e;
1107+
throw;
11071108
}
11081109
finally
11091110
{
@@ -1333,7 +1334,7 @@ public void TestBlockListener()
13331334
}
13341335
catch (MoneroError e)
13351336
{
1336-
throw e;
1337+
throw;
13371338
}
13381339
finally
13391340
{
@@ -1541,9 +1542,9 @@ private static void TestTx(MoneroTx? tx, TestContext? ctx)
15411542
if (tx.IsConfirmed() == true)
15421543
{
15431544
Assert.NotNull(tx.GetBlock());
1544-
Assert.True(tx.GetBlock().GetTxs().Contains(tx));
1545+
Assert.Contains(tx, tx.GetBlock().GetTxs());
15451546
Assert.True(tx.GetBlock().GetHeight() > 0);
1546-
Assert.True(tx.GetBlock().GetTxs().Contains(tx));
1547+
Assert.Contains(tx, tx.GetBlock().GetTxs());
15471548
Assert.True(tx.GetBlock().GetHeight() > 0);
15481549
Assert.True(tx.GetBlock().GetTimestamp() > 0);
15491550
Assert.True(tx.GetRelay());
@@ -1656,7 +1657,7 @@ private static void TestTx(MoneroTx? tx, TestContext? ctx)
16561657
if (ctx.fromBinaryBlock == true) Assert.Null(tx.GetFullHex()); // TODO: GetBlocksByHeight() has inconsistent client-side pruning
16571658
else Assert.True(tx.GetFullHex().Length > 0);
16581659
if (ctx.fromBinaryBlock == true) Assert.Null(tx.GetRctSigPrunable()); // TODO: GetBlocksByHeight() has inconsistent client-side pruning
1659-
//else Assert.NotNull((tx.GetRctSigPrunable()); // TODO: define and test this
1660+
//else Assert.NotNull((tx.GetRctSigPrunable()); // TODO: define and test this
16601661
Assert.False(tx.IsDoubleSpendSeen());
16611662
if (tx.IsConfirmed() == true)
16621663
{
@@ -1966,8 +1967,6 @@ private static void TestPeer(MoneroPeer peer)
19661967
Assert.True(peer.GetCurrentUpload() >= 0);
19671968
Assert.True(peer.GetHeight() >= 0);
19681969
Assert.True(peer.GetLiveTime() >= 0);
1969-
Assert.NotNull(peer.IsLocalIp());
1970-
Assert.NotNull(peer.IsLocalHost());
19711970
Assert.True(peer.GetNumReceives() >= 0);
19721971
Assert.True(peer.GetReceiveIdleTime() >= 0);
19731972
Assert.True(peer.GetNumSends() >= 0);
@@ -1984,7 +1983,6 @@ private static void TestKnownPeer(MoneroPeer peer, bool fromConnection)
19841983
Assert.True(peer.GetHost().Length > 0);
19851984
Assert.True(peer.GetPort() > 0);
19861985
Assert.True(peer.GetRpcPort() == null || peer.GetRpcPort() >= 0);
1987-
Assert.NotNull(peer.IsOnline());
19881986
//if (peer.GetRpcCreditsPerHash() != null) TestUtils.testUnsignedBigInteger(peer.GetRpcCreditsPerHash());
19891987
if (fromConnection) Assert.Null(peer.GetLastSeenTimestamp());
19901988
else
@@ -2053,7 +2051,7 @@ private static void TestSubmitTxResultGood(MoneroSubmitTxResult result)
20532051
catch (Exception e)
20542052
{
20552053
MoneroUtils.Log(0, "Submit result is not good");
2056-
throw e;
2054+
throw;
20572055
}
20582056
}
20592057

@@ -2132,7 +2130,7 @@ private static void TestSubmitThenRelay(List<MoneroTx> txs)
21322130
catch (Exception e)
21332131
{
21342132
daemon.FlushTxPool(txHashes); // flush txs when relay fails to prevent double spends in other tests
2135-
throw e;
2133+
throw;
21362134
}
21372135

21382136
// wait for txs to be relayed // TODO (monero-project): all txs should be relayed: https://github.com/monero-project/monero/issues/8523
Lines changed: 91 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,117 @@
11
using Monero.Common;
22
using Monero.Test.Utils;
33

4-
namespace Monero.Test
4+
namespace Monero.Test;
5+
6+
public class TestMoneroRpcConnection
57
{
6-
public class TestMoneroRpcConnection
8+
// Can copy connection
9+
[Fact]
10+
public void TestClone()
711
{
8-
// Can copy connection
9-
[Fact]
10-
public void TestClone()
11-
{
12-
var connection = new MoneroRpcConnection("test", "user", "pass123", "test_zmq", 2);
12+
var connection = new MoneroRpcConnection("test", "user", "pass123", "test_zmq", 2);
1313

14-
var copy = connection.Clone();
15-
16-
Assert.True(connection.Equals(copy));
14+
var copy = connection.Clone();
1715

18-
connection = new MoneroRpcConnection(TestUtils.DAEMON_RPC_URI);
19-
20-
TestConnection(connection, TestUtils.DAEMON_RPC_URI, true);
16+
Assert.True(connection.Equals(copy));
2117

22-
copy = connection.Clone();
18+
connection = new MoneroRpcConnection(TestUtils.DAEMON_RPC_URI);
2319

24-
Assert.True(connection.Equals(copy));
25-
}
20+
TestConnection(connection, TestUtils.DAEMON_RPC_URI, true);
2621

27-
// Can connect to node
28-
[Fact]
29-
public void TestNodeRpcConnection()
30-
{
31-
var connection = new MoneroRpcConnection(TestUtils.DAEMON_RPC_URI);
32-
33-
TestConnection(connection, TestUtils.DAEMON_RPC_URI, true);
34-
}
35-
36-
// Can connect to wallet
37-
[Fact]
38-
public void TestWalletRpcConnection()
39-
{
40-
var connection = new MoneroRpcConnection(TestUtils.WALLET_RPC_URI);
41-
42-
TestConnection(connection, TestUtils.WALLET_RPC_URI, true);
43-
}
44-
45-
// Test invalid url
46-
[Fact]
47-
public void TestInvalidConnection()
48-
{
49-
var connection = new MoneroRpcConnection("");
22+
copy = connection.Clone();
5023

51-
TestConnection(connection, "", false);
52-
}
53-
54-
// Can send request to RPC
55-
[Fact]
56-
public void TestSendRequest()
57-
{
58-
// Setup connection
24+
Assert.True(connection.Equals(copy));
25+
}
26+
27+
// Can connect to node
28+
[Fact]
29+
public void TestNodeRpcConnection()
30+
{
31+
var connection = new MoneroRpcConnection(TestUtils.DAEMON_RPC_URI);
32+
33+
TestConnection(connection, TestUtils.DAEMON_RPC_URI, true);
34+
}
35+
36+
// Can connect to wallet
37+
[Fact]
38+
public void TestWalletRpcConnection()
39+
{
40+
var connection = new MoneroRpcConnection(TestUtils.WALLET_RPC_URI);
41+
42+
TestConnection(connection, TestUtils.WALLET_RPC_URI, true);
43+
}
44+
45+
// Test invalid url
46+
[Fact]
47+
public void TestInvalidConnection()
48+
{
49+
var connection = new MoneroRpcConnection("");
5950

60-
var connection = new MoneroRpcConnection(TestUtils.DAEMON_RPC_URI);
51+
TestConnection(connection, "", false);
52+
}
6153

62-
TestConnection(connection, TestUtils.DAEMON_RPC_URI, true);
54+
// Can send request to RPC
55+
[Fact]
56+
public void TestSendRequest()
57+
{
58+
// Setup connection
6359

64-
// Test monerod JSON request
60+
var connection = new MoneroRpcConnection(TestUtils.DAEMON_RPC_URI);
6561

66-
var jsonResponse = connection.SendJsonRequest("get_info");
62+
TestConnection(connection, TestUtils.DAEMON_RPC_URI, true);
6763

68-
Assert.NotNull(jsonResponse);
69-
Assert.Null(jsonResponse.Error);
70-
Assert.NotNull(jsonResponse.Result);
64+
// Test monerod JSON request
7165

72-
// Test monerod PATH request
66+
var jsonResponse = connection.SendJsonRequest("get_info");
7367

74-
var pathResponse = connection.SendPathRequest("get_info");
68+
Assert.NotNull(jsonResponse);
69+
Assert.Null(jsonResponse.Error);
70+
Assert.NotNull(jsonResponse.Result);
7571

76-
Assert.NotNull(pathResponse);
77-
Assert.Null(pathResponse.GetValueOrDefault("error"));
72+
// Test monerod PATH request
7873

79-
// Test monerod BINARY request
74+
var pathResponse = connection.SendPathRequest("get_info");
8075

81-
// TODO implement MoneroRpcConnection.SendBinaryRequest()
76+
Assert.NotNull(pathResponse);
77+
Assert.Null(pathResponse.GetValueOrDefault("error"));
8278

83-
//var binaryResponse = connection.SendBinaryRequest("get_outs.bin");
84-
//Assert.NotNull(binaryResponse);
85-
}
79+
// Test monerod BINARY request
8680

87-
private static void TestConnection(MoneroRpcConnection? connection, string? uri, bool online)
81+
// TODO implement MoneroRpcConnection.SendBinaryRequest()
82+
83+
//var binaryResponse = connection.SendBinaryRequest("get_outs.bin");
84+
//Assert.NotNull(binaryResponse);
85+
}
86+
87+
private static void TestConnection(MoneroRpcConnection? connection, string? uri, bool online)
88+
{
89+
Assert.NotNull(connection);
90+
91+
if (online)
92+
{
93+
Assert.NotNull(uri);
94+
Assert.NotEmpty(uri);
95+
Assert.Equal(uri, connection.GetUri());
96+
Assert.True(connection.IsClearnet());
97+
Assert.False(connection.IsOnion());
98+
Assert.False(connection.IsI2P());
99+
Assert.True(connection.CheckConnection());
100+
Assert.True(connection.IsOnline());
101+
Assert.True(connection.IsAuthenticated());
102+
Assert.True(connection.IsConnected());
103+
}
104+
else
88105
{
89-
Assert.NotNull(connection);
90-
91-
if (online)
92-
{
93-
Assert.NotNull(uri);
94-
Assert.NotEmpty(uri);
95-
Assert.Equal(uri, connection.GetUri());
96-
Assert.True(connection.IsClearnet());
97-
Assert.False(connection.IsOnion());
98-
Assert.False(connection.IsI2P());
99-
Assert.True(connection.CheckConnection());
100-
Assert.True(connection.IsOnline());
101-
Assert.True(connection.IsAuthenticated());
102-
Assert.True(connection.IsConnected());
103-
}
104-
else
105-
{
106-
Assert.Equal(uri, connection.GetUri());
107-
Assert.False(connection.IsClearnet());
108-
Assert.False(connection.IsOnion());
109-
Assert.False(connection.IsI2P());
110-
Assert.True(connection.CheckConnection());
111-
Assert.False(connection.IsOnline());
112-
Assert.Null(connection.IsAuthenticated());
113-
Assert.False(connection.IsConnected());
114-
}
106+
Assert.Equal(uri, connection.GetUri());
107+
Assert.False(connection.IsClearnet());
108+
Assert.False(connection.IsOnion());
109+
Assert.False(connection.IsI2P());
110+
Assert.True(connection.CheckConnection());
111+
Assert.False(connection.IsOnline());
112+
Assert.Null(connection.IsAuthenticated());
113+
Assert.False(connection.IsConnected());
115114
}
116-
117115
}
118-
}
116+
117+
}

Monero.Test/TestMoneroUtils.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ namespace Monero.Test;
55

66
public class TestMoneroUtils
77
{
8-
public TestMoneroUtils() {
9-
10-
}
11-
128
// Can get integrated addresses
139
[Fact(Skip = "MoneroUtils.GetIntegratedAddress(): not implemented")]
1410
public void TestGetIntegratedAddresses()
@@ -258,4 +254,4 @@ private static void TestInvalidPublicSpendKey(string publicSpendKey)
258254

259255
#endregion
260256

261-
}
257+
}

0 commit comments

Comments
 (0)