Skip to content

Commit

Permalink
Merge pull request #7 from luca-domenichini/master
Browse files Browse the repository at this point in the history
Prerelease 2023-12-13 .NET8.0
  • Loading branch information
luca-domenichini authored Dec 13, 2023
2 parents e0abdbb + 7181535 commit 665521e
Show file tree
Hide file tree
Showing 55 changed files with 1,528 additions and 272 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/dotnet-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Setup .NET
- name: Setup .NET6
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Setup .NET8
uses: actions/setup-dotnet@v2
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore SmartIOT.Connector.sln
- name: Build
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/dotnet-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Setup .NET
- name: Setup .NET6
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Setup .NET8
uses: actions/setup-dotnet@v2
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore SmartIOT.Connector.sln
- name: Build
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/dotnet-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

env:
VERSION_MAJOR: 0
VERSION_MINOR: 3
VERSION_MINOR: 4
VERSION_SUFFIX: "-beta"

jobs:
Expand All @@ -22,10 +22,14 @@ jobs:
id: version
run: echo "::set-output name=PRODUCT_VERSION::${{ env.VERSION_MAJOR }}.${{ env.VERSION_MINOR }}.${{ steps.date.outputs.date }}.${{ github.run_attempt }}${{ env.VERSION_SUFFIX }}"
- uses: actions/checkout@v3
- name: Setup .NET
- name: Setup .NET6
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Setup .NET8
uses: actions/setup-dotnet@v2
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore SmartIOT.Connector.sln
- name: Build
Expand All @@ -44,4 +48,5 @@ jobs:
dotnet nuget push Core\SmartIOT.Connector.RestApi\bin\Release\SmartIOT.Connector.RestApi.${{ steps.version.outputs.PRODUCT_VERSION }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
dotnet nuget push Devices\SmartIOT.Connector.Plc.S7Net\bin\Release\SmartIOT.Connector.Plc.S7Net.${{ steps.version.outputs.PRODUCT_VERSION }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
dotnet nuget push Devices\SmartIOT.Connector.Plc.Snap7\bin\Release\SmartIOT.Connector.Plc.Snap7.${{ steps.version.outputs.PRODUCT_VERSION }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
dotnet nuget push Devices\SmartIOT.Connector.Plc.SnapModbus\bin\Release\SmartIOT.Connector.Plc.SnapModbus.${{ steps.version.outputs.PRODUCT_VERSION }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
10 changes: 7 additions & 3 deletions .github/workflows/dotnet-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

env:
VERSION_MAJOR: 0
VERSION_MINOR: 3
VERSION_MINOR: 4
VERSION_SUFFIX: ""

jobs:
Expand All @@ -22,10 +22,14 @@ jobs:
id: version
run: echo "::set-output name=PRODUCT_VERSION::${{ env.VERSION_MAJOR }}.${{ env.VERSION_MINOR }}.${{ steps.date.outputs.date }}.${{ github.run_attempt }}${{ env.VERSION_SUFFIX }}"
- uses: actions/checkout@v3
- name: Setup .NET
- name: Setup .NET6
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Setup .NET8
uses: actions/setup-dotnet@v2
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore SmartIOT.Connector.sln
- name: Build
Expand All @@ -44,4 +48,4 @@ jobs:
dotnet nuget push Core\SmartIOT.Connector.RestApi\bin\Release\SmartIOT.Connector.RestApi.${{ steps.version.outputs.PRODUCT_VERSION }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
dotnet nuget push Devices\SmartIOT.Connector.Plc.S7Net\bin\Release\SmartIOT.Connector.Plc.S7Net.${{ steps.version.outputs.PRODUCT_VERSION }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
dotnet nuget push Devices\SmartIOT.Connector.Plc.Snap7\bin\Release\SmartIOT.Connector.Plc.Snap7.${{ steps.version.outputs.PRODUCT_VERSION }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
dotnet nuget push Devices\SmartIOT.Connector.Plc.SnapModbus\bin\Release\SmartIOT.Connector.Plc.SnapModbus.${{ steps.version.outputs.PRODUCT_VERSION }}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
4 changes: 3 additions & 1 deletion Apps/SmartIOT.Connector.ConsoleApp/AspNetExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public static IServiceCollection AddSmartIotConnectorRunner(this IServiceCollect
services.AddSingleton<ISchedulerFactory>(s => s.GetRequiredService<Runner>().SchedulerFactory);
services.AddSingleton<ITimeService>(s => s.GetRequiredService<Runner>().TimeService);

services.AddHostedService<Runner>();
// add custom Runner as a singleton and as a hosted service
services.AddSingleton<Runner>();
services.AddHostedService<Runner>(sp => sp.GetRequiredService<Runner>());

return services;
}
Expand Down
12 changes: 7 additions & 5 deletions Apps/SmartIOT.Connector.ConsoleApp/ConfigurationPersister.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ namespace SmartIOT.Connector.ConsoleApp;

internal class ConfigurationPersister : IConfigurationPersister
{
private AppConfiguration _appConfiguration;
private readonly AppConfiguration _appConfiguration;
private readonly JsonSerializerOptions _options;
private readonly string _configFilePath;

public ConfigurationPersister(AppConfiguration appConfiguration, string configFilePath)
{
_appConfiguration = appConfiguration;
_configFilePath = configFilePath;
_options = new JsonSerializerOptions()
{
WriteIndented = true
};
}

public void PersistConfiguration(SmartIotConnectorConfiguration configuration)
{
_appConfiguration.Configuration = configuration;

File.WriteAllText(_configFilePath, JsonSerializer.Serialize(_appConfiguration, new JsonSerializerOptions()
{
WriteIndented = true
}));
File.WriteAllText(_configFilePath, JsonSerializer.Serialize(_appConfiguration, _options));
}
}
2 changes: 1 addition & 1 deletion Apps/SmartIOT.Connector.ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Asp.Versioning.ApiExplorer;
using Serilog;
using SmartIOT.Connector.RestApi;
using System.Diagnostics;
Expand Down
2 changes: 1 addition & 1 deletion Apps/SmartIOT.Connector.ConsoleApp/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Runner(AppConfiguration configuration, ILogger<Runner> logger)
SmartIotConnector.TagWriteEvent += (s, e) =>
{
};
SmartIotConnector.ExceptionHandler += (s, e) => _logger.LogError(e.Exception, $"Exception caught: {e.Exception.Message}");
SmartIotConnector.ExceptionHandler += (s, e) => _logger.LogError(e.Exception, "Exception caught: {message}", e.Exception.Message);
SmartIotConnector.Starting += (s, e) => _logger.LogInformation("SmartIOT.Connector starting..");
SmartIotConnector.Started += (s, e) => _logger.LogInformation("SmartIOT.Connector started. Press Ctrl-C for graceful stop.");
SmartIotConnector.Stopping += (s, e) => _logger.LogInformation("SmartIOT.Connector stopping..");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
Expand All @@ -16,16 +16,16 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Luca Domenichini</Copyright>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<UserSecretsId>test</UserSecretsId>
<OpenApiGenerateDocumentsOnBuild>false</OpenApiGenerateDocumentsOnBuild> <!-- Starting with .NET7, we need this -->
</PropertyGroup>

<ItemGroup>
<!--<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.15.1" />-->
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Enrichers.Context" Version="4.6.5" />
<PackageReference Include="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
Expand All @@ -38,6 +38,7 @@
<ProjectReference Include="..\..\Core\SmartIOT.Connector.RestApi\SmartIOT.Connector.RestApi.csproj" />
<ProjectReference Include="..\..\Devices\SmartIOT.Connector.Plc.S7Net\SmartIOT.Connector.Plc.S7Net.csproj" />
<ProjectReference Include="..\..\Devices\SmartIOT.Connector.Plc.Snap7\SmartIOT.Connector.Plc.Snap7.csproj" />
<ProjectReference Include="..\..\Devices\SmartIOT.Connector.Plc.SnapModBus\SmartIOT.Connector.Plc.SnapModBus.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Apps/SmartIOT.Connector.ConsoleApp/smartiot-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}
},
"PrometheusConfiguration": {
"HostName": "\u002B",
"HostName": "+",
"Port": 0,
"Url": "metrics/",
"MetricsPrefix": "smartiot_connector",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>Luca Domenichini</Authors>
Expand All @@ -17,8 +17,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MQTTnet.Extensions.ManagedClient" Version="4.3.1.873" />
<PackageReference Include="protobuf-net" Version="3.2.26" />
<PackageReference Include="MQTTnet.Extensions.ManagedClient" Version="4.3.3.952" />
<PackageReference Include="protobuf-net" Version="3.2.30" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>Luca Domenichini</Authors>
Expand Down
2 changes: 1 addition & 1 deletion Core/SmartIOT.Connector.Core/Model/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public bool UpdateTag(TagConfiguration tagConfiguration)
}
}

internal void IncrementOrReseDeviceErrorCode(int err)
internal void IncrementOrResetDeviceErrorCode(int err)
{
ErrorCode = err;
if (err != 0)
Expand Down
4 changes: 2 additions & 2 deletions Core/SmartIOT.Connector.Core/Scheduler/TagSchedulerEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,14 +580,14 @@ public void RestartDriver()
success = false;
message = description;

device.IncrementOrReseDeviceErrorCode(err);
device.IncrementOrResetDeviceErrorCode(err);

OnDeviceStatusEvent(new DeviceStatusEvent(device, device.DeviceStatus, err, description));
}
else
{
(err, description) = TryWithDeviceDriver(x => x.Connect(device));
device.IncrementOrReseDeviceErrorCode(err);
device.IncrementOrResetDeviceErrorCode(err);

if (err != 0)
{
Expand Down
4 changes: 2 additions & 2 deletions Core/SmartIOT.Connector.Core/SmartIOT.Connector.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>Luca Domenichini</Authors>
Expand All @@ -10,7 +10,7 @@
<PackageProjectUrl>https://github.com/luca-domenichini/SmartIOT.Connector</PackageProjectUrl>
<RepositoryUrl>https://github.com/luca-domenichini/SmartIOT.Connector.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>iot;mqtt;scheduler;connector;automation;snap7;s7net;azure;automation;siemens;plc;s7300;s71200;s71500</PackageTags>
<PackageTags>iot;mqtt;scheduler;connector;automation;snap7;s7net;azure;automation;siemens;plc;s7300;s71200;s71500;modbus</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Copyright>Luca Domenichini</Copyright>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>Luca Domenichini</Authors>
Expand All @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="protobuf-net" Version="3.2.26" />
<PackageReference Include="protobuf-net" Version="3.2.30" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>Luca Domenichini</Authors>
Expand All @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="prometheus-net" Version="8.0.1" />
<PackageReference Include="prometheus-net" Version="8.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 9 additions & 7 deletions Core/SmartIOT.Connector.RestApi/AspNetCoreExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Asp.Versioning;
using Asp.Versioning.ApiExplorer;
using Microsoft.Extensions.DependencyInjection;
using SmartIOT.Connector.Core;
using SmartIOT.Connector.RestApi.Services;
Expand All @@ -15,13 +16,14 @@ public static IServiceCollection AddSmartIotConnectorRestApi(this IServiceCollec
config.DefaultApiVersion = new ApiVersion(1, 0);
config.AssumeDefaultVersionWhenUnspecified = true;
config.ReportApiVersions = true;
});
})
.AddApiExplorer(options =>
{
options.GroupNameFormat = "'v'VVV";
options.SubstituteApiVersionInUrl = true;
});

services.AddVersionedApiExplorer(setup =>
{
setup.GroupNameFormat = "'v'VVV";
setup.SubstituteApiVersionInUrl = true;
});
services.AddTransient<IApiVersionDescriptionProvider, GroupedApiVersionDescriptionProvider>();

services.ConfigureOptions<SwaggerVersioningOptions>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using Asp.Versioning;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartIOT.Connector.Core;
using SmartIOT.Connector.RestApi.Services;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using Asp.Versioning;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartIOT.Connector.Core;
using SmartIOT.Connector.RestApi.Services;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using Asp.Versioning;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartIOT.Connector.Core;
using SmartIOT.Connector.Core.Conf;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using Asp.Versioning;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartIOT.Connector.Core;
using SmartIOT.Connector.Core.Conf;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand All @@ -26,11 +26,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />

<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
<PackageReference Include="Asp.Versioning.Mvc" Version="8.0.0" />
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 665521e

Please sign in to comment.