Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

126 move gitversion from gui to libeds #127

Merged
merged 5 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: microsoft/setup-msbuild@v2
- name: C# problem matcher
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: microsoft/setup-msbuild@v2
- name: Add Packages
Expand Down
12 changes: 6 additions & 6 deletions EDSEditorGUI/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void exportCanOpenNode(DeviceView dv, string FileName, ExporterFactory.E
string savePath = Path.GetDirectoryName(FileName);
string baseFileName = Path.GetFileNameWithoutExtension(FileName);
var filepath = $"{savePath}/{baseFileName}";
exporter.export(filepath, this.gitVersion, dv.eds);
exporter.export(filepath, dv.eds);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -622,7 +622,7 @@ void dosave(DeviceView dv, string FileName, bool xddfileVersion_1_1, bool stripp

case ".md":
DocumentationGenMarkup docgen = new DocumentationGenMarkup();
docgen.genmddoc(FileName, dv.eds, this.gitVersion);
docgen.genmddoc(FileName, dv.eds);
dv.eds.mdfilename = FileName;
break;

Expand Down Expand Up @@ -873,12 +873,12 @@ private void saveNetworkXmlToolStripMenuItem_Click(object sender, EventArgs e)

case 2: // .nxdc V1.1 with actual value, denotation and deviceCommissioning info
CanOpenXDD_1_1 xdc_1_1 = new CanOpenXDD_1_1();
xdc_1_1.WriteMultiXML(sfd.FileName, network, this.gitVersion, true);
xdc_1_1.WriteMultiXML(sfd.FileName, network, true);
break;

case 1: // .nxdd V1.1
CanOpenXDD_1_1 xdd_1_1 = new CanOpenXDD_1_1();
xdd_1_1.WriteMultiXML(sfd.FileName, network, this.gitVersion, false);
xdd_1_1.WriteMultiXML(sfd.FileName, network, false);
break;
}
}
Expand Down Expand Up @@ -1031,7 +1031,7 @@ private void documentationToolStripMenuItem_Click(object sender, EventArgs e)
DocumentationGenHtml docgenHtml = new DocumentationGenHtml();
docgenHtml.genhtmldoc(temp, dv.eds);
DocumentationGenMarkup docgenMarkup = new DocumentationGenMarkup();
docgenMarkup.genmddoc(temp2, dv.eds, this.gitVersion);
docgenMarkup.genmddoc(temp2, dv.eds);
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("cmd", $"/c start {temp2}"));
Expand Down Expand Up @@ -1094,7 +1094,7 @@ private void saveExportAllToolStripMenuItem_Click(object sender, EventArgs e)
if (dv.eds.mdfilename != null && dv.eds.mdfilename != "")
{
DocumentationGenMarkup docgen = new DocumentationGenMarkup();
docgen.genmddoc(dv.eds.mdfilename, dv.eds, this.gitVersion);
docgen.genmddoc(dv.eds.mdfilename, dv.eds);
cnt++;
}

Expand Down
3 changes: 1 addition & 2 deletions EDSSharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class Program
{

static libEDSsharp.EDSsharp eds = new EDSsharp();
static string gitversion = "";

static void Main(string[] args)
{
Expand Down Expand Up @@ -103,7 +102,7 @@ private static void exportCOOD(string outpath,ExporterFactory.Exporter type)
IExporter exporter = ExporterFactory.getExporter(type);
var filepath = Path.Combine(savePath, Path.GetFileNameWithoutExtension(outpath));

exporter.export(filepath, gitversion, eds);
exporter.export(filepath, eds);

foreach(string warning in Warnings.warning_list)
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/ExporterTestsV4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void GetExportResult(EDSsharp eds, out IEnumerable<String> cfile, out IEnumerabl

var cfilePath = fullPath + ".c";
var hfilePath = fullPath + ".h";
export(cfilePath, ".", eds);
export(cfilePath, eds);
cfile = File.ReadLines(cfilePath);
hfile = File.ReadLines(hfilePath);
odname = tempfile;
Expand Down
11 changes: 8 additions & 3 deletions libEDSsharp/CanOpenNodeExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ based heavily on the files CO_OD.h and CO_OD.c from CANopenNode which are
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.IO;
using System.Reflection;



Expand Down Expand Up @@ -95,13 +96,17 @@ public void prepareCanOpenNames()
/// Export eds into CanOpenNode v1-3 source files (.h and .c)
/// </summary>
/// <param name="filepath">filepath, .c and .h will be added to this to make the mulitiple files</param>
/// <param name="gitVersion">git version of this software</param>
/// <param name="eds">the eds data to be exported</param>
public void export(string filepath, string gitVersion, EDSsharp eds)
public void export(string filepath, EDSsharp eds)
{
this.folderpath = Path.GetDirectoryName(filepath);
string filename = Path.GetFileNameWithoutExtension(filepath);
this.gitVersion = gitVersion;
var versionAttributes = Assembly
.GetExecutingAssembly()
.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false)
as AssemblyInformationalVersionAttribute[];

this.gitVersion = versionAttributes[0].InformationalVersion;
this.eds = eds;


Expand Down
10 changes: 8 additions & 2 deletions libEDSsharp/CanOpenNodeExporter_V4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ You should have received a copy of the GNU General Public License
using System.Text.RegularExpressions;
using System.IO;
using System.Linq;
using System.Reflection;

namespace libEDSsharp
{
Expand All @@ -50,16 +51,21 @@ public class CanOpenNodeExporter_V4 : IExporter
/// export the current data set in the CanOpen Node format V4
/// </summary>
/// <param name="filepath">filepath, .c and .h will be added to this to make the mulitiple files</param>
/// <param name="gitVersion"></param>
/// <param name="eds"></param>
public void export(string filepath, string gitVersion, EDSsharp eds)
public void export(string filepath, EDSsharp eds)
{
string filename = Path.GetFileNameWithoutExtension(filepath);
string folderpath = Path.GetDirectoryName(filepath);
this.odname = filename;

Prepare(eds);

var versionAttributes = Assembly
.GetExecutingAssembly()
.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false)
as AssemblyInformationalVersionAttribute[];

string gitVersion = versionAttributes[0].InformationalVersion;
Export_h(folderpath, filename, gitVersion, eds);
Export_c(folderpath, filename, gitVersion, eds);
}
Expand Down
10 changes: 8 additions & 2 deletions libEDSsharp/CanOpenXDD_1_1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ You should have received a copy of the GNU General Public License
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using System.Linq;
using System.Reflection;

namespace libEDSsharp
{
Expand Down Expand Up @@ -98,10 +99,15 @@ public List<EDSsharp> ReadMultiXML(string file )
/// </summary>
/// <param name="file">Name of the multi xdd file</param>
/// <param name="edss">List of EDSsharp objects</param>
/// <param name="gitVersion">Git version string for documentation field</param>
/// <param name="deviceCommissioning">If true, device commisioning, denotations and actual values will be included</param>
public void WriteMultiXML(string file, List<EDSsharp> edss, string gitVersion, bool deviceCommissioning)
public void WriteMultiXML(string file, List<EDSsharp> edss, bool deviceCommissioning)
{
var versionAttributes = Assembly
.GetExecutingAssembly()
.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false)
as AssemblyInformationalVersionAttribute[];

string gitVersion = versionAttributes[0].InformationalVersion;
List<ISO15745ProfileContainer> devs = new List<ISO15745ProfileContainer>();

foreach (EDSsharp eds in edss)
Expand Down
10 changes: 8 additions & 2 deletions libEDSsharp/DocumentationGenMarkup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ You should have received a copy of the GNU General Public License
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;

namespace libEDSsharp
{
Expand All @@ -36,9 +37,14 @@ public class DocumentationGenMarkup
/// </summary>
/// <param name="filepath">where the documentation should be created</param>
/// <param name="eds">data to generate the documentation from</param>
/// <param name="gitVersion">git version of this software</param>
public void genmddoc(string filepath, EDSsharp eds, string gitVersion)
public void genmddoc(string filepath, EDSsharp eds)
{
var versionAttributes = Assembly
.GetExecutingAssembly()
.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false)
as AssemblyInformationalVersionAttribute[];

string gitVersion = versionAttributes[0].InformationalVersion;
file = new StreamWriter(filepath, false);
file.NewLine = "\n";

Expand Down
3 changes: 1 addition & 2 deletions libEDSsharp/IExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ public interface IExporter
/// Export file(s)
/// </summary>
/// <param name="filepath">filepath, .c and .h will be added to this to make the mulitiple files</param>
/// <param name="gitVersion">version that will be saved to the file</param>
/// <param name="eds">The eds that will be exported</param>
void export(string filepath, string gitVersion, EDSsharp eds);
void export(string filepath, EDSsharp eds);
}
}
36 changes: 0 additions & 36 deletions libEDSsharp/Properties/AssemblyInfo.cs

This file was deleted.

25 changes: 23 additions & 2 deletions libEDSsharp/libEDSsharp.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk" InitialTargets="AssignInformationalVersion">
<PropertyGroup>
<TargetFrameworks Condition="'$(BuildNet481)' == 'true'">net481</TargetFrameworks>
<TargetFrameworks Condition="'$(BuildNet6)' == 'true'">net6.0</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworks)' == ''">net481;net6.0</TargetFrameworks>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>

<Company></Company>
<Configuration></Configuration>
<Description></Description>
<InformationalVersion></InformationalVersion>
<Product>libEDSsharp</Product>
<Copyright>Copyright © 2016</Copyright>
<AssemblyTitle>libEDSsharp</AssemblyTitle>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<NeutralLanguage></NeutralLanguage>
</PropertyGroup>

<Target Name="AssignInformationalVersion" >
<Exec Command="git describe --tags --long --dirty" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="gitInfo" />
</Exec>
<PropertyGroup>
<InformationalVersion>$(gitInfo)</InformationalVersion>
</PropertyGroup>
</Target>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DocumentationFile>docs\libEDSsharp.xml</DocumentationFile>
</PropertyGroup>
Expand Down
Loading