Skip to content

Commit

Permalink
Merge branch 'release/v1.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswalpen committed Sep 26, 2022
2 parents f5ed997 + 6bf78f3 commit f79e088
Show file tree
Hide file tree
Showing 38 changed files with 832 additions and 124 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"WickedFlame_Yaml" /o:"wickedflame" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="src/Tests/YamlMap.Tests/coverage.opencover.xml"
.\.sonar\scanner\dotnet-sonarscanner begin /k:"WickedFlame_Yaml" /o:"wickedflame" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="src/Tests/YamlMap.Tests/coverage.*.opencover.xml"
dotnet build
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*.user
*.userosscache
*.sln.docstates
*.lutconfig

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Change Log
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased] - yyyy-mm-dd

### Added
- Create instances of types with parameterless constructors
- Added Benchmarks to ensure performance

### Changed

### Fixed

## [1.2.3] - 2022-08-15

### Added

### Changed
- Downgrade to netstandard2.0 instead of netstandard2.1
- Update building to use [https://nuke.build/](https://nuke.build/)

### Fixed
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,8 @@ WrappedText: >
```

# Best practice
## Deserialing to Object
To deserialize a Yaml to a object, it is best to have a parameterless constructor.
If a object needs to have a constructor with parameters, the parameter names have to be the same as the properties that they are mapped to.
Else YamlMap will not be able to mapt the correct values to the parameters.
8 changes: 8 additions & 0 deletions YamlMap.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.travis.yml = .travis.yml
appveyor.yml = appveyor.yml
.github\workflows\build.yml = .github\workflows\build.yml
CHANGELOG.md = CHANGELOG.md
LICENSE = LICENSE
.github\workflows\linux.yml = .github\workflows\linux.yml
README.md = README.md
Expand All @@ -22,6 +23,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{61A95099
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{720AA512-BFE2-4345-A1ED-2D3B2D91F4B2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YamlMap.Benchmark", "src\Tests\YamlMap.Benchmark\YamlMap.Benchmark.csproj", "{7FFE3802-EDF9-4764-8259-BD0B9142C9FD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -38,13 +41,18 @@ Global
{4FF32EEA-66F0-4A99-8D95-7D1E5A6E0CF4}.Release|Any CPU.Build.0 = Release|Any CPU
{720AA512-BFE2-4345-A1ED-2D3B2D91F4B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{720AA512-BFE2-4345-A1ED-2D3B2D91F4B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FFE3802-EDF9-4764-8259-BD0B9142C9FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FFE3802-EDF9-4764-8259-BD0B9142C9FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FFE3802-EDF9-4764-8259-BD0B9142C9FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FFE3802-EDF9-4764-8259-BD0B9142C9FD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{4FF32EEA-66F0-4A99-8D95-7D1E5A6E0CF4} = {61A95099-5D81-4BE8-AFA3-C1779E02A7AF}
{720AA512-BFE2-4345-A1ED-2D3B2D91F4B2} = {B215E0CA-21DD-453C-89E7-D39337E6215D}
{7FFE3802-EDF9-4764-8259-BD0B9142C9FD} = {61A95099-5D81-4BE8-AFA3-C1779E02A7AF}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FAEBE709-29D8-48BA-91F8-ABF8E2471FAD}
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# http://www.appveyor.com/docs/appveyor-yml

environment:
base_version: 1.2.3
base_version: 1.2.4

version: $(base_version).{build}

Expand Down
3 changes: 1 addition & 2 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.DotNet.DotNetTasks;

[CheckBuildProjectConfigurations]
[ShutdownDotNetAfterServerBuild]
class Build : NukeBuild
{
Expand All @@ -39,7 +38,7 @@ class Build : NukeBuild
AbsolutePath TestsDirectory => RootDirectory / "Tests";

[Parameter("Version to be injected in the Build")]
public string Version { get; set; } = $"1.2.3";
public string Version { get; set; } = $"1.2.4";

[Parameter("The Buildnumber provided by the CI")]
public string BuildNo = "2";
Expand Down
38 changes: 38 additions & 0 deletions src/Tests/YamlMap.Benchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// See https://aka.ms/new-console-template for more information

using MeasureMap;
using System.Text;
using YamlMap;
using YamlMap.Benchmark;

var value = new StringBuilder().AppendLine("Simple: root")
.AppendLine("StringList:")
.AppendLine(" - one")
.AppendLine(" - 2")
.AppendLine("ObjList:")
.AppendLine(" - Simple: simple")
.AppendLine(" - Child:")
.AppendLine(" Simple: child").ToString();


ProfilerSession.StartSession()
.SetIterations(10)
.SetThreads(10)
.Task(c =>
{
var reader = new YamlReader();
reader.Read<TestlItem>(value);
})
.RunSession()
.Trace();


//ProfilerSession.StartSession()
// .SetIterations(10)
// .Task(c =>
// {
// var reader = new YamlReader();
// reader.Read<TestlItem>(value);
// })
// .RunSession()
// .Trace();
67 changes: 67 additions & 0 deletions src/Tests/YamlMap.Benchmark/Results.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@



# MeasureMap - v1.2.4
## Summary
| Category | Metric | Value |
| --- | --- | ---: |
| Warmup | Duration Warmup | 00:00:00.0850161 |
| Setup | Threads | 10 |
| | Iterations | 100 |
| Duration | Duration | 00:00:00.2859164 |
| | Total Time | 00:00:00.5425069 |
| | Average Time | 00:00:00.0054250 |
| | Average Milliseconds | 5.425 ms |
| | Throughput | 349.75259/s |
| | Fastest | 00:00:00.0003884 |
| | Slowest | 00:00:00.0147817 |
| Memory | Memory Initial size | 128336 |
| | Memory End size | 185048 |
| | Memory Increase | 56712 |

## Details per Thread
| ThreadId | Iterations | Average Time | Slowest | Fastest | Throughput |
| --- | --- | ---: | ---: | ---: | ---: |
| 4 | 10 | 00:00:00.0058555 | 00:00:00.0140982 | 00:00:00.0014117 | 170.77873/s |
| 5 | 10 | 00:00:00.0057905 | 00:00:00.0139230 | 00:00:00.0018329 | 172.69606/s |
| 6 | 10 | 00:00:00.0038066 | 00:00:00.0065659 | 00:00:00.0012217 | 262.69886/s |
| 7 | 10 | 00:00:00.0057911 | 00:00:00.0120258 | 00:00:00.0013858 | 172.67787/s |
| 8 | 10 | 00:00:00.0062313 | 00:00:00.0130830 | 00:00:00.0038898 | 160.47887/s |
| 9 | 10 | 00:00:00.0047726 | 00:00:00.0075059 | 00:00:00.0003884 | 209.5272/s |
| 10 | 10 | 00:00:00.0045559 | 00:00:00.0072848 | 00:00:00.0005383 | 219.49271/s |
| 11 | 10 | 00:00:00.0057704 | 00:00:00.0147817 | 00:00:00.0017698 | 173.29731/s |
| 12 | 10 | 00:00:00.0047492 | 00:00:00.0073229 | 00:00:00.0011710 | 210.56178/s |
| 13 | 10 | 00:00:00.0069272 | 00:00:00.0093442 | 00:00:00.0043829 | 144.3568/s |


# MeasureMap - v1.2.3
## Summary
| Category | Metric | Value |
| --- | --- | ---: |
| Warmup | Duration Warmup | 00:00:00.0934861 |
| Setup | Threads | 10 |
| | Iterations | 100 |
| Duration | Duration | 00:00:00.3045892 |
| | Total Time | 00:00:00.5476232 |
| | Average Time | 00:00:00.0054762 |
| | Average Milliseconds | 5.4762 ms |
| | Throughput | 328.31105/s |
| | Fastest | 00:00:00.0000867 |
| | Slowest | 00:00:00.0143229 |
| Memory | Memory Initial size | 126288 |
| | Memory End size | 198552 |
| | Memory Increase | 72264 |

## Details per Thread
| ThreadId | Iterations | Average Time | Slowest | Fastest | Throughput |
| --- | --- | ---: | ---: | ---: | ---: |
| 4 | 10 | 00:00:00.0071977 | 00:00:00.0141091 | 00:00:00.0026345 | 138.93231/s |
| 5 | 10 | 00:00:00.0051405 | 00:00:00.0098962 | 00:00:00.0001348 | 194.53058/s |
| 6 | 10 | 00:00:00.0051938 | 00:00:00.0099995 | 00:00:00.0014394 | 192.53689/s |
| 7 | 10 | 00:00:00.0042084 | 00:00:00.0087129 | 00:00:00.0004524 | 237.61774/s |
| 8 | 10 | 00:00:00.0064520 | 00:00:00.0143229 | 00:00:00.0000867 | 154.98926/s |
| 9 | 10 | 00:00:00.0054007 | 00:00:00.0104453 | 00:00:00.0029130 | 185.15981/s |
| 10 | 10 | 00:00:00.0051964 | 00:00:00.0071006 | 00:00:00.0030690 | 192.44092/s |
| 11 | 10 | 00:00:00.0051198 | 00:00:00.0076924 | 00:00:00.0023300 | 195.3186/s |
| 12 | 10 | 00:00:00.0051012 | 00:00:00.0089473 | 00:00:00.0002999 | 196.03077/s |
| 13 | 10 | 00:00:00.0057514 | 00:00:00.0104961 | 00:00:00.0001130 | 173.8689/s |
25 changes: 25 additions & 0 deletions src/Tests/YamlMap.Benchmark/TestItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

namespace YamlMap.Benchmark
{
public class TestlItem
{
public string Simple { get; set; }

public TestlItemChild Child { get; set; }

public IEnumerable<string> StringList { get; set; }

public IEnumerable<TestlItemChild> ObjList { get; set; }
}

public class TestlItemChild
{
public string Simple { get; set; }

public TestlItem Child { get; set; }

public IEnumerable<string> StringList { get; set; }

public IEnumerable<TestlItem> ObjList { get; set; }
}
}
18 changes: 18 additions & 0 deletions src/Tests/YamlMap.Benchmark/YamlMap.Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MeasureMap" Version="2.0.1-RC17" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\YamlMap\YamlMap.csproj" />
</ItemGroup>

</Project>
8 changes: 4 additions & 4 deletions src/Tests/YamlMap.Tests/Reader/YamlReaderArrayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace YamlMap.Tests.Reader
public class YamlReaderArrayTests
{
[Test]
public void WickedFlame_Yaml_YamlReader_Array()
public void YamlMap_YamlReader_Array()
{
var lines = new[]
{
Expand All @@ -31,7 +31,7 @@ public void WickedFlame_Yaml_YamlReader_Array()
}

[Test]
public void WickedFlame_Yaml_YamlReader_Array_Brackets()
public void YamlMap_YamlReader_Array_Brackets()
{
var lines = new[]
{
Expand All @@ -48,7 +48,7 @@ public void WickedFlame_Yaml_YamlReader_Array_Brackets()
}

[Test]
public void WickedFlame_Yaml_YamlReader_Array_Object()
public void YamlMap_YamlReader_Array_Object()
{
var lines = new[]
{
Expand All @@ -68,7 +68,7 @@ public void WickedFlame_Yaml_YamlReader_Array_Object()
}

[Test]
public void WickedFlame_Yaml_YamlReader_Array_Nested()
public void YamlMap_YamlReader_Array_Nested()
{
var lines = new[]
{
Expand Down
8 changes: 4 additions & 4 deletions src/Tests/YamlMap.Tests/Reader/YamlReaderDictionaryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace YamlMap.Tests.Reader
public class YamlReaderDictionaryTests
{
[Test]
public void WickedFlame_Yaml_YamlReader_Dictionary()
public void YamlMap_YamlReader_Dictionary()
{
var lines = new[]
{
Expand All @@ -28,7 +28,7 @@ public void WickedFlame_Yaml_YamlReader_Dictionary()
}

[Test]
public void WickedFlame_Yaml_YamlReader_Dictionary_Interface()
public void YamlMap_YamlReader_Dictionary_Interface()
{
var lines = new[]
{
Expand All @@ -46,7 +46,7 @@ public void WickedFlame_Yaml_YamlReader_Dictionary_Interface()
}

[Test]
public void WickedFlame_Yaml_YamlReader_Dictionary_List()
public void YamlMap_YamlReader_Dictionary_List()
{
// this is a list of object instead of a dictionary
// to use dictionary remove the -
Expand All @@ -62,7 +62,7 @@ public void WickedFlame_Yaml_YamlReader_Dictionary_List()
}

[Test]
public void WickedFlame_Yaml_YamlReader_Dictionary_Objects()
public void YamlMap_YamlReader_Dictionary_Objects()
{
var lines = new[]
{
Expand Down
6 changes: 3 additions & 3 deletions src/Tests/YamlMap.Tests/Reader/YamlReaderListTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace YamlMap.Tests.Reader
public class YamlReaderListTests
{
[Test]
public void WickedFlame_Yaml_YamlReader_List()
public void YamlMap_YamlReader_List()
{
var lines = new[]
{
Expand All @@ -28,7 +28,7 @@ public void WickedFlame_Yaml_YamlReader_List()
}

[Test]
public void WickedFlame_Yaml_YamlReader_List_Interface()
public void YamlMap_YamlReader_List_Interface()
{
var lines = new[]
{
Expand All @@ -46,7 +46,7 @@ public void WickedFlame_Yaml_YamlReader_List_Interface()
}

[Test]
public void WickedFlame_Yaml_YamlReader_List_IEnumerable()
public void YamlMap_YamlReader_List_IEnumerable()
{
var lines = new[]
{
Expand Down
28 changes: 28 additions & 0 deletions src/Tests/YamlMap.Tests/Serialization/ArrayInstanceFactoryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using FluentAssertions;
using NUnit.Framework;
using YamlMap.Serialization;

namespace YamlMap.Tests.Serialization
{
public class ArrayInstanceFactoryTests
{
[Test]
public void ArrayInstanceFactory_Type()
{
var token = new Token("", 0);
token.Set(new ValueToken("Value", "1", 0));

ArrayInstanceFactory.Factory.CreateInstance(typeof(int[]), token).Invoke().Should().BeAssignableTo<int[][]>();
}

[Test]
public void ArrayInstanceFactory_Length()
{
var token = new Token("", 0);
token.Set(new ValueToken("Value1", "1", 0));
token.Set(new ValueToken("Value2", "2", 0));

((int[][])ArrayInstanceFactory.Factory.CreateInstance(typeof(int[]), token).Invoke()).Should().HaveCount(2);
}
}
}
Loading

0 comments on commit f79e088

Please sign in to comment.