├── .dockerignore ├── .editorconfig ├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── question.md ├── pull_request_template.md └── workflows │ ├── create-release.yml │ ├── syntax-checker.yml │ └── test-build.yml ├── .gitignore ├── .gitmodules ├── CONTRIBUTING.md ├── Directory.Build.props ├── Directory.Packages.props ├── Dockerfile ├── Dockerfile.NonEnglish ├── GitVersion.yml ├── LICENSE-libyaml ├── LICENSE.txt ├── README.md ├── YamlDotNet.Analyzers.StaticGenerator ├── ClassObject.cs ├── EnumMappings.cs ├── File.cs ├── ObjectAccessorFileGenerator.cs ├── SerializableSyntaxReceiver.cs ├── StaticContextFile.cs ├── StaticObjectFactoryFile.cs ├── StaticPropertyDescriptorFile.cs ├── StaticTypeInspectorFile.cs ├── StaticTypeResolverFile.cs ├── SymbolCollectionExtensions.cs ├── SymbolExtensions.cs ├── TypeFactoryGenerator.cs └── YamlDotNet.Analyzers.StaticGenerator.csproj ├── YamlDotNet.Benchmark ├── BigFileBenchmark.cs ├── Program.cs ├── Resources │ ├── saltern.yml │ └── saltern.yml.gz ├── SerializationBenchmarks.cs ├── YamlDotNet.Benchmark.csproj └── YamlStreamBenchmark.cs ├── YamlDotNet.Core7AoTCompileTest.Model ├── ExternalModel.cs └── YamlDotNet.Core7AoTCompileTest.Model.csproj ├── YamlDotNet.Core7AoTCompileTest ├── Program.cs ├── StaticAoTContext.cs └── YamlDotNet.Core7AoTCompileTest.csproj ├── YamlDotNet.Fsharp.Test ├── DeserializerTests.fs ├── SerializerTests.fs ├── StringExtensions.fs └── YamlDotNet.Fsharp.Test.fsproj ├── YamlDotNet.Samples.Fsharp ├── DeserializeObjectGraph.fs └── YamlDotNet.Samples.Fsharp.fsproj ├── YamlDotNet.Samples ├── ConvertYamlToJson.cs ├── DeserializeGenericObject.cs ├── DeserializeObjectGraph.cs ├── DeserializingMultipleDocuments.cs ├── Helpers │ ├── SampleAttribute.cs │ └── TestOutputHelperExtensions.cs ├── LoadingAYamlStream.cs ├── SerializeObjectGraph.cs ├── UseTypeConverters.cs ├── ValidatingDuringDeserialization.cs └── YamlDotNet.Samples.csproj ├── YamlDotNet.Test ├── Analyzers │ └── StaticGenerator │ │ ├── ObjectTests.cs │ │ ├── RootCollectionTests.cs │ │ ├── StaticAoTContext.cs │ │ └── StructTests.cs ├── Core │ ├── EmitterTests.cs │ ├── EmitterTestsHelper.cs │ ├── EventsHelper.cs │ ├── InsertionQueueTests.cs │ ├── LookAheadBufferTests.cs │ ├── MarkCursorTests.cs │ ├── ParserTests.cs │ ├── ScannerTests.cs │ ├── TokenHelper.cs │ └── YamlExceptionTests.cs ├── EnumerableExtensions.cs ├── GlobalSuppressions.cs ├── Helpers │ ├── OrderedDictionaryTests.cs │ └── PortabilityTests.cs ├── RepresentationModel │ └── YamlStreamTests.cs ├── Serialization │ ├── BufferedDeserialization │ │ ├── KeyValueTypeDiscriminatorTests.cs │ │ ├── TypeDiscriminatingNodeDeserializerTests.cs │ │ └── UniqueKeyTypeDiscriminatorTests.cs │ ├── ComplexYamlTypeConverterTests.cs │ ├── DateOnlyConverterTests.cs │ ├── DateTime8601ConverterTests.cs │ ├── DateTimeConverterTests.cs │ ├── DateTimeOffsetConverterTests.cs │ ├── DeserializerTest.cs │ ├── EmitDefaultValuesTests.cs │ ├── ForcedPlainStyleTests.cs │ ├── GenericTestDictionary.cs │ ├── GenericTestList.cs │ ├── HiddenPropertyTests.cs │ ├── MergingParserTests.cs │ ├── NamingConventionTests.cs │ ├── ObjectFactoryTests.cs │ ├── PrivateConstructorTests.cs │ ├── RepresentationModelSerializationTests.cs │ ├── SerializationTestHelper.cs │ ├── SerializationTests.cs │ ├── TimeOnlyConverterTests.cs │ ├── TypeConverterAttributeTests.cs │ ├── TypeConverterTests.cs │ └── YamlCommentTests.cs ├── Spec │ ├── ParserSpecTests.cs │ ├── SerializerSpecTests.cs │ └── SpecTestData.cs ├── StringExtensions.cs ├── Yaml.cs ├── YamlDotNet.Test.csproj ├── YamlTests.cs ├── files │ ├── 01-directives.yaml │ ├── 02-scalar-in-imp-doc.yaml │ ├── 03-scalar-in-exp-doc.yaml │ ├── 04-scalars-in-multi-docs.yaml │ ├── 05-circular-sequence.yaml │ ├── 06-float-tag.yaml │ ├── 07-scalar-styles.yaml │ ├── 08-flow-sequence.yaml │ ├── 09-flow-mapping.yaml │ ├── 10-mixed-nodes-in-sequence.yaml │ ├── 11-mixed-nodes-in-mapping.yaml │ ├── 12-compact-sequence.yaml │ ├── 13-compact-mapping.yaml │ ├── 14-mapping-wo-indent.yaml │ ├── anchors-overwriting.yaml │ ├── backreference.yaml │ ├── backwards-alias.yaml │ ├── convertible.template │ ├── dictionary-explicit.yaml │ ├── dictionary.yaml │ ├── explicit-type.template │ ├── fail-backreference.yaml │ ├── forward-alias.yaml │ ├── guid.yaml │ ├── invalid-reference.yaml │ ├── list-explicit.yaml │ ├── list-of-dictionaries.yaml │ ├── list.yaml │ ├── local-tags.yaml │ ├── multi-doc-tag.yaml │ ├── ordered-properties.yaml │ ├── tags.yaml │ └── unicode-32bits-escape.yaml ├── xunit.runner.linux.json └── xunit.runner.windows.json ├── YamlDotNet.sln ├── YamlDotNet.snk ├── YamlDotNet ├── Core │ ├── AnchorName.cs │ ├── AnchorNotFoundException.cs │ ├── CharacterAnalyzer.cs │ ├── Constants.cs │ ├── Cursor.cs │ ├── Emitter.cs │ ├── EmitterSettings.cs │ ├── EmitterState.cs │ ├── Events │ │ ├── AnchorAlias.cs │ │ ├── Comment.cs │ │ ├── DocumentEnd.cs │ │ ├── DocumentStart.cs │ │ ├── EventType.cs │ │ ├── IParsingEventVisitor.cs │ │ ├── MappingEnd.cs │ │ ├── MappingStart.cs │ │ ├── MappingStyle.cs │ │ ├── NodeEvent.cs │ │ ├── ParsingEvent.cs │ │ ├── Scalar.cs │ │ ├── SequenceEnd.cs │ │ ├── SequenceStart.cs │ │ ├── SequenceStyle.cs │ │ ├── StreamEnd.cs │ │ └── StreamStart.cs │ ├── ForwardAnchorNotSupportedException.cs │ ├── HashCode.cs │ ├── IEmitter.cs │ ├── ILookAheadBuffer.cs │ ├── IParser.cs │ ├── IScanner.cs │ ├── InsertionQueue.cs │ ├── LookAheadBuffer.cs │ ├── Mark.cs │ ├── MaximumRecursionLevelReachedException.cs │ ├── MergingParser.cs │ ├── ObjectPool │ │ ├── DefaultObjectPool.cs │ │ ├── DefaultPooledObjectPolicy.cs │ │ ├── IPooledObjectPolicy.cs │ │ ├── IResettable.cs │ │ ├── ObjectPool.cs │ │ ├── StringBuilderPool.cs │ │ ├── StringBuilderPooledObjectPolicy.cs │ │ └── StringLookAheadBufferPool.cs │ ├── Parser.cs │ ├── ParserExtensions.cs │ ├── ParserState.cs │ ├── RecursionLevel.cs │ ├── ScalarStyle.cs │ ├── Scanner.cs │ ├── SemanticErrorException.cs │ ├── SimpleKey.cs │ ├── StringLookAheadBuffer.cs │ ├── SyntaxErrorException.cs │ ├── TagDirectiveCollection.cs │ ├── TagName.cs │ ├── Tokens │ │ ├── Anchor.cs │ │ ├── AnchorAlias.cs │ │ ├── BlockEnd.cs │ │ ├── BlockEntry.cs │ │ ├── BlockMappingStart.cs │ │ ├── BlockSequenceStart.cs │ │ ├── Comment.cs │ │ ├── DocumentEnd.cs │ │ ├── DocumentStart.cs │ │ ├── Error.cs │ │ ├── FlowEntry.cs │ │ ├── FlowMappingEnd.cs │ │ ├── FlowMappingStart.cs │ │ ├── FlowSequenceEnd.cs │ │ ├── FlowSequenceStart.cs │ │ ├── Key.cs │ │ ├── Scalar.cs │ │ ├── StreamEnd.cs │ │ ├── StreamStart.cs │ │ ├── Tag.cs │ │ ├── TagDirective.cs │ │ ├── Token.cs │ │ ├── Value.cs │ │ └── VersionDirective.cs │ ├── Version.cs │ └── YamlException.cs ├── CultureInfoAdapter.cs ├── Helpers │ ├── DefaultFsharpHelper.cs │ ├── DictionaryExtensions.cs │ ├── ExpressionExtensions.cs │ ├── FsharpHelper.cs │ ├── GenericCollectionToNonGenericAdapter.cs │ ├── GenericDictionaryToNonGenericAdapter.cs │ ├── IFsharpHelper.cs │ ├── IOrderedDictionary.cs │ ├── NullFsharpHelper.cs │ ├── NumberExtensions.cs │ ├── OrderedDictionary.cs │ ├── Polyfills.cs │ ├── ReadOnlyCollectionExtensions.cs │ └── ThrowHelper.cs ├── Portability │ └── readme.txt ├── Properties │ ├── AssemblyInfo.template │ └── CustomAssemblyInfo.cs ├── PropertyInfoExtensions.cs ├── ReflectionExtensions.cs ├── RepresentationModel │ ├── DocumentLoadingState.cs │ ├── EmitterState.cs │ ├── IYamlVisitor.cs │ ├── LibYamlEventStream.cs │ ├── YamlAliasNode.cs │ ├── YamlDocument.cs │ ├── YamlMappingNode.cs │ ├── YamlNode.cs │ ├── YamlNodeIdentityEqualityComparer.cs │ ├── YamlNodeType.cs │ ├── YamlScalarNode.cs │ ├── YamlSequenceNode.cs │ ├── YamlStream.cs │ ├── YamlVisitor.cs │ └── YamlVisitorBase.cs ├── Serialization │ ├── BufferedDeserialization │ │ ├── ITypeDiscriminatingNodeDeserializerOptions.cs │ │ ├── ParserBuffer.cs │ │ ├── TypeDiscriminatingNodeDeserializer.cs │ │ ├── TypeDiscriminatingNodeDeserializerOptions.cs │ │ └── TypeDiscriminators │ │ │ ├── IValueTypeDiscriminator.cs │ │ │ ├── KeyValueTypeDiscriminator.cs │ │ │ └── UniqueKeyTypeDiscriminator.cs │ ├── BuilderSkeleton.cs │ ├── Callbacks │ │ ├── OnDeserializedAttribute.cs │ │ ├── OnDeserializingAttribute.cs │ │ ├── OnSerializedAttribute.cs │ │ └── OnSerializingAttribute.cs │ ├── Converters │ │ ├── DateOnlyConverter.cs │ │ ├── DateTime8601Converter.cs │ │ ├── DateTimeConverter.cs │ │ ├── DateTimeOffsetConverter.cs │ │ ├── GuidConverter.cs │ │ ├── SystemTypeConverter.cs │ │ └── TimeOnlyConverter.cs │ ├── DefaultValuesHandling.cs │ ├── Deserializer.cs │ ├── DeserializerBuilder.cs │ ├── EmissionPhaseObjectGraphVisitorArgs.cs │ ├── EventEmitters │ │ ├── ChainedEventEmitter.cs │ │ ├── JsonEventEmitter.cs │ │ ├── TypeAssigningEventEmitter.cs │ │ └── WriterEventEmitter.cs │ ├── EventInfo.cs │ ├── IAliasProvider.cs │ ├── IDeserializer.cs │ ├── IEventEmitter.cs │ ├── INamingConvention.cs │ ├── INodeDeserializer.cs │ ├── INodeTypeResolver.cs │ ├── IObjectAccessor.cs │ ├── IObjectDescriptor.cs │ ├── IObjectFactory.cs │ ├── IObjectGraphTraversalStrategy.cs │ ├── IObjectGraphVisitor.cs │ ├── IPropertyDescriptor.cs │ ├── IRegistrationLocationSelectionSyntax.cs │ ├── ISerializer.cs │ ├── ITypeInspector.cs │ ├── ITypeResolver.cs │ ├── IValueDeserializer.cs │ ├── IValuePromise.cs │ ├── IValueSerializer.cs │ ├── IYamlConvertible.cs │ ├── IYamlSerializable.cs │ ├── IYamlTypeConverter.cs │ ├── LazyComponentRegistrationList.cs │ ├── LazyComponentRegistrationListExtensions.cs │ ├── NamingConventions │ │ ├── CamelCaseNamingConvention.cs │ │ ├── HyphenatedNamingConvention.cs │ │ ├── LowerCaseNamingConvention.cs │ │ ├── NullNamingConvention.cs │ │ ├── PascalCaseNamingConvention.cs │ │ └── UnderscoredNamingConvention.cs │ ├── NodeDeserializers │ │ ├── ArrayNodeDeserializer.cs │ │ ├── CollectionDeserializer.cs │ │ ├── CollectionNodeDeserializer.cs │ │ ├── DictionaryDeserializer.cs │ │ ├── DictionaryNodeDeserializer.cs │ │ ├── EnumerableNodeDeserializer.cs │ │ ├── FsharpListNodeDeserializer.cs │ │ ├── NullNodeDeserializer.cs │ │ ├── ObjectNodeDeserializer.cs │ │ ├── ScalarNodeDeserializer.cs │ │ ├── StaticArrayNodeDeserializer.cs │ │ ├── StaticCollectionNodeDeserializer.cs │ │ ├── StaticDictionaryNodeDeserializer.cs │ │ ├── TypeConverterNodeDeserializer.cs │ │ ├── YamlConvertibleNodeDeserializer.cs │ │ └── YamlSerializableNodeDeserializer.cs │ ├── NodeTypeResolvers │ │ ├── DefaultContainersNodeTypeResolver.cs │ │ ├── MappingNodeTypeResolver.cs │ │ ├── RejectUnknownTagsNodeTypeResolver.cs │ │ ├── TagNodeTypeResolver.cs │ │ ├── TypeNameInTagNodeTypeResolver.cs │ │ ├── YamlConvertibleTypeResolver.cs │ │ └── YamlSerializableTypeResolver.cs │ ├── Nothing.cs │ ├── ObjectDescriptor.cs │ ├── ObjectFactories │ │ ├── DefaultObjectFactory.cs │ │ ├── LambdaObjectFactory.cs │ │ ├── ObjectFactoryBase.cs │ │ └── StaticObjectFactory.cs │ ├── ObjectGraphTraversalStrategies │ │ ├── FullObjectGraphTraversalStrategy.cs │ │ └── RoundtripObjectGraphTraversalStrategy.cs │ ├── ObjectGraphTraversalStrategyFactory.cs │ ├── ObjectGraphVisitors │ │ ├── AnchorAssigner.cs │ │ ├── AnchorAssigningObjectGraphVisitor.cs │ │ ├── ChainedObjectGraphVisitor.cs │ │ ├── CommentsObjectGraphVisitor.cs │ │ ├── CustomSerializationObjectGraphVisitor.cs │ │ ├── DefaultExclusiveObjectGraphVisitor.cs │ │ ├── DefaultValuesObjectGraphVisitor.cs │ │ ├── EmittingObjectGraphVisitor.cs │ │ └── PreProcessingPhaseObjectGraphVisitorSkeleton.cs │ ├── PropertyDescriptor.cs │ ├── Schemas │ │ └── FailsafeSchema.cs │ ├── Serializer.cs │ ├── SerializerBuilder.cs │ ├── Settings.cs │ ├── StaticBuilderSkeleton.cs │ ├── StaticContext.cs │ ├── StaticDeserializerBuilder.cs │ ├── StaticSerializerBuilder.cs │ ├── StreamFragment.cs │ ├── TagMappings.cs │ ├── TypeInspectors │ │ ├── CachedTypeInspector.cs │ │ ├── CompositeTypeInspector.cs │ │ ├── NamingConventionTypeInspector.cs │ │ ├── ReadableAndWritablePropertiesTypeInspector.cs │ │ ├── ReadableFieldsTypeInspector.cs │ │ ├── ReadablePropertiesTypeInspector.cs │ │ ├── ReflectionTypeInspector.cs │ │ ├── TypeInspectorSkeleton.cs │ │ └── WritablePropertiesTypeInspector.cs │ ├── TypeResolvers │ │ ├── DynamicTypeResolver.cs │ │ └── StaticTypeResolver.cs │ ├── Utilities │ │ ├── IPostDeserializationCallback.cs │ │ ├── ITypeConverter.cs │ │ ├── NullTypeConverter.cs │ │ ├── ObjectAnchorCollection.cs │ │ ├── ReflectionTypeConverter.cs │ │ ├── SerializerState.cs │ │ ├── StringExtensions.cs │ │ ├── TypeConverter.cs │ │ └── TypeConverterCache.cs │ ├── ValueDeserializers │ │ ├── AliasValueDeserializer.cs │ │ └── NodeValueDeserializer.cs │ ├── YamlAttributeOverrides.cs │ ├── YamlAttributeOverridesInspector.cs │ ├── YamlAttributesTypeInspector.cs │ ├── YamlConverterAttribute.cs │ ├── YamlFormatter.cs │ ├── YamlIgnoreAttribute.cs │ ├── YamlMemberAttribute.cs │ ├── YamlSerializable.cs │ └── YamlStaticContextAttribute.cs ├── StandardRegexOptions.cs └── YamlDotNet.csproj ├── appveyor.yml ├── build.cmd ├── build.sh ├── docker-build.sh ├── tools ├── build │ ├── AutoNumberToStringConverter.cs │ ├── BuildDefinition.cs │ ├── GitHubApiModels.cs │ ├── Program.cs │ ├── TwitterProvider.cs │ ├── build.csproj │ └── build.sln ├── parsers │ ├── build.ps1 │ ├── perl-yaml-pp │ │ ├── Dockerfile │ │ └── parse.pl │ ├── python │ │ └── Dockerfile │ └── reference │ │ ├── Dockerfile │ │ └── run.sh └── syntax-checker │ ├── Dockerfile │ ├── build.cmd │ └── check-syntax.ps1 ├── yamldotnet.png └── yamldotnet.xcf /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | Dockerfile.NonEnglish 3 | Dockerfile 4 | bin 5 | obj -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sh text eol=lf 2 | *.cs text eol=crlf 3 | *.fs text eol=crlf -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [EdwardCooke] 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. Please explain what you observe and what you expected to happen instead. If there is an exception, include its message and stack trace. 12 | 13 | **To Reproduce** 14 | Try to add the steps needed to reproduce the problem. Feel free to open a pull request with a failing test if that makes sense. Otherwise, at least provide some code and / or YAML that reproduce the issue. 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: For general usage questions 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Feel free to ask any question on how to use the library. Alternatively, consider asking the question on [Stackoverflow](https://stackoverflow.com), tagged with [yamldotnet](https://stackoverflow.com/questions/tagged/yamldotnet). 11 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Welcome! 2 | 3 | Thanks for your interest in contributing to this project. Any contribution will 4 | be gladly accepted, provided that they are generally useful and follow the 5 | conventions of the project. 6 | 7 | 1. Please create **one pull request for each feature**. This results in smaller pull requests that are easier to review and validate. 8 | 9 | 1. **Avoid reformatting existing code** unless you are making other changes to it. 10 | - Cleaning-up of `using`s is acceptable, if you made other changes to that file. 11 | - If you believe that some code is badly formatted and needs fixing, isolate that change in a separate pull request. 12 | 13 | 1. Always add one or more **unit tests** that prove that the feature / fix you are submitting is working correctly. 14 | 15 | 1. Please **describe the motivation** behind the pull request. Explain what was the problem / requirement. Unless the implementation is self-explanatory, also describe the solution. 16 | * Of course, there's no need to be too verbose. Usually one or two lines will be enough. 17 | 18 | 1. Follow the project's [coding conventions](CONTRIBUTING.md#coding-style) 19 | -------------------------------------------------------------------------------- /.github/workflows/create-release.yml: -------------------------------------------------------------------------------- 1 | name: Create a new release 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | ref: 6 | description: Commit name to release (defaults to master) 7 | required: false 8 | args: 9 | description: Additional command line arguments 10 | required: false 11 | 12 | jobs: 13 | release: 14 | name: Draft Release 15 | runs-on: ubuntu-latest 16 | env: 17 | DOTNET_CLI_TELEMETRY_OPTOUT: 1 18 | steps: 19 | - name: Checkout the repository 20 | uses: actions/checkout@v2 21 | with: 22 | fetch-depth: 0 23 | ref: ${{ github.event.inputs.ref }} 24 | 25 | # Make sure the required versions of dotnet core on the server 26 | - name: Install dotnet 3.1 27 | uses: actions/setup-dotnet@v3 28 | with: 29 | dotnet-version: 3.1.x 30 | 31 | - name: Install dotnet 6.0 32 | uses: actions/setup-dotnet@v3 33 | with: 34 | dotnet-version: 6.0.x 35 | 36 | - name: Install dotnet 8.0 37 | uses: actions/setup-dotnet@v3 38 | with: 39 | dotnet-version: 8.0.x 40 | 41 | - name: Install GitVersion.Tool 42 | run: dotnet tool install --global GitVersion.Tool 43 | 44 | - name: Create draft release 45 | env: 46 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 47 | run: ./build.sh CreateGithubRelease ${{ github.event.inputs.args }} 48 | -------------------------------------------------------------------------------- /.github/workflows/syntax-checker.yml: -------------------------------------------------------------------------------- 1 | name: Check Yaml Syntax 2 | 3 | on: 4 | issues: 5 | types: [ opened, edited ] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Check syntax on YAML code blocks 12 | uses: docker://aaubry/yamldotnet-syntax-checker:latest 13 | with: 14 | args: -repository ${{ github.repository }} -issueNumber ${{ github.event.issue.number }} -apiToken ${{ secrets.BOT_TOKEN }} 15 | -------------------------------------------------------------------------------- /.github/workflows/test-build.yml: -------------------------------------------------------------------------------- 1 | name: Test build 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | ref: 6 | description: Commit name (defaults to master) 7 | required: false 8 | target: 9 | description: Command line 10 | required: true 11 | default: ResolveVersion --verbose 12 | 13 | jobs: 14 | release: 15 | name: Test build 16 | runs-on: ubuntu-latest 17 | env: 18 | DOTNET_CLI_TELEMETRY_OPTOUT: 1 19 | steps: 20 | - name: Checkout the repository 21 | uses: actions/checkout@v2 22 | with: 23 | fetch-depth: 0 24 | ref: ${{ github.event.inputs.ref }} 25 | 26 | - name: Install GitVersion.Tool 27 | run: dotnet tool install --global GitVersion.Tool 28 | 29 | - name: Build 30 | env: 31 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 32 | TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} 33 | TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} 34 | TWITTER_CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }} 35 | TWITTER_CONSUMER_API_SECRET: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} 36 | run: ./build.sh ${{ github.event.inputs.target }} 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | bin 3 | obj 4 | 5 | # mstest test results 6 | TestResults 7 | *.suo 8 | *.user 9 | *.userprefs 10 | *.pidb 11 | *.bak 12 | *.orig 13 | Help/* 14 | release/* 15 | _ReSharper.* 16 | *.pidb 17 | *.userprefs 18 | packages 19 | packages/* 20 | !packages/repositories.config 21 | .vscode 22 | 23 | *.nuspec.tmp 24 | README.html 25 | 26 | samples/dotnet/project.lock.json 27 | YamlDotNet/Properties/AssemblyInfo.Generated.cs 28 | 29 | .vs 30 | .idea 31 | 32 | /YamlDotNet/Properties/AssemblyInfo.cs 33 | BenchmarkDotNet.Artifacts* 34 | 35 | /YamlDotNet.AotTest/exitcode.txt 36 | /tools/build/Properties/launchSettings.json 37 | /YamlDotNet.Unity 38 | *.meta 39 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "BuildUtils.UnityPrerequisites"] 2 | path = BuildUtils.UnityPrerequisites 3 | url = https://github.com/aaubry/BuildUtils.UnityPrerequisites.git 4 | [submodule "yaml-test-suite"] 5 | path = YamlDotNet.Test/yaml-test-suite 6 | url = https://github.com/yaml/yaml-test-suite 7 | branch = data-2022-01-17 8 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Antoine Aubry 5 | https://github.com/aaubry/YamlDotNet/wiki 6 | https://github.com/aaubry/YamlDotNet 7 | MIT 8 | Copyright (c) Antoine Aubry and contributors 9 | yaml parser development library serialization 10 | 11 | 12 | 13 | 9999 14 | True 15 | 12.0 16 | 17 | 18 | 19 | true 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Directory.Packages.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | true 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /GitVersion.yml: -------------------------------------------------------------------------------- 1 | mode: ContinuousDelivery 2 | increment: None 3 | commit-message-incrementing: MergeMessageOnly 4 | branches: 5 | master: 6 | commit-message-incrementing: MergeMessageOnly 7 | increment: None 8 | regex: "^master$" 9 | -------------------------------------------------------------------------------- /LICENSE-libyaml: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006 Kirill Simonov 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Antoine Aubry and contributors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /YamlDotNet.Analyzers.StaticGenerator/EnumMappings.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using Microsoft.CodeAnalysis; 23 | 24 | namespace YamlDotNet.Analyzers.StaticGenerator 25 | { 26 | public class EnumMappings 27 | { 28 | public ITypeSymbol Type { get; set; } 29 | public string ActualName { get; set; } 30 | public string EnumMemberValue { get; set; } 31 | 32 | public EnumMappings(ITypeSymbol type, string actualName, string enumMemberValue) 33 | { 34 | ActualName = actualName; 35 | EnumMemberValue = enumMemberValue; 36 | Type = type; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /YamlDotNet.Analyzers.StaticGenerator/SymbolCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System.Collections.Generic; 23 | using System.Linq; 24 | using Microsoft.CodeAnalysis; 25 | 26 | namespace YamlDotNet.Analyzers.StaticGenerator 27 | { 28 | static class SymbolCollectionExtensions 29 | { 30 | public static bool ContainsName(this IEnumerable enumerable, T symbol) 31 | where T : ISymbol 32 | { 33 | return enumerable.Any(t => t.Name == symbol.Name); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /YamlDotNet.Analyzers.StaticGenerator/YamlDotNet.Analyzers.StaticGenerator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | enable 6 | false 7 | true 8 | 9 | 10 | 11 | YamlDotNet.Analyzers.StaticGenerator 12 | YamlDotNet Contributors 13 | Roslyn Code Generator that will generate a static context for use with YamlDotNet to support ahead-of-time and library trimming. 14 | images/yamldotnet.png 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | all 26 | runtime; build; native; contentfiles; analyzers; buildtransitive 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /YamlDotNet.Benchmark/BigFileBenchmark.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System.IO.Compression; 23 | using System.Text; 24 | using BenchmarkDotNet.Attributes; 25 | using FastSerialization; 26 | using YamlDotNet.RepresentationModel; 27 | using YamlDotNet.Serialization; 28 | 29 | namespace YamlDotNet.Benchmark; 30 | 31 | [MemoryDiagnoser] 32 | public class BigFileBenchmark 33 | { 34 | private string yamlString = ""; 35 | 36 | [GlobalSetup] 37 | public void Setup() 38 | { 39 | var stringBuilder = new StringBuilder(); 40 | //100mb 41 | while (stringBuilder.Length < 1000 * 1000 * 100) 42 | { 43 | stringBuilder.AppendLine("- test"); 44 | } 45 | yamlString = stringBuilder.ToString(); 46 | } 47 | 48 | [Benchmark] 49 | public void LoadLarge() 50 | { 51 | var deserializer = new DeserializerBuilder().Build(); 52 | var result = deserializer.Deserialize>(yamlString); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /YamlDotNet.Benchmark/Program.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using BenchmarkDotNet.Running; 23 | using YamlDotNet.Benchmark; 24 | 25 | BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args); 26 | -------------------------------------------------------------------------------- /YamlDotNet.Benchmark/Resources/saltern.yml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aaubry/YamlDotNet/b8ac2a98ffcc12434eff6c6abb75b38ad1b1ab04/YamlDotNet.Benchmark/Resources/saltern.yml.gz -------------------------------------------------------------------------------- /YamlDotNet.Benchmark/YamlDotNet.Benchmark.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0;net472 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /YamlDotNet.Benchmark/YamlStreamBenchmark.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using BenchmarkDotNet.Attributes; 23 | using YamlDotNet.RepresentationModel; 24 | 25 | namespace YamlDotNet.Benchmark; 26 | 27 | [MemoryDiagnoser] 28 | public class YamlStreamBenchmark 29 | { 30 | private string yamlString = ""; 31 | 32 | [GlobalSetup] 33 | public void Setup() 34 | { 35 | using var reader = new StreamReader(File.OpenRead("Resources/saltern.yml")); 36 | yamlString = reader.ReadToEnd(); 37 | } 38 | 39 | [Benchmark] 40 | public void LoadLarge() 41 | { 42 | var yamlStream = new YamlStream(); 43 | yamlStream.Load(new StringReader(yamlString)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /YamlDotNet.Core7AoTCompileTest.Model/ExternalModel.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core7AoTCompileTest.Model; 23 | 24 | public class ExternalModel 25 | { 26 | public string? Text { get; set; } 27 | public string NotNull { get; set; } = string.Empty; 28 | } 29 | -------------------------------------------------------------------------------- /YamlDotNet.Core7AoTCompileTest.Model/YamlDotNet.Core7AoTCompileTest.Model.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /YamlDotNet.Core7AoTCompileTest/StaticAoTContext.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using YamlDotNet.Core7AoTCompileTest.Model; 23 | using YamlDotNet.Serialization; 24 | 25 | namespace YamlDotNet.Core7AoTCompileTest 26 | { 27 | // The rest of this partial class gets generated at build time 28 | [YamlStaticContext] 29 | [YamlSerializable(typeof(ExternalModel))] 30 | public partial class StaticContext : YamlDotNet.Serialization.StaticContext 31 | { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /YamlDotNet.Core7AoTCompileTest/YamlDotNet.Core7AoTCompileTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net8.0 6 | true 7 | true 8 | enable 9 | true 10 | true 11 | 12 | 13 | 14 | AnyCPU 15 | true 16 | full 17 | false 18 | bin\Debug\ 19 | DEBUG;TRACE 20 | prompt 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /YamlDotNet.Fsharp.Test/StringExtensions.fs: -------------------------------------------------------------------------------- 1 | namespace YamlDotNet.Fsharp.Test 2 | 3 | open System.Runtime.CompilerServices 4 | 5 | [] 6 | type StringExtensions() = 7 | [] 8 | static member NormalizeNewLines(x: string) = 9 | x.Replace("\r\n", "\n").Replace("\n", System.Environment.NewLine) 10 | 11 | [] 12 | static member TrimNewLines(x: string) = x.TrimEnd('\r').TrimEnd('\n') 13 | 14 | [] 15 | static member Clean(x: string) = x.NormalizeNewLines().TrimNewLines() 16 | -------------------------------------------------------------------------------- /YamlDotNet.Fsharp.Test/YamlDotNet.Fsharp.Test.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net8.0;net6.0;net47 4 | false 5 | ..\YamlDotNet.snk 6 | true 7 | 8 | true 9 | 5 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | all 23 | runtime; build; native; contentfiles; analyzers; buildtransitive 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /YamlDotNet.Samples.Fsharp/YamlDotNet.Samples.Fsharp.fsproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net8.0 6 | false 7 | 8 | 5 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /YamlDotNet.Samples/Helpers/SampleAttribute.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using Xunit; 23 | 24 | namespace YamlDotNet.Samples.Helpers 25 | { 26 | /// 27 | /// Marks a test as being a code sample. 28 | /// 29 | public class SampleAttribute : FactAttribute 30 | { 31 | public string Description { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /YamlDotNet.Samples/Helpers/TestOutputHelperExtensions.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using Xunit.Abstractions; 23 | 24 | namespace YamlDotNet.Samples.Helpers 25 | { 26 | public static class TestOutputHelperExtensions 27 | { 28 | public static void WriteLine(this ITestOutputHelper output) 29 | { 30 | output.WriteLine(string.Empty); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /YamlDotNet.Samples/YamlDotNet.Samples.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /YamlDotNet.Test/Analyzers/StaticGenerator/StaticAoTContext.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using YamlDotNet.Serialization; 23 | 24 | namespace YamlDotNet.Test.Analyzers.StaticGenerator 25 | { 26 | [YamlStaticContext] 27 | public partial class StaticContext : YamlDotNet.Serialization.StaticContext 28 | { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /YamlDotNet.Test/Core/MarkCursorTests.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using FluentAssertions; 23 | using Xunit; 24 | using YamlDotNet.Core; 25 | 26 | namespace YamlDotNet.Test.Core 27 | { 28 | public class MarkCursorTests 29 | { 30 | [Fact] 31 | public void ShouldProvideAnOneIndexedMark() 32 | { 33 | var cursor = new Cursor(); 34 | 35 | var result = cursor.Mark(); 36 | 37 | result.Line.Should().Be(1, "the mark should be at line 1"); 38 | result.Column.Should().Be(1, "the mark should be at column 1"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /YamlDotNet.Test/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | 25 | namespace YamlDotNet.Test 26 | { 27 | public static class EnumerableExtensions 28 | { 29 | public static IEnumerable Do(this IEnumerable source, Action action) 30 | { 31 | foreach (var item in source) 32 | { 33 | action(item); 34 | yield return item; 35 | } 36 | } 37 | 38 | public static void Run(this IEnumerable source, Action action) 39 | { 40 | foreach (var element in source) 41 | { 42 | action(element); 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /YamlDotNet.Test/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | // This file is used by Code Analysis to maintain SuppressMessage 23 | // attributes that are applied to this project. 24 | // Project-level suppressions either have no target or are given 25 | // a specific target and scoped to a namespace, type, member, etc. 26 | 27 | using System.Diagnostics.CodeAnalysis; 28 | 29 | [assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Many test classes use non-compliant properties to test specific cases.", Scope = "namespaceanddescendants", Target = "~N:YamlDotNet.Test")] 30 | -------------------------------------------------------------------------------- /YamlDotNet.Test/Helpers/PortabilityTests.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using System.Globalization; 24 | using Xunit; 25 | 26 | namespace YamlDotNet.Test.Helpers 27 | { 28 | public class PortabilityTests 29 | { 30 | [Fact] 31 | public void GetPublicStaticMethodReturnsCorrectMethodInfo() 32 | { 33 | var expected = DateTimeOffset.UtcNow; 34 | 35 | var type = typeof(DateTimeOffset); 36 | var method = type.GetPublicStaticMethod("Parse", typeof(string), typeof(IFormatProvider)); 37 | 38 | var actual = (DateTimeOffset)method.Invoke(null, new object[] { expected.ToString("o"), CultureInfo.InvariantCulture }); 39 | 40 | Assert.Equal(expected, actual); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /YamlDotNet.Test/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | 24 | namespace YamlDotNet.Test 25 | { 26 | public static class StringExtensions 27 | { 28 | public static string NormalizeNewLines(this string value) 29 | { 30 | return value 31 | .Replace("\r\n", "\n") 32 | .Replace("\n", Environment.NewLine); 33 | } 34 | 35 | public static string TrimNewLines(this string value) 36 | { 37 | return value.TrimEnd('\r', '\n'); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /YamlDotNet.Test/YamlDotNet.Test.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net8.0;net6.0;net47 4 | false 5 | ..\YamlDotNet.snk 6 | true 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | {BF32DE1B-6276-4341-B212-F8862ADBBA7A} 21 | YamlDotNet 22 | 23 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | xunit.runner.json 35 | PreserveNewest 36 | 37 | 38 | 39 | 40 | 41 | 42 | xunit.runner.json 43 | PreserveNewest 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /YamlDotNet.Test/files/01-directives.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG ! !foo 3 | %TAG !yaml! tag:yaml.org,2002: 4 | --- -------------------------------------------------------------------------------- /YamlDotNet.Test/files/02-scalar-in-imp-doc.yaml: -------------------------------------------------------------------------------- 1 | 'a scalar' -------------------------------------------------------------------------------- /YamlDotNet.Test/files/03-scalar-in-exp-doc.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | 'a scalar' 3 | ... -------------------------------------------------------------------------------- /YamlDotNet.Test/files/04-scalars-in-multi-docs.yaml: -------------------------------------------------------------------------------- 1 | 'a scalar' 2 | --- 3 | 'another scalar' 4 | --- 5 | 'yet another scalar' -------------------------------------------------------------------------------- /YamlDotNet.Test/files/05-circular-sequence.yaml: -------------------------------------------------------------------------------- 1 | &A [ *A ] -------------------------------------------------------------------------------- /YamlDotNet.Test/files/06-float-tag.yaml: -------------------------------------------------------------------------------- 1 | !!float "3.14" # A good approximation. -------------------------------------------------------------------------------- /YamlDotNet.Test/files/07-scalar-styles.yaml: -------------------------------------------------------------------------------- 1 | --- # Implicit empty plain scalars do not produce tokens. 2 | --- a plain scalar 3 | --- 'a single-quoted scalar' 4 | --- "a double-quoted scalar" 5 | --- |- 6 | a literal scalar 7 | --- >- 8 | a folded 9 | scalar -------------------------------------------------------------------------------- /YamlDotNet.Test/files/08-flow-sequence.yaml: -------------------------------------------------------------------------------- 1 | [item 1, item 2, item 3] -------------------------------------------------------------------------------- /YamlDotNet.Test/files/09-flow-mapping.yaml: -------------------------------------------------------------------------------- 1 | { 2 | a simple key: a value, # Note that the KEY token is produced. 3 | ? a complex key: another value, 4 | } -------------------------------------------------------------------------------- /YamlDotNet.Test/files/10-mixed-nodes-in-sequence.yaml: -------------------------------------------------------------------------------- 1 | - item 1 2 | - item 2 3 | - 4 | - item 3.1 5 | - item 3.2 6 | - 7 | key 1: value 1 8 | key 2: value 2 -------------------------------------------------------------------------------- /YamlDotNet.Test/files/11-mixed-nodes-in-mapping.yaml: -------------------------------------------------------------------------------- 1 | a simple key: a value # The KEY token is produced here. 2 | ? a complex key 3 | : another value 4 | a mapping: 5 | key 1: value 1 6 | key 2: value 2 7 | a sequence: 8 | - item 1 9 | - item 2 -------------------------------------------------------------------------------- /YamlDotNet.Test/files/12-compact-sequence.yaml: -------------------------------------------------------------------------------- 1 | - - item 1 2 | - item 2 3 | - key 1: value 1 4 | key 2: value 2 5 | - ? complex key 6 | : complex value -------------------------------------------------------------------------------- /YamlDotNet.Test/files/13-compact-mapping.yaml: -------------------------------------------------------------------------------- 1 | ? a sequence 2 | : - item 1 3 | - item 2 4 | ? a mapping 5 | : key 1: value 1 6 | key 2: value 2 -------------------------------------------------------------------------------- /YamlDotNet.Test/files/14-mapping-wo-indent.yaml: -------------------------------------------------------------------------------- 1 | key: 2 | - item 1 # BLOCK-SEQUENCE-START is NOT produced here. 3 | - item 2 -------------------------------------------------------------------------------- /YamlDotNet.Test/files/anchors-overwriting.yaml: -------------------------------------------------------------------------------- 1 | a : &anchor [foo] 2 | c : *anchor 3 | b : &anchor [bar] 4 | d : *anchor 5 | 6 | e : &anchor2 baz 7 | g : *anchor2 8 | f : &anchor2 foobar 9 | h : *anchor2 -------------------------------------------------------------------------------- /YamlDotNet.Test/files/backreference.yaml: -------------------------------------------------------------------------------- 1 | anchor: &default 2 | key1: value1 3 | key2: value2 4 | alias: 5 | <<: *default 6 | key2: Overriding key2 7 | key3: value3 8 | -------------------------------------------------------------------------------- /YamlDotNet.Test/files/backwards-alias.yaml: -------------------------------------------------------------------------------- 1 | - &first a scalar 2 | - another scalar 3 | - *first -------------------------------------------------------------------------------- /YamlDotNet.Test/files/convertible.template: -------------------------------------------------------------------------------- 1 | aaa: 2 | !{type} 3 | Left: hello 4 | Right: world -------------------------------------------------------------------------------- /YamlDotNet.Test/files/dictionary-explicit.yaml: -------------------------------------------------------------------------------- 1 | !Dictionary { 2 | key1: 1, 3 | key2: 2 4 | } -------------------------------------------------------------------------------- /YamlDotNet.Test/files/dictionary.yaml: -------------------------------------------------------------------------------- 1 | !!map { 2 | key1: value1, 3 | key2: value2 4 | } -------------------------------------------------------------------------------- /YamlDotNet.Test/files/explicit-type.template: -------------------------------------------------------------------------------- 1 | !{type} { 2 | aaa: bbb 3 | } -------------------------------------------------------------------------------- /YamlDotNet.Test/files/forward-alias.yaml: -------------------------------------------------------------------------------- 1 | - *first 2 | - another scalar 3 | - &first a scalar -------------------------------------------------------------------------------- /YamlDotNet.Test/files/guid.yaml: -------------------------------------------------------------------------------- 1 | 9462790D-5C44-4689-8542-5E2DD38EBD98 2 | ... 3 | -------------------------------------------------------------------------------- /YamlDotNet.Test/files/invalid-reference.yaml: -------------------------------------------------------------------------------- 1 | - [*municipality-0701, *municipality-0711, *municipality-0707, *municipality-0708, *municipality-0709] 2 | - [*municipality-1501, *municipality-1505, *municipality-1509, *municipality-1513, *municipality-0211] 3 | - 4 | - &municipality-0211 0211 5 | - &municipality-0701 0701 6 | - &municipality-0707 0707 7 | - &municipality-0708 0708 8 | - &municipality-0709 0709 9 | - &municipality-0711 0711 10 | - &municipality-1513 1513 11 | -------------------------------------------------------------------------------- /YamlDotNet.Test/files/list-explicit.yaml: -------------------------------------------------------------------------------- 1 | !List [ 3, 4, 5 ] -------------------------------------------------------------------------------- /YamlDotNet.Test/files/list-of-dictionaries.yaml: -------------------------------------------------------------------------------- 1 | - 2 | connection: conn1 3 | path: path1 4 | - 5 | connection: conn2 6 | path: path2 -------------------------------------------------------------------------------- /YamlDotNet.Test/files/list.yaml: -------------------------------------------------------------------------------- 1 | - one 2 | - two 3 | - three 4 | -------------------------------------------------------------------------------- /YamlDotNet.Test/files/local-tags.yaml: -------------------------------------------------------------------------------- 1 | --- !MyObject 2 | a: 1.0 3 | b: 42 4 | c: -7 5 | -------------------------------------------------------------------------------- /YamlDotNet.Test/files/multi-doc-tag.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !x! tag:example.com,2014: 3 | --- !x!foo 4 | x: 0 5 | --- !x!bar 6 | x: 1 -------------------------------------------------------------------------------- /YamlDotNet.Test/files/ordered-properties.yaml: -------------------------------------------------------------------------------- 1 | Order1: Order1 value 2 | Order2: Order2 value 3 | -------------------------------------------------------------------------------- /YamlDotNet.Test/files/tags.yaml: -------------------------------------------------------------------------------- 1 | !!point 2 | X: 10 3 | Y: 20 4 | -------------------------------------------------------------------------------- /YamlDotNet.Test/files/unicode-32bits-escape.yaml: -------------------------------------------------------------------------------- 1 | - hel􏿿lo♥ 2 | - "hel\U0010fffflo\u2665" 3 | -------------------------------------------------------------------------------- /YamlDotNet.Test/xunit.runner.linux.json: -------------------------------------------------------------------------------- 1 | { 2 | "appDomain": "denied", 3 | "methodDisplay": "method" 4 | } -------------------------------------------------------------------------------- /YamlDotNet.Test/xunit.runner.windows.json: -------------------------------------------------------------------------------- 1 | { 2 | "methodDisplay": "method" 3 | } -------------------------------------------------------------------------------- /YamlDotNet.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aaubry/YamlDotNet/b8ac2a98ffcc12434eff6c6abb75b38ad1b1ab04/YamlDotNet.snk -------------------------------------------------------------------------------- /YamlDotNet/Core/Constants.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using YamlDotNet.Core.Tokens; 23 | 24 | namespace YamlDotNet.Core 25 | { 26 | /// 27 | /// Defines constants that relate to the YAML specification. 28 | /// 29 | public static class Constants 30 | { 31 | public static readonly TagDirective[] DefaultTagDirectives = 32 | [ 33 | new TagDirective("!", "!"), 34 | new TagDirective("!!", "tag:yaml.org,2002:") 35 | ]; 36 | 37 | public const int MajorVersion = 1; 38 | public const int MinorVersion = 3; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /YamlDotNet/Core/EmitterState.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core 23 | { 24 | internal enum EmitterState 25 | { 26 | StreamStart, 27 | StreamEnd, 28 | FirstDocumentStart, 29 | DocumentStart, 30 | DocumentContent, 31 | DocumentEnd, 32 | FlowSequenceFirstItem, 33 | FlowSequenceItem, 34 | FlowMappingFirstKey, 35 | FlowMappingKey, 36 | FlowMappingSimpleValue, 37 | FlowMappingValue, 38 | BlockSequenceFirstItem, 39 | BlockSequenceItem, 40 | BlockMappingFirstKey, 41 | BlockMappingKey, 42 | BlockMappingSimpleValue, 43 | BlockMappingValue 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Events/EventType.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Events 23 | { 24 | internal enum EventType 25 | { 26 | None, 27 | StreamStart, 28 | StreamEnd, 29 | DocumentStart, 30 | DocumentEnd, 31 | Alias, 32 | Scalar, 33 | SequenceStart, 34 | SequenceEnd, 35 | MappingStart, 36 | MappingEnd, 37 | Comment, 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Events/IParsingEventVisitor.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Events 23 | { 24 | /// 25 | /// Callback interface for external event Visitor. 26 | /// 27 | public interface IParsingEventVisitor 28 | { 29 | void Visit(AnchorAlias e); 30 | void Visit(StreamStart e); 31 | void Visit(StreamEnd e); 32 | void Visit(DocumentStart e); 33 | void Visit(DocumentEnd e); 34 | void Visit(Scalar e); 35 | void Visit(SequenceStart e); 36 | void Visit(SequenceEnd e); 37 | void Visit(MappingStart e); 38 | void Visit(MappingEnd e); 39 | void Visit(Comment e); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Events/MappingStyle.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Events 23 | { 24 | /// 25 | /// Specifies the style of a mapping. 26 | /// 27 | public enum MappingStyle 28 | { 29 | /// 30 | /// Let the emitter choose the style. 31 | /// 32 | Any, 33 | 34 | /// 35 | /// The block mapping style. 36 | /// 37 | Block, 38 | 39 | /// 40 | /// The flow mapping style. 41 | /// 42 | Flow 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Events/SequenceStyle.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Events 23 | { 24 | /// 25 | /// Specifies the style of a sequence. 26 | /// 27 | public enum SequenceStyle 28 | { 29 | /// 30 | /// Let the emitter choose the style. 31 | /// 32 | Any, 33 | 34 | /// 35 | /// The block sequence style. 36 | /// 37 | Block, 38 | 39 | /// 40 | /// The flow sequence style. 41 | /// 42 | Flow 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /YamlDotNet/Core/HashCode.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core 23 | { 24 | /// 25 | /// Supports implementations of by providing methods to combine two hash codes. 26 | /// 27 | internal static class HashCode 28 | { 29 | /// 30 | /// Combines two hash codes. 31 | /// 32 | /// The first hash code. 33 | /// The second hash code. 34 | /// 35 | public static int CombineHashCodes(int h1, int h2) 36 | { 37 | return ((h1 << 5) + h1) ^ h2; 38 | } 39 | 40 | public static int CombineHashCodes(int h1, object? o2) 41 | { 42 | return CombineHashCodes(h1, GetHashCode(o2)); 43 | } 44 | 45 | private static int GetHashCode(object? obj) 46 | { 47 | return obj != null ? obj.GetHashCode() : 0; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /YamlDotNet/Core/IEmitter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using YamlDotNet.Core.Events; 23 | 24 | namespace YamlDotNet.Core 25 | { 26 | /// 27 | /// Represents a YAML stream emitter. 28 | /// 29 | public interface IEmitter 30 | { 31 | /// 32 | /// Emits an event. 33 | /// 34 | void Emit(ParsingEvent @event); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /YamlDotNet/Core/ILookAheadBuffer.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core 23 | { 24 | internal interface ILookAheadBuffer 25 | { 26 | /// 27 | /// Gets a value indicating whether the end of the input reader has been reached. 28 | /// 29 | bool EndOfInput { get; } 30 | 31 | /// 32 | /// Gets the character at the specified offset. 33 | /// 34 | char Peek(int offset); 35 | 36 | /// 37 | /// Skips the next characters. Those characters must have been 38 | /// obtained first by calling the method. 39 | /// 40 | void Skip(int length); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /YamlDotNet/Core/IParser.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using YamlDotNet.Core.Events; 23 | 24 | namespace YamlDotNet.Core 25 | { 26 | /// 27 | /// Represents a YAML stream parser. 28 | /// 29 | public interface IParser 30 | { 31 | /// 32 | /// Gets the current event. Returns null before the first call to , 33 | /// and also after returns false. 34 | /// 35 | ParsingEvent? Current { get; } 36 | 37 | /// 38 | /// Moves to the next event. 39 | /// 40 | /// Returns true if there are more events available, otherwise returns false. 41 | bool MoveNext(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /YamlDotNet/Core/ParserState.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core 23 | { 24 | internal enum ParserState 25 | { 26 | StreamStart, 27 | StreamEnd, 28 | ImplicitDocumentStart, 29 | DocumentStart, 30 | DocumentContent, 31 | DocumentEnd, 32 | BlockNode, 33 | BlockNodeOrIndentlessSequence, 34 | FlowNode, 35 | BlockSequenceFirstEntry, 36 | BlockSequenceEntry, 37 | IndentlessSequenceEntry, 38 | BlockMappingFirstKey, 39 | BlockMappingKey, 40 | BlockMappingValue, 41 | FlowSequenceFirstEntry, 42 | FlowSequenceEntry, 43 | FlowSequenceEntryMappingKey, 44 | FlowSequenceEntryMappingValue, 45 | FlowSequenceEntryMappingEnd, 46 | FlowMappingFirstKey, 47 | FlowMappingKey, 48 | FlowMappingValue, 49 | FlowMappingEmptyValue 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/BlockEnd.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a block end token. 26 | /// 27 | public sealed class BlockEnd : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public BlockEnd() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public BlockEnd(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/BlockEntry.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a block entry event. 26 | /// 27 | public sealed class BlockEntry : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public BlockEntry() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public BlockEntry(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/BlockMappingStart.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a block mapping start token. 26 | /// 27 | public sealed class BlockMappingStart : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public BlockMappingStart() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public BlockMappingStart(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/BlockSequenceStart.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a block sequence start token. 26 | /// 27 | public sealed class BlockSequenceStart : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public BlockSequenceStart() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public BlockSequenceStart(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/DocumentEnd.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a document end token. 26 | /// 27 | public sealed class DocumentEnd : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public DocumentEnd() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public DocumentEnd(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/DocumentStart.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a document start token. 26 | /// 27 | public sealed class DocumentStart : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public DocumentStart() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public DocumentStart(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/Error.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Error tokens. 26 | /// 27 | public class Error : Token 28 | { 29 | /// 30 | /// Gets the value of the error 31 | /// 32 | public string Value { get; } 33 | 34 | public Error(string value, Mark start, Mark end) 35 | : base(start, end) 36 | { 37 | Value = value; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/FlowEntry.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a flow entry event. 26 | /// 27 | public sealed class FlowEntry : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public FlowEntry() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public FlowEntry(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/FlowMappingEnd.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a flow mapping end token. 26 | /// 27 | public sealed class FlowMappingEnd : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public FlowMappingEnd() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public FlowMappingEnd(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/FlowMappingStart.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a flow mapping start token. 26 | /// 27 | public sealed class FlowMappingStart : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public FlowMappingStart() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public FlowMappingStart(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/FlowSequenceEnd.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a flow sequence end token. 26 | /// 27 | public sealed class FlowSequenceEnd : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public FlowSequenceEnd() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public FlowSequenceEnd(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/FlowSequenceStart.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a flow sequence start token. 26 | /// 27 | public sealed class FlowSequenceStart : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public FlowSequenceStart() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public FlowSequenceStart(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/Key.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a key token. 26 | /// 27 | public sealed class Key : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public Key() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public Key(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/StreamEnd.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a stream end event. 26 | /// 27 | public sealed class StreamEnd : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public StreamEnd() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public StreamEnd(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/StreamStart.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a stream start token. 26 | /// 27 | public sealed class StreamStart : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public StreamStart() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public StreamStart(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/Token.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Base class for YAML tokens. 26 | /// 27 | public abstract class Token 28 | { 29 | /// 30 | /// Gets the start of the token in the input stream. 31 | /// 32 | public Mark Start { get; } 33 | 34 | /// 35 | /// Gets the end of the token in the input stream. 36 | /// 37 | public Mark End { get; } 38 | 39 | /// 40 | /// Initializes a new instance of the class. 41 | /// 42 | /// The start position of the token. 43 | /// The end position of the token. 44 | protected Token(in Mark start, in Mark end) 45 | { 46 | this.Start = start; 47 | this.End = end; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /YamlDotNet/Core/Tokens/Value.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Core.Tokens 23 | { 24 | /// 25 | /// Represents a value token. 26 | /// 27 | public sealed class Value : Token 28 | { 29 | /// 30 | /// Initializes a new instance of the class. 31 | /// 32 | public Value() 33 | : this(Mark.Empty, Mark.Empty) 34 | { 35 | } 36 | 37 | /// 38 | /// Initializes a new instance of the class. 39 | /// 40 | /// The start position of the token. 41 | /// The end position of the token. 42 | public Value(in Mark start, in Mark end) 43 | : base(start, end) 44 | { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/CultureInfoAdapter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using System.Globalization; 24 | 25 | namespace YamlDotNet 26 | { 27 | internal sealed class CultureInfoAdapter : CultureInfo 28 | { 29 | private readonly IFormatProvider provider; 30 | 31 | public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider) 32 | : base(baseCulture.Name) 33 | { 34 | this.provider = provider; 35 | } 36 | 37 | #if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER 38 | public override object GetFormat(Type? formatType) 39 | #else 40 | public override object? GetFormat(Type formatType) 41 | #endif 42 | { 43 | return provider.GetFormat(formatType)!; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /YamlDotNet/Helpers/FsharpHelper.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Serialization; 24 | 25 | namespace YamlDotNet.Helpers 26 | { 27 | public static class FsharpHelper 28 | { 29 | public static IFsharpHelper? Instance { get; set; } 30 | 31 | public static bool IsOptionType(Type t) => Instance?.IsOptionType(t) ?? false; 32 | 33 | public static Type? GetOptionUnderlyingType(Type t) => Instance?.GetOptionUnderlyingType(t); 34 | 35 | public static object? GetValue(IObjectDescriptor objectDescriptor) => Instance?.GetValue(objectDescriptor); 36 | 37 | public static bool IsFsharpListType(Type t) => Instance?.IsFsharpListType(t) ?? false; 38 | 39 | public static object? CreateFsharpListFromArray(Type t, Type itemsType, Array arr) => Instance?.CreateFsharpListFromArray(t, itemsType, arr); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /YamlDotNet/Helpers/IFsharpHelper.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Serialization; 24 | 25 | namespace YamlDotNet.Helpers 26 | { 27 | public interface IFsharpHelper 28 | { 29 | bool IsOptionType(Type t); 30 | Type? GetOptionUnderlyingType(Type t); 31 | object? GetValue(IObjectDescriptor objectDescriptor); 32 | bool IsFsharpListType(Type t); 33 | object? CreateFsharpListFromArray(Type t, Type itemsType, Array arr); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /YamlDotNet/Helpers/NullFsharpHelper.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Serialization; 24 | 25 | namespace YamlDotNet.Helpers 26 | { 27 | /// 28 | /// Empty implementation of the fsharphelper to allow trimming of csharp applications. 29 | /// 30 | public class NullFsharpHelper : IFsharpHelper 31 | { 32 | public object? CreateFsharpListFromArray(Type t, Type itemsType, Array arr) => null; 33 | 34 | public Type? GetOptionUnderlyingType(Type t) => null; 35 | 36 | public object? GetValue(IObjectDescriptor objectDescriptor) => null; 37 | 38 | public bool IsFsharpListType(Type t) => false; 39 | 40 | public bool IsOptionType(Type t) => false; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /YamlDotNet/Helpers/NumberExtensions.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Helpers 23 | { 24 | internal static class NumberExtensions 25 | { 26 | public static bool IsPowerOfTwo(this int value) 27 | { 28 | return (value & (value - 1)) == 0; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /YamlDotNet/Helpers/Polyfills.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #pragma warning disable IDE0130 23 | namespace YamlDotNet 24 | #pragma warning restore IDE0130 25 | { 26 | internal static class Polyfills 27 | { 28 | #if NETFRAMEWORK || NETSTANDARD2_0 29 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] 30 | internal static bool Contains(this string source, char c) => source.IndexOf(c) != -1; 31 | 32 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] 33 | internal static bool EndsWith(this string source, char c) => source.Length > 0 && source[source.Length - 1] == c; 34 | 35 | [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] 36 | internal static bool StartsWith(this string source, char c) => source.Length > 0 && source[0] == c; 37 | #endif 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /YamlDotNet/Helpers/ReadOnlyCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System.Collections.Generic; 23 | 24 | namespace YamlDotNet.Helpers 25 | { 26 | internal static class ReadOnlyCollectionExtensions 27 | { 28 | public static IReadOnlyList AsReadonlyList(this List list) 29 | { 30 | return list; 31 | } 32 | 33 | public static IReadOnlyDictionary AsReadonlyDictionary(this Dictionary dictionary) where TKey : notnull 34 | { 35 | return dictionary; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /YamlDotNet/Helpers/ThrowHelper.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using System.Runtime.CompilerServices; 24 | 25 | namespace YamlDotNet.Helpers 26 | { 27 | internal static class ThrowHelper 28 | { 29 | [MethodImpl(MethodImplOptions.NoInlining)] 30 | public static void ThrowArgumentOutOfRangeException(string paramName, string message) 31 | { 32 | throw new ArgumentOutOfRangeException(paramName, message); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /YamlDotNet/Portability/readme.txt: -------------------------------------------------------------------------------- 1 | The subdirectories of this directory contain platform-specific code 2 | that aims to bridge the gap between the different targetted platforms. 3 | 4 | Each directory should contain code that should only be included or excluded 5 | on a set of platforms. The name of the directory should consist of a list 6 | of target platforms, separated by a plus sign (+). 7 | In that directory, every file inside the 'include' subdirectory 8 | will be included in those platforms, while every file inside the 'exclude' subdirectory 9 | will be included in all other platforms. 10 | 11 | Most (all?) types added to this folder should be internal to avoid conflicting 12 | with other libraries. 13 | -------------------------------------------------------------------------------- /YamlDotNet/Properties/AssemblyInfo.template: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #pragma warning disable IDE0055 23 | #if !UNITY 24 | using System.Reflection; 25 | using System.Runtime.InteropServices; 26 | 27 | // Setting ComVisible to false makes the types in this assembly not visible 28 | // to COM components. If you need to access a type in this assembly from 29 | // COM, set the ComVisible attribute to true on that type. 30 | [assembly: ComVisible(false)] 31 | 32 | // Version information for an assembly consists of the following four values: 33 | // 34 | // Major Version 35 | // Minor Version 36 | // Build Number 37 | // Revision 38 | // 39 | // You can specify all the values or you can default the Revision and Build Numbers 40 | // by using the '*' as shown below: 41 | [assembly: AssemblyVersion("<%assemblyVersion%>")] 42 | [assembly: AssemblyFileVersion("<%assemblyFileVersion%>")] 43 | [assembly: AssemblyInformationalVersion("<%assemblyInformationalVersion%>")] 44 | 45 | #endif 46 | #pragma warning restore IDE0055 47 | -------------------------------------------------------------------------------- /YamlDotNet/PropertyInfoExtensions.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System.Reflection; 23 | 24 | namespace YamlDotNet 25 | { 26 | internal static class PropertyInfoExtensions 27 | { 28 | public static object? ReadValue(this PropertyInfo property, object target) 29 | { 30 | return property.GetValue(target, null); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /YamlDotNet/RepresentationModel/EmitterState.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System.Collections.Generic; 23 | using YamlDotNet.Core; 24 | 25 | namespace YamlDotNet.RepresentationModel 26 | { 27 | /// 28 | /// Holds state that is used when emitting a stream. 29 | /// 30 | internal class EmitterState 31 | { 32 | /// 33 | /// Gets the already emitted anchors. 34 | /// 35 | /// The emitted anchors. 36 | public HashSet EmittedAnchors { get; } = []; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /YamlDotNet/RepresentationModel/YamlNodeIdentityEqualityComparer.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System.Collections.Generic; 23 | using System.Diagnostics.CodeAnalysis; 24 | 25 | namespace YamlDotNet.RepresentationModel 26 | { 27 | /// 28 | /// Comparer that is based on identity comparisons. 29 | /// 30 | public sealed class YamlNodeIdentityEqualityComparer : IEqualityComparer 31 | { 32 | #region IEqualityComparer Members 33 | 34 | /// 35 | public bool Equals([AllowNull] YamlNode x, [AllowNull] YamlNode y) 36 | { 37 | return ReferenceEquals(x, y); 38 | } 39 | 40 | /// 41 | public int GetHashCode(YamlNode obj) 42 | { 43 | return obj.GetHashCode(); 44 | } 45 | 46 | #endregion 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /YamlDotNet/RepresentationModel/YamlNodeType.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.RepresentationModel 23 | { 24 | /// 25 | /// Specifies the type of node in the representation model. 26 | /// 27 | public enum YamlNodeType 28 | { 29 | /// 30 | /// The node is a . 31 | /// 32 | Alias, 33 | 34 | /// 35 | /// The node is a . 36 | /// 37 | Mapping, 38 | 39 | /// 40 | /// The node is a . 41 | /// 42 | Scalar, 43 | 44 | /// 45 | /// The node is a . 46 | /// 47 | Sequence 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/Callbacks/OnDeserializedAttribute.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | 24 | namespace YamlDotNet.Serialization.Callbacks 25 | { 26 | [AttributeUsage(AttributeTargets.Method)] 27 | public sealed class OnDeserializedAttribute : Attribute 28 | { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/Callbacks/OnDeserializingAttribute.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | 24 | namespace YamlDotNet.Serialization.Callbacks 25 | { 26 | [AttributeUsage(AttributeTargets.Method)] 27 | public sealed class OnDeserializingAttribute : Attribute 28 | { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/Callbacks/OnSerializedAttribute.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | 24 | namespace YamlDotNet.Serialization.Callbacks 25 | { 26 | [AttributeUsage(AttributeTargets.Method)] 27 | public sealed class OnSerializedAttribute : Attribute 28 | { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/Callbacks/OnSerializingAttribute.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | 24 | namespace YamlDotNet.Serialization.Callbacks 25 | { 26 | [AttributeUsage(AttributeTargets.Method)] 27 | public sealed class OnSerializingAttribute : Attribute 28 | { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/IAliasProvider.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using YamlDotNet.Core; 23 | 24 | namespace YamlDotNet.Serialization 25 | { 26 | public interface IAliasProvider 27 | { 28 | AnchorName GetAlias(object target); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/IEventEmitter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using YamlDotNet.Core; 23 | 24 | namespace YamlDotNet.Serialization 25 | { 26 | public interface IEventEmitter 27 | { 28 | void Emit(AliasEventInfo eventInfo, IEmitter emitter); 29 | void Emit(ScalarEventInfo eventInfo, IEmitter emitter); 30 | void Emit(MappingStartEventInfo eventInfo, IEmitter emitter); 31 | void Emit(MappingEndEventInfo eventInfo, IEmitter emitter); 32 | void Emit(SequenceStartEventInfo eventInfo, IEmitter emitter); 33 | void Emit(SequenceEndEventInfo eventInfo, IEmitter emitter); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/INamingConvention.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | 23 | namespace YamlDotNet.Serialization 24 | { 25 | /// 26 | /// Translates property names according to a specific convention. 27 | /// 28 | public interface INamingConvention 29 | { 30 | string Apply(string value); 31 | string Reverse(string value); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/INodeDeserializer.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Core; 24 | 25 | namespace YamlDotNet.Serialization 26 | { 27 | public interface INodeDeserializer 28 | { 29 | 30 | bool Deserialize(IParser reader, Type expectedType, Func nestedObjectDeserializer, out object? value, ObjectDeserializer rootDeserializer); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/INodeTypeResolver.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Core.Events; 24 | 25 | namespace YamlDotNet.Serialization 26 | { 27 | public interface INodeTypeResolver 28 | { 29 | /// 30 | /// Determines the type of the specified node. 31 | /// 32 | /// The node to be deserialized. 33 | /// The type that has been determined so far. 34 | /// 35 | /// true if has been resolved completely; 36 | /// false if the next type should be invoked. 37 | /// 38 | bool Resolve(NodeEvent? nodeEvent, ref Type currentType); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/IObjectGraphTraversalStrategy.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Serialization 23 | { 24 | /// 25 | /// Defines a strategy that walks through an object graph. 26 | /// 27 | public interface IObjectGraphTraversalStrategy 28 | { 29 | /// 30 | /// Traverses the specified object graph. 31 | /// 32 | /// The graph. 33 | /// An that is to be notified during the traversal. 34 | /// A that will be passed to the . 35 | /// The serializer to use to serialize complex objects. 36 | void Traverse(IObjectDescriptor graph, IObjectGraphVisitor visitor, TContext context, ObjectSerializer serializer); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/IPropertyDescriptor.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Core; 24 | 25 | namespace YamlDotNet.Serialization 26 | { 27 | public interface IPropertyDescriptor 28 | { 29 | string Name { get; } 30 | bool AllowNulls { get; } 31 | bool CanWrite { get; } 32 | Type Type { get; } 33 | Type? TypeOverride { get; set; } 34 | int Order { get; set; } 35 | ScalarStyle ScalarStyle { get; set; } 36 | bool Required { get; } 37 | Type? ConverterType { get; } 38 | 39 | T? GetCustomAttribute() where T : Attribute; 40 | 41 | IObjectDescriptor Read(object target); 42 | void Write(object target, object? value); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/ITypeResolver.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | 24 | namespace YamlDotNet.Serialization 25 | { 26 | /// 27 | /// Resolves the type of values. 28 | /// 29 | public interface ITypeResolver 30 | { 31 | Type Resolve(Type staticType, object? actualValue); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/IValueDeserializer.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Core; 24 | using YamlDotNet.Serialization.Utilities; 25 | 26 | namespace YamlDotNet.Serialization 27 | { 28 | public interface IValueDeserializer 29 | { 30 | object? DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/IValuePromise.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | 24 | namespace YamlDotNet.Serialization 25 | { 26 | public interface IValuePromise 27 | { 28 | event Action ValueAvailable; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/IValueSerializer.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Core; 24 | 25 | namespace YamlDotNet.Serialization 26 | { 27 | public interface IValueSerializer 28 | { 29 | void SerializeValue(IEmitter emitter, object? value, Type? type); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/IYamlSerializable.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Core; 24 | 25 | namespace YamlDotNet.Serialization 26 | { 27 | /// 28 | /// Allows an object to customize how it is serialized and deserialized. 29 | /// 30 | [Obsolete("Please use IYamlConvertible instead")] 31 | public interface IYamlSerializable 32 | { 33 | /// 34 | /// Reads this object's state from a YAML parser. 35 | /// 36 | void ReadYaml(IParser parser); 37 | 38 | /// 39 | /// Writes this object's state to a YAML emitter. 40 | /// 41 | void WriteYaml(IEmitter emitter); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/IYamlTypeConverter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Core; 24 | 25 | namespace YamlDotNet.Serialization 26 | { 27 | /// 28 | /// Allows to customize how a type is serialized and deserialized. 29 | /// 30 | public interface IYamlTypeConverter 31 | { 32 | /// 33 | /// Gets a value indicating whether the current converter supports converting the specified type. 34 | /// 35 | bool Accepts(Type type); 36 | 37 | /// 38 | /// Reads an object's state from a YAML parser. 39 | /// 40 | object? ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer); 41 | 42 | /// 43 | /// Writes the specified object's state to a YAML emitter. 44 | /// 45 | void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializer serializer); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/NamingConventions/NullNamingConvention.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | 23 | using System; 24 | using YamlDotNet.Serialization.Utilities; 25 | 26 | namespace YamlDotNet.Serialization.NamingConventions 27 | { 28 | /// 29 | /// Performs no naming conversion. 30 | /// 31 | public sealed class NullNamingConvention : INamingConvention 32 | { 33 | [Obsolete("Use the Instance static field instead of creating new instances")] 34 | public NullNamingConvention() { } 35 | 36 | public string Apply(string value) 37 | { 38 | return value; 39 | } 40 | 41 | public string Reverse(string value) 42 | { 43 | return value; 44 | } 45 | 46 | #pragma warning disable CS0618 // Type or member is obsolete 47 | public static readonly INamingConvention Instance = new NullNamingConvention(); 48 | #pragma warning restore CS0618 // Type or member is obsolete 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/NodeTypeResolvers/DefaultContainersNodeTypeResolver.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using System.Collections.Generic; 24 | using YamlDotNet.Core.Events; 25 | 26 | namespace YamlDotNet.Serialization.NodeTypeResolvers 27 | { 28 | public sealed class DefaultContainersNodeTypeResolver : INodeTypeResolver 29 | { 30 | bool INodeTypeResolver.Resolve(NodeEvent? nodeEvent, ref Type currentType) 31 | { 32 | if (currentType == typeof(object)) 33 | { 34 | if (nodeEvent is SequenceStart) 35 | { 36 | currentType = typeof(List); 37 | return true; 38 | } 39 | if (nodeEvent is MappingStart) 40 | { 41 | currentType = typeof(Dictionary); 42 | return true; 43 | } 44 | } 45 | 46 | return false; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/NodeTypeResolvers/RejectUnknownTagsNodeTypeResolver.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Core; 24 | using YamlDotNet.Core.Events; 25 | 26 | namespace YamlDotNet.Serialization.NodeTypeResolvers 27 | { 28 | public class PreventUnknownTagsNodeTypeResolver : INodeTypeResolver 29 | { 30 | bool INodeTypeResolver.Resolve(NodeEvent? nodeEvent, ref Type currentType) 31 | { 32 | if (nodeEvent != null && !nodeEvent.Tag.IsEmpty) 33 | { 34 | throw new YamlException(nodeEvent.Start, nodeEvent.End, $"Encountered an unresolved tag '{nodeEvent.Tag}'"); 35 | } 36 | return false; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/NodeTypeResolvers/YamlConvertibleTypeResolver.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Core.Events; 24 | 25 | namespace YamlDotNet.Serialization.NodeTypeResolvers 26 | { 27 | public sealed class YamlConvertibleTypeResolver : INodeTypeResolver 28 | { 29 | public bool Resolve(NodeEvent? nodeEvent, ref Type currentType) 30 | { 31 | return typeof(IYamlConvertible).IsAssignableFrom(currentType); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/NodeTypeResolvers/YamlSerializableTypeResolver.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Core.Events; 24 | 25 | namespace YamlDotNet.Serialization.NodeTypeResolvers 26 | { 27 | public sealed class YamlSerializableTypeResolver : INodeTypeResolver 28 | { 29 | public bool Resolve(NodeEvent? nodeEvent, ref Type currentType) 30 | { 31 | #pragma warning disable 0618 // IYamlSerializable is obsolete 32 | return typeof(IYamlSerializable).IsAssignableFrom(currentType); 33 | #pragma warning restore 0618 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/Nothing.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | 23 | namespace YamlDotNet.Serialization 24 | { 25 | /// 26 | /// An empty type for cases where a type needs to be provided but won't be used. 27 | /// 28 | public struct Nothing 29 | { 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/ObjectDescriptor.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Core; 24 | 25 | namespace YamlDotNet.Serialization 26 | { 27 | public sealed class ObjectDescriptor : IObjectDescriptor 28 | { 29 | public object? Value { get; private set; } 30 | public Type Type { get; private set; } 31 | public Type StaticType { get; private set; } 32 | public ScalarStyle ScalarStyle { get; private set; } 33 | 34 | public ObjectDescriptor(object? value, Type type, Type staticType) 35 | : this(value, type, staticType, ScalarStyle.Any) 36 | { 37 | } 38 | 39 | public ObjectDescriptor(object? value, Type type, Type staticType, ScalarStyle scalarStyle) 40 | { 41 | Value = value; 42 | Type = type ?? throw new ArgumentNullException(nameof(type)); 43 | StaticType = staticType ?? throw new ArgumentNullException(nameof(staticType)); 44 | 45 | ScalarStyle = scalarStyle; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/ObjectFactories/LambdaObjectFactory.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using System.Collections; 24 | using System.Collections.Generic; 25 | using YamlDotNet.Helpers; 26 | using YamlDotNet.Serialization.Utilities; 27 | 28 | namespace YamlDotNet.Serialization.ObjectFactories 29 | { 30 | /// 31 | /// Creates objects using a Func{Type,object}"/>. 32 | /// 33 | public sealed class LambdaObjectFactory : ObjectFactoryBase 34 | { 35 | private readonly Func factory; 36 | 37 | public LambdaObjectFactory(Func factory) 38 | { 39 | this.factory = factory ?? throw new ArgumentNullException(nameof(factory)); 40 | } 41 | 42 | public override object Create(Type type) 43 | { 44 | return factory(type); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/ObjectGraphVisitors/CommentsObjectGraphVisitor.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using YamlDotNet.Core; 23 | 24 | namespace YamlDotNet.Serialization.ObjectGraphVisitors 25 | { 26 | public sealed class CommentsObjectGraphVisitor : ChainedObjectGraphVisitor 27 | { 28 | public CommentsObjectGraphVisitor(IObjectGraphVisitor nextVisitor) 29 | : base(nextVisitor) 30 | { 31 | } 32 | 33 | public override bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, IEmitter context, ObjectSerializer serializer) 34 | { 35 | var yamlMember = key.GetCustomAttribute(); 36 | if (yamlMember?.Description != null) 37 | { 38 | context.Emit(new Core.Events.Comment(yamlMember.Description, false)); 39 | } 40 | 41 | return base.EnterMapping(key, value, context, serializer); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/Settings.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Serialization 23 | { 24 | public class Settings 25 | { 26 | /// 27 | /// If true then private, parameterless constructors will be invoked if a public one is not available. 28 | /// 29 | public bool AllowPrivateConstructors { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/TypeResolvers/DynamicTypeResolver.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | 24 | namespace YamlDotNet.Serialization.TypeResolvers 25 | { 26 | /// 27 | /// The type returned will be the actual type of the value, if available. 28 | /// 29 | public sealed class DynamicTypeResolver : ITypeResolver 30 | { 31 | public Type Resolve(Type staticType, object? actualValue) 32 | { 33 | return actualValue != null ? actualValue.GetType() : staticType; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/Utilities/IPostDeserializationCallback.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | namespace YamlDotNet.Serialization.Utilities 23 | { 24 | /// 25 | /// Indicates that a class used as deserialization state 26 | /// needs to be notified after deserialization. 27 | /// 28 | public interface IPostDeserializationCallback 29 | { 30 | void OnDeserialization(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/Utilities/ITypeConverter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | 24 | namespace YamlDotNet.Serialization.Utilities 25 | { 26 | public interface ITypeConverter 27 | { 28 | /// 29 | /// Convert a value to a specified type 30 | /// 31 | /// 32 | /// 33 | /// Naming convention to use on enums in the type converter. 34 | /// The type inspector to use when getting information about a type. 35 | /// 36 | object? ChangeType(object? value, Type expectedType, INamingConvention enumNamingConvention, ITypeInspector typeInspector); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/Utilities/NullTypeConverter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | 24 | namespace YamlDotNet.Serialization.Utilities 25 | { 26 | public class NullTypeConverter : ITypeConverter 27 | { 28 | public object? ChangeType(object? value, Type expectedType, INamingConvention enumNamingConvention, ITypeInspector typeInspector) => value; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/Utilities/ReflectionTypeConverter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | using YamlDotNet.Serialization.NamingConventions; 24 | 25 | namespace YamlDotNet.Serialization.Utilities 26 | { 27 | public class ReflectionTypeConverter : ITypeConverter 28 | { 29 | public object? ChangeType(object? value, Type expectedType, ITypeInspector typeInspector) => ChangeType(value, expectedType, NullNamingConvention.Instance, typeInspector); 30 | public object? ChangeType(object? value, Type expectedType, INamingConvention enumNamingConvention, ITypeInspector typeInspector) => TypeConverter.ChangeType(value, expectedType, enumNamingConvention, typeInspector); 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/YamlConverterAttribute.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | 24 | namespace YamlDotNet.Serialization 25 | { 26 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] 27 | public sealed class YamlConverterAttribute : Attribute 28 | { 29 | public Type ConverterType { get; } 30 | 31 | public YamlConverterAttribute(Type converterType) 32 | { 33 | ConverterType = converterType; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/YamlIgnoreAttribute.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | 24 | namespace YamlDotNet.Serialization 25 | { 26 | /// 27 | /// Instructs the YamlSerializer not to serialize the public field or public read/write property value. 28 | /// 29 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)] 30 | public sealed class YamlIgnoreAttribute : Attribute 31 | { 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /YamlDotNet/Serialization/YamlStaticContextAttribute.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System; 23 | 24 | namespace YamlDotNet.Serialization 25 | { 26 | [AttributeUsage(AttributeTargets.Class)] 27 | public sealed class YamlStaticContextAttribute : Attribute 28 | { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /YamlDotNet/StandardRegexOptions.cs: -------------------------------------------------------------------------------- 1 | // This file is part of YamlDotNet - A .NET library for YAML. 2 | // Copyright (c) Antoine Aubry and contributors 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | // of the Software, and to permit persons to whom the Software is furnished to do 9 | // so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | using System.Text.RegularExpressions; 23 | 24 | namespace YamlDotNet 25 | { 26 | internal static class StandardRegexOptions 27 | { 28 | public const RegexOptions Compiled = RegexOptions.Compiled; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 0.0.{build} 2 | 3 | image: Visual Studio 2022 4 | 5 | test: off 6 | 7 | environment: 8 | NUGET_API_KEY: 9 | secure: IqF+zcEvCdvPlKDJs34AyfG24p990HSJ2Tdh9ml1v57bzVLYgHSRvcNoW/daApfi 10 | GITHUB_TOKEN: 11 | secure: ulVa56sjSUcOy/08/Qn88LsGVfndWBizu5gRdVTvsGu/ju1fKUe8XCZPvUvypvWH 12 | TWITTER_CONSUMER_API_KEY: 13 | secure: o4jM6NnXqtI3/Bzef2xpcTAOuPn/WwO+khiWvrbletk= 14 | TWITTER_CONSUMER_API_SECRET: 15 | secure: a4TQjB1vp0lRFZ7aA7RamHAhkHlPlMqdvsaZvzGs/pPkR+YfuGQ7AKlknD26HIE0xGUTi8M1wqffQUKJL1knHg== 16 | TWITTER_ACCESS_TOKEN: 17 | secure: TfgxKzf9AAbDuJmuYnnzjYKhHcxyYv7Z+AnFRzlQc5CcIJ3h52YZAokQGF3n3K8r21V1DxeKHc/qWG1yZs4NKg== 18 | TWITTER_ACCESS_TOKEN_SECRET: 19 | secure: aMvxmavbq8tylMDe8QGEdemNMPzrd7i6982i/iVydNYHhUvzV7lw5AJsiEpfRyzt 20 | 21 | install: 22 | - cmd: git submodule update --init 23 | - cmd: dotnet tool install --global GitVersion.Tool 24 | 25 | build_script: 26 | - cmd: .\build.cmd --appveyor 27 | 28 | artifacts: 29 | - path: YamlDotNet\bin\Release\netstandard2.0 30 | name: Release-NetStandard-2.0 31 | 32 | - path: YamlDotNet\bin\Release\netstandard2.1 33 | name: Release-NetStandard-2.1 34 | 35 | - path: YamlDotNet\bin\Release\net47 36 | name: Release-Net47 37 | 38 | - path: YamlDotNet\bin\Release\net6.0 39 | name: Release-Net60 40 | 41 | - path: YamlDotNet\bin\Release\net8.0 42 | name: Release-Net80 43 | 44 | - path: YamlDotNet\bin\*.nupkg 45 | - path: YamlDotNet\bin\*.snupkg 46 | -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | dotnet run --project .\tools\build\build.csproj -- %* 3 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dotnet run --project ./tools/build/build.csproj -- $@ 3 | -------------------------------------------------------------------------------- /docker-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -d ../YamlDotNet.wiki ] 4 | then 5 | docker run -u=`id -u` -v `pwd`:/build/YamlDotNet -v `pwd`/../YamlDotNet.wiki:/build/YamlDotNet.wiki -v ~/.nuget/packages:/home/build/.nuget/packages -w /build/YamlDotNet -it aaubry/yamldotnet.local ./build.sh "$@" 6 | else 7 | docker run -u=`id -u` -v `pwd`:/build/YamlDotNet -v ~/.nuget/packages:/home/build/.nuget/packages -w /build/YamlDotNet -it aaubry/yamldotnet.local ./build.sh "$@" 8 | fi 9 | -------------------------------------------------------------------------------- /tools/build/AutoNumberToStringConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Text.Json; 4 | using System.Text.Json.Serialization; 5 | 6 | namespace build 7 | { 8 | internal class AutoNumberToStringConverter : JsonConverter 9 | { 10 | public override bool CanConvert(Type typeToConvert) 11 | { 12 | return typeof(string) == typeToConvert; 13 | } 14 | 15 | public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) 16 | { 17 | if (reader.TokenType == JsonTokenType.Number) 18 | { 19 | if (reader.TryGetInt64(out long number)) 20 | { 21 | return number.ToString(CultureInfo.InvariantCulture); 22 | } 23 | 24 | if (reader.TryGetDouble(out var doubleNumber)) 25 | { 26 | return doubleNumber.ToString(CultureInfo.InvariantCulture); 27 | } 28 | } 29 | 30 | if (reader.TokenType == JsonTokenType.String) 31 | { 32 | return reader.GetString()!; 33 | } 34 | 35 | using var document = JsonDocument.ParseValue(ref reader); 36 | return document.RootElement.Clone().ToString(); 37 | } 38 | 39 | public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options) 40 | { 41 | writer.WriteStringValue(value); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tools/build/GitHubApiModels.cs: -------------------------------------------------------------------------------- 1 | namespace build 2 | { 3 | internal static class GitHubApiModels 4 | { 5 | public class Release 6 | { 7 | public string? html_url { get; set; } 8 | public string? body { get; set; } 9 | } 10 | 11 | public class Issue 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tools/build/build.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net8.0 6 | AnyCPU 7 | Enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /tools/build/build.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30804.86 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "build", "build.csproj", "{65F9A775-7BFB-4C55-9894-5E318C64CF24}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {65F9A775-7BFB-4C55-9894-5E318C64CF24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {65F9A775-7BFB-4C55-9894-5E318C64CF24}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {65F9A775-7BFB-4C55-9894-5E318C64CF24}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {65F9A775-7BFB-4C55-9894-5E318C64CF24}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {1F7799BC-20C9-4894-8A16-D0B0CC7B1BF4} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /tools/parsers/build.ps1: -------------------------------------------------------------------------------- 1 | 2 | dir -Attributes Directory | % { 3 | docker build $_.Name -t "aaubry/yaml-$($_.Name)" 4 | } 5 | 6 | dir -Attributes Directory | % { 7 | Write-Host "echo a:b | docker run --rm -i aaubry/yaml-$($_.Name)" 8 | } 9 | -------------------------------------------------------------------------------- /tools/parsers/perl-yaml-pp/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | RUN apt-get update && apt-get install -y libyaml-pp-perl 4 | COPY parse.pl /app/ 5 | WORKDIR /app 6 | 7 | ENTRYPOINT [ "/usr/bin/perl", "-w", "/app/parse.pl" ] 8 | -------------------------------------------------------------------------------- /tools/parsers/perl-yaml-pp/parse.pl: -------------------------------------------------------------------------------- 1 | use YAML::PP qw/ Load Dump /; 2 | 3 | my $input; 4 | while(<>) { 5 | $input .= $_; 6 | } 7 | 8 | my $doc = Load($input); 9 | print(Dump($doc)); 10 | -------------------------------------------------------------------------------- /tools/parsers/python/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | RUN apt-get update && apt-get install -y python3 python3-yaml 4 | WORKDIR /app 5 | 6 | ENTRYPOINT [ "/usr/bin/python3", "-c", "import sys, yaml, json; print(json.dumps(yaml.load(sys.stdin.read(), Loader=yaml.SafeLoader)))" ] 7 | -------------------------------------------------------------------------------- /tools/parsers/reference/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | WORKDIR /app 4 | 5 | RUN apt-get update && apt-get install -y cabal-install git 6 | RUN cabal update 7 | RUN git clone https://github.com/orenbenkiki/yamlreference.git . 8 | RUN cabal install --only-dependencies 9 | RUN cabal configure 10 | RUN cabal build 11 | COPY run.sh /app/ 12 | 13 | ENTRYPOINT [ "/usr/bin/bash", "/app/run.sh" ] 14 | -------------------------------------------------------------------------------- /tools/parsers/reference/run.sh: -------------------------------------------------------------------------------- 1 | 2 | if [ "$1" == "--html" ]; then 3 | /app/dist/build/yaml2yeast/yaml2yeast <&0 | /app/yeast2html 4 | else 5 | echo "Use --html for HTML output" 6 | /app/dist/build/yaml2yeast/yaml2yeast <&0 | grep --color -E '^!.*|$' 7 | fi 8 | -------------------------------------------------------------------------------- /tools/syntax-checker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y cabal-install git wget apt-transport-https software-properties-common python3-pip 4 | RUN cabal update 5 | 6 | WORKDIR /opt/yamlreference 7 | RUN git clone https://github.com/orenbenkiki/yamlreference.git . 8 | RUN cabal install --only-dependencies 9 | RUN cabal configure 10 | RUN cabal build 11 | 12 | WORKDIR /tmp 13 | RUN wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb 14 | RUN dpkg -i packages-microsoft-prod.deb 15 | RUN apt-get update 16 | RUN add-apt-repository universe 17 | RUN apt-get install -y powershell 18 | 19 | RUN pip3 install rundoc 20 | 21 | RUN apt-get clean 22 | 23 | WORKDIR /app 24 | COPY check-syntax.ps1 /app 25 | 26 | ENTRYPOINT [ "/opt/microsoft/powershell/7/pwsh", "/app/check-syntax.ps1" ] 27 | -------------------------------------------------------------------------------- /tools/syntax-checker/build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | docker build -t aaubry/yamldotnet-syntax-checker . 4 | REM docker push aaubry/yamldotnet-syntax-checker 5 | -------------------------------------------------------------------------------- /yamldotnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aaubry/YamlDotNet/b8ac2a98ffcc12434eff6c6abb75b38ad1b1ab04/yamldotnet.png -------------------------------------------------------------------------------- /yamldotnet.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aaubry/YamlDotNet/b8ac2a98ffcc12434eff6c6abb75b38ad1b1ab04/yamldotnet.xcf --------------------------------------------------------------------------------