diff --git a/Build/Packaging.targets b/Build/Packaging.targets index a7b8bf88bc0672c29608c0d917ec24814e32906a..2c0d6b9cbca39eb9864cd589ef5fdc1f42c69db5 100644 --- a/Build/Packaging.targets +++ b/Build/Packaging.targets @@ -53,13 +53,6 @@ <Exec Command=""$(solutiondir)documentation\VectoHashingTool\convert.bat"" WorkingDirectory="$(solutiondir)documentation\VectoHashingTool"/> </Target> -<Target Name="BeforeBuild" Condition="$(Configuration) == 'Deploy' OR $(Configuration) == 'Release'"> - <ItemGroup> - <VersionTemplates Include="$(SolutionDir)**\Version.tt"/> - </ItemGroup> - <Exec Command=""%CommonProgramFiles(x86)%\Microsoft Shared\TextTemplating\12.0\TextTransform.exe" "%(VersionTemplates.Identity)""/> -</Target> - <Target Name="AfterBuild" Condition="$(Configuration) == 'Deploy'"> <ItemGroup> <VectoCoreAssembly Include="$(OutputPath)VectoCore.dll" /> diff --git a/Build/TextPreProcessing.targets b/Build/TextPreProcessing.targets new file mode 100644 index 0000000000000000000000000000000000000000..84040e35b32256a9d0fbbe0fc0c525e0534f0da0 --- /dev/null +++ b/Build/TextPreProcessing.targets @@ -0,0 +1,9 @@ +<Project DefaultTargets = "Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" > + <Target Name="BeforeBuild" Condition="$(Configuration) == 'Deploy' OR $(Configuration) == 'Release'"> + <ItemGroup> + <VersionTemplates Include="$(ProjectDir)**\Version.tt"/> + <VersionTemplates Include="$(ProjectDir)**\*.tt"/> + </ItemGroup> + <Exec Condition="'@(VersionTemplates)'!=''" Command=""%CommonProgramFiles(x86)%\Microsoft Shared\TextTemplating\12.0\TextTransform.exe" -I $(SolutionDir) "%(VersionTemplates.Identity)""/> + </Target> +</Project> \ No newline at end of file diff --git a/HashingCmd/Properties/Version.tt b/HashingCmd/Properties/Version.tt index a1d6b02cff4884e378c4067d1c7b0e93ce5e07a2..bf6606a7433a501c60753609366ac702934d292a 100644 --- a/HashingCmd/Properties/Version.tt +++ b/HashingCmd/Properties/Version.tt @@ -31,9 +31,10 @@ <#@ template language="C#" #> <#@ output extension=".cs"#> +<#@ include file="../../VectoCore/VectoCore/VersionNumber.t4" once="true" #> using System.Reflection; -[assembly: AssemblyVersion("0.1.0.<#= this.RevisionNumber #>")] -[assembly: AssemblyFileVersion("0.1.0.<#= this.RevisionNumber #>")] +[assembly: AssemblyVersion("0.1.0.<#= GetBuildNumber() #>")] +[assembly: AssemblyFileVersion("0.1.0.<#= GetBuildNumber() #>")] <#+ int RevisionNumber = (int)(DateTime.UtcNow - new DateTime(2017, 1, 1)).TotalDays; #> \ No newline at end of file diff --git a/HashingTool/HashingTool.csproj b/HashingTool/HashingTool.csproj index b614ca958c58122579273e9d91756a58fbca5656..c64fcb1aec14093d66d043508d7fe5d1ba1bc7b5 100644 --- a/HashingTool/HashingTool.csproj +++ b/HashingTool/HashingTool.csproj @@ -251,4 +251,5 @@ <Target Name="AfterBuild"> </Target> --> + <Import Project="$(SolutionDir)Build\TextPreProcessing.targets" /> </Project> \ No newline at end of file diff --git a/HashingTool/Properties/Version.tt b/HashingTool/Properties/Version.tt index a1d6b02cff4884e378c4067d1c7b0e93ce5e07a2..bf6606a7433a501c60753609366ac702934d292a 100644 --- a/HashingTool/Properties/Version.tt +++ b/HashingTool/Properties/Version.tt @@ -31,9 +31,10 @@ <#@ template language="C#" #> <#@ output extension=".cs"#> +<#@ include file="../../VectoCore/VectoCore/VersionNumber.t4" once="true" #> using System.Reflection; -[assembly: AssemblyVersion("0.1.0.<#= this.RevisionNumber #>")] -[assembly: AssemblyFileVersion("0.1.0.<#= this.RevisionNumber #>")] +[assembly: AssemblyVersion("0.1.0.<#= GetBuildNumber() #>")] +[assembly: AssemblyFileVersion("0.1.0.<#= GetBuildNumber() #>")] <#+ int RevisionNumber = (int)(DateTime.UtcNow - new DateTime(2017, 1, 1)).TotalDays; #> \ No newline at end of file diff --git a/VECTO/GUI/MainForm.vb b/VECTO/GUI/MainForm.vb index cccfd32417de084c68259ce1f69f80224e7002a4..0eaeddb9708b2c82f703bf9a057a4d38628eb8d3 100644 --- a/VECTO/GUI/MainForm.vb +++ b/VECTO/GUI/MainForm.vb @@ -105,7 +105,7 @@ Public Class MainForm Private Sub FB_Initialize() FileBrowserFolderHistoryIninialized = False Try - COREvers = Assembly.LoadFrom("VectoCore.dll").GetName().Version.ToString() + COREvers = VectoSimulationCore.VersionNumber() Catch ex As Exception LogFile.WriteToLog(MessageType.Err, ex.StackTrace) End Try diff --git a/VECTO/VECTO.vbproj b/VECTO/VECTO.vbproj index 4db0186bc0e244964cb21e5d2c41685eff3ccdeb..1eb8d624686c6a045252554217ddb783bbc5528d 100644 --- a/VECTO/VECTO.vbproj +++ b/VECTO/VECTO.vbproj @@ -536,6 +536,7 @@ </ItemGroup> <ItemGroup /> <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" /> + <PropertyGroup> <PostBuildEvent> </PostBuildEvent> @@ -547,7 +548,6 @@ <Target Name="AfterBuild"> </Target> --> - - <Import Project="$(SolutionDir)Build\Packaging.targets"/> - + <Import Project="$(SolutionDir)Build\TextPreProcessing.targets" /> + <Import Project="$(SolutionDir)Build\Packaging.targets" /> </Project> \ No newline at end of file diff --git a/VectoCommon/VectoCommon/Properties/Version.tt b/VectoCommon/VectoCommon/Properties/Version.tt index 2e262103697d1c6280bf1d5fbfd272b2464c2e9b..f4f873f59b30153f05ee22358b886672b9da1131 100644 --- a/VectoCommon/VectoCommon/Properties/Version.tt +++ b/VectoCommon/VectoCommon/Properties/Version.tt @@ -29,11 +29,8 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -<#@ template language="C#" #> <#@ output extension=".cs"#> +<#@ include file="../../../VectoCore/VectoCore/VersionNumber.t4" once="true" #> using System.Reflection; -[assembly: AssemblyVersion("3.2.0.<#= this.RevisionNumber #>")] -[assembly: AssemblyFileVersion("3.2.0.<#= this.RevisionNumber #>")] -<#+ - int RevisionNumber = (int)(DateTime.UtcNow - new DateTime(2015, 1, 1)).TotalDays; -#> \ No newline at end of file +[assembly: AssemblyVersion("<#= GetVectoCoreVersionNumber() #>")] +[assembly: AssemblyFileVersion("<#= GetVectoCoreVersionNumber() #>")] \ No newline at end of file diff --git a/VectoCommon/VectoHashing/Properties/Version.tt b/VectoCommon/VectoHashing/Properties/Version.tt index bb1eeec0af04fc0976cc872752504cae8b93d7ac..7d01959c7f78fbd0f727127a37ed5ebf9f8a7f4b 100644 --- a/VectoCommon/VectoHashing/Properties/Version.tt +++ b/VectoCommon/VectoHashing/Properties/Version.tt @@ -31,9 +31,10 @@ <#@ template language="C#" #> <#@ output extension=".cs"#> +<#@ include file="../../../VectoCore/VectoCore/VersionNumber.t4" once="true" #> using System.Reflection; -[assembly: AssemblyVersion("1.2.0.<#= this.RevisionNumber #>")] -[assembly: AssemblyFileVersion("1.2.0.<#= this.RevisionNumber #>")] +[assembly: AssemblyVersion("1.2.0.<#= GetBuildNumber() #>")] +[assembly: AssemblyFileVersion("1.2.0.<#= GetBuildNumber() #>")] <#+ int RevisionNumber = (int)(DateTime.UtcNow - new DateTime(2015, 1, 1)).TotalDays; #> \ No newline at end of file diff --git a/VectoCommon/VectoHashing/VectoHashing.csproj b/VectoCommon/VectoHashing/VectoHashing.csproj index 606b515e22996d91e8bdb085ea22ff5a4b0a8f2e..dbc297d72ab6f209085e9cb089ed9c00cc0ef3f2 100644 --- a/VectoCommon/VectoHashing/VectoHashing.csproj +++ b/VectoCommon/VectoHashing/VectoHashing.csproj @@ -73,9 +73,7 @@ <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <PropertyGroup> - <PreBuildEvent>if $(ConfigurationName) == Release forfiles /p "$(ProjectDir)." /m "*.tt" /s /c "cmd /c echo Transforming @path && \"%25CommonProgramFiles(x86)%25\Microsoft Shared\TextTemplating\12.0\TextTransform.exe\" @file"</PreBuildEvent> - </PropertyGroup> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> @@ -83,4 +81,5 @@ <Target Name="AfterBuild"> </Target> --> + <Import Project="$(SolutionDir)Build\TextPreProcessing.targets" /> </Project> \ No newline at end of file diff --git a/VectoConsole/Program.cs b/VectoConsole/Program.cs index 0a23117745ed764a1d58c44c81354822c67c51ba..86600c2a818a406bab03580c2a0eb07562e65329 100644 --- a/VectoConsole/Program.cs +++ b/VectoConsole/Program.cs @@ -51,6 +51,7 @@ using TUGraz.VectoCore.InputData.FileIO.XML.Engineering; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.OutputData; using TUGraz.VectoCore.OutputData.FileIO; +using TUGraz.VectoCore.Utils; using LogManager = NLog.LogManager; namespace VectoConsole @@ -350,8 +351,7 @@ Examples: private static void ShowVersionInformation() { WriteLine(string.Format(@"VectoConsole: {0}", Assembly.GetExecutingAssembly().GetName().Version)); - WriteLine(string.Format(@"VectoCore: {0}", - Assembly.LoadFrom(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "VectoCore.dll")).GetName().Version)); + WriteLine(string.Format(@"VectoCore: {0}", VectoSimulationCore.VersionNumber)); } private static void PrintProgress(Dictionary<int, JobContainer.ProgressEntry> progessData, @@ -413,4 +413,4 @@ Examples: } } } -} \ No newline at end of file +} diff --git a/VectoConsole/VectoConsole.csproj b/VectoConsole/VectoConsole.csproj index 082fd87fc7f39ef2e6db3be3d12dbddad481808f..671c8be5944be881ca0b039003c864021f7dd33e 100644 --- a/VectoConsole/VectoConsole.csproj +++ b/VectoConsole/VectoConsole.csproj @@ -152,9 +152,7 @@ <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" /> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <PropertyGroup> - <PreBuildEvent>if $(ConfigurationName) == Release forfiles /p "$(ProjectDir)." /m "*.tt" /s /c "cmd /c echo Transforming @path && \"%25CommonProgramFiles(x86)%25\Microsoft Shared\TextTemplating\12.0\TextTransform.exe\" @file"</PreBuildEvent> - </PropertyGroup> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> @@ -162,4 +160,5 @@ <Target Name="AfterBuild"> </Target> --> + <Import Project="$(SolutionDir)Build\TextPreProcessing.targets" /> </Project> \ No newline at end of file diff --git a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs index abe086ff6bc4a25d8be46508b741db85fa6186d8..0bc4ced820dc0c31e41fa5f658f5e2562d74e103 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLCustomerReport.cs @@ -43,6 +43,7 @@ using TUGraz.VectoCommon.Utils; using TUGraz.VectoCore.Models.Declaration; using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; +using TUGraz.VectoCore.Utils; using TUGraz.VectoHashing; namespace TUGraz.VectoCore.OutputData.XML @@ -148,9 +149,8 @@ namespace TUGraz.VectoCore.OutputData.XML private XElement GetApplicationInfo() { - var vectodll = Assembly.LoadFrom(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "VectoCore.dll")).GetName(); return new XElement(tns + XMLNames.Report_ApplicationInfo_ApplicationInformation, - new XElement(tns + XMLNames.Report_ApplicationInfo_SimulationToolVersion, vectodll.Version), + new XElement(tns + XMLNames.Report_ApplicationInfo_SimulationToolVersion, VectoSimulationCore.VersionNumber), new XElement(tns + XMLNames.Report_ApplicationInfo_Date, XmlConvert.ToString(DateTime.Now, XmlDateTimeSerializationMode.Utc))); } diff --git a/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReport.cs b/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReport.cs index 27c3987b10c49f3dc3964a26a13a510858f660be..2a3247961f225e7fd455765c0b1858e4f6713067 100644 --- a/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReport.cs +++ b/VectoCore/VectoCore/OutputData/XML/XMLManufacturerReport.cs @@ -45,6 +45,7 @@ using TUGraz.VectoCore.Models.Simulation.Data; using TUGraz.VectoCore.Models.Simulation.Impl; using TUGraz.VectoCore.Models.SimulationComponent.Data; using TUGraz.VectoCore.Models.SimulationComponent.Data.Gearbox; +using TUGraz.VectoCore.Utils; using TUGraz.VectoHashing; namespace TUGraz.VectoCore.OutputData.XML @@ -330,9 +331,8 @@ namespace TUGraz.VectoCore.OutputData.XML private XElement GetApplicationInfo() { - var vectodll = Assembly.LoadFrom(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "VectoCore.dll")).GetName(); return new XElement(tns + XMLNames.Report_ApplicationInfo_ApplicationInformation, - new XElement(tns + XMLNames.Report_ApplicationInfo_SimulationToolVersion, vectodll.Version), + new XElement(tns + XMLNames.Report_ApplicationInfo_SimulationToolVersion, VectoSimulationCore.VersionNumber), new XElement(tns + XMLNames.Report_ApplicationInfo_Date, XmlConvert.ToString(DateTime.Now, XmlDateTimeSerializationMode.Utc))); } diff --git a/VectoCore/VectoCore/Properties/Version.tt b/VectoCore/VectoCore/Properties/Version.tt index 2e262103697d1c6280bf1d5fbfd272b2464c2e9b..700e82edf59e5f2a720fb6a431424b49af36ae8b 100644 --- a/VectoCore/VectoCore/Properties/Version.tt +++ b/VectoCore/VectoCore/Properties/Version.tt @@ -29,11 +29,8 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -<#@ template language="C#" #> <#@ output extension=".cs"#> +<#@ include file="../VersionNumber.t4" once="true" #> using System.Reflection; -[assembly: AssemblyVersion("3.2.0.<#= this.RevisionNumber #>")] -[assembly: AssemblyFileVersion("3.2.0.<#= this.RevisionNumber #>")] -<#+ - int RevisionNumber = (int)(DateTime.UtcNow - new DateTime(2015, 1, 1)).TotalDays; -#> \ No newline at end of file +[assembly: AssemblyVersion("<#= GetVectoCoreVersionNumber() #>")] +[assembly: AssemblyFileVersion("<#= GetVectoCoreVersionNumber() #>")] diff --git a/VectoCore/VectoCore/Utils/VectoVersionCore.cs b/VectoCore/VectoCore/Utils/VectoVersionCore.cs new file mode 100644 index 0000000000000000000000000000000000000000..83f1cbea17f58186e5c821964ea606515489e850 --- /dev/null +++ b/VectoCore/VectoCore/Utils/VectoVersionCore.cs @@ -0,0 +1,50 @@ +/* +* This file is part of VECTO. +* +* Copyright © 2012-2017 European Union +* +* Developed by Graz University of Technology, +* Institute of Internal Combustion Engines and Thermodynamics, +* Institute of Technical Informatics +* +* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved +* by the European Commission - subsequent versions of the EUPL (the "Licence"); +* You may not use VECTO except in compliance with the Licence. +* You may obtain a copy of the Licence at: +* +* https://joinup.ec.europa.eu/community/eupl/og_page/eupl +* +* Unless required by applicable law or agreed to in writing, VECTO +* distributed under the Licence is distributed on an "AS IS" basis, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the Licence for the specific language governing permissions and +* limitations under the Licence. +* +* Authors: +* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology +* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology +* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology +* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology +* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology +* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology +*/ + +namespace TUGraz.VectoCore.Utils +{ + public static class VectoSimulationCore + { + public static string VersionNumber + { + get { + return "3.2.0.1015"; + } + } + + public static string FullVersion + { + get { + return string.Format("VectoCore {0}", VersionNumber); + } + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/Utils/VectoVersionCore.tt b/VectoCore/VectoCore/Utils/VectoVersionCore.tt new file mode 100644 index 0000000000000000000000000000000000000000..e8d990bf308af3b0fe32bd1ac95b4a8742905b52 --- /dev/null +++ b/VectoCore/VectoCore/Utils/VectoVersionCore.tt @@ -0,0 +1,53 @@ +/* +* This file is part of VECTO. +* +* Copyright © 2012-2017 European Union +* +* Developed by Graz University of Technology, +* Institute of Internal Combustion Engines and Thermodynamics, +* Institute of Technical Informatics +* +* VECTO is licensed under the EUPL, Version 1.1 or - as soon they will be approved +* by the European Commission - subsequent versions of the EUPL (the "Licence"); +* You may not use VECTO except in compliance with the Licence. +* You may obtain a copy of the Licence at: +* +* https://joinup.ec.europa.eu/community/eupl/og_page/eupl +* +* Unless required by applicable law or agreed to in writing, VECTO +* distributed under the Licence is distributed on an "AS IS" basis, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the Licence for the specific language governing permissions and +* limitations under the Licence. +* +* Authors: +* Stefan Hausberger, hausberger@ivt.tugraz.at, IVT, Graz University of Technology +* Christian Kreiner, christian.kreiner@tugraz.at, ITI, Graz University of Technology +* Michael Krisper, michael.krisper@tugraz.at, ITI, Graz University of Technology +* Raphael Luz, luz@ivt.tugraz.at, IVT, Graz University of Technology +* Markus Quaritsch, markus.quaritsch@tugraz.at, IVT, Graz University of Technology +* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology +*/ +<#@ template debug="false" hostspecific="false" language="C#" #> +<#@ include file="../VersionNumber.t4" onnce="true" #> +<#@ output extension=".cs" #> + +namespace TUGraz.VectoCore.Utils +{ + public static class VectoSimulationCore + { + public static string VersionNumber + { + get { + return "<#= GetVectoCoreVersionNumber() #>"; + } + } + + public static string FullVersion + { + get { + return string.Format("VectoCore {0}", VersionNumber); + } + } + } +} \ No newline at end of file diff --git a/VectoCore/VectoCore/VectoCore.csproj b/VectoCore/VectoCore/VectoCore.csproj index 517d4f3dfb1c403e9e250522e595a683ad505e32..734ddce0d1fc171013b28277750c6da4fcbdc9dc 100644 --- a/VectoCore/VectoCore/VectoCore.csproj +++ b/VectoCore/VectoCore/VectoCore.csproj @@ -331,6 +331,11 @@ <Compile Include="Utils\SwitchExtension.cs" /> <Compile Include="Utils\VectoCSVFile.cs" /> <Compile Include="Utils\DelaunayMap.cs" /> + <Compile Include="Utils\VectoVersionCore.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>VectoVersionCore.tt</DependentUpon> + </Compile> <Compile Include="Utils\XmlResourceResolver.cs" /> <Compile Include="Utils\XPathHelper.cs" /> </ItemGroup> @@ -418,6 +423,14 @@ <EmbeddedResource Include="Resources\XSD\VectoOutputCustomer.xsd"> <SubType>Designer</SubType> </EmbeddedResource> + <None Include="Utils\VectoVersionCore.tt"> + <Generator>TextTemplatingFileGenerator</Generator> + <LastGenOutput>VectoVersionCore.cs</LastGenOutput> + </None> + <None Include="VersionNumber.t4"> + <Generator>TextTemplatingFileGenerator</Generator> + <LastGenOutput>VersionNumber1.cs</LastGenOutput> + </None> </ItemGroup> <ItemGroup> <EmbeddedResource Include="Resources\Declaration\Report\4x2r.png" /> @@ -449,16 +462,15 @@ <Name>VectoHashing</Name> </ProjectReference> </ItemGroup> - <ItemGroup /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <PropertyGroup> - <PreBuildEvent>if $(ConfigurationName) == Release forfiles /p "$(ProjectDir)." /m "*.tt" /s /c "cmd /c echo Transforming @path && \"%25CommonProgramFiles(x86)%25\Microsoft Shared\TextTemplating\12.0\TextTransform.exe\" @file"</PreBuildEvent> - </PropertyGroup> - <!-- To modify your build process, add your task inside one of the targets below and uncomment it. - Other similar extension points exist, see Microsoft.Common.targets. - <Target Name="BeforeBuild"> - </Target> - <Target Name="AfterBuild"> - </Target> + + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> --> + + <Import Project="$(SolutionDir)Build\TextPreProcessing.targets" /> </Project> \ No newline at end of file diff --git a/VectoCore/VectoCore/VersionNumber.t4 b/VectoCore/VectoCore/VersionNumber.t4 new file mode 100644 index 0000000000000000000000000000000000000000..940611a3af4c02c29915f5b13055ae13c4870730 --- /dev/null +++ b/VectoCore/VectoCore/VersionNumber.t4 @@ -0,0 +1,11 @@ +<#+ +int GetBuildNumber() +{ + return (int)(DateTime.UtcNow - new DateTime(2015, 1, 1)).TotalDays; +} + +string GetVectoCoreVersionNumber() +{ + return "3.2.0." + GetBuildNumber(); +} +#> \ No newline at end of file diff --git a/VectoCore/VectoCoreTest/FileIO/VectoCSVFileTest.cs b/VectoCore/VectoCoreTest/FileIO/VectoCSVFileTest.cs index aa38bd2497095fac6b3906c7d1cf30bfb9854301..66d49342390f98d9fa188c39e0df75e320dba4f1 100644 --- a/VectoCore/VectoCoreTest/FileIO/VectoCSVFileTest.cs +++ b/VectoCore/VectoCoreTest/FileIO/VectoCSVFileTest.cs @@ -29,190 +29,191 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ -using System.Data; -using System.IO; -using System.Linq; -using NUnit.Framework; -using TUGraz.VectoCommon.Exceptions; -using TUGraz.VectoCommon.Utils; -using TUGraz.VectoCore.Tests.Utils; -using TUGraz.VectoCore.Utils; - -namespace TUGraz.VectoCore.Tests.FileIO -{ - - [TestFixture] - public class VectoCSVFileTest +using System.Data; +using System.IO; +using System.Linq; +using NUnit.Framework; +using TUGraz.VectoCommon.Exceptions; +using TUGraz.VectoCommon.Utils; +using TUGraz.VectoCore.Tests.Utils; +using TUGraz.VectoCore.Utils; + +namespace TUGraz.VectoCore.Tests.FileIO +{ + [TestFixture] + public class VectoCSVFileTest { - [OneTimeSetUp] - public void RunBeforeAnyTests() - { - Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); - } - - [Test] - public void VectoCSVFile_Read() - { - var table = VectoCSVFile.Read(@"TestData\test.csv"); - Assert.AreEqual(3, table.Columns.Count); - CollectionAssert.AreEqual(new[] { "a", "b", "c" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); - Assert.AreEqual(2, table.Rows.Count); - - CollectionAssert.AreEqual(new[] { "1", "2", "3" }, table.Rows[0].ItemArray); - CollectionAssert.AreEqual(new[] { "4", "5", "6" }, table.Rows[1].ItemArray); - } - - [Test] - public void VectoCSVFile_Read_RealLossMap() - { - var table = VectoCSVFile.Read(@"TestData\Components\Axle.vtlm"); - Assert.AreEqual(3, table.Columns.Count); - CollectionAssert.AreEqual( - new[] { "Input Speed", "Input Torque", "Torque Loss" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); - Assert.AreEqual(285, table.Rows.Count); - } - - [Test] - public void VectoCSVFile_ReadStream_Normal() - { - var stream = "a,b,c\n1,2,3\n4,5,6".ToStream(); - var table = VectoCSVFile.ReadStream(stream); - - CollectionAssert.AreEqual(new[] { "a", "b", "c" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); - Assert.AreEqual(2, table.Rows.Count); - - CollectionAssert.AreEqual(new[] { "1", "2", "3" }, table.Rows[0].ItemArray); - CollectionAssert.AreEqual(new[] { "4", "5", "6" }, table.Rows[1].ItemArray); - } - - [Test] - public void VectoCSVFile_ReadStream_Escaped() - { - var stream = "a,b,c\n\"1,1\",2,3\n4,5,6".ToStream(); - var table = VectoCSVFile.ReadStream(stream); - - CollectionAssert.AreEqual(new[] { "a", "b", "c" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); - Assert.AreEqual(2, table.Rows.Count); - - CollectionAssert.AreEqual(new[] { "1,1", "2", "3" }, table.Rows[0].ItemArray); - CollectionAssert.AreEqual(new[] { "4", "5", "6" }, table.Rows[1].ItemArray); - } - - [Test] - public void VectoCSVFile_ReadStream_Comment() - { - var stream = "a,b,c\n\"1,1\",2,3#asdf\n4,5,6".ToStream(); - var table = VectoCSVFile.ReadStream(stream); - - CollectionAssert.AreEqual(new[] { "a", "b", "c" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); - Assert.AreEqual(2, table.Rows.Count); - - CollectionAssert.AreEqual(new[] { "1,1", "2", "3" }, table.Rows[0].ItemArray); - CollectionAssert.AreEqual(new[] { "4", "5", "6" }, table.Rows[1].ItemArray); - } - - [Test] - public void VectoCSVFile_ReadStream_EscapedComment() - { - var stream = "a,b,c\n\"1,1\",2,\"3#asdf\"\n4,5,6".ToStream(); - var table = VectoCSVFile.ReadStream(stream); - - CollectionAssert.AreEqual(new[] { "a", "b", "c" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); - Assert.AreEqual(2, table.Rows.Count); - - CollectionAssert.AreEqual(new[] { "1,1", "2", "3" }, table.Rows[0].ItemArray); - CollectionAssert.AreEqual(new[] { "4", "5", "6" }, table.Rows[1].ItemArray); - } - - [Test] - public void VectoCSVFile_ReadStream_No_Header() - { - var stream = "1,2,3\n4,5,6".ToStream(); - var table = VectoCSVFile.ReadStream(stream); - - CollectionAssert.AreEqual(new[] { "0", "1", "2" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); - Assert.AreEqual(2, table.Rows.Count); - - CollectionAssert.AreEqual(new[] { "1", "2", "3" }, table.Rows[0].ItemArray); - CollectionAssert.AreEqual(new[] { "4", "5", "6" }, table.Rows[1].ItemArray); - } - - [Test] - public void VectoCSVFile_ReadStream_No_Content() - { - var stream = "a,b,c".ToStream(); - var table = VectoCSVFile.ReadStream(stream); - - Assert.AreEqual(3, table.Columns.Count); - CollectionAssert.AreEqual(new[] { "a", "b", "c" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); - Assert.AreEqual(0, table.Rows.Count); - } - - [Test] - public void VectoCSVFile_ReadStream_Empty() - { - AssertHelper.Exception<VectoException>(() => VectoCSVFile.ReadStream("".ToStream())); - } - - [Test] - public void VectoCSVFile_ReadStream_Comments() - { - var stream = @"#a,b,c - #21,22,23 - #674,95,96 - a,b,c - #9,8,7 - 1,2,3 - 4,5,6".ToStream(); - var table = VectoCSVFile.ReadStream(stream); - - CollectionAssert.AreEqual(new[] { "a", "b", "c" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); - Assert.AreEqual(2, table.Rows.Count); - - CollectionAssert.AreEqual(new[] { "1", "2", "3" }, table.Rows[0].ItemArray); - CollectionAssert.AreEqual(new[] { "4", "5", "6" }, table.Rows[1].ItemArray); - } - - [Test] - public void VectoCSVFile_Write_Filename() - { - const string fileName = "out_test.csv"; - - if (File.Exists(fileName)) - File.Delete(fileName); - - var table = new DataTable(); - table.Columns.Add("a"); - table.Columns.Add("b"); - table.Rows.Add("1", "2"); - - VectoCSVFile.Write(fileName, table); - - var text = File.ReadAllText(fileName); - Assert.AreEqual("a,b\r\n1,2\r\n", text); - } - - [Test] - public void VectoCSVFile_Write_StreamWriter() - { - var table = new DataTable(); - table.Columns.Add("a"); - table.Columns.Add("b"); - var row = table.NewRow(); - row.ItemArray = new object[] { "1", "2" }; - table.Rows.Add(row); - - using (var stream = new MemoryStream()) { - using (var sw = new StreamWriter(stream)) { - VectoCSVFile.Write(sw, table); - sw.Flush(); - - stream.Position = 0; - - using (var sr = new StreamReader(stream)) - Assert.AreEqual("a,b\r\n1,2\r\n", sr.ReadToEnd()); - } - } - } - } -} \ No newline at end of file + [OneTimeSetUp] + public void RunBeforeAnyTests() + { + Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + } + + [Test] + public void VectoCSVFile_Read() + { + var table = VectoCSVFile.Read(@"TestData\test.csv"); + Assert.AreEqual(3, table.Columns.Count); + CollectionAssert.AreEqual(new[] { "a", "b", "c" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); + Assert.AreEqual(2, table.Rows.Count); + + CollectionAssert.AreEqual(new[] { "1", "2", "3" }, table.Rows[0].ItemArray); + CollectionAssert.AreEqual(new[] { "4", "5", "6" }, table.Rows[1].ItemArray); + } + + [Test] + public void VectoCSVFile_Read_RealLossMap() + { + var table = VectoCSVFile.Read(@"TestData\Components\Axle.vtlm"); + Assert.AreEqual(3, table.Columns.Count); + CollectionAssert.AreEqual( + new[] { "Input Speed", "Input Torque", "Torque Loss" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); + Assert.AreEqual(285, table.Rows.Count); + } + + [Test] + public void VectoCSVFile_ReadStream_Normal() + { + var stream = "a,b,c\n1,2,3\n4,5,6".ToStream(); + var table = VectoCSVFile.ReadStream(stream); + + CollectionAssert.AreEqual(new[] { "a", "b", "c" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); + Assert.AreEqual(2, table.Rows.Count); + + CollectionAssert.AreEqual(new[] { "1", "2", "3" }, table.Rows[0].ItemArray); + CollectionAssert.AreEqual(new[] { "4", "5", "6" }, table.Rows[1].ItemArray); + } + + [Test] + public void VectoCSVFile_ReadStream_Escaped() + { + var stream = "a,b,c\n\"1,1\",2,3\n4,5,6".ToStream(); + var table = VectoCSVFile.ReadStream(stream); + + CollectionAssert.AreEqual(new[] { "a", "b", "c" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); + Assert.AreEqual(2, table.Rows.Count); + + CollectionAssert.AreEqual(new[] { "1,1", "2", "3" }, table.Rows[0].ItemArray); + CollectionAssert.AreEqual(new[] { "4", "5", "6" }, table.Rows[1].ItemArray); + } + + [Test] + public void VectoCSVFile_ReadStream_Comment() + { + var stream = "a,b,c\n\"1,1\",2,3#asdf\n4,5,6".ToStream(); + var table = VectoCSVFile.ReadStream(stream); + + CollectionAssert.AreEqual(new[] { "a", "b", "c" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); + Assert.AreEqual(2, table.Rows.Count); + + CollectionAssert.AreEqual(new[] { "1,1", "2", "3" }, table.Rows[0].ItemArray); + CollectionAssert.AreEqual(new[] { "4", "5", "6" }, table.Rows[1].ItemArray); + } + + [Test] + public void VectoCSVFile_ReadStream_EscapedComment() + { + var stream = "a,b,c\n\"1,1\",2,\"3#asdf\"\n4,5,6".ToStream(); + var table = VectoCSVFile.ReadStream(stream); + + CollectionAssert.AreEqual(new[] { "a", "b", "c" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); + Assert.AreEqual(2, table.Rows.Count); + + CollectionAssert.AreEqual(new[] { "1,1", "2", "3" }, table.Rows[0].ItemArray); + CollectionAssert.AreEqual(new[] { "4", "5", "6" }, table.Rows[1].ItemArray); + } + + [Test] + public void VectoCSVFile_ReadStream_No_Header() + { + var stream = "1,2,3\n4,5,6".ToStream(); + var table = VectoCSVFile.ReadStream(stream); + + CollectionAssert.AreEqual(new[] { "0", "1", "2" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); + Assert.AreEqual(2, table.Rows.Count); + + CollectionAssert.AreEqual(new[] { "1", "2", "3" }, table.Rows[0].ItemArray); + CollectionAssert.AreEqual(new[] { "4", "5", "6" }, table.Rows[1].ItemArray); + } + + [Test] + public void VectoCSVFile_ReadStream_No_Content() + { + var stream = "a,b,c".ToStream(); + var table = VectoCSVFile.ReadStream(stream); + + Assert.AreEqual(3, table.Columns.Count); + CollectionAssert.AreEqual(new[] { "a", "b", "c" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); + Assert.AreEqual(0, table.Rows.Count); + } + + [Test] + public void VectoCSVFile_ReadStream_Empty() + { + AssertHelper.Exception<VectoException>(() => VectoCSVFile.ReadStream("".ToStream())); + } + + [Test] + public void VectoCSVFile_ReadStream_Comments() + { + var stream = @"#a,b,c + #21,22,23 + #674,95,96 + a,b,c + #9,8,7 + 1,2,3 + 4,5,6".ToStream(); + var table = VectoCSVFile.ReadStream(stream); + + CollectionAssert.AreEqual(new[] { "a", "b", "c" }, table.Columns.Cast<DataColumn>().Select(c => c.ColumnName)); + Assert.AreEqual(2, table.Rows.Count); + + CollectionAssert.AreEqual(new[] { "1", "2", "3" }, table.Rows[0].ItemArray); + CollectionAssert.AreEqual(new[] { "4", "5", "6" }, table.Rows[1].ItemArray); + } + + [Test] + public void VectoCSVFile_Write_Filename() + { + const string fileName = "out_test.csv"; + + if (File.Exists(fileName)) { + File.Delete(fileName); + } + + var table = new DataTable(); + table.Columns.Add("a"); + table.Columns.Add("b"); + table.Rows.Add("1", "2"); + + VectoCSVFile.Write(fileName, table); + + var text = File.ReadAllText(fileName); + Assert.AreEqual("a,b\r\n1,2\r\n", text); + } + + [Test] + public void VectoCSVFile_Write_StreamWriter() + { + var table = new DataTable(); + table.Columns.Add("a"); + table.Columns.Add("b"); + var row = table.NewRow(); + row.ItemArray = new object[] { "1", "2" }; + table.Rows.Add(row); + + using (var stream = new MemoryStream()) { + using (var sw = new StreamWriter(stream)) { + VectoCSVFile.Write(sw, table); + sw.Flush(); + + stream.Position = 0; + + using (var sr = new StreamReader(stream)) { + Assert.AreEqual("a,b\r\n1,2\r\n", sr.ReadToEnd()); + } + } + } + } + } +} diff --git a/VectoCore/VectoCoreTest/Integration/FuelTypesTest.cs b/VectoCore/VectoCoreTest/Integration/FuelTypesTest.cs index 68d4fdb4a97ad5b84b718bc306e6b1e923eb29c6..d0b1144f7a0bcd13c0bcaee83a08d1afeabb5796 100644 --- a/VectoCore/VectoCoreTest/Integration/FuelTypesTest.cs +++ b/VectoCore/VectoCoreTest/Integration/FuelTypesTest.cs @@ -29,6 +29,7 @@ * Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology */ +using System.IO; using NUnit.Framework; using TUGraz.VectoCommon.Models; using TUGraz.VectoCore.InputData.FileIO.JSON; @@ -42,6 +43,13 @@ namespace TUGraz.VectoCore.Tests.Integration [TestFixture] public class FuelTypesTest { + + [OneTimeSetUp] + public void RunBeforeAnyTests() + { + Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); + } + [TestCase(FuelType.DieselCI, @"TestData\Integration\DeclarationMode\Class2_RigidTruck_4x2\Class2_RigidTruck_DECL.vecto", 0, 0.0006886, 9391.5411, TestName = "Diesel LH Low"), diff --git a/packages/repositories.config b/packages/repositories.config index e49f9b7a32243024a02f2ee533335efcc84c95da..fa1c87525b249fed012bcbad70982af129909bba 100644 --- a/packages/repositories.config +++ b/packages/repositories.config @@ -5,7 +5,6 @@ <repository path="..\..\VECTO_API\VectoDB\packages.config" /> <repository path="..\..\VECTO_API\VectoEngineeringAPI\packages.config" /> <repository path="..\..\VECTO-Bugreports\BugReportTests\packages.config" /> - <repository path="..\Tools\VectoLegacyTests\packages.config" /> <repository path="..\VECTO\packages.config" /> <repository path="..\VECTOAux\VectoAuxiliaries\packages.config" /> <repository path="..\VECTOAux\VectoAuxiliariesTests\packages.config" />