Skip to content

Commit 2a07dd9

Browse files
Upgrade to .NET 7
1 parent 6c29bc0 commit 2a07dd9

File tree

20 files changed

+63
-23
lines changed

20 files changed

+63
-23
lines changed

.github/workflows/CI.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: Setup .NET Core
1212
uses: actions/setup-dotnet@v1
1313
with:
14-
dotnet-version: 6.0.x
14+
dotnet-version: 7.0.x
1515

1616
- name: Restore
1717
run: dotnet restore

.github/workflows/CodeQL.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ jobs:
5050
# Prefix the list here with "+" to use these queries and those in the config file.
5151
# queries: ./path/to/local/query, your-org/your-repo/queries@main
5252

53-
- name: Setup .NET 6
53+
- name: Setup .NET 7
5454
uses: actions/setup-dotnet@v1
5555
with:
56-
dotnet-version: 6.0.x
56+
dotnet-version: 7.0.x
5757

5858
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5959
# If this step fails, then you should remove it and run the build manually (see below)

.github/workflows/Sonar.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
with:
1313
fetch-depth: 0
1414

15-
- name: Setup .NET 6
15+
- name: Setup .NET 7
1616
uses: actions/setup-dotnet@v1
1717
with:
18-
dotnet-version: 6.0.x
18+
dotnet-version: 7.0.x
1919

2020
- name: Install Sonar Scanner
2121
run: dotnet tool install --global dotnet-sonarscanner

.github/workflows/nuget.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
- uses: actions/setup-dotnet@v1
1616
with:
17-
dotnet-version: 6.0.x
17+
dotnet-version: 7.0.x
1818

1919
- name: Run tests
2020
run: dotnet test

Examples/CLI/CLI.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net7.0</TargetFramework>
66
<RuntimeIdentifiers>linux-arm</RuntimeIdentifiers>
77
<LangVersion>latest</LangVersion>
88
<ImplicitUsings>enable</ImplicitUsings>

Examples/Components/DotMatrix/DotMatrix.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>SimpleGPIO.Examples.Components.DotMatrix</RootNamespace>

Examples/Components/Motor/Motor.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>SimpleGPIO.Examples.Components.Motor</RootNamespace>

Examples/Components/RGBLED/RGBLED.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>SimpleGPIO.Examples.Components.RGBLED</RootNamespace>

Examples/Components/RotaryEncoder/RotaryEncoder.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>

Examples/Components/SevenSegmentDisplay/SevenSegmentDisplay.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>SimpleGPIO.Examples.Components.SevenSegmentDisplay</RootNamespace>

Examples/Components/ShiftRegister/ShiftRegister.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>SimpleGPIO.Examples.Components.ShiftRegister</RootNamespace>

Examples/Input/Input.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net7.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<RootNamespace>SimpleGPIO.Examples.Input</RootNamespace>

Examples/PWM/PWM.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net7.0</TargetFramework>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<RootNamespace>SimpleGPIO.Examples.PWM</RootNamespace>

Examples/Web/Web.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
3-
<TargetFramework>net6.0</TargetFramework>
3+
<TargetFramework>net7.0</TargetFramework>
44
<ImplicitUsings>enable</ImplicitUsings>
55
<Nullable>enable</Nullable>
66
<RootNamespace>SimpleGPIO.Examples.Web</RootNamespace>

SimpleGPIO.Tests/MathTests.cs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Xunit;
2+
3+
namespace SimpleGPIO.Tests;
4+
5+
public class MathTests
6+
{
7+
[Theory]
8+
[InlineData(1, 2, 4, 2)]
9+
[InlineData(2, 2, 4, 2)]
10+
[InlineData(3, 2, 4, 3)]
11+
[InlineData(4, 2, 4, 4)]
12+
[InlineData(5, 2, 4, 4)]
13+
public void CanClampNumber(int value, int min, int max, int expected)
14+
{
15+
//act
16+
var actual = value.Clamp(min, max);
17+
18+
//assert
19+
Assert.Equal(expected, actual);
20+
}
21+
}

SimpleGPIO.Tests/SimpleGPIO.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net6.0</TargetFramework>
3+
<TargetFramework>net7.0</TargetFramework>
44
<ImplicitUsings>enable</ImplicitUsings>
55
<Nullable>enable</Nullable>
66
</PropertyGroup>

SimpleGPIO/GPIO/PinInterface.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public double Strength
4444
get => _strength;
4545
set
4646
{
47-
_strength = Math.Clamp(value, 0, 100);
47+
_strength = value.Clamp(0, 100);
4848

4949
if (Power == PowerValue.On && _strength == 0)
5050
{
@@ -60,7 +60,6 @@ public double Strength
6060
}
6161
}
6262

63-
6463
protected abstract void RefreshPWM();
6564

6665
public void Enable() => Enabled = true;
@@ -127,7 +126,7 @@ private async Task RunToggleHalfIteration(Stopwatch stopwatch, long delay)
127126
}
128127

129128

130-
private static long Delay(double hz) => (long)(TimeSpan.TicksPerSecond / hz / 2);
129+
private static long Delay(double hz) => (long) (TimeSpan.TicksPerSecond / hz / 2);
131130

132131
public async Task FadeIn(TimeSpan duration) => await FadeTo(100, duration);
133132
public async Task FadeOut(TimeSpan duration) => await FadeTo(0, duration);
@@ -139,7 +138,7 @@ public async Task FadeTo(double strength, TimeSpan duration)
139138

140139
while (timer.Elapsed < duration)
141140
{
142-
var progress = timer.Elapsed / duration;
141+
var progress = timer.Elapsed.TotalMilliseconds / duration.TotalMilliseconds;
143142
Strength = initial + (strength - initial) * progress;
144143
await Task.Delay(TimeSpan.FromSeconds(1.0 / 60));
145144
}

SimpleGPIO/IsExternalInit.cs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// ReSharper disable once CheckNamespace
2+
3+
namespace System.Runtime.CompilerServices;
4+
5+
using ComponentModel;
6+
7+
// ReSharper disable once UnusedType.Global
8+
[EditorBrowsable(EditorBrowsableState.Never)]
9+
internal static class IsExternalInit
10+
{
11+
}

SimpleGPIO/Math.cs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace SimpleGPIO;
2+
3+
public static class Math
4+
{
5+
public static T Clamp<T>(this T value, T min, T max) where T : IComparable<T>
6+
=> value.CompareTo(min) < 0 ? min
7+
: value.CompareTo(max) > 0 ? max
8+
: value;
9+
}

SimpleGPIO/SimpleGPIO.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<Version>2.0.0</Version>
4-
<TargetFramework>net6.0</TargetFramework>
3+
<Version>2.0.1</Version>
4+
<TargetFramework>netstandard2.0</TargetFramework>
55
<OutputType>Library</OutputType>
66
<LangVersion>latest</LangVersion>
77
<Description>A simple, low-ceremony GPIO library for all your IoT needs</Description>

0 commit comments

Comments
 (0)