Skip to content

Commit

Permalink
Merge pull request #49 from ChrisPulman/UpdateToNet8_0
Browse files Browse the repository at this point in the history
Update To Net 8.0
  • Loading branch information
ChrisPulman authored Dec 27, 2023
2 parents 7091055 + 7871e98 commit 2e531ec
Show file tree
Hide file tree
Showing 21 changed files with 154 additions and 176 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ csharp_space_between_square_brackets = false

# analyzers
dotnet_diagnostic.AvoidAsyncVoid.severity = suggestion

dotnet_diagnostic.IDE1006.severity = none
dotnet_diagnostic.CA1000.severity = none
dotnet_diagnostic.CA1001.severity = error
dotnet_diagnostic.CA1009.severity = error
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/BuildDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,52 @@ jobs:
windows-latest:
name: windows-latest
runs-on: windows-latest

permissions: write-all
environment:
name: release
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: NBGV
id: nbgv
uses: dotnet/nbgv@master
with:
setAllVars: true
- run: echo 'SemVer2=${{ steps.nbgv.outputs.SemVer2 }}'

- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}

- name: 'Run: Compile, Deploy'
run: ./build.cmd Compile Deploy
env:
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}

- name: 'Publish: output'
uses: actions/upload-artifact@v3
with:
name: output
path: output

- name: Changelog
uses: glennawatson/ChangeLog@v1
id: changelog

- name: Create Release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.nbgv.outputs.SemVer2 }}
release_name: ${{ steps.nbgv.outputs.SemVer2 }}
body: |
${{ steps.changelog.outputs.commitLog }}
22 changes: 4 additions & 18 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,18 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
<ItemGroup Condition="'$(IsTestProject)' != 'true'">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)images\TwinCATRx.png" Pack="true" PackagePath="\" />
<None Include="$(MSBuildThisFileDirectory)LICENSE" Pack="true" PackagePath="LICENSE" />
<None Include="$(MSBuildThisFileDirectory)readme.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.6.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<!--<Compile Update="**\*.cs" DependentUpon="I%(Filename).cs" />-->
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" PrivateAssets="all" />
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.507" PrivateAssets="all" />
<PackageReference Include="Roslynator.Analyzers" Version="4.6.1" PrivateAssets="All" />
<PackageDownload Include="nbgv" Version="[3.6.133]" />
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.556" PrivateAssets="all" />
<PackageReference Include="Roslynator.Analyzers" Version="4.7.0" PrivateAssets="All" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "1.1",
"version": "1.2",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/heads/main$",
Expand Down
33 changes: 15 additions & 18 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
using Nuke.Common.Tools.PowerShell;
using CP.BuildTools;

[GitHubActions(
"BuildOnly",
GitHubActionsImage.WindowsLatest,
OnPushBranchesIgnore = new[] { "main" },
FetchDepth = 0,
InvokedTargets = new[] { nameof(Compile) })]
[GitHubActions(
"BuildDeploy",
GitHubActionsImage.WindowsLatest,
OnPushBranches = new[] { "main" },
FetchDepth = 0,
ImportSecrets = new[] { nameof(NuGetApiKey) },
InvokedTargets = new[] { nameof(Compile), nameof(Deploy) })]
////[GitHubActions(
//// "BuildOnly",
//// GitHubActionsImage.WindowsLatest,
//// OnPushBranchesIgnore = new[] { "main" },
//// FetchDepth = 0,
//// InvokedTargets = new[] { nameof(Compile) })]
////[GitHubActions(
//// "BuildDeploy",
//// GitHubActionsImage.WindowsLatest,
//// OnPushBranches = new[] { "main" },
//// FetchDepth = 0,
//// ImportSecrets = new[] { nameof(NuGetApiKey) },
//// InvokedTargets = new[] { nameof(Compile), nameof(Deploy) })]
partial class Build : NukeBuild
{
//// Support plugins are available for:
Expand All @@ -34,13 +34,10 @@ partial class Build : NukeBuild

public static int Main() => Execute<Build>(x => x.Compile);

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
[GitRepository] readonly GitRepository Repository;
[Solution(GenerateProjects = true)] readonly Solution Solution;
[NerdbankGitVersioning] readonly NerdbankGitVersioning NerdbankVersioning;
[Parameter][Secret] readonly string NuGetApiKey;
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;

Expand All @@ -59,8 +56,8 @@ partial class Build : NukeBuild
}

PackagesDirectory.CreateOrCleanDirectory();
await this.UpdateVisualStudio();
await this.InstallDotNetSdk("3.1.x", "5.x.x", "6.x.x", "7.x.x");
////await this.UpdateVisualStudio();
await this.InstallDotNetSdk("6.x.x", "7.x.x", "8.x.x");
});

Target Restore => _ => _
Expand Down
6 changes: 3 additions & 3 deletions build/_build.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>$(NoWarn);CS0649;CS0169;CA1822;IDE1006</NoWarn>
<NoWarn>$(NoWarn);CS0649;CS0169;CA1822;IDE1006;IDE0051</NoWarn>
<IsPackable>false</IsPackable>
<NukeRootDirectory>..</NukeRootDirectory>
<NukeScriptDirectory>..</NukeScriptDirectory>
Expand All @@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.133" />
<PackageReference Include="Nuke.Common" Version="7.0.6" />
<PackageReference Include="CP.Nuke.BuildTools" Version="1.0.34" />
<PackageReference Include="CP.Nuke.BuildTools" Version="1.0.36" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "8.0.10",
"rollForward": "latestMinor"
}
}
57 changes: 29 additions & 28 deletions src/TwinCATRx.Core/CodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace CP.TwinCatRx.Core
/// <seealso cref="ICodeGenerator"/>
public class CodeGenerator : ICodeGenerator
{
private readonly Hashtable _typeList = new();
private readonly Hashtable _typeList = [];
private AdsClient? _adsClient;
private bool _disposedValue;
private ISymbolLoader? _symbolLoader;
Expand All @@ -34,7 +34,7 @@ public class CodeGenerator : ICodeGenerator
/// Gets the symbol list.
/// </summary>
/// <value>The symbol list.</value>
public HashSet<INodeEmulator> SymbolList { get; } = new HashSet<INodeEmulator>();
public HashSet<INodeEmulator> SymbolList { get; } = [];

/// <summary>
/// PLCs to c sharp type converter. BIT BOOL System.Boolean bool Boolean For info about
Expand Down Expand Up @@ -118,35 +118,35 @@ public static string PLCToCSharpTypeConverter(string? pLCType)
{
var st = pLCType.Replace("ARRAY [", string.Empty);
st = st.Replace("] OF STRING", string.Empty);
return typeof(string[]).ToString() + "," + st;
return typeof(string[]) + "," + st;
}

if (pLCType.Contains("OF BOOL"))
{
var bo = pLCType.Replace("ARRAY [", string.Empty);
bo = bo.Replace("] OF BOOL", string.Empty);
return typeof(bool[]).ToString() + "," + bo;
return typeof(bool[]) + "," + bo;
}

if (pLCType.Contains("OF BIT"))
{
var bi = pLCType.Replace("ARRAY [", string.Empty);
bi = bi.Replace("] OF BIT", string.Empty);
return typeof(bool[]).ToString() + "," + bi;
return typeof(bool[]) + "," + bi;
}

if (pLCType.Contains("OF BIT8"))
{
var bi8 = pLCType.Replace("ARRAY [", string.Empty);
bi8 = bi8.Replace("] OF BIT8", string.Empty);
return typeof(bool[]).ToString() + "," + bi8;
return typeof(bool[]) + "," + bi8;
}

if (pLCType.Contains("OF BYTE"))
{
var b = pLCType.Replace("ARRAY [", string.Empty);
b = b.Replace("] OF BYTE", string.Empty);
return typeof(byte[]).ToString() + "," + b;
return typeof(byte[]) + "," + b;
}

if (pLCType.Contains("OF REAL"))
Expand Down Expand Up @@ -470,6 +470,7 @@ public object ReadSymbol(string aDSAddress, int port, string variable, Type vari
/// <returns>
/// NodeEmulator.
/// </returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1865:Use char overload", Justification = "Not valid for all TFM's")]
public INodeEmulator SearchSymbols(string? symbolName)
{
if (symbolName?.StartsWith(".", StringComparison.InvariantCulture) == true)
Expand Down Expand Up @@ -618,6 +619,26 @@ private static void WriteCSharpClassMembers(ref StringBuilder sb, INodeEmulator
}
}

/// <summary>
/// Creates the new node.
/// </summary>
/// <param name="symbol">The symbol.</param>
/// <returns>A Value.</returns>
private static INodeEmulator CreateNewNode(ISymbol symbol)
{
INodeEmulator node = new NodeEmulator
{
Text = symbol.InstanceName,
Tag = symbol
};
foreach (var subsymbol in symbol.SubSymbols)
{
node.Nodes?.Add(CodeGenerator.CreateNewNode(subsymbol));
}

return node;
}

/// <summary>
/// Builds the symbol list.
/// </summary>
Expand All @@ -630,7 +651,7 @@ private void BuildSymbolList()
{
foreach (var symbol in _symbolLoader.Symbols)
{
SymbolList.Add(CreateNewNode(symbol));
SymbolList.Add(CodeGenerator.CreateNewNode(symbol));
}
}
}
Expand Down Expand Up @@ -685,26 +706,6 @@ private void CreateCsharpCodeFile(ref StringBuilder sb, INodeEmulator? selectedT
sb.AppendLine("}");
}

/// <summary>
/// Creates the new node.
/// </summary>
/// <param name="symbol">The symbol.</param>
/// <returns>A Value.</returns>
private INodeEmulator CreateNewNode(ISymbol symbol)
{
INodeEmulator node = new NodeEmulator
{
Text = symbol.InstanceName,
Tag = symbol
};
foreach (var subsymbol in symbol.SubSymbols)
{
node.Nodes?.Add(CreateNewNode(subsymbol));
}

return node;
}

/// <summary>
/// Finds the next node.
/// </summary>
Expand Down
14 changes: 0 additions & 14 deletions src/TwinCATRx.Core/InvalidVariableException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,6 @@ public class InvalidVariableException : Exception
public InvalidVariableException(string message, Exception innerException)
: base(message, innerException) => _variable = message;

/// <summary>
/// Initializes a new instance of the <see cref="InvalidVariableException"/> class.
/// </summary>
/// <param name="info">
/// The <see cref="System.Runtime.Serialization.SerializationInfo"/> that holds the
/// serialized object data about the exception being thrown.
/// </param>
/// <param name="context">
/// The <see cref="System.Runtime.Serialization.StreamingContext"/> that contains
/// contextual information about the source or destination.
/// </param>
protected InvalidVariableException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
: base(info, context) => _variable = string.Empty;

/// <summary>
/// Gets a message that describes the current exception.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/TwinCATRx.Core/NodeEmulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class NodeEmulator : INodeEmulator
/// <summary>
/// Gets contains Child Nodes of this node.
/// </summary>
public HashSet<INodeEmulator>? Nodes { get; private set; } = new HashSet<INodeEmulator>();
public HashSet<INodeEmulator>? Nodes { get; private set; } = [];

/// <summary>
/// Gets or sets container for object Data.
Expand Down
Loading

0 comments on commit 2e531ec

Please sign in to comment.