Skip to content

Commit 58f550d

Browse files
authored
- Update GitHub Pipeline to .NET 6 - Updated to .NET 6 TFM and updated libraries - Use C# 10.0 file scoped namespaces - Add sorting system usings to editorconfig sharpbrick#181 non-breaking
1 parent ea45ffc commit 58f550d

File tree

261 files changed

+9718
-9978
lines changed

Some content is hidden

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

261 files changed

+9718
-9978
lines changed

.editorconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
root = true
22

33
[*.cs]
4-
dotnet_diagnostic.CA1822.severity = none
4+
dotnet_sort_system_directives_first = true
5+
dotnet_diagnostic.CA1822.severity = none
6+
csharp_style_namespace_declarations = file_scoped:warning

.github/workflows/build-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Setup .NET Core
2323
uses: actions/setup-dotnet@v1
2424
with:
25-
dotnet-version: 5.0.100
25+
dotnet-version: 6.0.100
2626
- name: Build SharpBrick.PoweredUp
2727
run: dotnet build --configuration Release
2828
- name: Test SharpBrick.PoweredUp

.github/workflows/build-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v1
1616
- uses: actions/setup-dotnet@v1
1717
with:
18-
dotnet-version: 5.0.100
18+
dotnet-version: 6.0.100
1919
- name: Build Version
2020
# run: echo ::set-env name=RELEASE_VERSION::$(echo ${GITHUB_REF:11}) // deprecated
2121
run: echo "RELEASE_VERSION=$($env:GITHUB_REF.SubString(11))" >> $env:GITHUB_ENV
@@ -41,7 +41,7 @@ jobs:
4141
- name: Setup .NET Core
4242
uses: actions/setup-dotnet@v1
4343
with:
44-
dotnet-version: 5.0.100
44+
dotnet-version: 6.0.100
4545
source-url: https://api.nuget.org/v3/index.json
4646
- uses: actions/download-artifact@v1
4747
with:

examples/SharpBrick.PoweredUp.Examples/BaseExample.cs

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,73 +7,72 @@
77
using SharpBrick.PoweredUp;
88
using SharpBrick.PoweredUp.Functions;
99

10-
namespace Example
10+
namespace Example;
11+
12+
public abstract class BaseExample
1113
{
12-
public abstract class BaseExample
13-
{
14-
protected PoweredUpHost Host { get; set; }
15-
protected IServiceProvider ServiceProvider { get; set; }
16-
public Hub SelectedHub { get; set; }
14+
protected PoweredUpHost Host { get; set; }
15+
protected IServiceProvider ServiceProvider { get; set; }
16+
public Hub SelectedHub { get; set; }
1717

18-
public ILogger Log { get; private set; }
18+
public ILogger Log { get; private set; }
1919

20-
public abstract Task ExecuteAsync();
20+
public abstract Task ExecuteAsync();
2121

22-
public virtual void Configure(IServiceCollection serviceCollection)
23-
{
24-
serviceCollection
25-
.AddPoweredUp();
26-
}
22+
public virtual void Configure(IServiceCollection serviceCollection)
23+
{
24+
serviceCollection
25+
.AddPoweredUp();
26+
}
2727

28-
public async Task InitExampleAndDiscoverAsync(IServiceProvider serviceProvider, IConfiguration configuration)
29-
{
30-
ServiceProvider = serviceProvider;
28+
public async Task InitExampleAndDiscoverAsync(IServiceProvider serviceProvider, IConfiguration configuration)
29+
{
30+
ServiceProvider = serviceProvider;
3131

32-
Host = serviceProvider.GetService<PoweredUpHost>();
32+
Host = serviceProvider.GetService<PoweredUpHost>();
3333

34-
Log = serviceProvider.GetService<ILoggerFactory>().CreateLogger("Example");
34+
Log = serviceProvider.GetService<ILoggerFactory>().CreateLogger("Example");
3535

36-
var enableTrace = bool.TryParse(configuration["EnableTrace"], out var x) && x;
36+
var enableTrace = bool.TryParse(configuration["EnableTrace"], out var x) && x;
3737

38-
await DiscoverAsync(enableTrace);
39-
}
38+
await DiscoverAsync(enableTrace);
39+
}
4040

41-
public virtual Task DiscoverAsync(bool enableTrace)
42-
{
43-
Hub result = null;
41+
public virtual Task DiscoverAsync(bool enableTrace)
42+
{
43+
Hub result = null;
4444

45-
Log.LogInformation("Finding Service");
46-
var cts = new CancellationTokenSource();
47-
Host.Discover(async hub =>
45+
Log.LogInformation("Finding Service");
46+
var cts = new CancellationTokenSource();
47+
Host.Discover(async hub =>
48+
{
49+
// add this when you are interested in a tracing of the message ("human readable")
50+
if (enableTrace)
4851
{
49-
// add this when you are interested in a tracing of the message ("human readable")
50-
if (enableTrace)
51-
{
52-
var tracer = hub.ServiceProvider.GetService<TraceMessages>();
53-
await tracer.ExecuteAsync();
54-
}
52+
var tracer = hub.ServiceProvider.GetService<TraceMessages>();
53+
await tracer.ExecuteAsync();
54+
}
5555

56-
Log.LogInformation("Connecting to Hub");
57-
await hub.ConnectAsync();
56+
Log.LogInformation("Connecting to Hub");
57+
await hub.ConnectAsync();
5858

59-
result = hub;
59+
result = hub;
6060

61-
Log.LogInformation(hub.AdvertisingName);
62-
Log.LogInformation(hub.SystemType.ToString());
61+
Log.LogInformation(hub.AdvertisingName);
62+
Log.LogInformation(hub.SystemType.ToString());
6363

64-
cts.Cancel();
64+
cts.Cancel();
6565

66-
Log.LogInformation("Press RETURN to continue to the action");
67-
}, cts.Token);
66+
Log.LogInformation("Press RETURN to continue to the action");
67+
}, cts.Token);
6868

69-
Log.LogInformation("Press RETURN to cancel Scanning");
70-
Console.ReadLine();
69+
Log.LogInformation("Press RETURN to cancel Scanning");
70+
Console.ReadLine();
7171

72-
cts.Cancel();
72+
cts.Cancel();
7373

74-
SelectedHub = result;
74+
SelectedHub = result;
7575

76-
return Task.CompletedTask;
77-
}
76+
return Task.CompletedTask;
7877
}
79-
}
78+
}
Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
11
using System.Threading.Tasks;
22
using SharpBrick.PoweredUp;
33

4-
namespace Example
4+
namespace Example;
5+
6+
public class ExampleBluetoothByKnownAddress : BaseExample
57
{
6-
public class ExampleBluetoothByKnownAddress : BaseExample
7-
{
8-
public const ulong ChangeMe_BluetoothAddress = 158897336311065;
9-
public TechnicMediumHub DirectlyConnectedHub { get; private set; }
8+
public const ulong ChangeMe_BluetoothAddress = 158897336311065;
9+
public TechnicMediumHub DirectlyConnectedHub { get; private set; }
1010

11-
// device needs to be switched on!
12-
public override async Task DiscoverAsync(bool enableTrace)
13-
{
14-
var hub = await Host.CreateByStateAsync<TechnicMediumHub>(ChangeMe_BluetoothAddress);
11+
// device needs to be switched on!
12+
public override async Task DiscoverAsync(bool enableTrace)
13+
{
14+
var hub = await Host.CreateByStateAsync<TechnicMediumHub>(ChangeMe_BluetoothAddress);
1515

16-
SelectedHub = DirectlyConnectedHub = hub;
16+
SelectedHub = DirectlyConnectedHub = hub;
1717

18-
await hub.ConnectAsync();
19-
}
18+
await hub.ConnectAsync();
19+
}
2020

21-
public override async Task ExecuteAsync()
22-
{
23-
using var technicMediumHub = DirectlyConnectedHub;
21+
public override async Task ExecuteAsync()
22+
{
23+
using var technicMediumHub = DirectlyConnectedHub;
2424

25-
await technicMediumHub.RgbLight.SetRgbColorsAsync(0xff, 0x00, 0x00);
25+
await technicMediumHub.RgbLight.SetRgbColorsAsync(0xff, 0x00, 0x00);
2626

27-
await Task.Delay(2000);
27+
await Task.Delay(2000);
2828

29-
await technicMediumHub.RgbLight.SetRgbColorsAsync(0x00, 0xff, 0x00);
29+
await technicMediumHub.RgbLight.SetRgbColorsAsync(0x00, 0xff, 0x00);
3030

31-
await Task.Delay(2000);
31+
await Task.Delay(2000);
3232

33-
await technicMediumHub.RgbLight.SetRgbColorsAsync(0xff, 0xff, 0x00);
33+
await technicMediumHub.RgbLight.SetRgbColorsAsync(0xff, 0xff, 0x00);
3434

35-
await Task.Delay(2000);
35+
await Task.Delay(2000);
3636

37-
await technicMediumHub.SwitchOffAsync();
38-
}
37+
await technicMediumHub.SwitchOffAsync();
3938
}
40-
}
39+
}
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
using System.Threading.Tasks;
22
using SharpBrick.PoweredUp;
33

4-
namespace Example
4+
namespace Example;
5+
6+
public class ExampleBluetoothByName : BaseExample
57
{
6-
public class ExampleBluetoothByName : BaseExample
7-
{
8-
public TechnicMediumHub DirectlyConnectedHub { get; private set; }
8+
public TechnicMediumHub DirectlyConnectedHub { get; private set; }
99

10-
public override async Task ExecuteAsync()
11-
{
12-
using var technicMediumHub = Host.FindByName<TechnicMediumHub>("Technic Hub");
10+
public override async Task ExecuteAsync()
11+
{
12+
using var technicMediumHub = Host.FindByName<TechnicMediumHub>("Technic Hub");
1313

14-
await technicMediumHub.RgbLight.SetRgbColorsAsync(0xff, 0x00, 0x00);
14+
await technicMediumHub.RgbLight.SetRgbColorsAsync(0xff, 0x00, 0x00);
1515

16-
await Task.Delay(2000);
16+
await Task.Delay(2000);
1717

18-
await technicMediumHub.RgbLight.SetRgbColorsAsync(0x00, 0xff, 0x00);
18+
await technicMediumHub.RgbLight.SetRgbColorsAsync(0x00, 0xff, 0x00);
1919

20-
await Task.Delay(2000);
20+
await Task.Delay(2000);
2121

22-
await technicMediumHub.RgbLight.SetRgbColorsAsync(0xff, 0xff, 0x00);
22+
await technicMediumHub.RgbLight.SetRgbColorsAsync(0xff, 0xff, 0x00);
2323

24-
await Task.Delay(2000);
24+
await Task.Delay(2000);
2525

26-
await technicMediumHub.SwitchOffAsync();
27-
}
26+
await technicMediumHub.SwitchOffAsync();
2827
}
29-
}
28+
}

examples/SharpBrick.PoweredUp.Examples/ExampleCalibrationSteering.cs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,28 @@
44
using SharpBrick.PoweredUp.Functions;
55
using static SharpBrick.PoweredUp.Directions;
66

7-
namespace Example
7+
namespace Example;
8+
9+
public class ExampleCalibrationSteering : BaseExample
810
{
9-
public class ExampleCalibrationSteering : BaseExample
11+
public override async Task ExecuteAsync()
1012
{
11-
public override async Task ExecuteAsync()
12-
{
13-
using var technicMediumHub = Host.FindByType<TechnicMediumHub>();
13+
using var technicMediumHub = Host.FindByType<TechnicMediumHub>();
1414

15-
var motor = technicMediumHub.A.GetDevice<TechnicLargeLinearMotor>();
15+
var motor = technicMediumHub.A.GetDevice<TechnicLargeLinearMotor>();
1616

17-
var calibration = ServiceProvider.GetService<LinearMidCalibration>();
18-
await calibration.ExecuteAsync(motor);
19-
await technicMediumHub.WaitButtonClickAsync();
17+
var calibration = ServiceProvider.GetService<LinearMidCalibration>();
18+
await calibration.ExecuteAsync(motor);
19+
await technicMediumHub.WaitButtonClickAsync();
2020

21-
await motor.GotoPositionAsync(CW * 50, 20, 100, SpecialSpeed.Hold, SpeedProfiles.AccelerationProfile);
22-
await technicMediumHub.WaitButtonClickAsync();
21+
await motor.GotoPositionAsync(CW * 50, 20, 100, SpecialSpeed.Hold, SpeedProfiles.AccelerationProfile);
22+
await technicMediumHub.WaitButtonClickAsync();
2323

24-
await motor.GotoPositionAsync(CCW * 50, 20, 100, SpecialSpeed.Hold, SpeedProfiles.AccelerationProfile);
25-
await Task.Delay(5000);
24+
await motor.GotoPositionAsync(CCW * 50, 20, 100, SpecialSpeed.Hold, SpeedProfiles.AccelerationProfile);
25+
await Task.Delay(5000);
2626

27-
await technicMediumHub.SwitchOffAsync();
28-
}
27+
await technicMediumHub.SwitchOffAsync();
28+
}
2929

3030

31-
}
32-
}
31+
}

0 commit comments

Comments
 (0)