diff --git a/README.md b/README.md index 030de27bd..40ad7ef25 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# RSCG - 232 Examples of Roslyn Source Code Generators / 14 created by Microsoft / +# RSCG - 233 Examples of Roslyn Source Code Generators / 14 created by Microsoft / -The RSCG_Examples repository is a comprehensive documentation system that automatically processes and showcases 232 Roslyn Source Code Generator (RSCG) examples. The system transforms individual RSCG projects into structured documentation with code examples and cross-referenced content with a searchable website and code example exports. +The RSCG_Examples repository is a comprehensive documentation system that automatically processes and showcases 233 Roslyn Source Code Generator (RSCG) examples. The system transforms individual RSCG projects into structured documentation with code examples and cross-referenced content with a searchable website and code example exports. This system serves as both a learning resource for .NET developers interested in source generators and an automated pipeline for maintaining up-to-date documentation about the RSCG ecosystem -## Latest Update : 2025-10-02 => 02 October 2025 +## Latest Update : 2025-10-03 => 03 October 2025 If you want to see examples with code, please click ***[List V2](https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG)*** @@ -24,8 +24,30 @@ If you want to be notified each time I add a new RSCG example , please click htt ## Content -Those are the 232 Roslyn Source Code Generators that I have tested you can see and download source code example. +Those are the 233 Roslyn Source Code Generators that I have tested you can see and download source code example. ( including 14 from Microsoft ) +### 233. [VYaml](https://ignatandrei.github.io/RSCG_Examples/v2/docs/VYaml) , in the [Serializer](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#serializer) category + +Generated on : 2025-10-03 => 03 October 2025 + +
+ Expand + + + +Author: Hadashi A + +The extra fast YAML library for C# + +Nuget: [https://www.nuget.org/packages/VYaml/](https://www.nuget.org/packages/VYaml/) + + +Link: [https://ignatandrei.github.io/RSCG_Examples/v2/docs/VYaml](https://ignatandrei.github.io/RSCG_Examples/v2/docs/VYaml) + +Source: [https://github.com/hadashiA/VYaml](https://github.com/hadashiA/VYaml) + +
+ ### 232. [ConsoleAppFramework](https://ignatandrei.github.io/RSCG_Examples/v2/docs/ConsoleAppFramework) , in the [Console](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#console) category Generated on : 2025-10-02 => 02 October 2025 @@ -5488,280 +5510,273 @@ Why I have not tested : issue opened https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/GaoNian-NET/MapperToolkit&body=https://github.com/GaoNian-NET/MapperToolkit -28) [https://github.com/hadashiA/VYaml]( https://github.com/hadashiA/VYaml) , https://github.com/hadashiA/VYaml - -Why I have not tested : later - -https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/hadashiA/VYaml&body=https://github.com/hadashiA/VYaml - - -29) [https://github.com/hanachiru/RapidEnum]( https://github.com/hanachiru/RapidEnum) , https://github.com/hanachiru/RapidEnum +28) [https://github.com/hanachiru/RapidEnum]( https://github.com/hanachiru/RapidEnum) , https://github.com/hanachiru/RapidEnum Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/hanachiru/RapidEnum&body=https://github.com/hanachiru/RapidEnum -30) [https://github.com/Hookyns/validly]( https://github.com/Hookyns/validly) , https://github.com/Hookyns/validly +29) [https://github.com/Hookyns/validly]( https://github.com/Hookyns/validly) , https://github.com/Hookyns/validly Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/Hookyns/validly&body=https://github.com/Hookyns/validly -31) [https://github.com/inputfalken/Dynatello]( https://github.com/inputfalken/Dynatello) , https://github.com/inputfalken/Dynatello +30) [https://github.com/inputfalken/Dynatello]( https://github.com/inputfalken/Dynatello) , https://github.com/inputfalken/Dynatello Why I have not tested : too complicated https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/inputfalken/Dynatello&body=https://github.com/inputfalken/Dynatello -32) [https://github.com/ionite34/MinimalApiMapper]( https://github.com/ionite34/MinimalApiMapper) , https://github.com/ionite34/MinimalApiMapper +31) [https://github.com/ionite34/MinimalApiMapper]( https://github.com/ionite34/MinimalApiMapper) , https://github.com/ionite34/MinimalApiMapper Why I have not tested : own idea where to generate files, so overwrites https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/ionite34/MinimalApiMapper&body=https://github.com/ionite34/MinimalApiMapper -33) [https://github.com/JasonBock/CslaGeneratorSerialization]( https://github.com/JasonBock/CslaGeneratorSerialization) , https://github.com/JasonBock/CslaGeneratorSerialization +32) [https://github.com/JasonBock/CslaGeneratorSerialization]( https://github.com/JasonBock/CslaGeneratorSerialization) , https://github.com/JasonBock/CslaGeneratorSerialization Why I have not tested : too complicated https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/JasonBock/CslaGeneratorSerialization&body=https://github.com/JasonBock/CslaGeneratorSerialization -34) [https://github.com/nuskey8/Csv-CSharp]( https://github.com/nuskey8/Csv-CSharp) , https://github.com/nuskey8/Csv-CSharp +33) [https://github.com/nuskey8/Csv-CSharp]( https://github.com/nuskey8/Csv-CSharp) , https://github.com/nuskey8/Csv-CSharp Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/nuskey8/Csv-CSharp&body=https://github.com/nuskey8/Csv-CSharp -35) [https://github.com/OrgEleCho/EleCho.Internationalization]( https://github.com/OrgEleCho/EleCho.Internationalization) , https://github.com/OrgEleCho/EleCho.Internationalization +34) [https://github.com/OrgEleCho/EleCho.Internationalization]( https://github.com/OrgEleCho/EleCho.Internationalization) , https://github.com/OrgEleCho/EleCho.Internationalization Why I have not tested : issue opened https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/OrgEleCho/EleCho.Internationalization&body=https://github.com/OrgEleCho/EleCho.Internationalization -36) [https://github.com/pierre3/PlantUmlClassDiagramGenerator]( https://github.com/pierre3/PlantUmlClassDiagramGenerator) , https://github.com/pierre3/PlantUmlClassDiagramGenerator +35) [https://github.com/pierre3/PlantUmlClassDiagramGenerator]( https://github.com/pierre3/PlantUmlClassDiagramGenerator) , https://github.com/pierre3/PlantUmlClassDiagramGenerator Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/pierre3/PlantUmlClassDiagramGenerator&body=https://github.com/pierre3/PlantUmlClassDiagramGenerator -37) [https://github.com/stbychkov/AutoLoggerMessage]( https://github.com/stbychkov/AutoLoggerMessage) , https://github.com/stbychkov/AutoLoggerMessage +36) [https://github.com/stbychkov/AutoLoggerMessage]( https://github.com/stbychkov/AutoLoggerMessage) , https://github.com/stbychkov/AutoLoggerMessage Why I have not tested : Microsoft have done same feature https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/stbychkov/AutoLoggerMessage&body=https://github.com/stbychkov/AutoLoggerMessage -38) [https://github.com/Stepami/visitor-net]( https://github.com/Stepami/visitor-net) , https://github.com/Stepami/visitor-net +37) [https://github.com/Stepami/visitor-net]( https://github.com/Stepami/visitor-net) , https://github.com/Stepami/visitor-net Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/Stepami/visitor-net&body=https://github.com/Stepami/visitor-net -39) [https://github.com/svee4/RequiredStaticMembers]( https://github.com/svee4/RequiredStaticMembers) , https://github.com/svee4/RequiredStaticMembers +38) [https://github.com/svee4/RequiredStaticMembers]( https://github.com/svee4/RequiredStaticMembers) , https://github.com/svee4/RequiredStaticMembers Why I have not tested : issue opened https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/svee4/RequiredStaticMembers&body=https://github.com/svee4/RequiredStaticMembers -40) [https://github.com/SzymonHalucha/Minerals.AutoCommands]( https://github.com/SzymonHalucha/Minerals.AutoCommands) , https://github.com/SzymonHalucha/Minerals.AutoCommands +39) [https://github.com/SzymonHalucha/Minerals.AutoCommands]( https://github.com/SzymonHalucha/Minerals.AutoCommands) , https://github.com/SzymonHalucha/Minerals.AutoCommands Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/SzymonHalucha/Minerals.AutoCommands&body=https://github.com/SzymonHalucha/Minerals.AutoCommands -41) [https://github.com/Teleopti/Saspect]( https://github.com/Teleopti/Saspect) , https://github.com/Teleopti/Saspect +40) [https://github.com/Teleopti/Saspect]( https://github.com/Teleopti/Saspect) , https://github.com/Teleopti/Saspect Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/Teleopti/Saspect&body=https://github.com/Teleopti/Saspect -42) [https://github.com/TheFo2sh/AsyncFlow]( https://github.com/TheFo2sh/AsyncFlow) , https://github.com/TheFo2sh/AsyncFlow +41) [https://github.com/TheFo2sh/AsyncFlow]( https://github.com/TheFo2sh/AsyncFlow) , https://github.com/TheFo2sh/AsyncFlow Why I have not tested : too complicated https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/TheFo2sh/AsyncFlow&body=https://github.com/TheFo2sh/AsyncFlow -43) [https://github.com/wieslawsoltes/ReactiveGenerator]( https://github.com/wieslawsoltes/ReactiveGenerator) , https://github.com/wieslawsoltes/ReactiveGenerator +42) [https://github.com/wieslawsoltes/ReactiveGenerator]( https://github.com/wieslawsoltes/ReactiveGenerator) , https://github.com/wieslawsoltes/ReactiveGenerator Why I have not tested : too complicated https://github.com/ignatandrei/RSCG_Examples/issues/new?title=https://github.com/wieslawsoltes/ReactiveGenerator&body=https://github.com/wieslawsoltes/ReactiveGenerator -44) [Intellenum]( https://github.com/SteveDunn/Intellenum) , https://github.com/SteveDunn/Intellenum +43) [Intellenum]( https://github.com/SteveDunn/Intellenum) , https://github.com/SteveDunn/Intellenum Why I have not tested : not understand how to use https://github.com/ignatandrei/RSCG_Examples/issues/new?title=Intellenum&body=https://github.com/SteveDunn/Intellenum -45) [laker]( https://github.com/Lakerfield/Lakerfield.Rpc) , https://github.com/Lakerfield/Lakerfield.Rpc +44) [laker]( https://github.com/Lakerfield/Lakerfield.Rpc) , https://github.com/Lakerfield/Lakerfield.Rpc Why I have not tested : too complicated https://github.com/ignatandrei/RSCG_Examples/issues/new?title=laker&body=https://github.com/Lakerfield/Lakerfield.Rpc -46) [LoggingDecoratorGenerator]( https://github.com/DavidFineboym/LoggingDecoratorGenerator) , https://github.com/DavidFineboym/LoggingDecoratorGenerator +45) [LoggingDecoratorGenerator]( https://github.com/DavidFineboym/LoggingDecoratorGenerator) , https://github.com/DavidFineboym/LoggingDecoratorGenerator Why I have not tested : Microsoft have done same feature https://github.com/ignatandrei/RSCG_Examples/issues/new?title=LoggingDecoratorGenerator&body=https://github.com/DavidFineboym/LoggingDecoratorGenerator -47) [lucide-blazor]( https://github.com/brecht-vde/lucide-blazor/) , https://github.com/brecht-vde/lucide-blazor/ +46) [lucide-blazor]( https://github.com/brecht-vde/lucide-blazor/) , https://github.com/brecht-vde/lucide-blazor/ Why I have not tested : issue opened https://github.com/ignatandrei/RSCG_Examples/issues/new?title=lucide-blazor&body=https://github.com/brecht-vde/lucide-blazor/ -48) [ManagedDotnetProfiler]( https://github.com/kevingosse/ManagedDotnetProfiler) , https://github.com/kevingosse/ManagedDotnetProfiler +47) [ManagedDotnetProfiler]( https://github.com/kevingosse/ManagedDotnetProfiler) , https://github.com/kevingosse/ManagedDotnetProfiler Why I have not tested : too complicated https://github.com/ignatandrei/RSCG_Examples/issues/new?title=ManagedDotnetProfiler&body=https://github.com/kevingosse/ManagedDotnetProfiler -49) [Maui.BindableProperty.Generator]( https://github.com/rrmanzano/maui-bindableproperty-generator) , https://github.com/rrmanzano/maui-bindableproperty-generator +48) [Maui.BindableProperty.Generator]( https://github.com/rrmanzano/maui-bindableproperty-generator) , https://github.com/rrmanzano/maui-bindableproperty-generator Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=Maui.BindableProperty.Generator&body=https://github.com/rrmanzano/maui-bindableproperty-generator -50) [Minerals.AutoCQRS]( https://github.com/SzymonHalucha/Minerals.AutoCQRS) , https://github.com/SzymonHalucha/Minerals.AutoCQRS +49) [Minerals.AutoCQRS]( https://github.com/SzymonHalucha/Minerals.AutoCQRS) , https://github.com/SzymonHalucha/Minerals.AutoCQRS Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=Minerals.AutoCQRS&body=https://github.com/SzymonHalucha/Minerals.AutoCQRS -51) [Minerals.AutoDomain]( https://github.com/SzymonHalucha/Minerals.AutoDomain) , https://github.com/SzymonHalucha/Minerals.AutoDomain +50) [Minerals.AutoDomain]( https://github.com/SzymonHalucha/Minerals.AutoDomain) , https://github.com/SzymonHalucha/Minerals.AutoDomain Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=Minerals.AutoDomain&body=https://github.com/SzymonHalucha/Minerals.AutoDomain -52) [observable]( https://github.com/notanaverageman/Bindables) , https://github.com/notanaverageman/Bindables +51) [observable]( https://github.com/notanaverageman/Bindables) , https://github.com/notanaverageman/Bindables Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=observable&body=https://github.com/notanaverageman/Bindables -53) [PolySharp]( https://github.com/Sergio0694/PolySharp) , https://github.com/Sergio0694/PolySharp +52) [PolySharp]( https://github.com/Sergio0694/PolySharp) , https://github.com/Sergio0694/PolySharp Why I have not tested : too complicated https://github.com/ignatandrei/RSCG_Examples/issues/new?title=PolySharp&body=https://github.com/Sergio0694/PolySharp -54) [RazorGen]( https://github.com/dartk/RazorGen) , https://github.com/dartk/RazorGen +53) [RazorGen]( https://github.com/dartk/RazorGen) , https://github.com/dartk/RazorGen Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=RazorGen&body=https://github.com/dartk/RazorGen -55) [SerdeDn]( https://github.com/serdedotnet/serde) , https://github.com/serdedotnet/serde +54) [SerdeDn]( https://github.com/serdedotnet/serde) , https://github.com/serdedotnet/serde Why I have not tested : serializer. Done by MSFT with System.Text.Json https://github.com/ignatandrei/RSCG_Examples/issues/new?title=SerdeDn&body=https://github.com/serdedotnet/serde -56) [SogePoco]( https://github.com/d-p-y/SogePoco) , https://github.com/d-p-y/SogePoco +55) [SogePoco]( https://github.com/d-p-y/SogePoco) , https://github.com/d-p-y/SogePoco Why I have not tested : too complicated https://github.com/ignatandrei/RSCG_Examples/issues/new?title=SogePoco&body=https://github.com/d-p-y/SogePoco -57) [SourceCrafter.HttpServiceClientGenerator]( https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/) , https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/ +56) [SourceCrafter.HttpServiceClientGenerator]( https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/) , https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/ Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=SourceCrafter.HttpServiceClientGenerator&body=https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/ -58) [ST.NSwag.ServerSourceGenerator]( https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator) , https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator +57) [ST.NSwag.ServerSourceGenerator]( https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator) , https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=ST.NSwag.ServerSourceGenerator&body=https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator -59) [StrongInject]( https://github.com/YairHalberstadt/stronginject/) , https://github.com/YairHalberstadt/stronginject/ +58) [StrongInject]( https://github.com/YairHalberstadt/stronginject/) , https://github.com/YairHalberstadt/stronginject/ Why I have not tested : later https://github.com/ignatandrei/RSCG_Examples/issues/new?title=StrongInject&body=https://github.com/YairHalberstadt/stronginject/ -60) [TeuJson]( https://github.com/Terria-K/TeuJson) , https://github.com/Terria-K/TeuJson +59) [TeuJson]( https://github.com/Terria-K/TeuJson) , https://github.com/Terria-K/TeuJson Why I have not tested : json a class, was done in System.Text.Json https://github.com/ignatandrei/RSCG_Examples/issues/new?title=TeuJson&body=https://github.com/Terria-K/TeuJson -61) [Tinyhand]( https://github.com/archi-Doc/Tinyhand) , https://github.com/archi-Doc/Tinyhand +60) [Tinyhand]( https://github.com/archi-Doc/Tinyhand) , https://github.com/archi-Doc/Tinyhand Why I have not tested : tried, need documentation https://github.com/ignatandrei/RSCG_Examples/issues/new?title=Tinyhand&body=https://github.com/archi-Doc/Tinyhand -62) [TupleOverloadGenerator]( https://github.com/ProphetLamb/TupleOverloadGenerator) , https://github.com/ProphetLamb/TupleOverloadGenerator +61) [TupleOverloadGenerator]( https://github.com/ProphetLamb/TupleOverloadGenerator) , https://github.com/ProphetLamb/TupleOverloadGenerator Why I have not tested : too complicated https://github.com/ignatandrei/RSCG_Examples/issues/new?title=TupleOverloadGenerator&body=https://github.com/ProphetLamb/TupleOverloadGenerator -63) [TypealizR]( https://github.com/earloc/TypealizR) , https://github.com/earloc/TypealizR +62) [TypealizR]( https://github.com/earloc/TypealizR) , https://github.com/earloc/TypealizR Why I have not tested : depends on Microsoft.Extensions.Localization https://github.com/ignatandrei/RSCG_Examples/issues/new?title=TypealizR&body=https://github.com/earloc/TypealizR -64) [UnitTestBlazor]( https://github.com/bUnit-dev/bUnit) , https://github.com/bUnit-dev/bUnit +63) [UnitTestBlazor]( https://github.com/bUnit-dev/bUnit) , https://github.com/bUnit-dev/bUnit Why I have not tested : issue opened https://github.com/ignatandrei/RSCG_Examples/issues/new?title=UnitTestBlazor&body=https://github.com/bUnit-dev/bUnit -65) [ValueLink]( https://github.com/archi-Doc/ValueLink) , https://github.com/archi-Doc/ValueLink +64) [ValueLink]( https://github.com/archi-Doc/ValueLink) , https://github.com/archi-Doc/ValueLink Why I have not tested : too complicated https://github.com/ignatandrei/RSCG_Examples/issues/new?title=ValueLink&body=https://github.com/archi-Doc/ValueLink -66) [VisitorPatternGenerator]( https://github.com/hikarin522/VisitorPatternGenerator/) , https://github.com/hikarin522/VisitorPatternGenerator/ +65) [VisitorPatternGenerator]( https://github.com/hikarin522/VisitorPatternGenerator/) , https://github.com/hikarin522/VisitorPatternGenerator/ Why I have not tested : issue opened https://github.com/ignatandrei/RSCG_Examples/issues/new?title=VisitorPatternGenerator&body=https://github.com/hikarin522/VisitorPatternGenerator/ -67) [WrapperValueObject]( https://github.com/martinothamar/WrapperValueObject) , https://github.com/martinothamar/WrapperValueObject +66) [WrapperValueObject]( https://github.com/martinothamar/WrapperValueObject) , https://github.com/martinothamar/WrapperValueObject Why I have not tested : not maintained as in readme diff --git a/later.md b/later.md index 82210b666..604d3a2e2 100644 --- a/later.md +++ b/later.md @@ -1,6 +1,6 @@ # Just later -## Latest Update : 2025-10-02 => 02 October 2025 +## Latest Update : 2025-10-03 => 03 October 2025 @@ -62,97 +62,91 @@ Why I have not tested : later -10) [https://github.com/hadashiA/VYaml]( https://github.com/hadashiA/VYaml) , https://github.com/hadashiA/VYaml +10) [https://github.com/hanachiru/RapidEnum]( https://github.com/hanachiru/RapidEnum) , https://github.com/hanachiru/RapidEnum Why I have not tested : later -11) [https://github.com/hanachiru/RapidEnum]( https://github.com/hanachiru/RapidEnum) , https://github.com/hanachiru/RapidEnum +11) [https://github.com/Hookyns/validly]( https://github.com/Hookyns/validly) , https://github.com/Hookyns/validly Why I have not tested : later -12) [https://github.com/Hookyns/validly]( https://github.com/Hookyns/validly) , https://github.com/Hookyns/validly +12) [https://github.com/nuskey8/Csv-CSharp]( https://github.com/nuskey8/Csv-CSharp) , https://github.com/nuskey8/Csv-CSharp Why I have not tested : later -13) [https://github.com/nuskey8/Csv-CSharp]( https://github.com/nuskey8/Csv-CSharp) , https://github.com/nuskey8/Csv-CSharp +13) [https://github.com/pierre3/PlantUmlClassDiagramGenerator]( https://github.com/pierre3/PlantUmlClassDiagramGenerator) , https://github.com/pierre3/PlantUmlClassDiagramGenerator Why I have not tested : later -14) [https://github.com/pierre3/PlantUmlClassDiagramGenerator]( https://github.com/pierre3/PlantUmlClassDiagramGenerator) , https://github.com/pierre3/PlantUmlClassDiagramGenerator +14) [https://github.com/Stepami/visitor-net]( https://github.com/Stepami/visitor-net) , https://github.com/Stepami/visitor-net Why I have not tested : later -15) [https://github.com/Stepami/visitor-net]( https://github.com/Stepami/visitor-net) , https://github.com/Stepami/visitor-net +15) [https://github.com/SzymonHalucha/Minerals.AutoCommands]( https://github.com/SzymonHalucha/Minerals.AutoCommands) , https://github.com/SzymonHalucha/Minerals.AutoCommands Why I have not tested : later -16) [https://github.com/SzymonHalucha/Minerals.AutoCommands]( https://github.com/SzymonHalucha/Minerals.AutoCommands) , https://github.com/SzymonHalucha/Minerals.AutoCommands +16) [https://github.com/Teleopti/Saspect]( https://github.com/Teleopti/Saspect) , https://github.com/Teleopti/Saspect Why I have not tested : later -17) [https://github.com/Teleopti/Saspect]( https://github.com/Teleopti/Saspect) , https://github.com/Teleopti/Saspect +17) [Maui.BindableProperty.Generator]( https://github.com/rrmanzano/maui-bindableproperty-generator) , https://github.com/rrmanzano/maui-bindableproperty-generator Why I have not tested : later -18) [Maui.BindableProperty.Generator]( https://github.com/rrmanzano/maui-bindableproperty-generator) , https://github.com/rrmanzano/maui-bindableproperty-generator +18) [Minerals.AutoCQRS]( https://github.com/SzymonHalucha/Minerals.AutoCQRS) , https://github.com/SzymonHalucha/Minerals.AutoCQRS Why I have not tested : later -19) [Minerals.AutoCQRS]( https://github.com/SzymonHalucha/Minerals.AutoCQRS) , https://github.com/SzymonHalucha/Minerals.AutoCQRS +19) [Minerals.AutoDomain]( https://github.com/SzymonHalucha/Minerals.AutoDomain) , https://github.com/SzymonHalucha/Minerals.AutoDomain Why I have not tested : later -20) [Minerals.AutoDomain]( https://github.com/SzymonHalucha/Minerals.AutoDomain) , https://github.com/SzymonHalucha/Minerals.AutoDomain +20) [observable]( https://github.com/notanaverageman/Bindables) , https://github.com/notanaverageman/Bindables Why I have not tested : later -21) [observable]( https://github.com/notanaverageman/Bindables) , https://github.com/notanaverageman/Bindables +21) [RazorGen]( https://github.com/dartk/RazorGen) , https://github.com/dartk/RazorGen Why I have not tested : later -22) [RazorGen]( https://github.com/dartk/RazorGen) , https://github.com/dartk/RazorGen +22) [SourceCrafter.HttpServiceClientGenerator]( https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/) , https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/ Why I have not tested : later -23) [SourceCrafter.HttpServiceClientGenerator]( https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/) , https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/ +23) [ST.NSwag.ServerSourceGenerator]( https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator) , https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator Why I have not tested : later -24) [ST.NSwag.ServerSourceGenerator]( https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator) , https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator - -Why I have not tested : later - - - -25) [StrongInject]( https://github.com/YairHalberstadt/stronginject/) , https://github.com/YairHalberstadt/stronginject/ +24) [StrongInject]( https://github.com/YairHalberstadt/stronginject/) , https://github.com/YairHalberstadt/stronginject/ Why I have not tested : later diff --git a/v2/Generator/MultiGeneratorV2.cs b/v2/Generator/MultiGeneratorV2.cs index b9fa87982..92e61ae51 100644 --- a/v2/Generator/MultiGeneratorV2.cs +++ b/v2/Generator/MultiGeneratorV2.cs @@ -936,6 +936,8 @@ private async Task WroteDocusaurus(Description it, string pathDocusaurus) .Replace("```\r\n\r\n","\r\n\r\n```") .Replace("a Result type", "a Result<TTarget> type") .Replace("(e.g., Converter)", "(e.g., Converter<T>)") + .Replace("`IYamlFormatter`", "`IYamlFormatter<T>`") + .Replace("and identifies IYamlFormatter", "and identifies IYamlFormatter<T>") .Replace("width=\"400\">", "width=\"400\" />") .Replace("
","
") .Replace(" { ", " \\{ ") diff --git a/v2/Generator/all.csv b/v2/Generator/all.csv index 4e8b479f9..c79884b49 100644 --- a/v2/Generator/all.csv +++ b/v2/Generator/all.csv @@ -231,3 +231,4 @@ Nr,Key,Source,Category 230,Unflat, https://github.com/pstlnce/unflat,Database 231,kli.Localize, https://github.com/kl1mm/localize,FilesToCode 232,ConsoleAppFramework, https://github.com/Cysharp/ConsoleAppFramework,Console +233,Vyaml, https://github.com/hadashiA/VYaml,Serializer diff --git a/v2/RSCGExamplesData/GeneratorDataRec.json b/v2/RSCGExamplesData/GeneratorDataRec.json index a5da492d6..fb27e1f9f 100644 --- a/v2/RSCGExamplesData/GeneratorDataRec.json +++ b/v2/RSCGExamplesData/GeneratorDataRec.json @@ -1401,5 +1401,12 @@ "Category":34, "dtStart": "2025-10-02T00:00:00", "show": true +}, + +{ + "ID":"Vyaml", + "Category":16, + "dtStart": "2025-10-03T00:00:00", + "show": true } ] \ No newline at end of file diff --git a/v2/RSCGExamplesData/NoExample.json b/v2/RSCGExamplesData/NoExample.json index b7f1990ea..cafcad46b 100644 --- a/v2/RSCGExamplesData/NoExample.json +++ b/v2/RSCGExamplesData/NoExample.json @@ -892,11 +892,6 @@ "why":"later" }, { - "ID":229, - "name":"https://github.com/hadashiA/VYaml", - "why":"later" - }, - { "ID":230, "name":"https://github.com/FoundatioFx/Foundatio.Mediator", "why":"later" diff --git a/v2/book/examples/VYaml.html b/v2/book/examples/VYaml.html new file mode 100644 index 000000000..621478219 --- /dev/null +++ b/v2/book/examples/VYaml.html @@ -0,0 +1,59 @@ + +

RSCG nr 233 : VYaml

+ +

Info

+Nuget : https://www.nuget.org/packages/VYaml/ + +

You can find more details at : https://github.com/hadashiA/VYaml

+ +

Author :Hadashi A

+ +

Source: https://github.com/hadashiA/VYaml

+ +

About

+ +Serializing to/from YAML format + +

+ How to use +

+

+ Add reference to the VYaml in the csproj +

+ + +

This was for me the starting code

+ +
+ I have coded the file Program.cs +
+ +
+ +
+ I have coded the file Person.cs +
+ +
+

And here are the generated files

+ +
+ The file generated is SerializerDemo.Person.YamlFormatter.g.cs +
+ + +

+ You can download the code and this page as pdf from + + https://ignatandrei.github.io/RSCG_Examples/v2/docs/VYaml + +

+ + +

+ You can see the whole list at + + https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG + +

+ diff --git a/v2/book/list.html b/v2/book/list.html index 10ff173be..61f1a78c5 100644 --- a/v2/book/list.html +++ b/v2/book/list.html @@ -17,7 +17,7 @@

-This is the list of 232 RSCG with examples => +This is the list of 233 RSCG with examples =>

@@ -954,6 +954,10 @@

+ + + +
232 ConsoleAppFramework
233VYaml
diff --git a/v2/book/pandocHTML.yaml b/v2/book/pandocHTML.yaml index 5a332a8e4..c63844cfa 100644 --- a/v2/book/pandocHTML.yaml +++ b/v2/book/pandocHTML.yaml @@ -246,6 +246,7 @@ input-files: - examples/Unflat.html - examples/kli.Localize.html - examples/ConsoleAppFramework.html +- examples/VYaml.html # or you may use input-file: with a single value # defaults: diff --git a/v2/rscg_examples/VYaml/description.json b/v2/rscg_examples/VYaml/description.json new file mode 100644 index 000000000..ddb6bcaaf --- /dev/null +++ b/v2/rscg_examples/VYaml/description.json @@ -0,0 +1,22 @@ +{ + "generator":{ + "name":"VYaml", + "nuget":[ + "https://www.nuget.org/packages/VYaml/" + ], + "link":"https://github.com/hadashiA/VYaml", + "author":"Hadashi A", + "source":"https://github.com/hadashiA/VYaml" + }, + "data":{ + "goodFor":["Serializing to/from YAML format"], + "csprojDemo":"Serializer.csproj", + "csFiles":["Program.cs","Person.cs"], + "excludeDirectoryGenerated":[""], + "includeAdditionalFiles":[""] + }, + "links":{ + "blog":"", + "video":"" + } +} \ No newline at end of file diff --git a/v2/rscg_examples/VYaml/nuget.txt b/v2/rscg_examples/VYaml/nuget.txt new file mode 100644 index 000000000..e43265eb0 --- /dev/null +++ b/v2/rscg_examples/VYaml/nuget.txt @@ -0,0 +1 @@ +The extra fast YAML library for C# \ No newline at end of file diff --git a/v2/rscg_examples/VYaml/readme.txt b/v2/rscg_examples/VYaml/readme.txt new file mode 100644 index 000000000..e0652d385 --- /dev/null +++ b/v2/rscg_examples/VYaml/readme.txt @@ -0,0 +1,936 @@ +# VYaml + +[![GitHub license](https://img.shields.io/github/license/hadashiA/VYaml)](./LICENSE) +![Unity 2022.2+](https://img.shields.io/badge/unity-2021.3+-000.svg) +[![NuGet](https://img.shields.io/nuget/v/VYaml.svg)](https://www.nuget.org/packages/VYaml) + +VYaml is a pure C# YAML 1.2 implementation, which is extra fast, low memory footprint with focued on .NET and Unity. + +- The parser is heavily influenced by [yaml-rust](https://github.com/chyh1990/yaml-rust), and libyaml, yaml-cpp. +- Serialization interface/implementation is heavily influenced by [Utf8Json](https://github.com/neuecc/Utf8Json), [MessagePack-CSharp](https://github.com/neuecc/MessagePack-CSharp), [MemoryPack](https://github.com/Cysharp/MemoryPack). + +The reason VYaml is fast is it handles utf8 byte sequences directly with newface api set of C# (`System.Buffers.*`, etc). +In parsing, scalar values are pooled and no allocation occurs until `Scalar.ToString()`. This works with very low memory footprint and low performance overhead, in environments such as Unity. + +![screenshot_benchmark_dotnet.png](./screenshots/screenshot_benchmark_dotnet.png) +![screenshot_benchmark_unity.png](./screenshots/screenshot_benchmark_unity.png) + +Compared with [YamlDotNet](https://github.com/aaubry/YamlDotNet) (most popular yaml library in C#), basically 6x faster and about 1/50 heap allocations in some case. + + +## Features + +- YAML Parser (Reader) + - [YAML 1.2 mostly supported](#httpsyamlorgspec122) + - Support Unity serialized weird YAML format + - https://forum.unity.com/threads/scene-files-invalid-yaml.355653/ + - YAML automatically generated by Unity may contain the symbol `"stripped"` in the document start line. This is against the YAML specification, but VYaml supports this format. +- YAML Emitter (Writer) + - Write primitive types. + - Write plain scalar, double-quoted scalar, literal scalar. + - Write block style sequence, flow style sequence, and block mapping. +- Deserialize / Serialize + - Convert between YAML and C# user-defined types. + - Convert between YAML and primitive collection via `dynamic` . + - Support interface-typed and abstract class-typed objects. + - Support anchor (`&`) and alias (`*`) in the YAML spec. + - Support multiple yaml documents to C# collection. + - Customization + - Rename key + - Ignore member +- Mainly focused on Unity + - Only 2021.3 and higher (netstandard2.1 compatible) + +## Most recent roadmap + +- [ ] Support node tree representation + +## Installation + +### NuGet + +You can install the following nuget package. +https://www.nuget.org/packages/VYaml + +```bash +dotnet add package VYaml +``` + +### Unity + +> [!IMPORTANT] +> Starting with version 1.0, VYaml is now via NuGetForUnity. +> If you are using an older version, please follow these instructions to reinstall. + +> [!NOTE] +> Requirements: Unity 2021.3 or later. + +1. Install NugetForUnity. +2. Open the NuGet window by going to NuGet > Manage NuGet Packages, search for the "VYaml" package, and install it. +3. (Optional) Installing Unity-specific extensions: + - Open the Package Manager window by selecting Window > Package Manager, then click on [+] > Add package from git URL and enter the following URL: + - ``` + https://github.com/hadashiA/VYaml.git?path=VYaml.Unity/Assets/VYaml#1.2.0 + ``` + +## Usage + +### Serialize / Deserialize + +Define a struct or class to be serialized and annotate it with the `[YamlObject]` attribute and the partial keyword. + +```csharp +using VYaml.Annotations; + +[YamlObject] +public partial class Sample +{ + // By default, public fields and properties are serializable. + public string A; // public field + public string B { get; set; } // public property + public string C { get; private set; } // public property (private setter) + public string D { get; init; } // public property (init-only setter) + + // use `[YamlIgnore]` to remove target of a public member + [YamlIgnore] + public int PublicProperty2 => PublicProperty + PublicField; +} +``` + +Why partial is necessary ? +- VYaml uses [SourceGenerator](https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview) for metaprogramming, which supports automatic generation of partial declarations, sets to private fields. + +``` csharp +var utf8Yaml = YamlSerializer.Serialize(new Sample +{ + A = "hello", + B = "foo", + C = "bar", + D = "hoge", +}); +``` + + +Result: + +```yaml +a: hello +b: foo +c: bar +d: hoge +``` + +By default, The `Serialize` method returns an utf8 byte array. +This is because it is common for writes to files or any data stores to be stored as strings in utf8 format. + + +If you wish to receive the results in a C# string, do the following +Note that this has the overhead of conversion to utf16. + +``` csharp +var yamlString = YamlSerializer.SerializeToString(...); +``` + +You can also convert yaml to C#. + +```csharp +using var stream = File.OpenRead("/path/to/yaml"); +var sample = await YamlSerializer.DeserializeAsync(stream); + +// Or +// var yamlUtf8Bytes = System.Text.Encoding.UTF8.GetBytes(""); +// var sample = YamlSerializer.Deserialize(yamlUtf8Bytes); +``` + +```csharp +sample.A // #=> "hello" +sample.B // #=> "foo" +sample.C // #=> "bar" +sample.D // #=> "hoge" +``` + +#### Built-in supported types + +These types can be serialized by default: + +- .NET primitives (`byte`, `int`, `bool`, `char`, `double`, etc.) +- Any enum (Currently, only simple string representation) +- `string`, `decimal`, `Half`, `BigInteger`, `Complex` +- `TimeSpan`, `DateTime`, `DateTimeOffset` +- `Guid`, `Uri`, `Version`, `Type` +- `byte[]` as base64 string +- `T[]`, `T[,]`, `T[,,]`, `T[,,]`, `BitArray` +- `Nullable<>`, `KeyValuePair<,>`, `Tuple<,...>`, `ValueTuple<,...>` +- `List<>`, `Stack<>`, `Queue<>`, `LinkedList<>`, `HashSet<>`, `SortedSet<>`, `BlockingCollection<>`, `ConcurrentQueue<>`, `ConcurrentStack<>`, `ConcurrentBag<>` +- `Dictionary<,>` +- `IEnumerable<>`, `ICollection<>`, `IList<>`, `IReadOnlyCollection<>`, `IReadOnlyList<>`, `ISet<>` +- `IDictionary<,>`, `IReadOnlyDictionary<,>` + +The following types of support are included in the package for Unity. + +- `Color`, `Color32` +- `Vector2`, `Vector2Int`, `Vector3`, `Vector3Int`, `Vector4`, `Vector4Int` +- `Matrix4x4` +- `Quaternion` +- `Rect`, `RectInt`, `RectOffset` +- Addtionaly, If the `Unity.Mathmatics` package is installed, the following support is enabled: + - `bool2`, `bool3`, `bool4` + - `float2`, `float3`, `float4` + - `double2`, `double3`, `double4` + - `half2`, `half3`, `half4` + - `int2`, `int3`, `int4` + - `uint2`, `uint3`, `uint4` + - `bool2x2`, `bool2x3`, `bool2x4`, `bool3x2`, `bool3x3`, `bool3x4`, `bool4x2`, `bool4x3`, `bool4x4` + - `float2x2`, `float2x3`, `float2x4`, `float3x2`, `float3x3`, `float3x4`, `float4x2`, `float4x3`, `float4x4` + - `double2x2`, `double2x3`, `double2x4`, `double3x2`, `double3x3`, `double3x4`, `double4x2`, `double4x3`, `double4x4` + - `int2x2`, `int2x3`, `int2x4`, `int3x2`, `int3x3`, `int3x4`, `int4x2`, `int4x3`, `int4x4` + - `uint2x2`, `uint2x3`, `uint2x4`, `uint3x2`, `uint3x3`, `uint3x4`, `uint4x2`, `uint4x3`, `uint4x4` + - `quaternion` + + +- To enable it, do the following +1. Install the unity package. + - See [Installation/Unity](#unity) section. +2. Add UnityResolver to YamlSeriarOptions. + - ```cs + YamlSerializer.DefaultOptions = new YamlSerializerOptions + { + Resolver = CompositeResolver.Create(new IYamlFormatterResolver[] + { + StandardResolver.Instance, + UnityResolver.Instance, + }) + }; + ``` + +#### Deserialize as `dynamic` + +You can also deserialize into primitive `object` type implicitly. + +``` csharp +var yaml = YamlSerializer.Deserialize(yamlUtf8Bytes); +``` + +```csharp +yaml["a"] // #=> "hello" +yaml["b"] // #=> "aaa" +yaml["c"] // #=> "hoge" +yaml["d"] // #=> "ddd" +``` + +#### Deserialize multiple documents + + +YAML allows for multiple data in one file by separating them with `---`. This is called a "Document". +If you want to load multiple documents, you can use `Yamlserializer.DeserializeMultipleDocuments(...)`. + +For example: + +``` yaml +--- +Time: 2001-11-23 15:01:42 -5 +User: ed +Warning: + This is an error message + for the log file +--- +Time: 2001-11-23 15:02:31 -5 +User: ed +Warning: + A slightly different error + message. +--- +Date: 2001-11-23 15:03:17 -5 +User: ed +Fatal: + Unknown variable "bar" +Stack: +- file: TopClass.py + line: 23 + code: | + x = MoreObject("345\n") +- file: MoreClass.py + line: 58 + code: |- + foo = bar +``` + +``` csharp +var documents = YamlSerializer.DeserializeMultipleDocuments(yaml); +``` + +```csharp +documents[0]["Warning"] // #=> "This is an error message for the log file" +documents[1]["Warning"] // #=> "A slightly different error message." +documents[2]["Fatal"] // #=> "Unknown variable \"bar\"" +``` + +#### Naming convention + +:exclamation: By default, VYaml maps C# property names in lower camel case (e.g. `propertyName`) format to yaml keys. + +If you want to customize this behaviour, `YamlSerializerOptions.NamingConvention` to set it. + +```cs +var options = YamlSerializerOptions.Standard; +options.NamingConvention = NamingConvention.SnakeCase; + +YamlSerializer.Serialize(new A { FooBar = 123 }, options); // #=> "{ foo_bar: 123 }" +``` + +List of possible values: +- NamingConvention.LowerCamelCase + - Like `propertyName` +- NamingConvention.UpperCamelCase: + - Like `PropertyName` +- NamingConvention.SnakeCase: + - Like `property_name` +- NamingConvention.KebabCase: + - Like `property-name` + + +> [!TIP] +> If you specify an option other than the default `LowerCamelCase`, there will be a slight performance degradation at runtime. + +You may specify NamingConvention for each type declaration by `[YamlObject]` attribute. +In this case, no performance degradation occurs. + +```csharp +[YamlObject(NamingConvention.SnakeCase)] +public partial class Sample +{ + public int FooBar { get; init; } +} +``` + +This serialize as: + +```yaml +foo_bar: 100 +``` + +Also, you can change the key name each members with `[YamlMember("name")]` + +```csharp +[YamlObject] +public partial class Sample +{ + [YamlMember("foo-bar-alias")] + public int FooBar { get; init; } +} +``` + +This serialize as: + +```yaml +foo-bar-alias: 100 +``` + +#### Custom constructor + +VYaml supports both parameterized and parameterless constructors. The selection of the constructor follows these rules. + +- If there is `[YamlConstructor]`, use it. +- If there is no explicit constructor use a parameterless one. +- If there is one constructor use it. +- If there are multiple constructors, then the `[YamlConstructor]` attribute must be applied to the desired constructor (the generator will not automatically choose one), otherwise the generator will emit an error. + +:note: If using a parameterized constructor, all parameter names must match corresponding member names (case-insensitive). + +``` csharp +[YamlObject] +public partial class Person +{ + public int Age { get; } + public string Name { get; } + + // You can use a parameterized constructor - parameter names must match corresponding members name (case-insensitive) + public Person(int age, string name) + { + Age = age; + Name = name; + } +} + +[YamlObject] +public partial class Person +{ + public int Age { get; set; } + public string Name { get; set; } + + public Person() + { + // ... + } + + // If there are multiple constructors, then [YamlConstructor] should be used + [YamlConstructor] + public Person(int age, string name) + { + this.Age = age; + this.Name = name; + } +} + + +[YamlObject] +public partial class Person +{ + public int Age { get; } // from constructor + public string Name { get; } // from constructor + public string Profile { get; set; } // from setter + + // If all members of the construct are not taken as arguments, setters are used for the other members + public Person(int age, string name) + { + this.Age = age; + this.Name = name; + } +} +``` + +#### Enum + +By default, Enum is serialized in camelCase with a leading lowercase letter, as is the key name of the object. +For example: + +``` csharp +enum Foo +{ + Item1, + Item2, + Item3, +} +``` + +``` csharp +YamlSerializer.Serialize(Foo.Item1); // #=> "item1" +``` + +It respect `[EnumMember]`, and `[DataMember]`. + + +``` csharp +enum Foo +{ + [EnumMember(Value = "item1-alias")] + Item1, + + [EnumMember(Value = "item2-alias")] + Item2, + + [EnumMember(Value = "item3-alias")] + Item3, +} +``` + +``` csharp +YamlSerializer.Serialize(Foo.Item1); // #=> "item1-alias" +``` + +And, naming covnention can also be specified by using the `[YamlMember]` attribute. + + +``` csharp +[YamlObject(NamingConvention.SnakeCase)] +enum Foo +{ + ItemOne, + ItemTwo, + ItemThree, +} +``` + +``` csharp +YamlSerializer.Serialize(Foo.ItemOne); // #=> "item_one" +``` + +#### Polymorphism (Union) + +VYaml supports deserialize interface or abstract class objects for. In VYaml this feature is called Union. +Only interfaces and abstracts classes are allowed to be annotated with `[YamlObjectUnion]` attributes. Unique union tags are required. + +``` csharp +[YamlObject] +[YamlObjectUnion("!foo", typeof(FooClass))] +[YamlObjectUnion("!bar", typeof(BarClass))] +public partial interface IUnionSample +{ +} + +[YamlObject] +public partial class FooClass : IUnionSample +{ + public int A { get; set; } +} + +[YamlObject] +public partial class BarClass : IUnionSample +{ + public string? B { get; set; } +} +``` + +``` csharp +// We can deserialize as interface type. +var obj = YamlSerializer.Deserialize(UTF8.GetBytes("!foo { a: 100 }")); + +obj.GetType(); // #=> FooClass +``` + +In the abobe example, The `!foo` and `!bar` are called tag in the YAML specification. +YAML can mark arbitrary data in this way, and VYaml Union takes advantage of this. + +You can also serialize: + +``` csharp +YamlSerializer.Serialize(new FooClass { A = 100 }); +``` + +Result: +``` yaml +!foo +a: 100 +``` + +## Customize serialization behaviour + +- `IYamlFormatter` is an interface customize the serialization behaviour of a your particular type. +- `IYamlFormatterResolver` is an interface can customize how it searches for `IYamlFormatter` at runtime. + +To perform Serialize/Deserialize, it need an `IYamlFormatter` corresponding to a certain C# type. +By default, the following `StandardResolver` works and identifies IYamlFormatter. + + +You can customize this behavior as follows: + +``` csharp +var options = new YamlSerializerOptions +{ + Resolver = CompositeResolver.Create( + new IYamlFormatter[] + { + new YourCustomFormatter1(), // You can add additional formatter + }, + new IYamlFormatterResolver[] + { + new YourCustomResolver(), // You can add additional resolver + StandardResolver.Instance, // Fallback to default behavior at the end. + }) +}; + +YamlSerializer.Deserialize(yaml, options); +YamlSerializer.Deserialize(yaml, options); +``` + + +## Low-Level API + +### Parser + +`YamlParser` struct provides access to the complete meta-information of yaml. + + +- `YamlParser.Read()` reads through to the next syntax on yaml. (If end of stream then return false.) +- `YamlParser.ParseEventType` indicates the state of the currently read yaml parsing result. +- How to access scalar value: + - `YamlParser.GetScalarAs*` families take the result of converting a scalar at the current position to a specified type. + - `YamlParser.TryGetScalarAs*` families return true and take a result if the current position is a scalar and of the specified type. + - `YamlParser.ReadScalarAs*` families is similar to GetScalarAs*, but advances the present position to after the scalar read. +- How to access meta information: + - `YamlParser.TryGetCurrentTag(out Tag tag)` + - `YamlParser.TryGetCurrentAnchor(out Anchor anchor)` + +Basic example: + +```csharp +var parser = YamlParser.FromBytes(utf8Bytes); + +// YAML contains more than one `Document`. +// Here we skip to before first document content. +parser.SkipAfter(ParseEventType.DocumentStart); + +// Scanning... +while (parser.Read()) +{ + // If the current syntax is Scalar, + if (parser.CurrentEventType == ParseEventType.Scalar) + { + var intValue = parser.GetScalarAsInt32(); + var stringValue = parser.GetScalarAsString(); + // ... + + if (parser.TryGetCurrentTag(out var tag)) + { + // Check for the tag... + } + + if (parser.TryGetCurrentAnchor(out var anchor)) + { + // Check for the anchor... + } + } + + // If the current syntax is Sequence (Like a list in yaml) + else if (parser.CurrentEventType == ParseEventType.SequenceStart) + { + // We can check for the tag... + // We can check for the anchor... + + parser.Read(); // Skip SequenceStart + + // Read to end of sequence + while (!parser.End && parser.CurrentEventType != ParseEventType.SequenceEnd) + { + // A sequence element may be a scalar or other... + if (parser.CurrentEventType == ParseEventType.Scalar) + { + // ... + } + // ... + // ... + else + { + // We can skip current element. (It could be a scalar, or alias, sequence, mapping...) + parser.SkipCurrentNode(); + } + } + parser.Read(); // Skip SequenceEnd. + } + + // If the current syntax is Mapping (like a Dictionary in yaml) + else if (parser.CurrentEventType == ParseEventType.MappingStart) + { + // We can check for the tag... + // We can check for the anchor... + + parser.Read(); // Skip MappingStart + + // Read to end of mapping + while (parser.CurrentEventType != ParseEventType.MappingEnd) + { + // After Mapping start, key and value appear alternately. + + var key = parser.ReadScalarAsString(); // if key is scalar + var value = parser.ReadScalarAsString(); // if value is scalar + + // Or we can skip current key/value. (It could be a scalar, or alias, sequence, mapping...) + // parser.SkipCurrentNode(); // skip key + // parser.SkipCurrentNode(); // skip value + } + parser.Read(); // Skip MappingEnd. + } + + // Alias + else if (parser.CurrentEventType == ParseEventType.Alias) + { + // If Alias is used, the previous anchors must be holded somewhere. + // In the High level Deserialize API, `YamlDeserializationContext` does exactly this. + } +} +``` + +See [test code](https://github.com/hadashiA/VYaml/blob/master/VYaml.Tests/Parser/SpecTest.cs) for more information. +The above test covers various patterns for the order of `ParsingEvent`. + + +### Emitter + +`Utf8YamlEmitter` struct provides to write YAML formatted string. + +Basic usage: + +``` csharp +var buffer = new ArrayBufferWriter(); +var emitter = new Utf8YamlEmitter(buffer); // It needs buffer implemented `IBufferWriter` + +emitter.BeginMapping(); // Mapping is a collection like Dictionary in YAML +{ + emitter.WriteString("key1"); + emitter.WriteString("value-1"); + + emitter.WriteString("key2"); + emitter.WriteInt32(222); + + emitter.WriteString("key3"); + emitter.WriteFloat(3.333f); +} +emitter.EndMapping(); +``` + +``` csharp +// If you want to expand a string in memory, you can do this. +System.Text.Encoding.UTF8.GetString(buffer.WrittenSpan); +``` + +``` yaml +key1: value-1 +key2: 222 +key3: 3.333 +``` + +#### Emit string in various formats + +By default, WriteString() automatically determines the format of a scalar. + + +Multi-line strings are automatically format as a literal scalar: + +``` csharp +emitter.WriteString("Hello,\nWorld!\n"); +``` + +``` yaml +| + Hello, + World! +``` + +Special characters contained strings are automatically quoted. + +``` csharp +emitter.WriteString("&aaaaa "); +``` + +``` yaml +"&aaaaa " +``` + +Or you can specify the style explicitly: + +``` csharp +emitter.WriteString("aaaaaaa", ScalarStyle.Literal); +``` + +``` yaml +|- + aaaaaaaa +``` + +#### Emit sequences and other structures + +e.g: + +``` csharp +emitter.BeginSequence(); +{ + emitter.BeginSequence(SequenceStyle.Flow); + { + emitter.WriteInt32(100); + emitter.WriteString("&hoge"); + emitter.WriteString("bra"); + } + emitter.EndSequence(); + + emitter.BeginMapping(); + { + emitter.WriteString("key1"); + emitter.WriteString("item1"); + + emitter.WriteString("key2"); + emitter.BeginSequence(); + { + emitter.WriteString("nested-item1") + emitter.WriteString("nested-item2") + emitter.BeginMapping(); + { + emitter.WriteString("nested-key1") + emitter.WriteInt32(100) + } + emitter.EndMapping(); + } + emitter.EndSequence(); + } + emitter.EndMapping(); +} +emitter.EndMapping(); +``` + +``` yaml +- [100, "&hoge", bra] +- key1: item1 + key2: + - nested-item1 + - nested-item2 + - nested-key1: 100 +``` + +## YAML 1.2 spec support status + +### Implicit primitive type conversion of scalar + +The following is the default implicit type interpretation. + +Basically, it follows YAML Core Schema. +https://yaml.org/spec/1.2.2/#103-core-schema + +|Support|Regular expression|Resolved to type| +|:-----|:-------|:-------| +| :white_check_mark: | `null \| Null \| NULL \| ~` | null | +| :white_check_mark: | `/* Empty */` | null | +| :white_check_mark: | `true \| True \| TRUE \| false \| False \| FALSE` | boolean | +| :white_check_mark: | `[-+]? [0-9]+` | int (Base 10) | +| :white_check_mark: | `0o [0-7]+` | int (Base 8) | +| :white_check_mark: | `0x [0-9a-fA-F]+` | int (Base 16) | +| :white_check_mark: | `[-+]? ( \. [0-9]+ \| [0-9]+ ( \. [0-9]* )? ) ( [eE] [-+]? [0-9]+ )?` | float | +| :white_check_mark: | `[-+]? ( \.inf \| \.Inf \| \.INF )` | float (Infinity) | +| :white_check_mark: | `\.nan \| \.NaN \| \.NAN` | float (Not a number) | + +### https://yaml.org/spec/1.2.2/ + +Following is the results of the [test](https://github.com/hadashiA/VYaml/blob/master/VYaml.Tests/Parser/SpecTest.cs) for the examples from the [yaml spec page](https://yaml.org/spec/1.2.2/). + +- 2.1. Collections + - :white_check_mark: Example 2.1 Sequence of Scalars (ball players) + - :white_check_mark: Example 2.2 Mapping Scalars to Scalars (player statistics) + - :white_check_mark: Example 2.3 Mapping Scalars to Sequences (ball clubs in each league) + - :white_check_mark: Example 2.4 Sequence of Mappings (players statistics) + - :white_check_mark: Example 2.5 Sequence of Sequences + - :white_check_mark: Example 2.6 Mapping of Mappings +- 2.2. Structures + - :white_check_mark: Example 2.7 Two Documents in a Stream (each with a leading comment) + - :white_check_mark: Example 2.8 Play by Play Feed from a Game + - :white_check_mark: Example 2.9 Single Document with Two Comments + - :white_check_mark: Example 2.10 Node for Sammy Sosa appears twice in this document + - :white_check_mark: Example 2.11 Mapping between Sequences + - :white_check_mark: Example 2.12 Compact Nested Mapping +- 2.3. Scalars + - :white_check_mark: Example 2.13 In literals, newlines are preserved + - :white_check_mark: Example 2.14 In the folded scalars, newlines become spaces + - :white_check_mark: Example 2.15 Folded newlines are preserved for more indented and blank lines + - :white_check_mark: Example 2.16 Indentation determines scope + - :white_check_mark: Example 2.17 Quoted Scalars + - :white_check_mark: Example 2.18 Multi-line Flow Scalars +- 2.4. Tags + - :white_check_mark: Example 2.19 Integers + - :white_check_mark: Example 2.20 Floating Point + - :white_check_mark: Example 2.21 Miscellaneous + - :white_check_mark: Example 2.22 Timestamps + - :white_check_mark: Example 2.23 Various Explicit Tags + - :white_check_mark: Example 2.24 Global Tags + - :white_check_mark: Example 2.25 Unordered Sets + - :white_check_mark: Example 2.26 Ordered Mappings +- 2.5. Full Length Example + - :white_check_mark: Example 2.27 Invoice + - :white_check_mark: Example 2.28 Log File +- 5.2. Character Encodings + - :white_check_mark: Example 5.1 Byte Order Mark + - :white_check_mark: Example 5.2 Invalid Byte Order Mark +- 5.3. Indicator Characters + - :white_check_mark: Example 5.3 Block Structure Indicators + - :white_check_mark: Example 5.4 Flow Collection Indicators + - :white_check_mark: Example 5.5 Comment Indicator + - :white_check_mark: Example 5.6 Node Property Indicators + - :white_check_mark: Example 5.7 Block Scalar Indicators + - :white_check_mark: Example 5.8 Quoted Scalar Indicators + - :white_check_mark: Example 5.9 Directive Indicator + - :white_check_mark: Example 5.10 Invalid use of Reserved Indicators +- 5.4. Line Break Characters + - :white_check_mark: Example 5.11 Line Break Characters + - :white_check_mark: Example 5.12 Tabs and Spaces + - :white_check_mark: Example 5.13 Escaped Characters + - :white_check_mark: Example 5.14 Invalid Escaped Characters +- 6.1. Indentation Spaces + - :white_check_mark: Example 6.1 Indentation Spaces + - :white_check_mark: Example 6.2 Indentation Indicators +- 6.2. Separation Spaces + - :white_check_mark: Example 6.3 Separation Spaces +- 6.3. Line Prefixes + - :white_check_mark: Example 6.4 Line Prefixes +- 6.4. Empty Lines + - :white_check_mark: Example 6.5 Empty Lines +- 6.5. Line Folding + - :white_check_mark: Example 6.6 Line Folding + - :white_check_mark: Example 6.7 Block Folding + - :white_check_mark: Example 6.8 Flow Folding +- 6.6. Comments + - :white_check_mark: Example 6.9 Separated Comment + - :white_check_mark: Example 6.10 Comment Lines + - :white_check_mark: Example 6.11 Multi-Line Comments +- 6.7. Separation Lines + - :white_check_mark: Example 6.12 Separation Spaces +- 6.8. Directives + - :white_check_mark: Example 6.13 Reserved Directives + - :white_check_mark: Example 6.14 YAML directive + - :white_check_mark: Example 6.15 Invalid Repeated YAML directive + - :white_check_mark: Example 6.16 TAG directive + - :white_check_mark: Example 6.17 Invalid Repeated TAG directive + - :white_check_mark: Example 6.18 Primary Tag Handle + - :white_check_mark: Example 6.19 Secondary Tag Handle + - :white_check_mark: Example 6.20 Tag Handles + - :white_check_mark: Example 6.21 Local Tag Prefix + - :white_check_mark: Example 6.22 Global Tag Prefix +- 6.9. Node Properties + - :white_check_mark: Example 6.23 Node Properties + - :white_check_mark: Example 6.24 Verbatim Tags + - :white_check_mark: Example 6.25 Invalid Verbatim Tags + - :white_check_mark: Example 6.26 Tag Shorthands + - :white_check_mark: Example 6.27 Invalid Tag Shorthands + - :white_check_mark: Example 6.28 Non-Specific Tags + - :white_check_mark: Example 6.29 Node Anchors +- 7.1. Alias Nodes + - :white_check_mark: Example 7.1 Alias Nodes +- 7.2. Empty Nodes + - :white_check_mark: Example 7.2 Empty Content + - :white_check_mark: Example 7.3 Completely Empty Flow Nodes +- 7.3. Flow Scalar Styles + - :white_check_mark: Example 7.4 Double Quoted Implicit Keys + - :white_check_mark: Example 7.5 Double Quoted Line Breaks + - :white_check_mark: Example 7.6 Double Quoted Lines + - :white_check_mark: Example 7.7 Single Quoted Characters + - :white_check_mark: Example 7.8 Single Quoted Implicit Keys + - :white_check_mark: Example 7.9 Single Quoted Lines + - :white_check_mark: Example 7.10 Plain Characters + - :white_check_mark: Example 7.11 Plain Implicit Keys + - :white_check_mark: Example 7.12 Plain Lines +- 7.4. Flow Collection Styles + - :white_check_mark: Example 7.13 Flow Sequence + - :white_check_mark: Example 7.14 Flow Sequence Entries + - :white_check_mark: Example 7.15 Flow Mappings + - :white_check_mark: Example 7.16 Flow Mapping Entries + - :white_check_mark: Example 7.17 Flow Mapping Separate Values + - :white_check_mark: Example 7.18 Flow Mapping Adjacent Values + - :white_check_mark: Example 7.20 Single Pair Explicit Entry + - :x: Example 7.21 Single Pair Implicit Entries + - :white_check_mark: Example 7.22 Invalid Implicit Keys + - :white_check_mark: Example 7.23 Flow Content + - :white_check_mark: Example 7.24 Flow Nodes +- 8.1. Block Scalar Styles + - :white_check_mark: Example 8.1 Block Scalar Header + - :x: Example 8.2 Block Indentation Indicator + - :white_check_mark: Example 8.3 Invalid Block Scalar Indentation Indicators + - :white_check_mark: Example 8.4 Chomping Final Line Break + - :white_check_mark: Example 8.5 Chomping Trailing Lines + - :white_check_mark: Example 8.6 Empty Scalar Chomping + - :white_check_mark: Example 8.7 Literal Scalar + - :white_check_mark: Example 8.8 Literal Content + - :white_check_mark: Example 8.9 Folded Scalar + - :white_check_mark: Example 8.10 Folded Lines + - :white_check_mark: Example 8.11 More Indented Lines + - :white_check_mark: Example 8.12 Empty Separation Lines + - :white_check_mark: Example 8.13 Final Empty Lines + - :white_check_mark: Example 8.14 Block Sequence + - :white_check_mark: Example 8.15 Block Sequence Entry Types + - :white_check_mark: Example 8.16 Block Mappings + - :white_check_mark: Example 8.17 Explicit Block Mapping Entries + - :white_check_mark: Example 8.18 Implicit Block Mapping Entries + - :white_check_mark: Example 8.19 Compact Block Mappings + - :white_check_mark: Example 8.20 Block Node Types + - :white_check_mark: Example 8.21 Block Scalar Nodes + - :white_check_mark: Example 8.22 Block Collection Nodes + +## Credits + +VYaml is inspired by: + +- [yaml-rust](https://github.com/chyh1990/yaml-rust) +- [Utf8Json](https://github.com/neuecc/Utf8Json), [MessagePack-CSharp](https://github.com/neuecc/MessagePack-CSharp), [MemoryPack](https://github.com/Cysharp/MemoryPack) + +## Aurhor + +[@hadashiA](https://github.com/hadashiA) + +## License + +MIT + diff --git a/v2/rscg_examples/VYaml/src/.tours/VYaml.tour b/v2/rscg_examples/VYaml/src/.tours/VYaml.tour new file mode 100644 index 000000000..896635090 --- /dev/null +++ b/v2/rscg_examples/VYaml/src/.tours/VYaml.tour @@ -0,0 +1,36 @@ + +{ + "$schema": "https://aka.ms/codetour-schema", + "title": "VYaml", + "steps": + [ + { + "file": "Serializer/Serializer.csproj", + "description": "First, we add Nuget [VYaml](https://www.nuget.org/packages/VYaml/) in csproj ", + "pattern": "VYaml" + } + + ,{ + "file": "Serializer/Person.cs", + "description": "File Person.cs ", + "pattern": "this is the code" + } + + ,{ + "file": "Serializer/Program.cs", + "description": "File Program.cs \r\n>> dotnet run --project Serializer/Serializer.csproj ", + "pattern": "this is the code" + } + + + ,{ + "file": "Serializer/obj/GX/VYaml.SourceGenerator/VYaml.SourceGenerator.VYamlIncrementalSourceGenerator/SerializerDemo.Person.YamlFormatter.g.cs", + "description": "Generated File 1 from 1 : SerializerDemo.Person.YamlFormatter.g.cs ", + "line": 1 + } + + ], + + "ref": "main" + +} \ No newline at end of file diff --git a/v2/rscg_examples/VYaml/src/Serializer.sln b/v2/rscg_examples/VYaml/src/Serializer.sln new file mode 100644 index 000000000..40466f7c7 --- /dev/null +++ b/v2/rscg_examples/VYaml/src/Serializer.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34031.279 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serializer", "Serializer\Serializer.csproj", "{7FC58895-BFD9-892B-A3D5-1812858E3D58}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7FC58895-BFD9-892B-A3D5-1812858E3D58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7FC58895-BFD9-892B-A3D5-1812858E3D58}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7FC58895-BFD9-892B-A3D5-1812858E3D58}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7FC58895-BFD9-892B-A3D5-1812858E3D58}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {13C14387-12AE-4C73-9EBA-2D145CD7C194} + EndGlobalSection +EndGlobal diff --git a/v2/rscg_examples/VYaml/src/Serializer/Person.cs b/v2/rscg_examples/VYaml/src/Serializer/Person.cs new file mode 100644 index 000000000..c4b6b310e --- /dev/null +++ b/v2/rscg_examples/VYaml/src/Serializer/Person.cs @@ -0,0 +1,11 @@ +using VYaml.Annotations; +namespace SerializerDemo; +[YamlObject] +public partial class Person +{ + public int Age { get; set; } + + public string Name { get; set; } = string.Empty; + +} + diff --git a/v2/rscg_examples/VYaml/src/Serializer/Program.cs b/v2/rscg_examples/VYaml/src/Serializer/Program.cs new file mode 100644 index 000000000..608769c0c --- /dev/null +++ b/v2/rscg_examples/VYaml/src/Serializer/Program.cs @@ -0,0 +1,11 @@ +using SerializerDemo; +using VYaml.Serialization; + +var p= new Person() { Name= "Andrei Ignat" , Age=55}; +var utf8Yaml = YamlSerializer.SerializeToString(p); +Console.WriteLine(utf8Yaml); +var p1 = YamlSerializer.Serialize(p); +var p2 = YamlSerializer.Deserialize(p1); + +Console.WriteLine(p2.Name); +Console.WriteLine(p2.Age); \ No newline at end of file diff --git a/v2/rscg_examples/VYaml/src/Serializer/Serializer.csproj b/v2/rscg_examples/VYaml/src/Serializer/Serializer.csproj new file mode 100644 index 000000000..23838adf9 --- /dev/null +++ b/v2/rscg_examples/VYaml/src/Serializer/Serializer.csproj @@ -0,0 +1,18 @@ + + + + Exe + net9.0 + enable + enable + + + true + $(BaseIntermediateOutputPath)\GX + + + + + + + diff --git a/v2/rscg_examples/VYaml/video.json b/v2/rscg_examples/VYaml/video.json new file mode 100644 index 000000000..46a29a197 --- /dev/null +++ b/v2/rscg_examples/VYaml/video.json @@ -0,0 +1,39 @@ +{ + "scriptName": "VYaml", + "steps": +[ + {"typeStep":"exec","arg":"clipchamp.exe launch"}, + {"typeStep":"text","arg": "Welcome to Roslyn Examples"}, + {"typeStep":"text","arg":"If you want to see more examples , see List Of RSCG"}, + {"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG"}, + {"typeStep":"text","arg": "My name is Andrei Ignat and I am deeply fond of Roslyn Source Code Generator. "}, + +{"typeStep":"text","arg": "Today I will present VYaml . Serializing to/from YAML format ."}, +{"typeStep":"browser","arg":"https://www.nuget.org/packages/VYaml/"}, +{"typeStep":"text","arg": "The whole example is here"}, +{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/VYaml"}, +{"typeStep":"text","arg": "You can download the code from here"}, +{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/VYaml#download-example-net--c-"}, +{"typeStep":"text","arg":"Here is the code downloaded "}, +{"typeStep":"exec","arg":"explorer.exe /select,D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\Vyaml\\src\\Serializer.sln"}, +{"typeStep":"text","arg": "So , let's start the project with Visual Studio Code "}, +{"typeStep":"stepvscode","arg": "-n D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\Vyaml\\src"}, + +{"typeStep":"text","arg": "To use it ,you will put the Nuget VYaml into the csproj "}, + +{"typeStep":"stepvscode","arg": "-r -g D:\\gth\\RSCG_Examples\\v2\\rscg_examples\\Vyaml\\src\\Serializer\\Serializer.csproj"}, + +{"typeStep":"text","arg": "And now I will show you an example of using VYaml"}, + +{"typeStep":"hide","arg": "now execute the tour in VSCode"}, +{"typeStep":"tour", "arg": "src/.tours/"}, +{"typeStep":"text","arg":" And I will execute the project"}, +{"typeStep":"showproj", "arg":"Serializer.csproj"}, +{"typeStep":"text","arg":" This concludes the project"}, +{"typeStep":"waitseconds","arg":"30"}, +{"typeStep":"text","arg": "Remember, you can download the code from here"}, +{"typeStep":"browser","arg":"https://ignatandrei.github.io/RSCG_Examples/v2/docs/VYaml#download-example-net--c-", +SpeakTest=" "}, +{"typeStep":"waitseconds","arg":"30"}, +] +} diff --git a/v2/rscg_examples_site/docs/Categories/Serializer.md b/v2/rscg_examples_site/docs/Categories/Serializer.md index 9e57d3837..e387056e5 100644 --- a/v2/rscg_examples_site/docs/Categories/Serializer.md +++ b/v2/rscg_examples_site/docs/Categories/Serializer.md @@ -1,6 +1,6 @@

Serializer

-Number RSCG: 9 +Number RSCG: 10 1 [GenPack](/docs/GenPack) @@ -19,4 +19,6 @@ Number RSCG: 9 8 [StackXML](/docs/StackXML) 9 [System.Text.Json](/docs/System.Text.Json) + + 10 [VYaml](/docs/VYaml) \ No newline at end of file diff --git a/v2/rscg_examples_site/docs/Categories/_PrimitiveSerializer.mdx b/v2/rscg_examples_site/docs/Categories/_PrimitiveSerializer.mdx index dd76c5931..b30a77ffd 100644 --- a/v2/rscg_examples_site/docs/Categories/_PrimitiveSerializer.mdx +++ b/v2/rscg_examples_site/docs/Categories/_PrimitiveSerializer.mdx @@ -18,6 +18,8 @@ 9 [System.Text.Json](/docs/System.Text.Json) + 10 [VYaml](/docs/VYaml) + ### See category [Serializer](/docs/Categories/Serializer) diff --git a/v2/rscg_examples_site/docs/NoExamples.md b/v2/rscg_examples_site/docs/NoExamples.md index b7efc03b5..cfed64b73 100644 --- a/v2/rscg_examples_site/docs/NoExamples.md +++ b/v2/rscg_examples_site/docs/NoExamples.md @@ -302,423 +302,419 @@ Why I have not put example: later Why I have not put example: issue opened -75)https://github.com/hadashiA/VYaml https://github.com/hadashiA/VYaml +75)https://github.com/hanachiru/RapidEnum https://github.com/hanachiru/RapidEnum Why I have not put example: later -76)https://github.com/hanachiru/RapidEnum https://github.com/hanachiru/RapidEnum +76)https://github.com/Hookyns/validly https://github.com/Hookyns/validly Why I have not put example: later -77)https://github.com/Hookyns/validly https://github.com/Hookyns/validly - -Why I have not put example: later - -78)https://github.com/inputfalken/Dynatello https://github.com/inputfalken/Dynatello +77)https://github.com/inputfalken/Dynatello https://github.com/inputfalken/Dynatello Why I have not put example: too complicated -79)https://github.com/ionite34/MinimalApiMapper https://github.com/ionite34/MinimalApiMapper +78)https://github.com/ionite34/MinimalApiMapper https://github.com/ionite34/MinimalApiMapper Why I have not put example: own idea where to generate files, so overwrites -80)https://github.com/JasonBock/CslaGeneratorSerialization https://github.com/JasonBock/CslaGeneratorSerialization +79)https://github.com/JasonBock/CslaGeneratorSerialization https://github.com/JasonBock/CslaGeneratorSerialization Why I have not put example: too complicated -81)https://github.com/nevsnirG/MinimalRichDomain https://github.com/nevsnirG/MinimalRichDomain +80)https://github.com/nevsnirG/MinimalRichDomain https://github.com/nevsnirG/MinimalRichDomain Why I have not put example: old ISourceGenerator -82)https://github.com/nuskey8/Csv-CSharp https://github.com/nuskey8/Csv-CSharp +81)https://github.com/nuskey8/Csv-CSharp https://github.com/nuskey8/Csv-CSharp Why I have not put example: later -83)https://github.com/OrgEleCho/EleCho.Internationalization https://github.com/OrgEleCho/EleCho.Internationalization +82)https://github.com/OrgEleCho/EleCho.Internationalization https://github.com/OrgEleCho/EleCho.Internationalization Why I have not put example: issue opened -84)https://github.com/pierre3/PlantUmlClassDiagramGenerator https://github.com/pierre3/PlantUmlClassDiagramGenerator +83)https://github.com/pierre3/PlantUmlClassDiagramGenerator https://github.com/pierre3/PlantUmlClassDiagramGenerator Why I have not put example: later -85)https://github.com/ramhari-dev/PropGenAoT https://github.com/ramhari-dev/PropGenAoT +84)https://github.com/ramhari-dev/PropGenAoT https://github.com/ramhari-dev/PropGenAoT Why I have not put example: no readme -86)https://github.com/stbychkov/AutoLoggerMessage https://github.com/stbychkov/AutoLoggerMessage +85)https://github.com/stbychkov/AutoLoggerMessage https://github.com/stbychkov/AutoLoggerMessage Why I have not put example: Microsoft have done same feature -87)https://github.com/Stepami/visitor-net https://github.com/Stepami/visitor-net +86)https://github.com/Stepami/visitor-net https://github.com/Stepami/visitor-net Why I have not put example: later -88)https://github.com/svee4/RequiredStaticMembers https://github.com/svee4/RequiredStaticMembers +87)https://github.com/svee4/RequiredStaticMembers https://github.com/svee4/RequiredStaticMembers Why I have not put example: issue opened -89)https://github.com/SzymonHalucha/Minerals.AutoCommands https://github.com/SzymonHalucha/Minerals.AutoCommands +88)https://github.com/SzymonHalucha/Minerals.AutoCommands https://github.com/SzymonHalucha/Minerals.AutoCommands Why I have not put example: later -90)https://github.com/Teleopti/Saspect https://github.com/Teleopti/Saspect +89)https://github.com/Teleopti/Saspect https://github.com/Teleopti/Saspect Why I have not put example: later -91)https://github.com/TheFo2sh/AsyncFlow https://github.com/TheFo2sh/AsyncFlow +90)https://github.com/TheFo2sh/AsyncFlow https://github.com/TheFo2sh/AsyncFlow Why I have not put example: too complicated -92)https://github.com/wieslawsoltes/ReactiveGenerator https://github.com/wieslawsoltes/ReactiveGenerator +91)https://github.com/wieslawsoltes/ReactiveGenerator https://github.com/wieslawsoltes/ReactiveGenerator Why I have not put example: too complicated -93)HubClientProxyGenerator https://www.nuget.org/packages/Microsoft.AspNetCore.SignalR.Client.SourceGenerator +92)HubClientProxyGenerator https://www.nuget.org/packages/Microsoft.AspNetCore.SignalR.Client.SourceGenerator Why I have not put example: not having nuget, but having IIncrementalGenerator -94)Imp.NET https://github.com/DouglasDwyer/Imp.NET +93)Imp.NET https://github.com/DouglasDwyer/Imp.NET Why I have not put example: old ISourceGenerator -95)Intellenum https://github.com/SteveDunn/Intellenum +94)Intellenum https://github.com/SteveDunn/Intellenum Why I have not put example: not understand how to use -96)InterfaceGenerator https://github.com/daver32/InterfaceGenerator +95)InterfaceGenerator https://github.com/daver32/InterfaceGenerator Why I have not put example: old ISourceGenerator -97)IoTHubClientGenerator https://github.com/alonf/IoTHubClientGenerator +96)IoTHubClientGenerator https://github.com/alonf/IoTHubClientGenerator Why I have not put example: old ISourceGenerator -98)JsonByExampleGenerator https://github.com/hermanussen/JsonByExampleGenerator +97)JsonByExampleGenerator https://github.com/hermanussen/JsonByExampleGenerator Why I have not put example: old ISourceGenerator -99)JsonDeserializeResourceSourceGenerator https://github.com/musictopia2/JsonDeserializeResourceSourceGenerator +98)JsonDeserializeResourceSourceGenerator https://github.com/musictopia2/JsonDeserializeResourceSourceGenerator Why I have not put example: no readme -100)JsonMergePatch https://github.com/ladeak/JsonMergePatch +99)JsonMergePatch https://github.com/ladeak/JsonMergePatch Why I have not put example: old ISourceGenerator -101)JsonSerializerContextGenerator https://github.com/musictopia2/JsonSerializerContextGenerator +100)JsonSerializerContextGenerator https://github.com/musictopia2/JsonSerializerContextGenerator Why I have not put example: no readme -102)JsonSourceGenerator https://github.com/Pilchie/JsonSourceGenerator +101)JsonSourceGenerator https://github.com/Pilchie/JsonSourceGenerator Why I have not put example: not having nuget, but having IIncrementalGenerator -103)JsonSrcGen https://github.com/trampster/JsonSrcGen +102)JsonSrcGen https://github.com/trampster/JsonSrcGen Why I have not put example: old ISourceGenerator -104)kli.Localize https://github.com/kl1mm/localize +103)kli.Localize https://github.com/kl1mm/localize Why I have not put example: old ISourceGenerator -105)laker https://github.com/Lakerfield/Lakerfield.Rpc +104)laker https://github.com/Lakerfield/Lakerfield.Rpc Why I have not put example: too complicated -106)lambdajection https://github.com/cythral/lambdajection +105)lambdajection https://github.com/cythral/lambdajection Why I have not put example: old ISourceGenerator -107)Lazysh https://github.com/B1Z0N/LazyshGen +106)Lazysh https://github.com/B1Z0N/LazyshGen Why I have not put example: old ISourceGenerator -108)LoggingDecoratorGenerator https://github.com/DavidFineboym/LoggingDecoratorGenerator +107)LoggingDecoratorGenerator https://github.com/DavidFineboym/LoggingDecoratorGenerator Why I have not put example: Microsoft have done same feature -109)lucide-blazor https://github.com/brecht-vde/lucide-blazor/ +108)lucide-blazor https://github.com/brecht-vde/lucide-blazor/ Why I have not put example: issue opened -110)ManagedDotnetProfiler https://github.com/kevingosse/ManagedDotnetProfiler +109)ManagedDotnetProfiler https://github.com/kevingosse/ManagedDotnetProfiler Why I have not put example: too complicated -111)MapDataReader https://github.com/jitbit/MapDataReader +110)MapDataReader https://github.com/jitbit/MapDataReader Why I have not put example: old ISourceGenerator -112)MappingCloningExtensions https://github.com/musictopia2/MappingCloningExtensions +111)MappingCloningExtensions https://github.com/musictopia2/MappingCloningExtensions Why I have not put example: no readme -113)Maui.BindableProperty.Generator https://github.com/rrmanzano/maui-bindableproperty-generator +112)Maui.BindableProperty.Generator https://github.com/rrmanzano/maui-bindableproperty-generator Why I have not put example: later -114)MediatR https://github.com/Burgyn/MMLib.MediatR.Generators +113)MediatR https://github.com/Burgyn/MMLib.MediatR.Generators Why I have not put example: old ISourceGenerator -115)MemberAccessGenerator https://github.com/ufcpp/MemberAccessGenerator +114)MemberAccessGenerator https://github.com/ufcpp/MemberAccessGenerator Why I have not put example: old ISourceGenerator -116)MemoizeSourceGenerator https://github.com/Zoxive/MemoizeSourceGenerator +115)MemoizeSourceGenerator https://github.com/Zoxive/MemoizeSourceGenerator Why I have not put example: old ISourceGenerator -117)Minerals.AutoCQRS https://github.com/SzymonHalucha/Minerals.AutoCQRS +116)Minerals.AutoCQRS https://github.com/SzymonHalucha/Minerals.AutoCQRS Why I have not put example: later -118)Minerals.AutoDomain https://github.com/SzymonHalucha/Minerals.AutoDomain +117)Minerals.AutoDomain https://github.com/SzymonHalucha/Minerals.AutoDomain Why I have not put example: later -119)MiniRazor https://github.com/Tyrrrz/MiniRazor/ +118)MiniRazor https://github.com/Tyrrrz/MiniRazor/ Why I have not put example: archived -120)MockableStaticGenerator https://github.com/HamedFathi/MockableStaticGenerator +119)MockableStaticGenerator https://github.com/HamedFathi/MockableStaticGenerator Why I have not put example: old ISourceGenerator -121)MockGen https://github.com/thomas-girotto/MockGen +120)MockGen https://github.com/thomas-girotto/MockGen Why I have not put example: old ISourceGenerator -122)MockSourceGenerator https://github.com/hermanussen/MockSourceGenerator +121)MockSourceGenerator https://github.com/hermanussen/MockSourceGenerator Why I have not put example: old ISourceGenerator -123)MrMeeseeks.DIE https://github.com/Yeah69/MrMeeseeks.DIE +122)MrMeeseeks.DIE https://github.com/Yeah69/MrMeeseeks.DIE Why I have not put example: old ISourceGenerator -124)MrMeeseeks.ResXToViewModelGenerator https://github.com/Yeah69/MrMeeseeks.ResXToViewModelGenerator +123)MrMeeseeks.ResXToViewModelGenerator https://github.com/Yeah69/MrMeeseeks.ResXToViewModelGenerator Why I have not put example: old ISourceGenerator -125)MrMeeseeks.StaticDelegateGenerator https://github.com/Yeah69/MrMeeseeks.StaticDelegateGenerator +124)MrMeeseeks.StaticDelegateGenerator https://github.com/Yeah69/MrMeeseeks.StaticDelegateGenerator Why I have not put example: old ISourceGenerator -126)MrMeeseeks.Visitor https://github.com/Yeah69/MrMeeseeks.Visitor +125)MrMeeseeks.Visitor https://github.com/Yeah69/MrMeeseeks.Visitor Why I have not put example: old ISourceGenerator -127)Neon.Roslyn https://www.nuget.org/packages/Neon.Roslyn +126)Neon.Roslyn https://www.nuget.org/packages/Neon.Roslyn Why I have not put example: old ISourceGenerator -128)net_automatic_interface https://github.com/codecentric/net_automatic_interface +127)net_automatic_interface https://github.com/codecentric/net_automatic_interface Why I have not put example: old ISourceGenerator -129)NSourceGenerators https://github.com/NeVeSpl/NSourceGenerators/ +128)NSourceGenerators https://github.com/NeVeSpl/NSourceGenerators/ Why I have not put example: old ISourceGenerator -130)observable https://github.com/notanaverageman/Bindables +129)observable https://github.com/notanaverageman/Bindables Why I have not put example: later -131)Pipelines https://github.com/DumplingsDevs/Pipelines/ +130)Pipelines https://github.com/DumplingsDevs/Pipelines/ Why I have not put example: old ISourceGenerator -132)Plastic https://github.com/sang-hyeon/Plastic +131)Plastic https://github.com/sang-hyeon/Plastic Why I have not put example: old ISourceGenerator -133)PolySharp https://github.com/Sergio0694/PolySharp +132)PolySharp https://github.com/Sergio0694/PolySharp Why I have not put example: too complicated -134)PrimaryConstructor https://github.com/chaowlert/PrimaryConstructor +133)PrimaryConstructor https://github.com/chaowlert/PrimaryConstructor Why I have not put example: old ISourceGenerator -135)PrimitiveStaticDataGenerator https://github.com/iiweis/PrimitiveStaticDataGenerator +134)PrimitiveStaticDataGenerator https://github.com/iiweis/PrimitiveStaticDataGenerator Why I have not put example: old ISourceGenerator -136)PrintMembersGenerator https://github.com/Youssef1313/PrintMembersGenerator +135)PrintMembersGenerator https://github.com/Youssef1313/PrintMembersGenerator Why I have not put example: old ISourceGenerator -137)ProxyInterfaceGenerator https://github.com/StefH/ProxyInterfaceSourceGenerator +136)ProxyInterfaceGenerator https://github.com/StefH/ProxyInterfaceSourceGenerator Why I have not put example: old ISourceGenerator -138)PureHDF https://github.com/Apollo3zehn/PureHDF +137)PureHDF https://github.com/Apollo3zehn/PureHDF Why I have not put example: old ISourceGenerator -139)RazorGen https://github.com/dartk/RazorGen +138)RazorGen https://github.com/dartk/RazorGen Why I have not put example: later -140)RazorPageRouteGenerator https://github.com/surgicalcoder/RazorPageRouteGenerator +139)RazorPageRouteGenerator https://github.com/surgicalcoder/RazorPageRouteGenerator Why I have not put example: old ISourceGenerator -141)ReForge.Union https://github.com/nalcorso/ReForge.Union +140)ReForge.Union https://github.com/nalcorso/ReForge.Union Why I have not put example: not having nuget, but having IIncrementalGenerator -142)RoslynWeave https://github.com/Jishun/RoslynWeave +141)RoslynWeave https://github.com/Jishun/RoslynWeave Why I have not put example: old ISourceGenerator -143)ScenarioTests https://github.com/koenbeuk/ScenarioTests +142)ScenarioTests https://github.com/koenbeuk/ScenarioTests Why I have not put example: old ISourceGenerator -144)SerdeDn https://github.com/serdedotnet/serde +143)SerdeDn https://github.com/serdedotnet/serde Why I have not put example: serializer. Done by MSFT with System.Text.Json -145)SmallSharp https://github.com/devlooped/SmallSharp +144)SmallSharp https://github.com/devlooped/SmallSharp Why I have not put example: old ISourceGenerator -146)SmartAnnotations https://github.com/fiseni/SmartAnnotations +145)SmartAnnotations https://github.com/fiseni/SmartAnnotations Why I have not put example: old ISourceGenerator -147)SogePoco https://github.com/d-p-y/SogePoco +146)SogePoco https://github.com/d-p-y/SogePoco Why I have not put example: too complicated -148)SourceApi https://github.com/alekshura/SourceApi +147)SourceApi https://github.com/alekshura/SourceApi Why I have not put example: old ISourceGenerator -149)SourceConfig https://github.com/alekshura/SourceConfig +148)SourceConfig https://github.com/alekshura/SourceConfig Why I have not put example: old ISourceGenerator -150)SourceCrafter.HttpServiceClientGenerator https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/ +149)SourceCrafter.HttpServiceClientGenerator https://github.com/pedro-gilmora/SourceCrafter.HttpServiceClientGenerator/ Why I have not put example: later -151)SourceGeneratorQuery https://github.com/roeibajayo/SourceGeneratorQuery +150)SourceGeneratorQuery https://github.com/roeibajayo/SourceGeneratorQuery Why I have not put example: old ISourceGenerator -152)SourceInject https://github.com/giggio/sourceinject/ +151)SourceInject https://github.com/giggio/sourceinject/ Why I have not put example: old ISourceGenerator -153)SourceMapper https://github.com/alekshura/SourceMapper +152)SourceMapper https://github.com/alekshura/SourceMapper Why I have not put example: old ISourceGenerator -154)SourceMapper https://github.com/paiden/SourceMapper/ +153)SourceMapper https://github.com/paiden/SourceMapper/ Why I have not put example: old ISourceGenerator -155)SqlMarshal https://github.com/kant2002/SqlMarshal +154)SqlMarshal https://github.com/kant2002/SqlMarshal Why I have not put example: old ISourceGenerator -156)ST.NSwag.ServerSourceGenerator https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator +155)ST.NSwag.ServerSourceGenerator https://github.com/s-tarasov/ST.NSwag.ServerSourceGenerator Why I have not put example: later -157)StackXML https://github.com/ZingBallyhoo/StackXML +156)StackXML https://github.com/ZingBallyhoo/StackXML Why I have not put example: old ISourceGenerator -158)StaticProxyGenerator https://github.com/robertturner/StaticProxyGenerator +157)StaticProxyGenerator https://github.com/robertturner/StaticProxyGenerator Why I have not put example: old ISourceGenerator -159)StrongInject https://github.com/YairHalberstadt/stronginject/ +158)StrongInject https://github.com/YairHalberstadt/stronginject/ Why I have not put example: later -160)StronglyTypedEmbeddedResources https://github.com/surgicalcoder/StronglyTypedEmbeddedResources +159)StronglyTypedEmbeddedResources https://github.com/surgicalcoder/StronglyTypedEmbeddedResources Why I have not put example: old ISourceGenerator -161)StructPacker https://github.com/RudolfKurka/StructPacker +160)StructPacker https://github.com/RudolfKurka/StructPacker Why I have not put example: old ISourceGenerator -162)Svg https://github.com/wieslawsoltes/Svg.Skia +161)Svg https://github.com/wieslawsoltes/Svg.Skia Why I have not put example: old ISourceGenerator -163)tecli https://github.com/tyevco/TeCLI +162)tecli https://github.com/tyevco/TeCLI Why I have not put example: old ISourceGenerator -164)TeuJson https://github.com/Terria-K/TeuJson +163)TeuJson https://github.com/Terria-K/TeuJson Why I have not put example: json a class, was done in System.Text.Json -165)Thunderboltloc https://github.com/AlyElhaddad/ThunderboltIoc +164)Thunderboltloc https://github.com/AlyElhaddad/ThunderboltIoc Why I have not put example: old ISourceGenerator -166)Tinyhand https://github.com/archi-Doc/Tinyhand +165)Tinyhand https://github.com/archi-Doc/Tinyhand Why I have not put example: tried, need documentation -167)ToString https://github.com/Burgyn/MMLib.ToString +166)ToString https://github.com/Burgyn/MMLib.ToString Why I have not put example: old ISourceGenerator -168)Transplator https://github.com/atifaziz/Transplator +167)Transplator https://github.com/atifaziz/Transplator Why I have not put example: old ISourceGenerator -169)TupleOverloadGenerator https://github.com/ProphetLamb/TupleOverloadGenerator +168)TupleOverloadGenerator https://github.com/ProphetLamb/TupleOverloadGenerator Why I have not put example: too complicated -170)TxtToListGenerator https://github.com/musictopia2/TxtToListGenerator +169)TxtToListGenerator https://github.com/musictopia2/TxtToListGenerator Why I have not put example: no readme -171)TypealizR https://github.com/earloc/TypealizR +170)TypealizR https://github.com/earloc/TypealizR Why I have not put example: depends on Microsoft.Extensions.Localization -172)UnitTestBlazor https://github.com/bUnit-dev/bUnit +171)UnitTestBlazor https://github.com/bUnit-dev/bUnit Why I have not put example: issue opened -173)ValueChangedGenerator https://github.com/ufcpp/ValueChangedGenerator +172)ValueChangedGenerator https://github.com/ufcpp/ValueChangedGenerator Why I have not put example: old ISourceGenerator -174)ValueLink https://github.com/archi-Doc/ValueLink +173)ValueLink https://github.com/archi-Doc/ValueLink Why I have not put example: too complicated -175)ValueObjectGenerator https://github.com/RyotaMurohoshi/ValueObjectGenerator +174)ValueObjectGenerator https://github.com/RyotaMurohoshi/ValueObjectGenerator Why I have not put example: old ISourceGenerator -176)VisitorPatternGenerator https://github.com/hikarin522/VisitorPatternGenerator/ +175)VisitorPatternGenerator https://github.com/hikarin522/VisitorPatternGenerator/ Why I have not put example: issue opened -177)Visor https://github.com/Tinkoff/Visor +176)Visor https://github.com/Tinkoff/Visor Why I have not put example: archived -178)WrapperValueObject https://github.com/martinothamar/WrapperValueObject +177)WrapperValueObject https://github.com/martinothamar/WrapperValueObject Why I have not put example: not maintained as in readme -179)Xtz.StronglyTyped https://github.com/dev-experience/Xtz.StronglyTyped +178)Xtz.StronglyTyped https://github.com/dev-experience/Xtz.StronglyTyped Why I have not put example: old ISourceGenerator diff --git a/v2/rscg_examples_site/docs/RSCG-Examples/VYaml.md b/v2/rscg_examples_site/docs/RSCG-Examples/VYaml.md new file mode 100644 index 000000000..a7bf4924a --- /dev/null +++ b/v2/rscg_examples_site/docs/RSCG-Examples/VYaml.md @@ -0,0 +1,1246 @@ +--- +sidebar_position: 2330 +title: 233 - VYaml +description: Serializing to/from YAML format +slug: /VYaml +--- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import TOCInline from '@theme/TOCInline'; +import SameCategory from '../Categories/_PrimitiveSerializer.mdx'; + +# VYaml by Hadashi A + + + + +## NuGet / site data +[![Nuget](https://img.shields.io/nuget/dt/VYaml?label=VYaml)](https://www.nuget.org/packages/VYaml/) +[![GitHub last commit](https://img.shields.io/github/last-commit/hadashiA/VYaml?label=updated)](https://github.com/hadashiA/VYaml) +![GitHub Repo stars](https://img.shields.io/github/stars/hadashiA/VYaml?style=social) + +## Details + +### Info +:::info + +Name: **VYaml** + +The extra fast YAML library for C# + +Author: Hadashi A + +NuGet: +*https://www.nuget.org/packages/VYaml/* + + +You can find more details at https://github.com/hadashiA/VYaml + +Source: https://github.com/hadashiA/VYaml + +::: + +### Author +:::note +Hadashi A +![Alt text](https://github.com/hadashiA.png) +::: + +### Original Readme +:::note + +# VYaml + +[![GitHub license](https://img.shields.io/github/license/hadashiA/VYaml)](https://github.com/hadashiA/VYaml/LICENSE) +![Unity 2022.2+](https://img.shields.io/badge/unity-2021.3+-000.svg) +[![NuGet](https://img.shields.io/nuget/v/VYaml.svg)](https://www.nuget.org/packages/VYaml) + +VYaml is a pure C# YAML 1.2 implementation, which is extra fast, low memory footprint with focued on .NET and Unity. + +- The parser is heavily influenced by [yaml-rust](https://github.com/chyh1990/yaml-rust), and libyaml, yaml-cpp. +- Serialization interface/implementation is heavily influenced by [Utf8Json](https://github.com/neuecc/Utf8Json), [MessagePack-CSharp](https://github.com/neuecc/MessagePack-CSharp), [MemoryPack](https://github.com/Cysharp/MemoryPack). + +The reason VYaml is fast is it handles utf8 byte sequences directly with newface api set of C# (`System.Buffers.*`, etc). +In parsing, scalar values are pooled and no allocation occurs until `Scalar.ToString()`. This works with very low memory footprint and low performance overhead, in environments such as Unity. + +![screenshot_benchmark_dotnet.png](https://github.com/hadashiA/VYaml/screenshots/screenshot_benchmark_dotnet.png) +![screenshot_benchmark_unity.png](https://github.com/hadashiA/VYaml/screenshots/screenshot_benchmark_unity.png) + +Compared with [YamlDotNet](https://github.com/aaubry/YamlDotNet) (most popular yaml library in C#), basically 6x faster and about 1/50 heap allocations in some case. + + +## Features + +- YAML Parser (Reader) + - [YAML 1.2 mostly supported](#httpsyamlorgspec122) + - Support Unity serialized weird YAML format + - https://forum.unity.com/threads/scene-files-invalid-yaml.355653/ + - YAML automatically generated by Unity may contain the symbol `"stripped"` in the document start line. This is against the YAML specification, but VYaml supports this format. +- YAML Emitter (Writer) + - Write primitive types. + - Write plain scalar, double-quoted scalar, literal scalar. + - Write block style sequence, flow style sequence, and block mapping. +- Deserialize / Serialize + - Convert between YAML and C# user-defined types. + - Convert between YAML and primitive collection via `dynamic` . + - Support interface-typed and abstract class-typed objects. + - Support anchor (`&`) and alias (`*`) in the YAML spec. + - Support multiple yaml documents to C# collection. + - Customization + - Rename key + - Ignore member +- Mainly focused on Unity + - Only 2021.3 and higher (netstandard2.1 compatible) + +## Most recent roadmap + +- [ ] Support node tree representation + +## Installation + +### NuGet + +You can install the following nuget package. +https://www.nuget.org/packages/VYaml + +```bash +dotnet add package VYaml +``` + +### Unity + +> [!IMPORTANT] +> Starting with version 1.0, VYaml is now via NuGetForUnity. +> If you are using an older version, please follow these instructions to reinstall. + +> [!NOTE] +> Requirements: Unity 2021.3 or later. + +1. Install NugetForUnity. +2. Open the NuGet window by going to NuGet > Manage NuGet Packages, search for the "VYaml" package, and install it. +3. (Optional) Installing Unity-specific extensions: + - Open the Package Manager window by selecting Window > Package Manager, then click on [+] > Add package from git URL and enter the following URL: + - ``` + https://github.com/hadashiA/VYaml.git?path=VYaml.Unity/Assets/VYaml#1.2.0 + ``` + +## Usage + +### Serialize / Deserialize + +Define a struct or class to be serialized and annotate it with the `[YamlObject]` attribute and the partial keyword. + +```csharp +using VYaml.Annotations; + +[YamlObject] +public partial class Sample +{ + // By default, public fields and properties are serializable. + public string A; // public field + public string B \{ get; set; \} // public property + public string C \{ get; private set; \} // public property (private setter) + public string D \{ get; init; \} // public property (init-only setter) + + // use `[YamlIgnore]` to remove target of a public member + [YamlIgnore] + public int PublicProperty2 => PublicProperty + PublicField; +} +``` + +Why partial is necessary ? +- VYaml uses [SourceGenerator](https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview) for metaprogramming, which supports automatic generation of partial declarations, sets to private fields. + +``` csharp +var utf8Yaml = YamlSerializer.Serialize(new Sample +{ + A = "hello", + B = "foo", + C = "bar", + D = "hoge", +}); +``` + + +Result: + +```yaml +a: hello +b: foo +c: bar +d: hoge +``` + +By default, The `Serialize` method returns an utf8 byte array. +This is because it is common for writes to files or any data stores to be stored as strings in utf8 format. + + +If you wish to receive the results in a C# string, do the following +Note that this has the overhead of conversion to utf16. + +``` csharp +var yamlString = YamlSerializer.SerializeToString(...); +``` + +You can also convert yaml to C#. + +```csharp +using var stream = File.OpenRead("/path/to/yaml"); +var sample = await YamlSerializer.DeserializeAsync(stream); + +// Or +// var yamlUtf8Bytes = System.Text.Encoding.UTF8.GetBytes(""); +// var sample = YamlSerializer.Deserialize(yamlUtf8Bytes); +``` + +```csharp +sample.A // #=> "hello" +sample.B // #=> "foo" +sample.C // #=> "bar" +sample.D // #=> "hoge" +``` + +#### Built-in supported types + +These types can be serialized by default: + +- .NET primitives (`byte`, `int`, `bool`, `char`, `double`, etc.) +- Any enum (Currently, only simple string representation) +- `string`, `decimal`, `Half`, `BigInteger`, `Complex` +- `TimeSpan`, `DateTime`, `DateTimeOffset` +- `Guid`, `Uri`, `Version`, `Type` +- `byte[]` as base64 string +- `T[]`, `T[,]`, `T[,,]`, `T[,,]`, `BitArray` +- `Nullable<>`, `KeyValuePair<,>`, `Tuple<,...>`, `ValueTuple<,...>` +- `List<>`, `Stack<>`, `Queue<>`, `LinkedList<>`, `HashSet<>`, `SortedSet<>`, `BlockingCollection<>`, `ConcurrentQueue<>`, `ConcurrentStack<>`, `ConcurrentBag<>` +- `Dictionary<,>` +- `IEnumerable<>`, `ICollection<>`, `IList<>`, `IReadOnlyCollection<>`, `IReadOnlyList<>`, `ISet<>` +- `IDictionary<,>`, `IReadOnlyDictionary<,>` + +The following types of support are included in the package for Unity. + +- `Color`, `Color32` +- `Vector2`, `Vector2Int`, `Vector3`, `Vector3Int`, `Vector4`, `Vector4Int` +- `Matrix4x4` +- `Quaternion` +- `Rect`, `RectInt`, `RectOffset` +- Addtionaly, If the `Unity.Mathmatics` package is installed, the following support is enabled: + - `bool2`, `bool3`, `bool4` + - `float2`, `float3`, `float4` + - `double2`, `double3`, `double4` + - `half2`, `half3`, `half4` + - `int2`, `int3`, `int4` + - `uint2`, `uint3`, `uint4` + - `bool2x2`, `bool2x3`, `bool2x4`, `bool3x2`, `bool3x3`, `bool3x4`, `bool4x2`, `bool4x3`, `bool4x4` + - `float2x2`, `float2x3`, `float2x4`, `float3x2`, `float3x3`, `float3x4`, `float4x2`, `float4x3`, `float4x4` + - `double2x2`, `double2x3`, `double2x4`, `double3x2`, `double3x3`, `double3x4`, `double4x2`, `double4x3`, `double4x4` + - `int2x2`, `int2x3`, `int2x4`, `int3x2`, `int3x3`, `int3x4`, `int4x2`, `int4x3`, `int4x4` + - `uint2x2`, `uint2x3`, `uint2x4`, `uint3x2`, `uint3x3`, `uint3x4`, `uint4x2`, `uint4x3`, `uint4x4` + - `quaternion` + + +- To enable it, do the following +1. Install the unity package. + - See [Installation/Unity](#unity) section. +2. Add UnityResolver to YamlSeriarOptions. + - ```cs + YamlSerializer.DefaultOptions = new YamlSerializerOptions + { + Resolver = CompositeResolver.Create(new IYamlFormatterResolver[] + { + StandardResolver.Instance, + UnityResolver.Instance, + }) + }; + ``` + +#### Deserialize as `dynamic` + +You can also deserialize into primitive `object` type implicitly. + +``` csharp +var yaml = YamlSerializer.Deserialize(yamlUtf8Bytes); +``` + +```csharp +yaml["a"] // #=> "hello" +yaml["b"] // #=> "aaa" +yaml["c"] // #=> "hoge" +yaml["d"] // #=> "ddd" +``` + +#### Deserialize multiple documents + + +YAML allows for multiple data in one file by separating them with `---`. This is called a "Document". +If you want to load multiple documents, you can use `Yamlserializer.DeserializeMultipleDocuments(...)`. + +For example: + +``` yaml +--- +Time: 2001-11-23 15:01:42 -5 +User: ed +Warning: + This is an error message + for the log file +--- +Time: 2001-11-23 15:02:31 -5 +User: ed +Warning: + A slightly different error + message. +--- +Date: 2001-11-23 15:03:17 -5 +User: ed +Fatal: + Unknown variable "bar" +Stack: +- file: TopClass.py + line: 23 + code: | + x = MoreObject("345\n") +- file: MoreClass.py + line: 58 + code: |- + foo = bar +``` + +``` csharp +var documents = YamlSerializer.DeserializeMultipleDocuments(yaml); +``` + +```csharp +documents[0]["Warning"] // #=> "This is an error message for the log file" +documents[1]["Warning"] // #=> "A slightly different error message." +documents[2]["Fatal"] // #=> "Unknown variable \"bar\"" +``` + +#### Naming convention + +:exclamation: By default, VYaml maps C# property names in lower camel case (e.g. `propertyName`) format to yaml keys. + +If you want to customize this behaviour, `YamlSerializerOptions.NamingConvention` to set it. + +```cs +var options = YamlSerializerOptions.Standard; +options.NamingConvention = NamingConvention.SnakeCase; + +YamlSerializer.Serialize(new A \{ FooBar = 123 }, options); // #=> "{ foo_bar: 123 }" +``` + +List of possible values: +- NamingConvention.LowerCamelCase + - Like `propertyName` +- NamingConvention.UpperCamelCase: + - Like `PropertyName` +- NamingConvention.SnakeCase: + - Like `property_name` +- NamingConvention.KebabCase: + - Like `property-name` + + +> [!TIP] +> If you specify an option other than the default `LowerCamelCase`, there will be a slight performance degradation at runtime. + +You may specify NamingConvention for each type declaration by `[YamlObject]` attribute. +In this case, no performance degradation occurs. + +```csharp +[YamlObject(NamingConvention.SnakeCase)] +public partial class Sample +{ + public int FooBar \{ get; init; } +} +``` + +This serialize as: + +```yaml +foo_bar: 100 +``` + +Also, you can change the key name each members with `[YamlMember("name")]` + +```csharp +[YamlObject] +public partial class Sample +{ + [YamlMember("foo-bar-alias")] + public int FooBar \{ get; init; } +} +``` + +This serialize as: + +```yaml +foo-bar-alias: 100 +``` + +#### Custom constructor + +VYaml supports both parameterized and parameterless constructors. The selection of the constructor follows these rules. + +- If there is `[YamlConstructor]`, use it. +- If there is no explicit constructor use a parameterless one. +- If there is one constructor use it. +- If there are multiple constructors, then the `[YamlConstructor]` attribute must be applied to the desired constructor (the generator will not automatically choose one), otherwise the generator will emit an error. + +:note: If using a parameterized constructor, all parameter names must match corresponding member names (case-insensitive). + +``` csharp +[YamlObject] +public partial class Person +{ + public int Age \{ get; \} + public string Name \{ get; } + + // You can use a parameterized constructor - parameter names must match corresponding members name (case-insensitive) + public Person(int age, string name) + { + Age = age; + Name = name; + } +} + +[YamlObject] +public partial class Person +{ + public int Age \{ get; set; } + public string Name \{ get; set; } + + public Person() + { + // ... + } + + // If there are multiple constructors, then [YamlConstructor] should be used + [YamlConstructor] + public Person(int age, string name) + { + this.Age = age; + this.Name = name; + } +} + + +[YamlObject] +public partial class Person +{ + public int Age \{ get; \} // from constructor + public string Name \{ get; \} // from constructor + public string Profile \{ get; set; \} // from setter + + // If all members of the construct are not taken as arguments, setters are used for the other members + public Person(int age, string name) + { + this.Age = age; + this.Name = name; + } +} +``` + +#### Enum + +By default, Enum is serialized in camelCase with a leading lowercase letter, as is the key name of the object. +For example: + +``` csharp +enum Foo +{ + Item1, + Item2, + Item3, +} +``` + +``` csharp +YamlSerializer.Serialize(Foo.Item1); // #=> "item1" +``` + +It respect `[EnumMember]`, and `[DataMember]`. + + +``` csharp +enum Foo +{ + [EnumMember(Value = "item1-alias")] + Item1, + + [EnumMember(Value = "item2-alias")] + Item2, + + [EnumMember(Value = "item3-alias")] + Item3, +} +``` + +``` csharp +YamlSerializer.Serialize(Foo.Item1); // #=> "item1-alias" +``` + +And, naming covnention can also be specified by using the `[YamlMember]` attribute. + + +``` csharp +[YamlObject(NamingConvention.SnakeCase)] +enum Foo +{ + ItemOne, + ItemTwo, + ItemThree, +} +``` + +``` csharp +YamlSerializer.Serialize(Foo.ItemOne); // #=> "item_one" +``` + +#### Polymorphism (Union) + +VYaml supports deserialize interface or abstract class objects for. In VYaml this feature is called Union. +Only interfaces and abstracts classes are allowed to be annotated with `[YamlObjectUnion]` attributes. Unique union tags are required. + +``` csharp +[YamlObject] +[YamlObjectUnion("!foo", typeof(FooClass))] +[YamlObjectUnion("!bar", typeof(BarClass))] +public partial interface IUnionSample +{ +} + +[YamlObject] +public partial class FooClass : IUnionSample +{ + public int A \{ get; set; } +} + +[YamlObject] +public partial class BarClass : IUnionSample +{ + public string? B \{ get; set; } +} +``` + +``` csharp +// We can deserialize as interface type. +var obj = YamlSerializer.Deserialize(UTF8.GetBytes("!foo \{ a: 100 }")); + +obj.GetType(); // #=> FooClass +``` + +In the abobe example, The `!foo` and `!bar` are called tag in the YAML specification. +YAML can mark arbitrary data in this way, and VYaml Union takes advantage of this. + +You can also serialize: + +``` csharp +YamlSerializer.Serialize(new FooClass \{ A = 100 }); +``` + +Result: +``` yaml +!foo +a: 100 +``` + +## Customize serialization behaviour + +- `IYamlFormatter<T>` is an interface customize the serialization behaviour of a your particular type. +- `IYamlFormatterResolver` is an interface can customize how it searches for `IYamlFormatter<T>` at runtime. + +To perform Serialize/Deserialize, it need an `IYamlFormatter<T>` corresponding to a certain C# type. +By default, the following `StandardResolver` works and identifies IYamlFormatter<T>. + + +You can customize this behavior as follows: + +``` csharp +var options = new YamlSerializerOptions +{ + Resolver = CompositeResolver.Create( + new IYamlFormatter[] + { + new YourCustomFormatter1(), // You can add additional formatter + }, + new IYamlFormatterResolver[] + { + new YourCustomResolver(), // You can add additional resolver + StandardResolver.Instance, // Fallback to default behavior at the end. + }) +}; + +YamlSerializer.Deserialize(yaml, options); +YamlSerializer.Deserialize(yaml, options); +``` + + +## Low-Level API + +### Parser + +`YamlParser` struct provides access to the complete meta-information of yaml. + + +- `YamlParser.Read()` reads through to the next syntax on yaml. (If end of stream then return false.) +- `YamlParser.ParseEventType` indicates the state of the currently read yaml parsing result. +- How to access scalar value: + - `YamlParser.GetScalarAs*` families take the result of converting a scalar at the current position to a specified type. + - `YamlParser.TryGetScalarAs*` families return true and take a result if the current position is a scalar and of the specified type. + - `YamlParser.ReadScalarAs*` families is similar to GetScalarAs*, but advances the present position to after the scalar read. +- How to access meta information: + - `YamlParser.TryGetCurrentTag(out Tag tag)` + - `YamlParser.TryGetCurrentAnchor(out Anchor anchor)` + +Basic example: + +```csharp +var parser = YamlParser.FromBytes(utf8Bytes); + +// YAML contains more than one `Document`. +// Here we skip to before first document content. +parser.SkipAfter(ParseEventType.DocumentStart); + +// Scanning... +while (parser.Read()) +{ + // If the current syntax is Scalar, + if (parser.CurrentEventType == ParseEventType.Scalar) + { + var intValue = parser.GetScalarAsInt32(); + var stringValue = parser.GetScalarAsString(); + // ... + + if (parser.TryGetCurrentTag(out var tag)) + { + // Check for the tag... + } + + if (parser.TryGetCurrentAnchor(out var anchor)) + { + // Check for the anchor... + \} + } + + // If the current syntax is Sequence (Like a list in yaml) + else if (parser.CurrentEventType == ParseEventType.SequenceStart) + { + // We can check for the tag... + // We can check for the anchor... + + parser.Read(); // Skip SequenceStart + + // Read to end of sequence + while (!parser.End && parser.CurrentEventType != ParseEventType.SequenceEnd) + { + // A sequence element may be a scalar or other... + if (parser.CurrentEventType == ParseEventType.Scalar) + { + // ... + } + // ... + // ... + else + { + // We can skip current element. (It could be a scalar, or alias, sequence, mapping...) + parser.SkipCurrentNode(); + } + } + parser.Read(); // Skip SequenceEnd. + } + + // If the current syntax is Mapping (like a Dictionary in yaml) + else if (parser.CurrentEventType == ParseEventType.MappingStart) + { + // We can check for the tag... + // We can check for the anchor... + + parser.Read(); // Skip MappingStart + + // Read to end of mapping + while (parser.CurrentEventType != ParseEventType.MappingEnd) + { + // After Mapping start, key and value appear alternately. + + var key = parser.ReadScalarAsString(); // if key is scalar + var value = parser.ReadScalarAsString(); // if value is scalar + + // Or we can skip current key/value. (It could be a scalar, or alias, sequence, mapping...) + // parser.SkipCurrentNode(); // skip key + // parser.SkipCurrentNode(); // skip value + } + parser.Read(); // Skip MappingEnd. + } + + // Alias + else if (parser.CurrentEventType == ParseEventType.Alias) + { + // If Alias is used, the previous anchors must be holded somewhere. + // In the High level Deserialize API, `YamlDeserializationContext` does exactly this. + } +} +``` + +See [test code](https://github.com/hadashiA/VYaml/blob/master/VYaml.Tests/Parser/SpecTest.cs) for more information. +The above test covers various patterns for the order of `ParsingEvent`. + + +### Emitter + +`Utf8YamlEmitter` struct provides to write YAML formatted string. + +Basic usage: + +``` csharp +var buffer = new ArrayBufferWriter(); +var emitter = new Utf8YamlEmitter(buffer); // It needs buffer implemented `IBufferWriter` + +emitter.BeginMapping(); // Mapping is a collection like Dictionary in YAML +{ + emitter.WriteString("key1"); + emitter.WriteString("value-1"); + + emitter.WriteString("key2"); + emitter.WriteInt32(222); + + emitter.WriteString("key3"); + emitter.WriteFloat(3.333f); +} +emitter.EndMapping(); +``` + +``` csharp +// If you want to expand a string in memory, you can do this. +System.Text.Encoding.UTF8.GetString(buffer.WrittenSpan); +``` + +``` yaml +key1: value-1 +key2: 222 +key3: 3.333 +``` + +#### Emit string in various formats + +By default, WriteString() automatically determines the format of a scalar. + + +Multi-line strings are automatically format as a literal scalar: + +``` csharp +emitter.WriteString("Hello,\nWorld!\n"); +``` + +``` yaml +| + Hello, + World! +``` + +Special characters contained strings are automatically quoted. + +``` csharp +emitter.WriteString("&aaaaa "); +``` + +``` yaml +"&aaaaa " +``` + +Or you can specify the style explicitly: + +``` csharp +emitter.WriteString("aaaaaaa", ScalarStyle.Literal); +``` + +``` yaml +|- + aaaaaaaa +``` + +#### Emit sequences and other structures + +e.g: + +``` csharp +emitter.BeginSequence(); +{ + emitter.BeginSequence(SequenceStyle.Flow); + { + emitter.WriteInt32(100); + emitter.WriteString("&hoge"); + emitter.WriteString("bra"); + } + emitter.EndSequence(); + + emitter.BeginMapping(); + { + emitter.WriteString("key1"); + emitter.WriteString("item1"); + + emitter.WriteString("key2"); + emitter.BeginSequence(); + { + emitter.WriteString("nested-item1") + emitter.WriteString("nested-item2") + emitter.BeginMapping(); + { + emitter.WriteString("nested-key1") + emitter.WriteInt32(100) + } + emitter.EndMapping(); + } + emitter.EndSequence(); + } + emitter.EndMapping(); +} +emitter.EndMapping(); +``` + +``` yaml +- [100, "&hoge", bra] +- key1: item1 + key2: + - nested-item1 + - nested-item2 + - nested-key1: 100 +``` + +## YAML 1.2 spec support status + +### Implicit primitive type conversion of scalar + +The following is the default implicit type interpretation. + +Basically, it follows YAML Core Schema. +https://yaml.org/spec/1.2.2/#103-core-schema + +|Support|Regular expression|Resolved to type| +|:-----|:-------|:-------| +| :white_check_mark: | `null \| Null \| NULL \| ~` | null | +| :white_check_mark: | `/* Empty */` | null | +| :white_check_mark: | `true \| True \| TRUE \| false \| False \| FALSE` | boolean | +| :white_check_mark: | `[-+]? [0-9]+` | int (Base 10) | +| :white_check_mark: | `0o [0-7]+` | int (Base 8) | +| :white_check_mark: | `0x [0-9a-fA-F]+` | int (Base 16) | +| :white_check_mark: | `[-+]? ( \. [0-9]+ \| [0-9]+ ( \. [0-9]* )? ) ( [eE] [-+]? [0-9]+ )?` | float | +| :white_check_mark: | `[-+]? ( \.inf \| \.Inf \| \.INF )` | float (Infinity) | +| :white_check_mark: | `\.nan \| \.NaN \| \.NAN` | float (Not a number) | + +### https://yaml.org/spec/1.2.2/ + +Following is the results of the [test](https://github.com/hadashiA/VYaml/blob/master/VYaml.Tests/Parser/SpecTest.cs) for the examples from the [yaml spec page](https://yaml.org/spec/1.2.2/). + +- 2.1. Collections + - :white_check_mark: Example 2.1 Sequence of Scalars (ball players) + - :white_check_mark: Example 2.2 Mapping Scalars to Scalars (player statistics) + - :white_check_mark: Example 2.3 Mapping Scalars to Sequences (ball clubs in each league) + - :white_check_mark: Example 2.4 Sequence of Mappings (players statistics) + - :white_check_mark: Example 2.5 Sequence of Sequences + - :white_check_mark: Example 2.6 Mapping of Mappings +- 2.2. Structures + - :white_check_mark: Example 2.7 Two Documents in a Stream (each with a leading comment) + - :white_check_mark: Example 2.8 Play by Play Feed from a Game + - :white_check_mark: Example 2.9 Single Document with Two Comments + - :white_check_mark: Example 2.10 Node for Sammy Sosa appears twice in this document + - :white_check_mark: Example 2.11 Mapping between Sequences + - :white_check_mark: Example 2.12 Compact Nested Mapping +- 2.3. Scalars + - :white_check_mark: Example 2.13 In literals, newlines are preserved + - :white_check_mark: Example 2.14 In the folded scalars, newlines become spaces + - :white_check_mark: Example 2.15 Folded newlines are preserved for more indented and blank lines + - :white_check_mark: Example 2.16 Indentation determines scope + - :white_check_mark: Example 2.17 Quoted Scalars + - :white_check_mark: Example 2.18 Multi-line Flow Scalars +- 2.4. Tags + - :white_check_mark: Example 2.19 Integers + - :white_check_mark: Example 2.20 Floating Point + - :white_check_mark: Example 2.21 Miscellaneous + - :white_check_mark: Example 2.22 Timestamps + - :white_check_mark: Example 2.23 Various Explicit Tags + - :white_check_mark: Example 2.24 Global Tags + - :white_check_mark: Example 2.25 Unordered Sets + - :white_check_mark: Example 2.26 Ordered Mappings +- 2.5. Full Length Example + - :white_check_mark: Example 2.27 Invoice + - :white_check_mark: Example 2.28 Log File +- 5.2. Character Encodings + - :white_check_mark: Example 5.1 Byte Order Mark + - :white_check_mark: Example 5.2 Invalid Byte Order Mark +- 5.3. Indicator Characters + - :white_check_mark: Example 5.3 Block Structure Indicators + - :white_check_mark: Example 5.4 Flow Collection Indicators + - :white_check_mark: Example 5.5 Comment Indicator + - :white_check_mark: Example 5.6 Node Property Indicators + - :white_check_mark: Example 5.7 Block Scalar Indicators + - :white_check_mark: Example 5.8 Quoted Scalar Indicators + - :white_check_mark: Example 5.9 Directive Indicator + - :white_check_mark: Example 5.10 Invalid use of Reserved Indicators +- 5.4. Line Break Characters + - :white_check_mark: Example 5.11 Line Break Characters + - :white_check_mark: Example 5.12 Tabs and Spaces + - :white_check_mark: Example 5.13 Escaped Characters + - :white_check_mark: Example 5.14 Invalid Escaped Characters +- 6.1. Indentation Spaces + - :white_check_mark: Example 6.1 Indentation Spaces + - :white_check_mark: Example 6.2 Indentation Indicators +- 6.2. Separation Spaces + - :white_check_mark: Example 6.3 Separation Spaces +- 6.3. Line Prefixes + - :white_check_mark: Example 6.4 Line Prefixes +- 6.4. Empty Lines + - :white_check_mark: Example 6.5 Empty Lines +- 6.5. Line Folding + - :white_check_mark: Example 6.6 Line Folding + - :white_check_mark: Example 6.7 Block Folding + - :white_check_mark: Example 6.8 Flow Folding +- 6.6. Comments + - :white_check_mark: Example 6.9 Separated Comment + - :white_check_mark: Example 6.10 Comment Lines + - :white_check_mark: Example 6.11 Multi-Line Comments +- 6.7. Separation Lines + - :white_check_mark: Example 6.12 Separation Spaces +- 6.8. Directives + - :white_check_mark: Example 6.13 Reserved Directives + - :white_check_mark: Example 6.14 YAML directive + - :white_check_mark: Example 6.15 Invalid Repeated YAML directive + - :white_check_mark: Example 6.16 TAG directive + - :white_check_mark: Example 6.17 Invalid Repeated TAG directive + - :white_check_mark: Example 6.18 Primary Tag Handle + - :white_check_mark: Example 6.19 Secondary Tag Handle + - :white_check_mark: Example 6.20 Tag Handles + - :white_check_mark: Example 6.21 Local Tag Prefix + - :white_check_mark: Example 6.22 Global Tag Prefix +- 6.9. Node Properties + - :white_check_mark: Example 6.23 Node Properties + - :white_check_mark: Example 6.24 Verbatim Tags + - :white_check_mark: Example 6.25 Invalid Verbatim Tags + - :white_check_mark: Example 6.26 Tag Shorthands + - :white_check_mark: Example 6.27 Invalid Tag Shorthands + - :white_check_mark: Example 6.28 Non-Specific Tags + - :white_check_mark: Example 6.29 Node Anchors +- 7.1. Alias Nodes + - :white_check_mark: Example 7.1 Alias Nodes +- 7.2. Empty Nodes + - :white_check_mark: Example 7.2 Empty Content + - :white_check_mark: Example 7.3 Completely Empty Flow Nodes +- 7.3. Flow Scalar Styles + - :white_check_mark: Example 7.4 Double Quoted Implicit Keys + - :white_check_mark: Example 7.5 Double Quoted Line Breaks + - :white_check_mark: Example 7.6 Double Quoted Lines + - :white_check_mark: Example 7.7 Single Quoted Characters + - :white_check_mark: Example 7.8 Single Quoted Implicit Keys + - :white_check_mark: Example 7.9 Single Quoted Lines + - :white_check_mark: Example 7.10 Plain Characters + - :white_check_mark: Example 7.11 Plain Implicit Keys + - :white_check_mark: Example 7.12 Plain Lines +- 7.4. Flow Collection Styles + - :white_check_mark: Example 7.13 Flow Sequence + - :white_check_mark: Example 7.14 Flow Sequence Entries + - :white_check_mark: Example 7.15 Flow Mappings + - :white_check_mark: Example 7.16 Flow Mapping Entries + - :white_check_mark: Example 7.17 Flow Mapping Separate Values + - :white_check_mark: Example 7.18 Flow Mapping Adjacent Values + - :white_check_mark: Example 7.20 Single Pair Explicit Entry + - :x: Example 7.21 Single Pair Implicit Entries + - :white_check_mark: Example 7.22 Invalid Implicit Keys + - :white_check_mark: Example 7.23 Flow Content + - :white_check_mark: Example 7.24 Flow Nodes +- 8.1. Block Scalar Styles + - :white_check_mark: Example 8.1 Block Scalar Header + - :x: Example 8.2 Block Indentation Indicator + - :white_check_mark: Example 8.3 Invalid Block Scalar Indentation Indicators + - :white_check_mark: Example 8.4 Chomping Final Line Break + - :white_check_mark: Example 8.5 Chomping Trailing Lines + - :white_check_mark: Example 8.6 Empty Scalar Chomping + - :white_check_mark: Example 8.7 Literal Scalar + - :white_check_mark: Example 8.8 Literal Content + - :white_check_mark: Example 8.9 Folded Scalar + - :white_check_mark: Example 8.10 Folded Lines + - :white_check_mark: Example 8.11 More Indented Lines + - :white_check_mark: Example 8.12 Empty Separation Lines + - :white_check_mark: Example 8.13 Final Empty Lines + - :white_check_mark: Example 8.14 Block Sequence + - :white_check_mark: Example 8.15 Block Sequence Entry Types + - :white_check_mark: Example 8.16 Block Mappings + - :white_check_mark: Example 8.17 Explicit Block Mapping Entries + - :white_check_mark: Example 8.18 Implicit Block Mapping Entries + - :white_check_mark: Example 8.19 Compact Block Mappings + - :white_check_mark: Example 8.20 Block Node Types + - :white_check_mark: Example 8.21 Block Scalar Nodes + - :white_check_mark: Example 8.22 Block Collection Nodes + +## Credits + +VYaml is inspired by: + +- [yaml-rust](https://github.com/chyh1990/yaml-rust) +- [Utf8Json](https://github.com/neuecc/Utf8Json), [MessagePack-CSharp](https://github.com/neuecc/MessagePack-CSharp), [MemoryPack](https://github.com/Cysharp/MemoryPack) + +## Aurhor + +[@hadashiA](https://github.com/hadashiA) + +## License + +MIT + + + +::: + +### About +:::note + +Serializing to/from YAML format + + +::: + +## How to use + +### Example (source csproj, source files) + + + + + +This is the CSharp Project that references **VYaml** +```xml showLineNumbers {14} + + + + Exe + net9.0 + enable + enable + + + true + $(BaseIntermediateOutputPath)\GX + + + + + + + + +``` + + + + + + This is the use of **VYaml** in *Program.cs* + +```csharp showLineNumbers +using SerializerDemo; +using VYaml.Serialization; + +var p= new Person() \{ Name= "Andrei Ignat" , Age=55}; +var utf8Yaml = YamlSerializer.SerializeToString(p); +Console.WriteLine(utf8Yaml); +var p1 = YamlSerializer.Serialize(p); +var p2 = YamlSerializer.Deserialize(p1); + +Console.WriteLine(p2.Name); +Console.WriteLine(p2.Age); +``` + + + + + This is the use of **VYaml** in *Person.cs* + +```csharp showLineNumbers +using VYaml.Annotations; +namespace SerializerDemo; +[YamlObject] +public partial class Person +{ + public int Age \{ get; set; } + + public string Name \{ get; set; \} = string.Empty; + +} + + +``` + + + + +### Generated Files + +Those are taken from $(BaseIntermediateOutputPath)\GX + + + + +```csharp showLineNumbers + // + #nullable enable + #pragma warning disable CS0162 // Unreachable code + #pragma warning disable CS0219 // Variable assigned but never used + #pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type. + #pragma warning disable CS8601 // Possible null reference assignment + #pragma warning disable CS8602 // Possible null return + #pragma warning disable CS8604 // Possible null reference argument for parameter + #pragma warning disable CS8619 // Possible null reference assignment fix + #pragma warning disable CS8631 // The type cannot be used as type parameter in the generic type or method + + using System; + using VYaml.Annotations; + using VYaml.Parser; + using VYaml.Emitter; + using VYaml.Serialization; + + namespace SerializerDemo + { + partial class Person + { + [VYaml.Annotations.Preserve] + public static void __RegisterVYamlFormatter() + { + global::VYaml.Serialization.GeneratedResolver.Register(new PersonGeneratedFormatter()); + } + [VYaml.Annotations.Preserve] + public class PersonGeneratedFormatter : IYamlFormatter + { + static readonly byte[] AgeKeyUtf8Bytes = \{ 97, 103, 101 }; // age + + static readonly byte[] NameKeyUtf8Bytes = \{ 110, 97, 109, 101 }; // name + + [VYaml.Annotations.Preserve] + public void Serialize(ref Utf8YamlEmitter emitter, global::SerializerDemo.Person? value, YamlSerializationContext context) + { + if (value is null) + { + emitter.WriteNull(); + return; + } + emitter.BeginMapping(); + if (context.Options.NamingConvention == global::VYaml.Annotations.NamingConvention.LowerCamelCase) + { + emitter.WriteScalar(AgeKeyUtf8Bytes); + } + else + { + global::VYaml.Serialization.NamingConventionMutator.MutateToThreadStaticBufferUtf8(AgeKeyUtf8Bytes, context.Options.NamingConvention, out var mutated, out var written); + emitter.WriteScalar(mutated.AsSpan(0, written)); + } + context.Serialize(ref emitter, value.Age); + if (context.Options.NamingConvention == global::VYaml.Annotations.NamingConvention.LowerCamelCase) + { + emitter.WriteScalar(NameKeyUtf8Bytes); + } + else + { + global::VYaml.Serialization.NamingConventionMutator.MutateToThreadStaticBufferUtf8(NameKeyUtf8Bytes, context.Options.NamingConvention, out var mutated, out var written); + emitter.WriteScalar(mutated.AsSpan(0, written)); + } + context.Serialize(ref emitter, value.Name); + emitter.EndMapping(); + } + [VYaml.Annotations.Preserve] + public global::SerializerDemo.Person? Deserialize(ref YamlParser parser, YamlDeserializationContext context) + { + if (parser.IsNullScalar()) + { + parser.Read(); + return default; + } + parser.ReadWithVerify(ParseEventType.MappingStart); + + var __Age__ = default(int); + var __Name__ = default(string); + while (!parser.End && parser.CurrentEventType != ParseEventType.MappingEnd) + { + if (parser.CurrentEventType != ParseEventType.Scalar) + { + throw new YamlSerializerException(parser.CurrentMark, "Custom type deserialization supports only string key"); + } + + if (!parser.TryGetScalarAsSpan(out var key)) + { + throw new YamlSerializerException(parser.CurrentMark, "Custom type deserialization supports only string key"); + } + + if (context.Options.NamingConvention != global::VYaml.Annotations.NamingConvention.LowerCamelCase) + { + global::VYaml.Serialization.NamingConventionMutator.MutateToThreadStaticBufferUtf8(key, global::VYaml.Annotations.NamingConvention.LowerCamelCase, out var mutated, out var written); + key = mutated.AsSpan(0, written); + } + switch (key.Length) + { + case 3: + if (key.SequenceEqual(AgeKeyUtf8Bytes)) + { + parser.Read(); // skip key + __Age__ = context.DeserializeWithAlias(ref parser); + continue; + } + goto default; + case 4: + if (key.SequenceEqual(NameKeyUtf8Bytes)) + { + parser.Read(); // skip key + __Name__ = context.DeserializeWithAlias(ref parser); + continue; + } + goto default; + default: + parser.Read(); // skip key + parser.SkipCurrentNode(); // skip value + continue; + } + } + parser.ReadWithVerify(ParseEventType.MappingEnd); + return new Person + { + Age = __Age__, + Name = __Name__, + } + ; + } + } + } + } + #pragma warning restore CS0162 // Unreachable code + #pragma warning restore CS0219 // Variable assigned but never used + #pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type. + #pragma warning restore CS8601 // Possible null reference assignment + #pragma warning restore CS8602 // Possible null return + #pragma warning restore CS8604 // Possible null reference argument for parameter + #pragma warning restore CS8631 // The type cannot be used as type parameter in the generic type or method + +``` + + + + +## Useful + +### Download Example (.NET C#) + +:::tip + +[Download Example project VYaml ](/sources/VYaml.zip) + +::: + + +### Share VYaml + + + +https://ignatandrei.github.io/RSCG_Examples/v2/docs/VYaml + + + diff --git a/v2/rscg_examples_site/docs/RSCG-Examples/index.md b/v2/rscg_examples_site/docs/RSCG-Examples/index.md index c9ab33e56..584c88423 100644 --- a/v2/rscg_examples_site/docs/RSCG-Examples/index.md +++ b/v2/rscg_examples_site/docs/RSCG-Examples/index.md @@ -1,7 +1,7 @@ --- sidebar_position: 30 -title: 232 RSCG list by category -description: 232 RSCG list by category +title: 233 RSCG list by category +description: 233 RSCG list by category slug: /rscg-examples --- @@ -1249,7 +1249,7 @@ import DocCardList from '@theme/DocCardList'; ## Serializer
- Expand Serializer =>examples:9 + Expand Serializer =>examples:10 @@ -1295,6 +1295,11 @@ import DocCardList from '@theme/DocCardList'; [mvvmgen](/docs/mvvmgen) + + + +[VYaml](/docs/VYaml) +
@@ -1868,6 +1873,8 @@ flowchart LR; Serializer--> mvvmgen((mvvmgen)) + Serializer--> VYaml((VYaml)) + SignalR--> TypedSignalR.Client((TypedSignalR.Client)) StateMachine--> SuperFluid((SuperFluid)) diff --git a/v2/rscg_examples_site/docs/about.md b/v2/rscg_examples_site/docs/about.md index 7ddf4ddbd..9539d2e55 100644 --- a/v2/rscg_examples_site/docs/about.md +++ b/v2/rscg_examples_site/docs/about.md @@ -6,7 +6,7 @@ title: About ## Content You will find here code examples -of 232 Roslyn Source Code Generator (RSCG) +of 233 Roslyn Source Code Generator (RSCG) that can be useful for you. That means, you will write more elegant and concise code - even if the generators code is not always nice to look. ## Are those examples ready for production? diff --git a/v2/rscg_examples_site/docs/indexRSCG.md b/v2/rscg_examples_site/docs/indexRSCG.md index 8cc483dbb..11a8743ca 100644 --- a/v2/rscg_examples_site/docs/indexRSCG.md +++ b/v2/rscg_examples_site/docs/indexRSCG.md @@ -7,9 +7,9 @@ slug: /List-of-RSCG import useBaseUrl from '@docusaurus/useBaseUrl'; -## 232 RSCG with examples in descending chronological order +## 233 RSCG with examples in descending chronological order -This is the list of 232 ( 14 from Microsoft) RSCG with examples +This is the list of 233 ( 14 from Microsoft) RSCG with examples [See by category](/docs/rscg-examples) [See as json](/exports/RSCG.json) [See as Excel](/exports/RSCG.xlsx) @@ -20,6 +20,7 @@ This is the list of 232 ( 14 from Microsoft) RSCG with examples | No | Name | Date | Category | | --------- | ----- | ---- | -------- | +|233| [VYaml by Hadashi A ](/docs/VYaml)|2025-10-03 => 03 October 2025 | [Serializer](/docs/Categories/Serializer) | |232| [ConsoleAppFramework by Cysharp, Inc. ](/docs/ConsoleAppFramework)|2025-10-02 => 02 October 2025 | [Console](/docs/Categories/Console) | |231| [kli.Localize by Tobias Klimm ](/docs/kli.Localize)|2025-10-01 => 01 October 2025 | [FilesToCode](/docs/Categories/FilesToCode) | |230| [Unflat by pstlnce ](/docs/Unflat)|2025-08-18 => 18 August 2025 | [Database](/docs/Categories/Database) | diff --git a/v2/rscg_examples_site/src/components/HomepageFeatures/index.js b/v2/rscg_examples_site/src/components/HomepageFeatures/index.js index 524194b36..c6cf9c7fc 100644 --- a/v2/rscg_examples_site/src/components/HomepageFeatures/index.js +++ b/v2/rscg_examples_site/src/components/HomepageFeatures/index.js @@ -4,7 +4,7 @@ import styles from './styles.module.css'; const FeatureList = [ { -title: '232 Examples (14 from MSFT)', +title: '233 Examples (14 from MSFT)', Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default, description: ( <> diff --git a/v2/rscg_examples_site/static/exports/RSCG.json b/v2/rscg_examples_site/static/exports/RSCG.json index b7edcbfdf..c29836914 100644 --- a/v2/rscg_examples_site/static/exports/RSCG.json +++ b/v2/rscg_examples_site/static/exports/RSCG.json @@ -1857,6 +1857,14 @@ "Source": "https://github.com/Cysharp/ConsoleAppFramework", "Category": "Console", "AddedOn": "2025-10-02T00:00:00" + }, + { + "Name": "VYaml", + "Link": "https://ignatandrei.github.io/RSCG_Examples/v2/docs/Vyaml", + "NuGet": "https://www.nuget.org/packages/VYaml/", + "Source": "https://github.com/hadashiA/VYaml", + "Category": "Serializer", + "AddedOn": "2025-10-03T00:00:00" } ] } \ No newline at end of file diff --git a/v2/rscg_examples_site/static/exports/RSCG.xlsx b/v2/rscg_examples_site/static/exports/RSCG.xlsx index d5979b913..f44832c5b 100644 Binary files a/v2/rscg_examples_site/static/exports/RSCG.xlsx and b/v2/rscg_examples_site/static/exports/RSCG.xlsx differ diff --git a/v2/rscg_examples_site/static/sources/VYaml.zip b/v2/rscg_examples_site/static/sources/VYaml.zip new file mode 100644 index 000000000..f83a70e88 Binary files /dev/null and b/v2/rscg_examples_site/static/sources/VYaml.zip differ