-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
201 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using NUnit.Framework; | ||
using Polaroider; | ||
|
||
namespace YamlMap.Tests.Reader | ||
{ | ||
public class YamlReaderCommentsTests | ||
{ | ||
[Test] | ||
public void YamlReader_Comments_InList() | ||
{ | ||
var lines = new[] | ||
{ | ||
"Items:", | ||
"# - first", | ||
" - second", | ||
" # - third", | ||
" - fourth", | ||
"Id: test" | ||
}; | ||
|
||
var reader = new YamlReader(); | ||
reader.Read<CommentsList>(lines).MatchSnapshot(); | ||
} | ||
|
||
public class CommentsList | ||
{ | ||
public List<string> Items { get; set; } | ||
|
||
public string Id{ get; set; } | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...mlMap.Tests/Reader/_Snapshots/YamlReaderCommentsTests_YamlReader_Comments_InList.snapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
---data | ||
Id: test | ||
Items: | ||
second | ||
fourth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Linq; | ||
|
||
namespace YamlMap.Serialization | ||
{ | ||
internal static class SerializerExtensions | ||
{ | ||
private static readonly char[] SpecialChars = new[] { ':', '[', ']' }; | ||
|
||
/// <summary> | ||
/// Convert a object to a string that is used for serialization | ||
/// </summary> | ||
/// <param name="value"></param> | ||
/// <returns></returns> | ||
public static string ToSerializeableString(this object value) | ||
{ | ||
if (value == null) | ||
{ | ||
return null; | ||
} | ||
|
||
if (value is string s && SpecialChars.Any(c => s.Contains(c))) | ||
{ | ||
value = $"'{s}'"; | ||
} | ||
|
||
return value.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,41 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.1</TargetFrameworks> | ||
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.1</TargetFrameworks> | ||
<SignAssembly>true</SignAssembly> | ||
<AssemblyOriginatorKeyFile>../YamlMap.snk</AssemblyOriginatorKeyFile> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
<Authors>Christian Walpen</Authors> | ||
<Company>WickedFlame</Company> | ||
<Description> | ||
A .NET Yaml Parser. | ||
Map Yaml to .NET objects and vice versa. | ||
</Description> | ||
<Copyright>@WickedFlame 2019</Copyright> | ||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | ||
<PackageTags>YAML Parser</PackageTags> | ||
<Title>YamlMap</Title> | ||
<Summary>A Yaml Parser for .NET</Summary> | ||
<PackageProjectUrl>http://wickedflame.github.io/</PackageProjectUrl> | ||
<NeutralLanguage>en</NeutralLanguage> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Version>1.0.0.0</Version> | ||
<AssemblyVersion>1.0.0</AssemblyVersion> | ||
<FileVersion>1.0.0.0</FileVersion> | ||
<PackageVersion>1.0.0</PackageVersion> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.1</TargetFrameworks> | ||
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netcoreapp2.1</TargetFrameworks> | ||
<SignAssembly>true</SignAssembly> | ||
<AssemblyOriginatorKeyFile>../YamlMap.snk</AssemblyOriginatorKeyFile> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
<Authors>Christian Walpen</Authors> | ||
<Company>WickedFlame</Company> | ||
<Description> | ||
A .NET Yaml Parser. | ||
Map Yaml to .NET objects and vice versa. | ||
</Description> | ||
<Copyright>@WickedFlame 2019</Copyright> | ||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | ||
<PackageTags>YAML Parser</PackageTags> | ||
<Title>YamlMap</Title> | ||
<Summary>A Yaml Parser for .NET</Summary> | ||
<PackageProjectUrl>http://wickedflame.github.io/</PackageProjectUrl> | ||
<NeutralLanguage>en</NeutralLanguage> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Version>1.0.0.0</Version> | ||
<AssemblyVersion>1.0.0</AssemblyVersion> | ||
<FileVersion>1.0.0.0</FileVersion> | ||
<PackageVersion>1.0.0</PackageVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\..\LICENSE"> | ||
<Pack>True</Pack> | ||
<PackagePath></PackagePath> | ||
</None> | ||
</ItemGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<DocumentationFile>bin\Release\netstandard2.0\YamlMap.xml</DocumentationFile> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\..\LICENSE"> | ||
<Pack>True</Pack> | ||
<PackagePath></PackagePath> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |