Skip to content

Commit

Permalink
Upgrade to .NET 7
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDesmond-ca committed Nov 9, 2022
1 parent 6c29bc0 commit 2a07dd9
Show file tree
Hide file tree
Showing 20 changed files with 63 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x

- name: Restore
run: dotnet restore
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/CodeQL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ jobs:
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Setup .NET 6
- name: Setup .NET 7
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
with:
fetch-depth: 0

- name: Setup .NET 6
- name: Setup .NET 7
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x

- name: Install Sonar Scanner
run: dotnet tool install --global dotnet-sonarscanner
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x

- name: Run tests
run: dotnet test
Expand Down
2 changes: 1 addition & 1 deletion Examples/CLI/CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<RuntimeIdentifiers>linux-arm</RuntimeIdentifiers>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
2 changes: 1 addition & 1 deletion Examples/Components/DotMatrix/DotMatrix.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>SimpleGPIO.Examples.Components.DotMatrix</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion Examples/Components/Motor/Motor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>SimpleGPIO.Examples.Components.Motor</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion Examples/Components/RGBLED/RGBLED.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>SimpleGPIO.Examples.Components.RGBLED</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion Examples/Components/RotaryEncoder/RotaryEncoder.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>SimpleGPIO.Examples.Components.SevenSegmentDisplay</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion Examples/Components/ShiftRegister/ShiftRegister.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>SimpleGPIO.Examples.Components.ShiftRegister</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion Examples/Input/Input.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>SimpleGPIO.Examples.Input</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion Examples/PWM/PWM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>SimpleGPIO.Examples.PWM</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion Examples/Web/Web.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>SimpleGPIO.Examples.Web</RootNamespace>
Expand Down
21 changes: 21 additions & 0 deletions SimpleGPIO.Tests/MathTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Xunit;

namespace SimpleGPIO.Tests;

public class MathTests
{
[Theory]
[InlineData(1, 2, 4, 2)]
[InlineData(2, 2, 4, 2)]
[InlineData(3, 2, 4, 3)]
[InlineData(4, 2, 4, 4)]
[InlineData(5, 2, 4, 4)]
public void CanClampNumber(int value, int min, int max, int expected)
{
//act
var actual = value.Clamp(min, max);

//assert
Assert.Equal(expected, actual);
}
}
2 changes: 1 addition & 1 deletion SimpleGPIO.Tests/SimpleGPIO.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
7 changes: 3 additions & 4 deletions SimpleGPIO/GPIO/PinInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public double Strength
get => _strength;
set
{
_strength = Math.Clamp(value, 0, 100);
_strength = value.Clamp(0, 100);

if (Power == PowerValue.On && _strength == 0)
{
Expand All @@ -60,7 +60,6 @@ public double Strength
}
}


protected abstract void RefreshPWM();

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


private static long Delay(double hz) => (long)(TimeSpan.TicksPerSecond / hz / 2);
private static long Delay(double hz) => (long) (TimeSpan.TicksPerSecond / hz / 2);

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

while (timer.Elapsed < duration)
{
var progress = timer.Elapsed / duration;
var progress = timer.Elapsed.TotalMilliseconds / duration.TotalMilliseconds;
Strength = initial + (strength - initial) * progress;
await Task.Delay(TimeSpan.FromSeconds(1.0 / 60));
}
Expand Down
11 changes: 11 additions & 0 deletions SimpleGPIO/IsExternalInit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// ReSharper disable once CheckNamespace

namespace System.Runtime.CompilerServices;

using ComponentModel;

// ReSharper disable once UnusedType.Global
[EditorBrowsable(EditorBrowsableState.Never)]
internal static class IsExternalInit
{
}
9 changes: 9 additions & 0 deletions SimpleGPIO/Math.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SimpleGPIO;

public static class Math
{
public static T Clamp<T>(this T value, T min, T max) where T : IComparable<T>
=> value.CompareTo(min) < 0 ? min
: value.CompareTo(max) > 0 ? max
: value;
}
4 changes: 2 additions & 2 deletions SimpleGPIO/SimpleGPIO.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>2.0.0</Version>
<TargetFramework>net6.0</TargetFramework>
<Version>2.0.1</Version>
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>Library</OutputType>
<LangVersion>latest</LangVersion>
<Description>A simple, low-ceremony GPIO library for all your IoT needs</Description>
Expand Down

0 comments on commit 2a07dd9

Please sign in to comment.