From 3cbf69b92828c14fc4cd0ce4ea1d330f7cb17eb5 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 11 Jan 2023 12:33:22 -0500 Subject: [PATCH] deserializing data --- namedropper/Assets/Resources.meta | 8 + namedropper/Assets/Resources/categories.yaml | 82 + .../Assets/Resources/categories.yaml.meta | 7 + namedropper/Assets/Scripts/CategoryData.cs | 10 + .../Assets/Scripts/CategoryData.cs.meta | 11 + namedropper/Assets/Scripts/Game.cs | 81 +- namedropper/Assets/Scripts/GameData.cs | 11 + namedropper/Assets/Scripts/GameData.cs.meta | 11 + namedropper/Assets/Scripts/Player.cs | 1 + namedropper/Assets/Sprites/TopicData.cs | 10 + namedropper/Assets/Sprites/TopicData.cs.meta | 11 + namedropper/Assets/YamlDotNet.meta | 8 + namedropper/Assets/YamlDotNet/Core.meta | 9 + .../Assets/YamlDotNet/Core/AnchorName.cs | 76 + .../Assets/YamlDotNet/Core/AnchorName.cs.meta | 11 + .../Core/AnchorNotFoundException.cs | 58 + .../Core/AnchorNotFoundException.cs.meta | 12 + .../YamlDotNet/Core/CharacterAnalyzer.cs | 166 ++ .../YamlDotNet/Core/CharacterAnalyzer.cs.meta | 12 + .../Assets/YamlDotNet/Core/Constants.cs | 40 + .../Assets/YamlDotNet/Core/Constants.cs.meta | 11 + namedropper/Assets/YamlDotNet/Core/Cursor.cs | 69 + .../Assets/YamlDotNet/Core/Cursor.cs.meta | 12 + namedropper/Assets/YamlDotNet/Core/Emitter.cs | 1903 ++++++++++++ .../Assets/YamlDotNet/Core/Emitter.cs.meta | 12 + .../Assets/YamlDotNet/Core/EmitterSettings.cs | 159 + .../YamlDotNet/Core/EmitterSettings.cs.meta | 11 + .../Assets/YamlDotNet/Core/EmitterState.cs | 45 + .../YamlDotNet/Core/EmitterState.cs.meta | 11 + .../Assets/YamlDotNet/Core/Events.meta | 9 + .../YamlDotNet/Core/Events/AnchorAlias.cs | 85 + .../Core/Events/AnchorAlias.cs.meta | 12 + .../Assets/YamlDotNet/Core/Events/Comment.cs | 59 + .../YamlDotNet/Core/Events/Comment.cs.meta | 12 + .../YamlDotNet/Core/Events/DocumentEnd.cs | 90 + .../Core/Events/DocumentEnd.cs.meta | 12 + .../YamlDotNet/Core/Events/DocumentStart.cs | 128 + .../Core/Events/DocumentStart.cs.meta | 12 + .../YamlDotNet/Core/Events/EventType.cs | 39 + .../YamlDotNet/Core/Events/EventType.cs.meta | 11 + .../Core/Events/IParsingEventVisitor.cs | 41 + .../Core/Events/IParsingEventVisitor.cs.meta | 11 + .../YamlDotNet/Core/Events/MappingEnd.cs | 79 + .../YamlDotNet/Core/Events/MappingEnd.cs.meta | 12 + .../YamlDotNet/Core/Events/MappingStart.cs | 116 + .../Core/Events/MappingStart.cs.meta | 12 + .../YamlDotNet/Core/Events/MappingStyle.cs | 44 + .../Core/Events/MappingStyle.cs.meta | 11 + .../YamlDotNet/Core/Events/NodeEvent.cs | 72 + .../YamlDotNet/Core/Events/NodeEvent.cs.meta | 12 + .../YamlDotNet/Core/Events/ParsingEvent.cs | 68 + .../Core/Events/ParsingEvent.cs.meta | 12 + .../Assets/YamlDotNet/Core/Events/Scalar.cs | 143 + .../YamlDotNet/Core/Events/Scalar.cs.meta | 12 + .../YamlDotNet/Core/Events/SequenceEnd.cs | 79 + .../Core/Events/SequenceEnd.cs.meta | 12 + .../YamlDotNet/Core/Events/SequenceStart.cs | 105 + .../Core/Events/SequenceStart.cs.meta | 12 + .../YamlDotNet/Core/Events/SequenceStyle.cs | 44 + .../Core/Events/SequenceStyle.cs.meta | 11 + .../YamlDotNet/Core/Events/StreamEnd.cs | 91 + .../YamlDotNet/Core/Events/StreamEnd.cs.meta | 12 + .../YamlDotNet/Core/Events/StreamStart.cs | 91 + .../Core/Events/StreamStart.cs.meta | 12 + .../ForwardAnchorNotSupportedException.cs | 59 + ...ForwardAnchorNotSupportedException.cs.meta | 12 + .../Assets/YamlDotNet/Core/HashCode.cs | 60 + .../Assets/YamlDotNet/Core/HashCode.cs.meta | 12 + .../Assets/YamlDotNet/Core/IEmitter.cs | 36 + .../Assets/YamlDotNet/Core/IEmitter.cs.meta | 11 + .../YamlDotNet/Core/ILookAheadBuffer.cs | 42 + .../YamlDotNet/Core/ILookAheadBuffer.cs.meta | 12 + namedropper/Assets/YamlDotNet/Core/IParser.cs | 43 + .../Assets/YamlDotNet/Core/IParser.cs.meta | 12 + .../Assets/YamlDotNet/Core/IScanner.cs | 58 + .../Assets/YamlDotNet/Core/IScanner.cs.meta | 12 + .../Assets/YamlDotNet/Core/InsertionQueue.cs | 216 ++ .../YamlDotNet/Core/InsertionQueue.cs.meta | 12 + .../Assets/YamlDotNet/Core/LookAheadBuffer.cs | 170 ++ .../YamlDotNet/Core/LookAheadBuffer.cs.meta | 12 + namedropper/Assets/YamlDotNet/Core/Mark.cs | 141 + .../Assets/YamlDotNet/Core/Mark.cs.meta | 12 + .../MaximumRecursionLevelReachedException.cs | 58 + ...imumRecursionLevelReachedException.cs.meta | 12 + .../Assets/YamlDotNet/Core/MergingParser.cs | 311 ++ .../YamlDotNet/Core/MergingParser.cs.meta | 12 + namedropper/Assets/YamlDotNet/Core/Parser.cs | 1103 +++++++ .../Assets/YamlDotNet/Core/Parser.cs.meta | 12 + .../YamlDotNet/Core/ParserExtensions.cs | 151 + .../YamlDotNet/Core/ParserExtensions.cs.meta | 11 + .../Assets/YamlDotNet/Core/ParserState.cs | 51 + .../YamlDotNet/Core/ParserState.cs.meta | 11 + .../Assets/YamlDotNet/Core/RecursionLevel.cs | 80 + .../YamlDotNet/Core/RecursionLevel.cs.meta | 11 + .../Assets/YamlDotNet/Core/ScalarStyle.cs | 59 + .../YamlDotNet/Core/ScalarStyle.cs.meta | 11 + namedropper/Assets/YamlDotNet/Core/Scanner.cs | 2566 +++++++++++++++++ .../Assets/YamlDotNet/Core/Scanner.cs.meta | 12 + .../YamlDotNet/Core/SemanticErrorException.cs | 58 + .../Core/SemanticErrorException.cs.meta | 12 + .../Assets/YamlDotNet/Core/SimpleKey.cs | 56 + .../Assets/YamlDotNet/Core/SimpleKey.cs.meta | 12 + .../YamlDotNet/Core/StringLookAheadBuffer.cs | 61 + .../Core/StringLookAheadBuffer.cs.meta | 12 + .../YamlDotNet/Core/SyntaxErrorException.cs | 58 + .../Core/SyntaxErrorException.cs.meta | 12 + .../YamlDotNet/Core/TagDirectiveCollection.cs | 63 + .../Core/TagDirectiveCollection.cs.meta | 12 + namedropper/Assets/YamlDotNet/Core/TagName.cs | 91 + .../Assets/YamlDotNet/Core/TagName.cs.meta | 11 + .../Assets/YamlDotNet/Core/Tokens.meta | 9 + .../Assets/YamlDotNet/Core/Tokens/Anchor.cs | 62 + .../YamlDotNet/Core/Tokens/Anchor.cs.meta | 12 + .../YamlDotNet/Core/Tokens/AnchorAlias.cs | 61 + .../Core/Tokens/AnchorAlias.cs.meta | 12 + .../Assets/YamlDotNet/Core/Tokens/BlockEnd.cs | 47 + .../YamlDotNet/Core/Tokens/BlockEnd.cs.meta | 12 + .../YamlDotNet/Core/Tokens/BlockEntry.cs | 47 + .../YamlDotNet/Core/Tokens/BlockEntry.cs.meta | 12 + .../Core/Tokens/BlockMappingStart.cs | 47 + .../Core/Tokens/BlockMappingStart.cs.meta | 12 + .../Core/Tokens/BlockSequenceStart.cs | 47 + .../Core/Tokens/BlockSequenceStart.cs.meta | 12 + .../Assets/YamlDotNet/Core/Tokens/Comment.cs | 59 + .../YamlDotNet/Core/Tokens/Comment.cs.meta | 12 + .../YamlDotNet/Core/Tokens/DocumentEnd.cs | 47 + .../Core/Tokens/DocumentEnd.cs.meta | 12 + .../YamlDotNet/Core/Tokens/DocumentStart.cs | 47 + .../Core/Tokens/DocumentStart.cs.meta | 12 + .../Assets/YamlDotNet/Core/Tokens/Error.cs | 40 + .../YamlDotNet/Core/Tokens/Error.cs.meta | 11 + .../YamlDotNet/Core/Tokens/FlowEntry.cs | 47 + .../YamlDotNet/Core/Tokens/FlowEntry.cs.meta | 12 + .../YamlDotNet/Core/Tokens/FlowMappingEnd.cs | 47 + .../Core/Tokens/FlowMappingEnd.cs.meta | 12 + .../Core/Tokens/FlowMappingStart.cs | 47 + .../Core/Tokens/FlowMappingStart.cs.meta | 12 + .../YamlDotNet/Core/Tokens/FlowSequenceEnd.cs | 47 + .../Core/Tokens/FlowSequenceEnd.cs.meta | 12 + .../Core/Tokens/FlowSequenceStart.cs | 47 + .../Core/Tokens/FlowSequenceStart.cs.meta | 12 + .../Assets/YamlDotNet/Core/Tokens/Key.cs | 47 + .../Assets/YamlDotNet/Core/Tokens/Key.cs.meta | 12 + .../Assets/YamlDotNet/Core/Tokens/Scalar.cs | 77 + .../YamlDotNet/Core/Tokens/Scalar.cs.meta | 12 + .../YamlDotNet/Core/Tokens/StreamEnd.cs | 47 + .../YamlDotNet/Core/Tokens/StreamEnd.cs.meta | 12 + .../YamlDotNet/Core/Tokens/StreamStart.cs | 47 + .../Core/Tokens/StreamStart.cs.meta | 12 + .../Assets/YamlDotNet/Core/Tokens/Tag.cs | 67 + .../Assets/YamlDotNet/Core/Tokens/Tag.cs.meta | 12 + .../YamlDotNet/Core/Tokens/TagDirective.cs | 118 + .../Core/Tokens/TagDirective.cs.meta | 12 + .../Assets/YamlDotNet/Core/Tokens/Token.cs | 52 + .../YamlDotNet/Core/Tokens/Token.cs.meta | 12 + .../Assets/YamlDotNet/Core/Tokens/Value.cs | 47 + .../YamlDotNet/Core/Tokens/Value.cs.meta | 12 + .../Core/Tokens/VersionDirective.cs | 80 + .../Core/Tokens/VersionDirective.cs.meta | 12 + namedropper/Assets/YamlDotNet/Core/Version.cs | 82 + .../Assets/YamlDotNet/Core/Version.cs.meta | 12 + .../Assets/YamlDotNet/Core/YamlException.cs | 83 + .../YamlDotNet/Core/YamlException.cs.meta | 12 + namedropper/Assets/YamlDotNet/Examples.meta | 9 + namedropper/Assets/YamlDotNet/Examples.unity | 406 +++ .../Assets/YamlDotNet/Examples.unity.meta | 7 + .../YamlDotNet/Examples/ConvertYamlToJson.cs | 63 + .../Examples/ConvertYamlToJson.cs.meta | 11 + .../Examples/DeserializeObjectGraph.cs | 165 ++ .../Examples/DeserializeObjectGraph.cs.meta | 11 + .../DeserializingMultipleDocuments.cs | 79 + .../DeserializingMultipleDocuments.cs.meta | 11 + .../Assets/YamlDotNet/Examples/Helpers.meta | 8 + .../Examples/Helpers/ExampleRunner.cs | 147 + .../Examples/Helpers/ExampleRunner.cs.meta | 11 + .../Examples/Helpers/ITestOutputHelper.cs | 8 + .../Helpers/ITestOutputHelper.cs.meta | 12 + .../Examples/Helpers/SampleAttribute.cs | 11 + .../Examples/Helpers/SampleAttribute.cs.meta | 11 + .../YamlDotNet/Examples/LoadingAYamlStream.cs | 106 + .../Examples/LoadingAYamlStream.cs.meta | 11 + .../Examples/SerializeObjectGraph.cs | 124 + .../Examples/SerializeObjectGraph.cs.meta | 11 + .../Examples/YamlDotNet.Examples.asmdef | 15 + .../Examples/YamlDotNet.Examples.asmdef.meta | 7 + namedropper/Assets/YamlDotNet/Helpers.meta | 8 + .../Helpers/ExpressionExtensions.cs | 85 + .../Helpers/ExpressionExtensions.cs.meta | 11 + .../GenericCollectionToNonGenericAdapter.cs | 125 + ...nericCollectionToNonGenericAdapter.cs.meta | 11 + .../GenericDictionaryToNonGenericAdapter.cs | 167 ++ ...nericDictionaryToNonGenericAdapter.cs.meta | 11 + .../YamlDotNet/Helpers/IOrderedDictionary.cs | 55 + .../Helpers/IOrderedDictionary.cs.meta | 11 + .../YamlDotNet/Helpers/NumberExtensions.cs | 31 + .../Helpers/NumberExtensions.cs.meta | 11 + .../YamlDotNet/Helpers/OrderedDictionary.cs | 234 ++ .../Helpers/OrderedDictionary.cs.meta | 11 + .../Assets/YamlDotNet/Portability.meta | 9 + .../Portability/NullableReferences.cs | 47 + .../Portability/NullableReferences.cs.meta | 11 + .../Portability/netstandard1.3.meta | 8 + .../netstandard1.3/CultureInfoAdapter.cs | 42 + .../netstandard1.3/CultureInfoAdapter.cs.meta | 11 + .../netstandard1.3/ReflectionExtensions.cs | 166 ++ .../ReflectionExtensions.cs.meta | 11 + .../Portability/unitysubset3.5.meta | 8 + .../unitysubset3.5/PropertyInfoExtensions.cs | 33 + .../PropertyInfoExtensions.cs.meta | 11 + .../unitysubset3.5/StandardRegexOptions.cs | 30 + .../StandardRegexOptions.cs.meta | 11 + namedropper/Assets/YamlDotNet/Readme.txt | 6 + namedropper/Assets/YamlDotNet/Readme.txt.meta | 8 + .../YamlDotNet/RepresentationModel.meta | 9 + .../DocumentLoadingState.cs | 111 + .../DocumentLoadingState.cs.meta | 11 + .../RepresentationModel/EmitterState.cs | 38 + .../RepresentationModel/EmitterState.cs.meta | 11 + .../RepresentationModel/IYamlVisitor.cs | 69 + .../RepresentationModel/IYamlVisitor.cs.meta | 11 + .../RepresentationModel/LibYamlEventStream.cs | 136 + .../LibYamlEventStream.cs.meta | 11 + .../RepresentationModel/YamlAliasNode.cs | 120 + .../RepresentationModel/YamlAliasNode.cs.meta | 12 + .../RepresentationModel/YamlDocument.cs | 211 ++ .../RepresentationModel/YamlDocument.cs.meta | 12 + .../RepresentationModel/YamlMappingNode.cs | 425 +++ .../YamlMappingNode.cs.meta | 12 + .../RepresentationModel/YamlNode.cs | 236 ++ .../RepresentationModel/YamlNode.cs.meta | 12 + .../YamlNodeIdentityEqualityComparer.cs | 48 + .../YamlNodeIdentityEqualityComparer.cs.meta | 11 + .../RepresentationModel/YamlNodeType.cs | 49 + .../RepresentationModel/YamlNodeType.cs.meta | 11 + .../RepresentationModel/YamlScalarNode.cs | 180 ++ .../YamlScalarNode.cs.meta | 12 + .../RepresentationModel/YamlSequenceNode.cs | 301 ++ .../YamlSequenceNode.cs.meta | 12 + .../RepresentationModel/YamlStream.cs | 172 ++ .../RepresentationModel/YamlStream.cs.meta | 12 + .../RepresentationModel/YamlVisitor.cs | 233 ++ .../RepresentationModel/YamlVisitor.cs.meta | 11 + .../RepresentationModel/YamlVisitorBase.cs | 151 + .../YamlVisitorBase.cs.meta | 11 + .../Assets/YamlDotNet/Serialization.meta | 9 + .../Serialization/BuilderSkeleton.cs | 326 +++ .../Serialization/BuilderSkeleton.cs.meta | 11 + .../YamlDotNet/Serialization/Converters.meta | 9 + .../Converters/DateTimeConverter.cs | 115 + .../Converters/DateTimeConverter.cs.meta | 11 + .../Serialization/Converters/GuidConverter.cs | 57 + .../Converters/GuidConverter.cs.meta | 12 + .../Converters/SystemTypeConverter.cs | 53 + .../Converters/SystemTypeConverter.cs.meta | 11 + .../Serialization/DefaultValuesHandling.cs | 52 + .../DefaultValuesHandling.cs.meta | 11 + .../YamlDotNet/Serialization/Deserializer.cs | 149 + .../Serialization/Deserializer.cs.meta | 12 + .../Serialization/DeserializerBuilder.cs | 389 +++ .../Serialization/DeserializerBuilder.cs.meta | 11 + .../EmissionPhaseObjectGraphVisitorArgs.cs | 82 + ...missionPhaseObjectGraphVisitorArgs.cs.meta | 11 + .../Serialization/EventEmitters.meta | 9 + .../EventEmitters/ChainedEventEmitter.cs | 70 + .../EventEmitters/ChainedEventEmitter.cs.meta | 12 + .../EventEmitters/JsonEventEmitter.cs | 126 + .../EventEmitters/JsonEventEmitter.cs.meta | 12 + .../TypeAssigningEventEmitter.cs | 155 + .../TypeAssigningEventEmitter.cs.meta | 12 + .../EventEmitters/WriterEventEmitter.cs | 59 + .../EventEmitters/WriterEventEmitter.cs.meta | 11 + .../YamlDotNet/Serialization/EventInfo.cs | 117 + .../Serialization/EventInfo.cs.meta | 12 + .../Serialization/IAliasProvider.cs | 30 + .../Serialization/IAliasProvider.cs.meta | 12 + .../YamlDotNet/Serialization/IDeserializer.cs | 46 + .../Serialization/IDeserializer.cs.meta | 11 + .../YamlDotNet/Serialization/IEventEmitter.cs | 35 + .../Serialization/IEventEmitter.cs.meta | 11 + .../Serialization/INamingConvention.cs | 32 + .../Serialization/INamingConvention.cs.meta | 11 + .../Serialization/INodeDeserializer.cs | 31 + .../Serialization/INodeDeserializer.cs.meta | 12 + .../Serialization/INodeTypeResolver.cs | 40 + .../Serialization/INodeTypeResolver.cs.meta | 12 + .../Serialization/IObjectDescriptor.cs | 67 + .../Serialization/IObjectDescriptor.cs.meta | 12 + .../Serialization/IObjectFactory.cs | 39 + .../Serialization/IObjectFactory.cs.meta | 11 + .../IObjectGraphTraversalStrategy.cs | 37 + .../IObjectGraphTraversalStrategy.cs.meta | 11 + .../Serialization/IObjectGraphVisitor.cs | 99 + .../Serialization/IObjectGraphVisitor.cs.meta | 11 + .../Serialization/IPropertyDescriptor.cs | 41 + .../Serialization/IPropertyDescriptor.cs.meta | 12 + .../IRegistrationLocationSelectionSyntax.cs | 59 + ...egistrationLocationSelectionSyntax.cs.meta | 11 + .../YamlDotNet/Serialization/ISerializer.cs | 66 + .../Serialization/ISerializer.cs.meta | 11 + .../Serialization/ITypeInspector.cs | 54 + .../Serialization/ITypeInspector.cs.meta | 12 + .../YamlDotNet/Serialization/ITypeResolver.cs | 33 + .../Serialization/ITypeResolver.cs.meta | 12 + .../Serialization/IValueDeserializer.cs | 32 + .../Serialization/IValueDeserializer.cs.meta | 12 + .../YamlDotNet/Serialization/IValuePromise.cs | 30 + .../Serialization/IValuePromise.cs.meta | 12 + .../Serialization/IValueSerializer.cs | 31 + .../Serialization/IValueSerializer.cs.meta | 11 + .../Serialization/IYamlConvertible.cs | 67 + .../Serialization/IYamlConvertible.cs.meta | 11 + .../Serialization/IYamlSerializable.cs | 43 + .../Serialization/IYamlSerializable.cs.meta | 11 + .../Serialization/IYamlTypeConverter.cs | 47 + .../Serialization/IYamlTypeConverter.cs.meta | 12 + .../LazyComponentRegistrationList.cs | 237 ++ .../LazyComponentRegistrationList.cs.meta | 11 + ...LazyComponentRegistrationListExtensions.cs | 64 + ...omponentRegistrationListExtensions.cs.meta | 11 + .../Serialization/NamingConventions.meta | 9 + .../CamelCaseNamingConvention.cs | 46 + .../CamelCaseNamingConvention.cs.meta | 12 + .../HyphenatedNamingConvention.cs | 44 + .../HyphenatedNamingConvention.cs.meta | 12 + .../LowerCaseNamingConvention.cs | 42 + .../LowerCaseNamingConvention.cs.meta | 11 + .../NamingConventions/NullNamingConvention.cs | 44 + .../NullNamingConvention.cs.meta | 12 + .../PascalCaseNamingConvention.cs | 46 + .../PascalCaseNamingConvention.cs.meta | 12 + .../UnderscoredNamingConvention.cs | 44 + .../UnderscoredNamingConvention.cs.meta | 12 + .../Serialization/NodeDeserializers.meta | 9 + .../ArrayNodeDeserializer.cs | 119 + .../ArrayNodeDeserializer.cs.meta | 12 + .../CollectionNodeDeserializer.cs | 111 + .../CollectionNodeDeserializer.cs.meta | 11 + .../DictionaryNodeDeserializer.cs | 144 + .../DictionaryNodeDeserializer.cs.meta | 11 + .../EnumerableNodeDeserializer.cs | 57 + .../EnumerableNodeDeserializer.cs.meta | 12 + .../NodeDeserializers/NullNodeDeserializer.cs | 63 + .../NullNodeDeserializer.cs.meta | 12 + .../ObjectNodeDeserializer.cs | 100 + .../ObjectNodeDeserializer.cs.meta | 12 + .../ScalarNodeDeserializer.cs | 282 ++ .../ScalarNodeDeserializer.cs.meta | 12 + .../TypeConverterNodeDeserializer.cs | 52 + .../TypeConverterNodeDeserializer.cs.meta | 12 + .../YamlConvertibleNodeDeserializer.cs | 50 + .../YamlConvertibleNodeDeserializer.cs.meta | 11 + .../YamlSerializableNodeDeserializer.cs | 52 + .../YamlSerializableNodeDeserializer.cs.meta | 11 + .../Serialization/NodeTypeResolvers.meta | 9 + .../DefaultContainersNodeTypeResolver.cs | 49 + .../DefaultContainersNodeTypeResolver.cs.meta | 12 + .../MappingNodeTypeResolver.cs | 61 + .../MappingNodeTypeResolver.cs.meta | 11 + .../RejectUnknownTagsNodeTypeResolver.cs | 39 + .../RejectUnknownTagsNodeTypeResolver.cs.meta | 11 + .../NodeTypeResolvers/TagNodeTypeResolver.cs | 48 + .../TagNodeTypeResolver.cs.meta | 12 + .../TypeNameInTagNodeTypeResolver.cs | 46 + .../TypeNameInTagNodeTypeResolver.cs.meta | 12 + .../YamlConvertibleTypeResolver.cs | 34 + .../YamlConvertibleTypeResolver.cs.meta | 11 + .../YamlSerializableTypeResolver.cs | 36 + .../YamlSerializableTypeResolver.cs.meta | 11 + .../YamlDotNet/Serialization/Nothing.cs | 31 + .../YamlDotNet/Serialization/Nothing.cs.meta | 11 + .../Serialization/ObjectDescriptor.cs | 48 + .../Serialization/ObjectDescriptor.cs.meta | 12 + .../Serialization/ObjectFactories.meta | 9 + .../ObjectFactories/DefaultObjectFactory.cs | 97 + .../DefaultObjectFactory.cs.meta | 12 + .../ObjectFactories/LambdaObjectFactory.cs | 43 + .../LambdaObjectFactory.cs.meta | 12 + .../ObjectGraphTraversalStrategies.meta | 9 + .../FullObjectGraphTraversalStrategy.cs | 258 ++ .../FullObjectGraphTraversalStrategy.cs.meta | 12 + .../RoundtripObjectGraphTraversalStrategy.cs | 53 + ...ndtripObjectGraphTraversalStrategy.cs.meta | 12 + .../ObjectGraphTraversalStrategyFactory.cs | 41 + ...bjectGraphTraversalStrategyFactory.cs.meta | 11 + .../Serialization/ObjectGraphVisitors.meta | 9 + .../ObjectGraphVisitors/AnchorAssigner.cs | 105 + .../AnchorAssigner.cs.meta | 12 + .../AnchorAssigningObjectGraphVisitor.cs | 78 + .../AnchorAssigningObjectGraphVisitor.cs.meta | 12 + .../ChainedObjectGraphVisitor.cs | 76 + .../ChainedObjectGraphVisitor.cs.meta | 11 + .../CommentsObjectGraphVisitor.cs | 44 + .../CommentsObjectGraphVisitor.cs.meta | 11 + .../CustomSerializationObjectGraphVisitor.cs | 69 + ...tomSerializationObjectGraphVisitor.cs.meta | 12 + .../DefaultExclusiveObjectGraphVisitor.cs | 58 + ...DefaultExclusiveObjectGraphVisitor.cs.meta | 12 + .../DefaultValuesObjectGraphVisitor.cs | 91 + .../DefaultValuesObjectGraphVisitor.cs.meta | 11 + .../EmittingObjectGraphVisitor.cs | 76 + .../EmittingObjectGraphVisitor.cs.meta | 11 + ...ocessingPhaseObjectGraphVisitorSkeleton.cs | 109 + ...ingPhaseObjectGraphVisitorSkeleton.cs.meta | 11 + .../Serialization/PropertyDescriptor.cs | 75 + .../Serialization/PropertyDescriptor.cs.meta | 12 + .../YamlDotNet/Serialization/Schemas.meta | 8 + .../Serialization/Schemas/FailsafeSchema.cs | 61 + .../Schemas/FailsafeSchema.cs.meta | 11 + .../YamlDotNet/Serialization/Serializer.cs | 144 + .../Serialization/Serializer.cs.meta | 12 + .../Serialization/SerializerBuilder.cs | 593 ++++ .../Serialization/SerializerBuilder.cs.meta | 11 + .../Serialization/StreamFragment.cs | 85 + .../Serialization/StreamFragment.cs.meta | 12 + .../YamlDotNet/Serialization/TagMappings.cs | 71 + .../Serialization/TagMappings.cs.meta | 12 + .../Serialization/TypeInspectors.meta | 9 + .../TypeInspectors/CachedTypeInspector.cs | 47 + .../CachedTypeInspector.cs.meta | 11 + .../TypeInspectors/CompositeTypeInspector.cs | 51 + .../CompositeTypeInspector.cs.meta | 11 + .../NamingConventionTypeInspector.cs | 57 + .../NamingConventionTypeInspector.cs.meta | 12 + ...dableAndWritablePropertiesTypeInspector.cs | 46 + ...AndWritablePropertiesTypeInspector.cs.meta | 12 + .../ReadableFieldsTypeInspector.cs | 87 + .../ReadableFieldsTypeInspector.cs.meta | 11 + .../ReadablePropertiesTypeInspector.cs | 101 + .../ReadablePropertiesTypeInspector.cs.meta | 12 + .../TypeInspectors/TypeInspectorSkeleton.cs | 62 + .../TypeInspectorSkeleton.cs.meta | 12 + .../Serialization/TypeResolvers.meta | 9 + .../TypeResolvers/DynamicTypeResolver.cs | 36 + .../TypeResolvers/DynamicTypeResolver.cs.meta | 12 + .../TypeResolvers/StaticTypeResolver.cs | 36 + .../TypeResolvers/StaticTypeResolver.cs.meta | 12 + .../YamlDotNet/Serialization/Utilities.meta | 9 + .../Utilities/IPostDeserializationCallback.cs | 32 + .../IPostDeserializationCallback.cs.meta | 11 + .../Utilities/ObjectAnchorCollection.cs | 75 + .../Utilities/ObjectAnchorCollection.cs.meta | 12 + .../Utilities/ReflectionUtility.cs | 54 + .../Utilities/ReflectionUtility.cs.meta | 12 + .../Utilities/SerializerState.cs | 67 + .../Utilities/SerializerState.cs.meta | 12 + .../Utilities/StringExtensions.cs | 79 + .../Utilities/StringExtensions.cs.meta | 11 + .../Serialization/Utilities/TypeConverter.cs | 236 ++ .../Utilities/TypeConverter.cs.meta | 12 + .../Serialization/ValueDeserializers.meta | 9 + .../AliasValueDeserializer.cs | 147 + .../AliasValueDeserializer.cs.meta | 12 + .../NodeValueDeserializer.cs | 89 + .../NodeValueDeserializer.cs.meta | 12 + .../Serialization/YamlAttributeOverrides.cs | 198 ++ .../YamlAttributeOverrides.cs.meta | 11 + .../YamlAttributeOverridesInspector.cs | 110 + .../YamlAttributeOverridesInspector.cs.meta | 11 + .../YamlAttributesTypeInspector.cs | 70 + .../YamlAttributesTypeInspector.cs.meta | 12 + .../YamlDotNet/Serialization/YamlFormatter.cs | 75 + .../Serialization/YamlFormatter.cs.meta | 12 + .../Serialization/YamlIgnoreAttribute.cs | 34 + .../Serialization/YamlIgnoreAttribute.cs.meta | 11 + .../Serialization/YamlMemberAttribute.cs | 95 + .../Serialization/YamlMemberAttribute.cs.meta | 11 + .../Assets/YamlDotNet/YamlDotNet.asmdef | 14 + .../Assets/YamlDotNet/YamlDotNet.asmdef.meta | 7 + .../Assets/YamlDotNet/YamlDotNet.license.txt | 7 + .../YamlDotNet/YamlDotNet.license.txt.meta | 8 + namedropper/Assets/YamlDotNet/csc.rsp | 1 + namedropper/Assets/YamlDotNet/csc.rsp.meta | 7 + 472 files changed, 27383 insertions(+), 2 deletions(-) create mode 100644 namedropper/Assets/Resources.meta create mode 100644 namedropper/Assets/Resources/categories.yaml create mode 100644 namedropper/Assets/Resources/categories.yaml.meta create mode 100644 namedropper/Assets/Scripts/CategoryData.cs create mode 100644 namedropper/Assets/Scripts/CategoryData.cs.meta create mode 100644 namedropper/Assets/Scripts/GameData.cs create mode 100644 namedropper/Assets/Scripts/GameData.cs.meta create mode 100644 namedropper/Assets/Sprites/TopicData.cs create mode 100644 namedropper/Assets/Sprites/TopicData.cs.meta create mode 100644 namedropper/Assets/YamlDotNet.meta create mode 100644 namedropper/Assets/YamlDotNet/Core.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/AnchorName.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/AnchorName.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/AnchorNotFoundException.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/AnchorNotFoundException.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/CharacterAnalyzer.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/CharacterAnalyzer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Constants.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Constants.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Cursor.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Cursor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Emitter.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Emitter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/EmitterSettings.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/EmitterSettings.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/EmitterState.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/EmitterState.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/AnchorAlias.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/AnchorAlias.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/Comment.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/Comment.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/DocumentEnd.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/DocumentEnd.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/DocumentStart.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/DocumentStart.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/EventType.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/EventType.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/IParsingEventVisitor.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/IParsingEventVisitor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/MappingEnd.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/MappingEnd.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/MappingStart.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/MappingStart.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/MappingStyle.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/MappingStyle.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/NodeEvent.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/NodeEvent.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/ParsingEvent.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/ParsingEvent.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/Scalar.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/Scalar.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/SequenceEnd.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/SequenceEnd.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/SequenceStart.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/SequenceStart.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/SequenceStyle.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/SequenceStyle.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/StreamEnd.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/StreamEnd.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/StreamStart.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Events/StreamStart.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/ForwardAnchorNotSupportedException.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/ForwardAnchorNotSupportedException.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/HashCode.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/HashCode.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/IEmitter.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/IEmitter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/ILookAheadBuffer.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/ILookAheadBuffer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/IParser.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/IParser.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/IScanner.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/IScanner.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/InsertionQueue.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/InsertionQueue.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/LookAheadBuffer.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/LookAheadBuffer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Mark.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Mark.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/MaximumRecursionLevelReachedException.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/MaximumRecursionLevelReachedException.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/MergingParser.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/MergingParser.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Parser.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Parser.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/ParserExtensions.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/ParserExtensions.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/ParserState.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/ParserState.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/RecursionLevel.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/RecursionLevel.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/ScalarStyle.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/ScalarStyle.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Scanner.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Scanner.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/SemanticErrorException.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/SemanticErrorException.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/SimpleKey.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/SimpleKey.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/StringLookAheadBuffer.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/StringLookAheadBuffer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/SyntaxErrorException.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/SyntaxErrorException.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/TagDirectiveCollection.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/TagDirectiveCollection.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/TagName.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/TagName.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Anchor.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Anchor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/AnchorAlias.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/AnchorAlias.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/BlockEnd.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/BlockEnd.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/BlockEntry.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/BlockEntry.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/BlockMappingStart.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/BlockMappingStart.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/BlockSequenceStart.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/BlockSequenceStart.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Comment.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Comment.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/DocumentEnd.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/DocumentEnd.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/DocumentStart.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/DocumentStart.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Error.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Error.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/FlowEntry.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/FlowEntry.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingEnd.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingEnd.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingStart.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingStart.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceEnd.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceEnd.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceStart.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceStart.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Key.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Key.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Scalar.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Scalar.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/StreamEnd.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/StreamEnd.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/StreamStart.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/StreamStart.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Tag.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Tag.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/TagDirective.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/TagDirective.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Token.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Token.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Value.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/Value.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/VersionDirective.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Tokens/VersionDirective.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/Version.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/Version.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Core/YamlException.cs create mode 100644 namedropper/Assets/YamlDotNet/Core/YamlException.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Examples.meta create mode 100644 namedropper/Assets/YamlDotNet/Examples.unity create mode 100644 namedropper/Assets/YamlDotNet/Examples.unity.meta create mode 100644 namedropper/Assets/YamlDotNet/Examples/ConvertYamlToJson.cs create mode 100644 namedropper/Assets/YamlDotNet/Examples/ConvertYamlToJson.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Examples/DeserializeObjectGraph.cs create mode 100644 namedropper/Assets/YamlDotNet/Examples/DeserializeObjectGraph.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Examples/DeserializingMultipleDocuments.cs create mode 100644 namedropper/Assets/YamlDotNet/Examples/DeserializingMultipleDocuments.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Examples/Helpers.meta create mode 100644 namedropper/Assets/YamlDotNet/Examples/Helpers/ExampleRunner.cs create mode 100644 namedropper/Assets/YamlDotNet/Examples/Helpers/ExampleRunner.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Examples/Helpers/ITestOutputHelper.cs create mode 100644 namedropper/Assets/YamlDotNet/Examples/Helpers/ITestOutputHelper.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Examples/Helpers/SampleAttribute.cs create mode 100644 namedropper/Assets/YamlDotNet/Examples/Helpers/SampleAttribute.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Examples/LoadingAYamlStream.cs create mode 100644 namedropper/Assets/YamlDotNet/Examples/LoadingAYamlStream.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Examples/SerializeObjectGraph.cs create mode 100644 namedropper/Assets/YamlDotNet/Examples/SerializeObjectGraph.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Examples/YamlDotNet.Examples.asmdef create mode 100644 namedropper/Assets/YamlDotNet/Examples/YamlDotNet.Examples.asmdef.meta create mode 100644 namedropper/Assets/YamlDotNet/Helpers.meta create mode 100644 namedropper/Assets/YamlDotNet/Helpers/ExpressionExtensions.cs create mode 100644 namedropper/Assets/YamlDotNet/Helpers/ExpressionExtensions.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Helpers/GenericCollectionToNonGenericAdapter.cs create mode 100644 namedropper/Assets/YamlDotNet/Helpers/GenericCollectionToNonGenericAdapter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Helpers/GenericDictionaryToNonGenericAdapter.cs create mode 100644 namedropper/Assets/YamlDotNet/Helpers/GenericDictionaryToNonGenericAdapter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Helpers/IOrderedDictionary.cs create mode 100644 namedropper/Assets/YamlDotNet/Helpers/IOrderedDictionary.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Helpers/NumberExtensions.cs create mode 100644 namedropper/Assets/YamlDotNet/Helpers/NumberExtensions.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Helpers/OrderedDictionary.cs create mode 100644 namedropper/Assets/YamlDotNet/Helpers/OrderedDictionary.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Portability.meta create mode 100644 namedropper/Assets/YamlDotNet/Portability/NullableReferences.cs create mode 100644 namedropper/Assets/YamlDotNet/Portability/NullableReferences.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Portability/netstandard1.3.meta create mode 100644 namedropper/Assets/YamlDotNet/Portability/netstandard1.3/CultureInfoAdapter.cs create mode 100644 namedropper/Assets/YamlDotNet/Portability/netstandard1.3/CultureInfoAdapter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Portability/netstandard1.3/ReflectionExtensions.cs create mode 100644 namedropper/Assets/YamlDotNet/Portability/netstandard1.3/ReflectionExtensions.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Portability/unitysubset3.5.meta create mode 100644 namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/PropertyInfoExtensions.cs create mode 100644 namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/PropertyInfoExtensions.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/StandardRegexOptions.cs create mode 100644 namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/StandardRegexOptions.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Readme.txt create mode 100644 namedropper/Assets/YamlDotNet/Readme.txt.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/DocumentLoadingState.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/DocumentLoadingState.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/EmitterState.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/EmitterState.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/IYamlVisitor.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/IYamlVisitor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/LibYamlEventStream.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/LibYamlEventStream.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlAliasNode.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlAliasNode.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlDocument.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlDocument.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlMappingNode.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlMappingNode.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlNode.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlNode.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeIdentityEqualityComparer.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeIdentityEqualityComparer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeType.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeType.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlScalarNode.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlScalarNode.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlSequenceNode.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlSequenceNode.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlStream.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlStream.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitor.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitorBase.cs create mode 100644 namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitorBase.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/BuilderSkeleton.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/BuilderSkeleton.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Converters.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Converters/DateTimeConverter.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Converters/DateTimeConverter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Converters/GuidConverter.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Converters/GuidConverter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Converters/SystemTypeConverter.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Converters/SystemTypeConverter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/DefaultValuesHandling.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/DefaultValuesHandling.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Deserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Deserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/DeserializerBuilder.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/DeserializerBuilder.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/EmissionPhaseObjectGraphVisitorArgs.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/EmissionPhaseObjectGraphVisitorArgs.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/EventEmitters.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/EventEmitters/ChainedEventEmitter.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/EventEmitters/ChainedEventEmitter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/EventEmitters/JsonEventEmitter.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/EventEmitters/JsonEventEmitter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/EventEmitters/TypeAssigningEventEmitter.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/EventEmitters/TypeAssigningEventEmitter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/EventEmitters/WriterEventEmitter.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/EventEmitters/WriterEventEmitter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/EventInfo.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/EventInfo.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IAliasProvider.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IAliasProvider.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IEventEmitter.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IEventEmitter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/INamingConvention.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/INamingConvention.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/INodeDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/INodeDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/INodeTypeResolver.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/INodeTypeResolver.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IObjectDescriptor.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IObjectDescriptor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IObjectFactory.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IObjectFactory.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IObjectGraphTraversalStrategy.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IObjectGraphTraversalStrategy.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IObjectGraphVisitor.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IObjectGraphVisitor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IPropertyDescriptor.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IPropertyDescriptor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IRegistrationLocationSelectionSyntax.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IRegistrationLocationSelectionSyntax.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ISerializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ISerializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ITypeInspector.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ITypeInspector.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ITypeResolver.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ITypeResolver.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IValueDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IValueDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IValuePromise.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IValuePromise.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IValueSerializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IValueSerializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IYamlConvertible.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IYamlConvertible.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IYamlSerializable.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IYamlSerializable.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IYamlTypeConverter.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/IYamlTypeConverter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationList.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationList.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationListExtensions.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationListExtensions.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NamingConventions.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NamingConventions/CamelCaseNamingConvention.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NamingConventions/CamelCaseNamingConvention.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NamingConventions/HyphenatedNamingConvention.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NamingConventions/HyphenatedNamingConvention.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NamingConventions/LowerCaseNamingConvention.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NamingConventions/LowerCaseNamingConvention.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NamingConventions/NullNamingConvention.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NamingConventions/NullNamingConvention.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NamingConventions/PascalCaseNamingConvention.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NamingConventions/PascalCaseNamingConvention.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NamingConventions/UnderscoredNamingConvention.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NamingConventions/UnderscoredNamingConvention.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ArrayNodeDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ArrayNodeDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/CollectionNodeDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/CollectionNodeDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/DictionaryNodeDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/DictionaryNodeDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/EnumerableNodeDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/EnumerableNodeDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/NullNodeDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/NullNodeDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ObjectNodeDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ObjectNodeDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ScalarNodeDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ScalarNodeDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/TypeConverterNodeDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/TypeConverterNodeDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlConvertibleNodeDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlConvertibleNodeDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlSerializableNodeDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlSerializableNodeDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/DefaultContainersNodeTypeResolver.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/DefaultContainersNodeTypeResolver.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/MappingNodeTypeResolver.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/MappingNodeTypeResolver.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/RejectUnknownTagsNodeTypeResolver.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/RejectUnknownTagsNodeTypeResolver.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TagNodeTypeResolver.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TagNodeTypeResolver.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TypeNameInTagNodeTypeResolver.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TypeNameInTagNodeTypeResolver.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlConvertibleTypeResolver.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlConvertibleTypeResolver.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlSerializableTypeResolver.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlSerializableTypeResolver.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Nothing.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Nothing.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectDescriptor.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectDescriptor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectFactories.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/DefaultObjectFactory.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/DefaultObjectFactory.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/LambdaObjectFactory.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/LambdaObjectFactory.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/FullObjectGraphTraversalStrategy.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/FullObjectGraphTraversalStrategy.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/RoundtripObjectGraphTraversalStrategy.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/RoundtripObjectGraphTraversalStrategy.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategyFactory.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategyFactory.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigner.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigner.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigningObjectGraphVisitor.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigningObjectGraphVisitor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/ChainedObjectGraphVisitor.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/ChainedObjectGraphVisitor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CommentsObjectGraphVisitor.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CommentsObjectGraphVisitor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CustomSerializationObjectGraphVisitor.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CustomSerializationObjectGraphVisitor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultExclusiveObjectGraphVisitor.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultExclusiveObjectGraphVisitor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultValuesObjectGraphVisitor.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultValuesObjectGraphVisitor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/EmittingObjectGraphVisitor.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/EmittingObjectGraphVisitor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/PreProcessingPhaseObjectGraphVisitorSkeleton.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/PreProcessingPhaseObjectGraphVisitorSkeleton.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/PropertyDescriptor.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/PropertyDescriptor.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Schemas.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Schemas/FailsafeSchema.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Schemas/FailsafeSchema.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Serializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Serializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/SerializerBuilder.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/SerializerBuilder.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/StreamFragment.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/StreamFragment.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TagMappings.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TagMappings.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CachedTypeInspector.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CachedTypeInspector.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CompositeTypeInspector.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CompositeTypeInspector.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/NamingConventionTypeInspector.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/NamingConventionTypeInspector.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableAndWritablePropertiesTypeInspector.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableAndWritablePropertiesTypeInspector.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableFieldsTypeInspector.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableFieldsTypeInspector.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadablePropertiesTypeInspector.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadablePropertiesTypeInspector.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/TypeInspectorSkeleton.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/TypeInspectorSkeleton.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeResolvers.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/DynamicTypeResolver.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/DynamicTypeResolver.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/StaticTypeResolver.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/StaticTypeResolver.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Utilities.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Utilities/IPostDeserializationCallback.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Utilities/IPostDeserializationCallback.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Utilities/ObjectAnchorCollection.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Utilities/ObjectAnchorCollection.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Utilities/ReflectionUtility.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Utilities/ReflectionUtility.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Utilities/SerializerState.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Utilities/SerializerState.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Utilities/StringExtensions.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Utilities/StringExtensions.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Utilities/TypeConverter.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/Utilities/TypeConverter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/AliasValueDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/AliasValueDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/NodeValueDeserializer.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/NodeValueDeserializer.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverrides.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverrides.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverridesInspector.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverridesInspector.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/YamlAttributesTypeInspector.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/YamlAttributesTypeInspector.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/YamlFormatter.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/YamlFormatter.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/YamlIgnoreAttribute.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/YamlIgnoreAttribute.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/Serialization/YamlMemberAttribute.cs create mode 100644 namedropper/Assets/YamlDotNet/Serialization/YamlMemberAttribute.cs.meta create mode 100644 namedropper/Assets/YamlDotNet/YamlDotNet.asmdef create mode 100644 namedropper/Assets/YamlDotNet/YamlDotNet.asmdef.meta create mode 100644 namedropper/Assets/YamlDotNet/YamlDotNet.license.txt create mode 100644 namedropper/Assets/YamlDotNet/YamlDotNet.license.txt.meta create mode 100644 namedropper/Assets/YamlDotNet/csc.rsp create mode 100644 namedropper/Assets/YamlDotNet/csc.rsp.meta diff --git a/namedropper/Assets/Resources.meta b/namedropper/Assets/Resources.meta new file mode 100644 index 0000000..324b4dc --- /dev/null +++ b/namedropper/Assets/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b5d23666a757eb844bb5c2dda8708246 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/Resources/categories.yaml b/namedropper/Assets/Resources/categories.yaml new file mode 100644 index 0000000..a67ea74 --- /dev/null +++ b/namedropper/Assets/Resources/categories.yaml @@ -0,0 +1,82 @@ +Topics: +- Topic: TV + Categories: + - Category: White Lotus + Elements: + - Armond + - Greg + - Tanya McQuoid + - Portia + - Harper + - Albie Di Grasso + - Dominic Di Grasso + - Bert Di Grasso + - Ethan + - Lucia + - Category: The Mandalorian + Elements: + - Din Djarin + - Grogu + - Greef Karga + - The Client + - Dr. Pershing + - Kuiil + - IG-11 + - Cara Dune + - Boba Fett + - Moff Gideon + - Category: Yellowstone + Elements: + - Beth Dutton + - John Dutton + - Chief Thomas Rainwater + - Rip Wheeler + - Teeter + - Carter + - Jimmy Hurdstrom + - Walker + - Laramie + - Avery + - Category: I Love Lucy + Elements: + - Ethel Mertz + - Fred Mertz + - Lucy Ricardo + - Ricky Ricardo + - Mrs. McGillicuddy + - Bobby the Bellboy + - Freddie Fillmore + - Category: F•R•I•E•N•D•S + Elements: + - Rachel Green + - Joey Tribbiani + - Chandler Bing + - Ross Geller + - Monica Geller + - Phoebe Buffay + - Janice Hosenstein + - Gunther + - Roy, the Stripper + - Ursula Buffay + - Category: Wednesday + Elements: + - Wednesday Addams + - Morticia Addams + - Uncle Fester + - Enid Sinclair + - Lurch + - Thing + - Xavier Thorpe + - Gomez Addams + - Pugsley Addams + - Larissa Weems +- Topic: Hip Hop + Categories: + - Category: Biggie + Elements: + - Ready to Die + - Juicy + - Category: Pac + Elements: + - All Eyez + - HIt Em Up diff --git a/namedropper/Assets/Resources/categories.yaml.meta b/namedropper/Assets/Resources/categories.yaml.meta new file mode 100644 index 0000000..4577a1c --- /dev/null +++ b/namedropper/Assets/Resources/categories.yaml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d407e0f4ea93648438adf207e06ca42c +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/Scripts/CategoryData.cs b/namedropper/Assets/Scripts/CategoryData.cs new file mode 100644 index 0000000..2ea842e --- /dev/null +++ b/namedropper/Assets/Scripts/CategoryData.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +[Serializable] + public class CategoryData +{ + public string Category; + public List Elements = new List(); +} diff --git a/namedropper/Assets/Scripts/CategoryData.cs.meta b/namedropper/Assets/Scripts/CategoryData.cs.meta new file mode 100644 index 0000000..df3c294 --- /dev/null +++ b/namedropper/Assets/Scripts/CategoryData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1ca73e6a69bdaf449ad91a940adbdd29 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/Scripts/Game.cs b/namedropper/Assets/Scripts/Game.cs index ed663b6..5748329 100644 --- a/namedropper/Assets/Scripts/Game.cs +++ b/namedropper/Assets/Scripts/Game.cs @@ -1,7 +1,8 @@ -using System.Collections; -using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; +using System.IO; +using YamlDotNet.Serialization; +using YamlDotNet.Serialization.NamingConventions; public class Game : MonoBehaviour { @@ -12,12 +13,88 @@ public class Game : MonoBehaviour [SerializeField] Text RedScoreCounter; Category[] _categories; + GameData _gameData = new GameData(); // Start is called before the first frame update void Awake() { + + Deserializer deserializer = new Deserializer(); + string yamlText = File.ReadAllText(Application.dataPath + "/Resources/categories.yaml"); + _gameData = deserializer.Deserialize(yamlText); + _categories = FindObjectsOfType(); + + int topicIndex = Random.Range(0, _gameData.Topics.Count); + topicIndex = 0; + TopicData topicData = _gameData.Topics[topicIndex]; + _gameData.Topics.RemoveAt(topicIndex); + + foreach (Category category in _categories) + { + int categoryIndex = Random.Range(0, topicData.Categories.Count); + CategoryData categoryData = topicData.Categories[categoryIndex]; + topicData.Categories.RemoveAt(categoryIndex); + + category.Name = categoryData.Category; + category.Elements = categoryData.Elements; + + } + } + + /* + void OldUnusedDataGenerator() + { + + TopicData td = new TopicData(); + td.Topic = "TV"; + + CategoryData cd = new CategoryData(); + cd.Category = "White Lotus"; + cd.Elements.Add("Tanya"); + cd.Elements.Add("Portia"); + td.Categories.Add(cd); + + cd = new CategoryData(); + cd.Category = "SNL"; + cd.Elements.Add("Pete"); + cd.Elements.Add("Josh"); + td.Categories.Add(cd); + + _gameData.Data.Add(td); + + // + td = new TopicData(); + td.Topic = "Hip Hop"; + + cd = new CategoryData(); + cd.Category = "Biggie"; + cd.Elements.Add("Ready to Die"); + cd.Elements.Add("Juicy"); + td.Categories.Add(cd); + + cd = new CategoryData(); + cd.Category = "Pac"; + cd.Elements.Add("All Eyez"); + cd.Elements.Add("HIt Em Up"); + td.Categories.Add(cd); + + _gameData.Data.Add(td); + + var serializer = new SerializerBuilder() + .WithNamingConvention(CamelCaseNamingConvention.Instance) + .Build(); + + string yaml = serializer.Serialize(_gameData); + Debug.Log("Game data: " + yaml); + + string json = JsonUtility.ToJson(_gameData, true); + Debug.Log("Game data: " + json); + + File.WriteAllText(Application.persistentDataPath + "/categories.json", json); + File.WriteAllText(Application.persistentDataPath + "/categories.yaml", yaml); } + */ private void Start() { diff --git a/namedropper/Assets/Scripts/GameData.cs b/namedropper/Assets/Scripts/GameData.cs new file mode 100644 index 0000000..8e86328 --- /dev/null +++ b/namedropper/Assets/Scripts/GameData.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[Serializable] +public class GameData +{ + + public List Topics = new List(); +} diff --git a/namedropper/Assets/Scripts/GameData.cs.meta b/namedropper/Assets/Scripts/GameData.cs.meta new file mode 100644 index 0000000..bf87842 --- /dev/null +++ b/namedropper/Assets/Scripts/GameData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fb0f225b216ea1f419e12cd39cabb993 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/Scripts/Player.cs b/namedropper/Assets/Scripts/Player.cs index 1f77e1a..28f2c3b 100644 --- a/namedropper/Assets/Scripts/Player.cs +++ b/namedropper/Assets/Scripts/Player.cs @@ -26,6 +26,7 @@ public class Player : MonoBehaviour _rigidbody = GetComponent(); _text = transform.GetChild(0).GetComponent(); _game = FindObjectOfType(); + _originalPosition = transform.position; } diff --git a/namedropper/Assets/Sprites/TopicData.cs b/namedropper/Assets/Sprites/TopicData.cs new file mode 100644 index 0000000..8f95113 --- /dev/null +++ b/namedropper/Assets/Sprites/TopicData.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[Serializable] +public class TopicData { + public string Topic; + public List Categories = new List(); +} diff --git a/namedropper/Assets/Sprites/TopicData.cs.meta b/namedropper/Assets/Sprites/TopicData.cs.meta new file mode 100644 index 0000000..8286ac0 --- /dev/null +++ b/namedropper/Assets/Sprites/TopicData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e3ac1feae3f91614ea454e6d0adf5f45 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet.meta b/namedropper/Assets/YamlDotNet.meta new file mode 100644 index 0000000..9f142d8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6298c1aa72d0cae4b980737fc7d60375 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core.meta b/namedropper/Assets/YamlDotNet/Core.meta new file mode 100644 index 0000000..43b22e9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: cbe04dd6a5622cf4fb8a12e664da340d +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/AnchorName.cs b/namedropper/Assets/YamlDotNet/Core/AnchorName.cs new file mode 100644 index 0000000..92c37c9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/AnchorName.cs @@ -0,0 +1,76 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Text.RegularExpressions; + +namespace YamlDotNet.Core +{ + public struct AnchorName : IEquatable + { + public static readonly AnchorName Empty = default; + + // https://yaml.org/spec/1.2/spec.html#id2785586 + private static readonly Regex AnchorPattern = new Regex(@"^[^\[\]\{\},]+$", StandardRegexOptions.Compiled); + + private readonly string? value; + + public string Value => value ?? throw new InvalidOperationException("Cannot read the Value of an empty anchor"); + + public bool IsEmpty => value is null; + + public AnchorName(string value) + { + this.value = value ?? throw new ArgumentNullException(nameof(value)); + + if (!AnchorPattern.IsMatch(value)) + { + throw new ArgumentException($"Anchor cannot be empty or contain disallowed characters: []{{}},\nThe value was '{value}'.", nameof(value)); + } + } + + public override string ToString() => value ?? "[empty]"; + + public bool Equals(AnchorName other) => Equals(value, other.value); + + public override bool Equals(object? obj) + { + return obj is AnchorName other && Equals(other); + } + + public override int GetHashCode() + { + return value?.GetHashCode() ?? 0; + } + + public static bool operator ==(AnchorName left, AnchorName right) + { + return left.Equals(right); + } + + public static bool operator !=(AnchorName left, AnchorName right) + { + return !(left == right); + } + + public static implicit operator AnchorName(string? value) => value == null ? Empty : new AnchorName(value); + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/AnchorName.cs.meta b/namedropper/Assets/YamlDotNet/Core/AnchorName.cs.meta new file mode 100644 index 0000000..f8b39ed --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/AnchorName.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4b743e73dd5df19488bf7108b4a7e5a8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/AnchorNotFoundException.cs b/namedropper/Assets/YamlDotNet/Core/AnchorNotFoundException.cs new file mode 100644 index 0000000..aa95297 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/AnchorNotFoundException.cs @@ -0,0 +1,58 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core +{ + /// + /// The exception that is thrown when an alias references an anchor that does not exist. + /// + public class AnchorNotFoundException : YamlException + { + /// + /// Initializes a new instance of the class. + /// + /// The message. + public AnchorNotFoundException(string message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class. + /// + public AnchorNotFoundException(Mark start, Mark end, string message) + : base(start, end, message) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The message. + /// The inner. + public AnchorNotFoundException(string message, Exception inner) + : base(message, inner) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/AnchorNotFoundException.cs.meta b/namedropper/Assets/YamlDotNet/Core/AnchorNotFoundException.cs.meta new file mode 100644 index 0000000..6b50eb5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/AnchorNotFoundException.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: bef940054d2c25041ba1a961abae6c79 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/CharacterAnalyzer.cs b/namedropper/Assets/YamlDotNet/Core/CharacterAnalyzer.cs new file mode 100644 index 0000000..fc4a1fe --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/CharacterAnalyzer.cs @@ -0,0 +1,166 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Diagnostics; + +namespace YamlDotNet.Core +{ + internal sealed class CharacterAnalyzer where TBuffer : class, ILookAheadBuffer + { + public CharacterAnalyzer(TBuffer buffer) + { + this.Buffer = buffer ?? throw new ArgumentNullException(nameof(buffer)); + } + + public TBuffer Buffer { get; } + + public bool EndOfInput => Buffer.EndOfInput; + + public char Peek(int offset) + { + return Buffer.Peek(offset); + } + + public void Skip(int length) + { + Buffer.Skip(length); + } + + public bool IsAlphaNumericDashOrUnderscore(int offset = 0) + { + var character = Buffer.Peek(offset); + return + (character >= '0' && character <= '9') || + (character >= 'A' && character <= 'Z') || + (character >= 'a' && character <= 'z') || + character == '_' || + character == '-'; + } + + public bool IsAscii(int offset = 0) + { + return Buffer.Peek(offset) <= '\x7F'; + } + + public bool IsPrintable(int offset = 0) + { + var character = Buffer.Peek(offset); + return + character == '\x9' || + character == '\xA' || + character == '\xD' || + (character >= '\x20' && character <= '\x7E') || + character == '\x85' || + (character >= '\xA0' && character <= '\xD7FF') || + (character >= '\xE000' && character <= '\xFFFD'); + } + + public bool IsDigit(int offset = 0) + { + var character = Buffer.Peek(offset); + return character >= '0' && character <= '9'; + } + + public int AsDigit(int offset = 0) + { + return Buffer.Peek(offset) - '0'; + } + + public bool IsHex(int offset) + { + var character = Buffer.Peek(offset); + return + (character >= '0' && character <= '9') || + (character >= 'A' && character <= 'F') || + (character >= 'a' && character <= 'f'); + } + + public int AsHex(int offset) + { + var character = Buffer.Peek(offset); + + if (character <= '9') + { + return character - '0'; + } + if (character <= 'F') + { + return character - 'A' + 10; + } + return character - 'a' + 10; + } + + public bool IsSpace(int offset = 0) + { + return Check(' ', offset); + } + + public bool IsZero(int offset = 0) + { + return Check('\0', offset); + } + + public bool IsTab(int offset = 0) + { + return Check('\t', offset); + } + + public bool IsWhite(int offset = 0) + { + return IsSpace(offset) || IsTab(offset); + } + + public bool IsBreak(int offset = 0) + { + return Check("\r\n\x85\x2028\x2029", offset); + } + + public bool IsCrLf(int offset = 0) + { + return Check('\r', offset) && Check('\n', offset + 1); + } + + public bool IsBreakOrZero(int offset = 0) + { + return IsBreak(offset) || IsZero(offset); + } + + public bool IsWhiteBreakOrZero(int offset = 0) + { + return IsWhite(offset) || IsBreakOrZero(offset); + } + + public bool Check(char expected, int offset = 0) + { + return Buffer.Peek(offset) == expected; + } + + public bool Check(string expectedCharacters, int offset = 0) + { + // Todo: using it this way doesn't break anything, it's not really wrong... + Debug.Assert(expectedCharacters.Length > 1, "Use Check(char, int) instead."); + + var character = Buffer.Peek(offset); + return expectedCharacters.IndexOf(character) != -1; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/CharacterAnalyzer.cs.meta b/namedropper/Assets/YamlDotNet/Core/CharacterAnalyzer.cs.meta new file mode 100644 index 0000000..a89b5de --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/CharacterAnalyzer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cdb65e878b6f92347849551efad9eb74 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Constants.cs b/namedropper/Assets/YamlDotNet/Core/Constants.cs new file mode 100644 index 0000000..7e90732 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Constants.cs @@ -0,0 +1,40 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using YamlDotNet.Core.Tokens; + +namespace YamlDotNet.Core +{ + /// + /// Defines constants that relate to the YAML specification. + /// + public static class Constants + { + public static readonly TagDirective[] DefaultTagDirectives = + { + new TagDirective("!", "!"), + new TagDirective("!!", "tag:yaml.org,2002:") + }; + + public const int MajorVersion = 1; + public const int MinorVersion = 3; + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Constants.cs.meta b/namedropper/Assets/YamlDotNet/Core/Constants.cs.meta new file mode 100644 index 0000000..1f7a94a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Constants.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6143f3f95b0bcb74c92b9996309fab40 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Cursor.cs b/namedropper/Assets/YamlDotNet/Core/Cursor.cs new file mode 100644 index 0000000..7b3740e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Cursor.cs @@ -0,0 +1,69 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core +{ + public sealed class Cursor + { + public int Index { get; private set; } + public int Line { get; private set; } + public int LineOffset { get; private set; } + + public Cursor() + { + Line = 1; + } + + public Cursor(Cursor cursor) + { + Index = cursor.Index; + Line = cursor.Line; + LineOffset = cursor.LineOffset; + } + + public Mark Mark() + { + return new Mark(Index, Line, LineOffset + 1); + } + + public void Skip() + { + Index++; + LineOffset++; + } + + public void SkipLineByOffset(int offset) + { + Index += offset; + Line++; + LineOffset = 0; + } + + public void ForceSkipLineAfterNonBreak() + { + if (LineOffset != 0) + { + Line++; + LineOffset = 0; + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Cursor.cs.meta b/namedropper/Assets/YamlDotNet/Core/Cursor.cs.meta new file mode 100644 index 0000000..47cb0c6 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Cursor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4262bdec0f3c254b9a29e755ba3a609 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Emitter.cs b/namedropper/Assets/YamlDotNet/Core/Emitter.cs new file mode 100644 index 0000000..6af2726 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Emitter.cs @@ -0,0 +1,1903 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Text; +using System.Text.RegularExpressions; +using YamlDotNet.Core.Events; +using ParsingEvent = YamlDotNet.Core.Events.ParsingEvent; +using TagDirective = YamlDotNet.Core.Tokens.TagDirective; +using VersionDirective = YamlDotNet.Core.Tokens.VersionDirective; + +namespace YamlDotNet.Core +{ + /// + /// Emits YAML streams. + /// + public class Emitter : IEmitter + { + private static readonly Regex UriReplacer = new Regex(@"[^0-9A-Za-z_\-;?@=$~\\\)\]/:&+,\.\*\(\[!]", + StandardRegexOptions.Compiled | RegexOptions.Singleline); + + private readonly TextWriter output; + private readonly bool outputUsesUnicodeEncoding; + + private readonly int maxSimpleKeyLength; + private readonly bool isCanonical; + private readonly bool skipAnchorName; + private readonly int bestIndent; + private readonly int bestWidth; + private EmitterState state; + + private readonly Stack states = new Stack(); + private readonly Queue events = new Queue(); + private readonly Stack indents = new Stack(); + private readonly TagDirectiveCollection tagDirectives = new TagDirectiveCollection(); + private int indent; + private int flowLevel; + private bool isMappingContext; + private bool isSimpleKeyContext; + + private int column; + private bool isWhitespace; + private bool isIndentation; + private readonly bool forceIndentLess; + + private bool isDocumentEndWritten; + + private readonly AnchorData anchorData = new AnchorData(); + private readonly TagData tagData = new TagData(); + private readonly ScalarData scalarData = new ScalarData(); + + private class AnchorData + { + public AnchorName Anchor; + public bool IsAlias; + } + + private class TagData + { + public string? Handle; + public string? Suffix; + } + + private class ScalarData + { + public string Value = string.Empty; + public bool IsMultiline; + public bool IsFlowPlainAllowed; + public bool IsBlockPlainAllowed; + public bool IsSingleQuotedAllowed; + public bool IsBlockAllowed; + public bool HasSingleQuotes; + public ScalarStyle Style; + } + + /// + /// Initializes a new instance of the class. + /// + /// The where the emitter will write. + public Emitter(TextWriter output) + : this(output, EmitterSettings.Default) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The where the emitter will write. + /// The preferred indentation. + public Emitter(TextWriter output, int bestIndent) + : this(output, bestIndent, int.MaxValue) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The where the emitter will write. + /// The preferred indentation. + /// The preferred text width. + public Emitter(TextWriter output, int bestIndent, int bestWidth) + : this(output, bestIndent, bestWidth, false) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The where the emitter will write. + /// The preferred indentation. + /// The preferred text width. + /// If true, write the output in canonical form. + public Emitter(TextWriter output, int bestIndent, int bestWidth, bool isCanonical) + : this(output, new EmitterSettings(bestIndent, bestWidth, isCanonical, 1024)) + { + } + + public Emitter(TextWriter output, EmitterSettings settings) + { + this.bestIndent = settings.BestIndent; + this.bestWidth = settings.BestWidth; + this.isCanonical = settings.IsCanonical; + this.maxSimpleKeyLength = settings.MaxSimpleKeyLength; + this.skipAnchorName = settings.SkipAnchorName; + this.forceIndentLess = !settings.IndentSequences; + + this.output = output; + this.outputUsesUnicodeEncoding = IsUnicode(output.Encoding); + } + + /// + /// Emit an evt. + /// + public void Emit(ParsingEvent @event) + { + events.Enqueue(@event); + + while (!NeedMoreEvents()) + { + var current = events.Peek(); + try + { + + AnalyzeEvent(current); + StateMachine(current); + } + finally + { + // Only dequeue after calling state_machine because it checks how many events are in the queue. + // Todo: well, move into StateMachine() then + events.Dequeue(); + } + } + } + + /// + /// Check if we need to accumulate more events before emitting. + /// + /// We accumulate extra + /// - 1 event for DOCUMENT-START + /// - 2 events for SEQUENCE-START + /// - 3 events for MAPPING-START + /// + private bool NeedMoreEvents() + { + if (events.Count == 0) + { + return true; + } + + int accumulate; + switch (events.Peek().Type) + { + case EventType.DocumentStart: + accumulate = 1; + break; + + case EventType.SequenceStart: + accumulate = 2; + break; + + case EventType.MappingStart: + accumulate = 3; + break; + + default: + return false; + } + + if (events.Count > accumulate) + { + return false; + } + + var level = 0; + foreach (var evt in events) + { + switch (evt.Type) + { + case EventType.DocumentStart: + case EventType.SequenceStart: + case EventType.MappingStart: + ++level; + break; + + case EventType.DocumentEnd: + case EventType.SequenceEnd: + case EventType.MappingEnd: + --level; + break; + } + if (level == 0) + { + return false; + } + } + + return true; + } + + private void AnalyzeEvent(ParsingEvent evt) + { + anchorData.Anchor = AnchorName.Empty; + tagData.Handle = null; + tagData.Suffix = null; + + if (evt is AnchorAlias alias) + { + AnalyzeAnchor(alias.Value, true); + return; + } + + if (evt is NodeEvent nodeEvent) + { + if (evt is Scalar scalar) + { + AnalyzeScalar(scalar); + } + + AnalyzeAnchor(nodeEvent.Anchor, false); + + if (!nodeEvent.Tag.IsEmpty && (isCanonical || nodeEvent.IsCanonical)) + { + AnalyzeTag(nodeEvent.Tag); + } + } + } + + private void AnalyzeAnchor(AnchorName anchor, bool isAlias) + { + anchorData.Anchor = anchor; + anchorData.IsAlias = isAlias; + } + + private void AnalyzeScalar(Scalar scalar) + { + var value = scalar.Value; + scalarData.Value = value; + + if (value.Length == 0) + { + if (scalar.Tag == "tag:yaml.org,2002:null") + { + scalarData.IsMultiline = false; + scalarData.IsFlowPlainAllowed = false; + scalarData.IsBlockPlainAllowed = true; + scalarData.IsSingleQuotedAllowed = false; + scalarData.IsBlockAllowed = false; + } + else + { + scalarData.IsMultiline = false; + scalarData.IsFlowPlainAllowed = false; + scalarData.IsBlockPlainAllowed = false; + scalarData.IsSingleQuotedAllowed = true; + scalarData.IsBlockAllowed = false; + } + return; + } + + var flowIndicators = false; + var blockIndicators = false; + if (value.StartsWith("---", StringComparison.Ordinal) || value.StartsWith("...", StringComparison.Ordinal)) + { + flowIndicators = true; + blockIndicators = true; + } + + var buffer = new CharacterAnalyzer(new StringLookAheadBuffer(value)); + var preceededByWhitespace = true; + var followedByWhitespace = buffer.IsWhiteBreakOrZero(1); + + var leadingSpace = false; + var leadingBreak = false; + var trailingSpace = false; + var trailingBreak = false; + var leadingQuote = false; + + var breakSpace = false; + var spaceBreak = false; + var previousSpace = false; + var previousBreak = false; + var lineOfSpaces = false; + + var lineBreaks = false; + + var specialCharacters = !ValueIsRepresentableInOutputEncoding(value); + var singleQuotes = false; + var linesOfSpaces = false; + + var isFirst = true; + while (!buffer.EndOfInput) + { + if (isFirst) + { + if (buffer.Check(@"#,[]{}&*!|>\""%@`'")) + { + flowIndicators = true; + blockIndicators = true; + leadingQuote = buffer.Check('\''); + singleQuotes |= buffer.Check('\''); + } + + if (buffer.Check("?:")) + { + flowIndicators = true; + if (followedByWhitespace) + { + blockIndicators = true; + } + } + + if (buffer.Check('-') && followedByWhitespace) + { + flowIndicators = true; + blockIndicators = true; + } + } + else + { + if (buffer.Check(",?[]{}")) + { + flowIndicators = true; + } + + if (buffer.Check(':')) + { + flowIndicators = true; + if (followedByWhitespace) + { + blockIndicators = true; + } + } + + if (buffer.Check('#') && preceededByWhitespace) + { + flowIndicators = true; + blockIndicators = true; + } + + singleQuotes |= buffer.Check('\''); + } + + if (!specialCharacters && !buffer.IsPrintable()) + { + specialCharacters = true; + } + + if (buffer.IsBreak()) + { + lineBreaks = true; + } + + if (buffer.IsSpace()) + { + if (isFirst) + { + leadingSpace = true; + } + + if (buffer.Buffer.Position >= buffer.Buffer.Length - 1) + { + trailingSpace = true; + } + + if (previousBreak) + { + breakSpace = true; + lineOfSpaces = true; + } + + previousSpace = true; + previousBreak = false; + } + else if (buffer.IsBreak()) + { + if (isFirst) + { + leadingBreak = true; + } + + if (buffer.Buffer.Position >= buffer.Buffer.Length - 1) + { + trailingBreak = true; + } + + if (previousSpace) + { + spaceBreak = true; + } + + if (lineOfSpaces) + { + linesOfSpaces = true; + } + + previousSpace = false; + previousBreak = true; + } + else + { + previousSpace = false; + previousBreak = false; + lineOfSpaces = false; + } + + preceededByWhitespace = buffer.IsWhiteBreakOrZero(); + buffer.Skip(1); + if (!buffer.EndOfInput) + { + followedByWhitespace = buffer.IsWhiteBreakOrZero(1); + } + + isFirst = false; + } + + scalarData.IsFlowPlainAllowed = true; + scalarData.IsBlockPlainAllowed = true; + scalarData.IsSingleQuotedAllowed = true; + scalarData.IsBlockAllowed = true; + + if (leadingSpace || leadingBreak || trailingSpace || trailingBreak || leadingQuote) + { + scalarData.IsFlowPlainAllowed = false; + scalarData.IsBlockPlainAllowed = false; + } + + if (trailingSpace) + { + scalarData.IsBlockAllowed = false; + } + + if (breakSpace) + { + scalarData.IsFlowPlainAllowed = false; + scalarData.IsBlockPlainAllowed = false; + scalarData.IsSingleQuotedAllowed = false; + } + + if (spaceBreak || specialCharacters) + { + scalarData.IsFlowPlainAllowed = false; + scalarData.IsBlockPlainAllowed = false; + scalarData.IsSingleQuotedAllowed = false; + } + if (linesOfSpaces) + { + scalarData.IsBlockAllowed = false; + } + + scalarData.IsMultiline = lineBreaks; + if (lineBreaks) + { + scalarData.IsFlowPlainAllowed = false; + scalarData.IsBlockPlainAllowed = false; + } + + if (flowIndicators) + { + scalarData.IsFlowPlainAllowed = false; + } + + if (blockIndicators) + { + scalarData.IsBlockPlainAllowed = false; + } + + scalarData.HasSingleQuotes = singleQuotes; + } + + private bool ValueIsRepresentableInOutputEncoding(string value) + { + if (outputUsesUnicodeEncoding) + { + return true; + } + + try + { + var encodedBytes = output.Encoding.GetBytes(value); + var decodedString = output.Encoding.GetString(encodedBytes, 0, encodedBytes.Length); + return decodedString.Equals(value); + } + catch (EncoderFallbackException) + { + return false; + } + catch (ArgumentOutOfRangeException) + { + return false; + } + } + + private bool IsUnicode(Encoding encoding) + { + return encoding is UTF8Encoding || + encoding is UnicodeEncoding || + encoding is UTF7Encoding; + } + + private void AnalyzeTag(TagName tag) + { + tagData.Handle = tag.Value; + foreach (var tagDirective in tagDirectives) + { + if (tag.Value.StartsWith(tagDirective.Prefix, StringComparison.Ordinal)) + { + tagData.Handle = tagDirective.Handle; + tagData.Suffix = tag.Value.Substring(tagDirective.Prefix.Length); + break; + } + } + } + + private void StateMachine(ParsingEvent evt) + { + if (evt is Comment comment) + { + EmitComment(comment); + return; + } + + switch (state) + { + case EmitterState.StreamStart: + EmitStreamStart(evt); + break; + + case EmitterState.FirstDocumentStart: + EmitDocumentStart(evt, true); + break; + + case EmitterState.DocumentStart: + EmitDocumentStart(evt, false); + break; + + case EmitterState.DocumentContent: + EmitDocumentContent(evt); + break; + + case EmitterState.DocumentEnd: + EmitDocumentEnd(evt); + break; + + case EmitterState.FlowSequenceFirstItem: + EmitFlowSequenceItem(evt, true); + break; + + case EmitterState.FlowSequenceItem: + EmitFlowSequenceItem(evt, false); + break; + + case EmitterState.FlowMappingFirstKey: + EmitFlowMappingKey(evt, true); + break; + + case EmitterState.FlowMappingKey: + EmitFlowMappingKey(evt, false); + break; + + case EmitterState.FlowMappingSimpleValue: + EmitFlowMappingValue(evt, true); + break; + + case EmitterState.FlowMappingValue: + EmitFlowMappingValue(evt, false); + break; + + case EmitterState.BlockSequenceFirstItem: + EmitBlockSequenceItem(evt, true); + break; + + case EmitterState.BlockSequenceItem: + EmitBlockSequenceItem(evt, false); + break; + + case EmitterState.BlockMappingFirstKey: + EmitBlockMappingKey(evt, true); + break; + + case EmitterState.BlockMappingKey: + EmitBlockMappingKey(evt, false); + break; + + case EmitterState.BlockMappingSimpleValue: + EmitBlockMappingValue(evt, true); + break; + + case EmitterState.BlockMappingValue: + EmitBlockMappingValue(evt, false); + break; + + case EmitterState.StreamEnd: + throw new YamlException("Expected nothing after STREAM-END"); + + default: + throw new InvalidOperationException(); + } + } + + private void EmitComment(Comment comment) + { + if (comment.IsInline) + { + Write(' '); + } + else + { + WriteIndent(); + } + + Write("# "); + Write(comment.Value); + WriteBreak(); + + isIndentation = true; + } + + /// + /// Expect STREAM-START. + /// + private void EmitStreamStart(ParsingEvent evt) + { + if (!(evt is StreamStart)) + { + throw new ArgumentException("Expected STREAM-START.", nameof(evt)); + } + + indent = -1; + column = 0; + isWhitespace = true; + isIndentation = true; + + state = EmitterState.FirstDocumentStart; + } + + /// + /// Expect DOCUMENT-START or STREAM-END. + /// + private void EmitDocumentStart(ParsingEvent evt, bool isFirst) + { + if (evt is DocumentStart documentStart) + { + var isImplicit = documentStart.IsImplicit + && isFirst + && !isCanonical; + + var documentTagDirectives = NonDefaultTagsAmong(documentStart.Tags); + + if (!isFirst && !isDocumentEndWritten && (documentStart.Version != null || documentTagDirectives.Count > 0)) + { + isDocumentEndWritten = false; + WriteIndicator("...", true, false, false); + WriteIndent(); + } + + if (documentStart.Version != null) + { + AnalyzeVersionDirective(documentStart.Version); + + var documentVersion = documentStart.Version.Version; + isImplicit = false; + WriteIndicator("%YAML", true, false, false); + WriteIndicator(string.Format(CultureInfo.InvariantCulture, + "{0}.{1}", documentVersion.Major, documentVersion.Minor), + true, false, false); + WriteIndent(); + } + + foreach (var tagDirective in documentTagDirectives) + { + AppendTagDirectiveTo(tagDirective, false, tagDirectives); + } + + foreach (var tagDirective in Constants.DefaultTagDirectives) + { + AppendTagDirectiveTo(tagDirective, true, tagDirectives); + } + + if (documentTagDirectives.Count > 0) + { + isImplicit = false; + foreach (var tagDirective in Constants.DefaultTagDirectives) + { + AppendTagDirectiveTo(tagDirective, true, documentTagDirectives); + } + + foreach (var tagDirective in documentTagDirectives) + { + WriteIndicator("%TAG", true, false, false); + WriteTagHandle(tagDirective.Handle); + WriteTagContent(tagDirective.Prefix, true); + WriteIndent(); + } + } + + if (CheckEmptyDocument()) + { + isImplicit = false; + } + + if (!isImplicit) + { + WriteIndent(); + WriteIndicator("---", true, false, false); + if (isCanonical) + { + WriteIndent(); + } + } + + state = EmitterState.DocumentContent; + } + + else if (evt is StreamEnd) + { + state = EmitterState.StreamEnd; + } + else + { + throw new YamlException("Expected DOCUMENT-START or STREAM-END"); + } + } + + private TagDirectiveCollection NonDefaultTagsAmong(IEnumerable? tagCollection) + { + var directives = new TagDirectiveCollection(); + if (tagCollection == null) + { + return directives; + } + + foreach (var tagDirective in tagCollection) + { + AppendTagDirectiveTo(tagDirective, false, directives); + } + foreach (var tagDirective in Constants.DefaultTagDirectives) + { + directives.Remove(tagDirective); + } + return directives; + } + + private void AnalyzeVersionDirective(VersionDirective versionDirective) + { + if (versionDirective.Version.Major != Constants.MajorVersion || versionDirective.Version.Minor > Constants.MinorVersion) + { + throw new YamlException("Incompatible %YAML directive"); + } + } + + private static void AppendTagDirectiveTo(TagDirective value, bool allowDuplicates, TagDirectiveCollection tagDirectives) + { + if (tagDirectives.Contains(value)) + { + if (!allowDuplicates) + { + throw new YamlException("Duplicate %TAG directive."); + } + } + else + { + tagDirectives.Add(value); + } + } + + /// + /// Expect the root node. + /// + private void EmitDocumentContent(ParsingEvent evt) + { + states.Push(EmitterState.DocumentEnd); + EmitNode(evt, false, false); + } + + /// + /// Expect a node. + /// + private void EmitNode(ParsingEvent evt, bool isMapping, bool isSimpleKey) + { + isMappingContext = isMapping; + isSimpleKeyContext = isSimpleKey; + + switch (evt.Type) + { + case EventType.Alias: + EmitAlias(); + break; + + case EventType.Scalar: + EmitScalar(evt); + break; + + case EventType.SequenceStart: + EmitSequenceStart(evt); + break; + + case EventType.MappingStart: + EmitMappingStart(evt); + break; + + default: + throw new YamlException($"Expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS, got {evt.Type}"); + } + } + + /// + /// Expect ALIAS. + /// + private void EmitAlias() + { + ProcessAnchor(); + state = states.Pop(); + } + + /// + /// Expect SCALAR. + /// + private void EmitScalar(ParsingEvent evt) + { + SelectScalarStyle(evt); + ProcessAnchor(); + ProcessTag(); + IncreaseIndent(true, false); + ProcessScalar(); + + indent = indents.Pop(); + state = states.Pop(); + } + + private void SelectScalarStyle(ParsingEvent evt) + { + var scalar = (Scalar)evt; + + var style = scalar.Style; + var noTag = tagData.Handle == null && tagData.Suffix == null; + + if (noTag && !scalar.IsPlainImplicit && !scalar.IsQuotedImplicit) + { + throw new YamlException("Neither tag nor isImplicit flags are specified."); + } + + if (style == ScalarStyle.Any) + { + style = scalarData.IsMultiline ? ScalarStyle.Folded : ScalarStyle.Plain; + } + + if (isCanonical) + { + style = ScalarStyle.DoubleQuoted; + } + + if (isSimpleKeyContext && scalarData.IsMultiline) + { + style = ScalarStyle.DoubleQuoted; + } + + if (style == ScalarStyle.Plain) + { + if ((flowLevel != 0 && !scalarData.IsFlowPlainAllowed) || (flowLevel == 0 && !scalarData.IsBlockPlainAllowed)) + { + style = (scalarData.IsSingleQuotedAllowed && !scalarData.HasSingleQuotes) ? ScalarStyle.SingleQuoted : ScalarStyle.DoubleQuoted; + } + if (string.IsNullOrEmpty(scalarData.Value) && (flowLevel != 0 || isSimpleKeyContext)) + { + style = ScalarStyle.SingleQuoted; + } + if (noTag && !scalar.IsPlainImplicit) + { + style = ScalarStyle.SingleQuoted; + } + } + + if (style == ScalarStyle.SingleQuoted) + { + if (!scalarData.IsSingleQuotedAllowed) + { + style = ScalarStyle.DoubleQuoted; + } + } + + if (style == ScalarStyle.Literal || style == ScalarStyle.Folded) + { + if (!scalarData.IsBlockAllowed || flowLevel != 0 || isSimpleKeyContext) + { + style = ScalarStyle.DoubleQuoted; + } + } + + scalarData.Style = style; + } + + private void ProcessScalar() + { + switch (scalarData.Style) + { + case ScalarStyle.Plain: + WritePlainScalar(scalarData.Value, !isSimpleKeyContext); + break; + + case ScalarStyle.SingleQuoted: + WriteSingleQuotedScalar(scalarData.Value, !isSimpleKeyContext); + break; + + case ScalarStyle.DoubleQuoted: + WriteDoubleQuotedScalar(scalarData.Value, !isSimpleKeyContext); + break; + + case ScalarStyle.Literal: + WriteLiteralScalar(scalarData.Value); + break; + + case ScalarStyle.Folded: + WriteFoldedScalar(scalarData.Value); + break; + + default: + throw new InvalidOperationException(); + } + } + + #region Write scalar Methods + + private void WritePlainScalar(string value, bool allowBreaks) + { + if (!isWhitespace) + { + Write(' '); + } + + var previousSpace = false; + var previousBreak = false; + for (var index = 0; index < value.Length; ++index) + { + var character = value[index]; + if (IsSpace(character)) + { + if (allowBreaks && !previousSpace && column > bestWidth && index + 1 < value.Length && value[index + 1] != ' ') + { + WriteIndent(); + } + else + { + Write(character); + } + previousSpace = true; + } + else if (IsBreak(character, out var breakCharacter)) + { + if (!previousBreak && character == '\n') + { + WriteBreak(); + } + WriteBreak(breakCharacter); + isIndentation = true; + previousBreak = true; + } + else + { + if (previousBreak) + { + WriteIndent(); + } + Write(character); + isIndentation = false; + previousSpace = false; + previousBreak = false; + } + } + + isWhitespace = false; + isIndentation = false; + } + + private void WriteSingleQuotedScalar(string value, bool allowBreaks) + { + WriteIndicator("'", true, false, false); + + var previousSpace = false; + var previousBreak = false; + + for (var index = 0; index < value.Length; ++index) + { + var character = value[index]; + if (character == ' ') + { + if (allowBreaks && !previousSpace && column > bestWidth && index != 0 && index + 1 < value.Length && + value[index + 1] != ' ') + { + WriteIndent(); + } + else + { + Write(character); + } + previousSpace = true; + } + else if (IsBreak(character, out var breakCharacter)) + { + if (!previousBreak && character == '\n') + { + WriteBreak(); + } + WriteBreak(breakCharacter); + isIndentation = true; + previousBreak = true; + } + else + { + if (previousBreak) + { + WriteIndent(); + } + if (character == '\'') + { + Write(character); + } + Write(character); + isIndentation = false; + previousSpace = false; + previousBreak = false; + } + } + + WriteIndicator("'", false, false, false); + + isWhitespace = false; + isIndentation = false; + } + + private void WriteDoubleQuotedScalar(string value, bool allowBreaks) + { + WriteIndicator("\"", true, false, false); + + var previousSpace = false; + for (var index = 0; index < value.Length; ++index) + { + var character = value[index]; + if (!IsPrintable(character) || IsBreak(character, out _) || character == '"' || character == '\\') + { + Write('\\'); + + switch (character) + { + case '\0': + Write('0'); + break; + + case '\x7': + Write('a'); + break; + + case '\x8': + Write('b'); + break; + + case '\x9': + Write('t'); + break; + + case '\xA': + Write('n'); + break; + + case '\xB': + Write('v'); + break; + + case '\xC': + Write('f'); + break; + + case '\xD': + Write('r'); + break; + + case '\x1B': + Write('e'); + break; + + case '\x22': + Write('"'); + break; + + case '\x5C': + Write('\\'); + break; + + case '\x85': + Write('N'); + break; + + case '\xA0': + Write('_'); + break; + + case '\x2028': + Write('L'); + break; + + case '\x2029': + Write('P'); + break; + + default: + var code = (ushort)character; + if (code <= 0xFF) + { + Write('x'); + Write(code.ToString("X02", CultureInfo.InvariantCulture)); + } + else if (IsHighSurrogate(character)) + { + if (index + 1 < value.Length && IsLowSurrogate(value[index + 1])) + { + Write('U'); + Write(char.ConvertToUtf32(character, value[index + 1]).ToString("X08", CultureInfo.InvariantCulture)); + index++; + } + else + { + throw new SyntaxErrorException("While writing a quoted scalar, found an orphaned high surrogate."); + } + } + else + { + Write('u'); + Write(code.ToString("X04", CultureInfo.InvariantCulture)); + } + break; + } + previousSpace = false; + } + else if (character == ' ') + { + if (allowBreaks && !previousSpace && column > bestWidth && index > 0 && index + 1 < value.Length) + { + WriteIndent(); + if (value[index + 1] == ' ') + { + Write('\\'); + } + } + else + { + Write(character); + } + previousSpace = true; + } + else + { + Write(character); + previousSpace = false; + } + } + + WriteIndicator("\"", false, false, false); + + isWhitespace = false; + isIndentation = false; + } + + private void WriteLiteralScalar(string value) + { + var previousBreak = true; + + WriteIndicator("|", true, false, false); + WriteBlockScalarHints(value); + WriteBreak(); + + isIndentation = true; + isWhitespace = true; + + for (var i = 0; i < value.Length; ++i) + { + var character = value[i]; + if (character == '\r' && (i + 1) < value.Length && value[i + 1] == '\n') + { + continue; + } + + if (IsBreak(character, out var breakCharacter)) + { + WriteBreak(breakCharacter); + isIndentation = true; + previousBreak = true; + } + else + { + if (previousBreak) + { + WriteIndent(); + } + Write(character); + isIndentation = false; + previousBreak = false; + } + } + } + + private void WriteFoldedScalar(string value) + { + var previousBreak = true; + var leadingSpaces = true; + + WriteIndicator(">", true, false, false); + WriteBlockScalarHints(value); + WriteBreak(); + + isIndentation = true; + isWhitespace = true; + + for (var i = 0; i < value.Length; ++i) + { + var character = value[i]; + if (IsBreak(character, out var breakCharacter)) + { + if (character == '\r' && (i + 1) < value.Length && value[i + 1] == '\n') + { + continue; + } + + if (!previousBreak && !leadingSpaces && breakCharacter == '\n') + { + var k = 0; + while (i + k < value.Length && IsBreak(value[i + k], out _)) + { + ++k; + } + if (i + k < value.Length && !(IsBlank(value[i + k]) || IsBreak(value[i + k], out _))) + { + WriteBreak(); + } + } + + WriteBreak(breakCharacter); + isIndentation = true; + previousBreak = true; + } + else + { + if (previousBreak) + { + WriteIndent(); + leadingSpaces = IsBlank(character); + } + if (!previousBreak && character == ' ' && i + 1 < value.Length && value[i + 1] != ' ' && column > bestWidth) + { + WriteIndent(); + } + else + { + Write(character); + } + isIndentation = false; + previousBreak = false; + } + } + } + + // Todo: isn't this what CharacterAnalyser is for? + private static bool IsSpace(char character) + { + return character == ' '; + } + + private static bool IsBreak(char character, out char breakChar) + { + switch (character) + { + case '\r': + case '\n': + case '\x85': + breakChar = '\n'; + return true; + + case '\x2028': + case '\x2029': + breakChar = character; + return true; + + default: + breakChar = '\0'; + return false; + } + } + + private static bool IsBlank(char character) + { + return character == ' ' || character == '\t'; + } + + private static bool IsPrintable(char character) + { + return + character == '\x9' || + character == '\xA' || + character == '\xD' || + (character >= '\x20' && character <= '\x7E') || + character == '\x85' || + (character >= '\xA0' && character <= '\xD7FF') || + (character >= '\xE000' && character <= '\xFFFD'); + } + + private static bool IsHighSurrogate(char c) + { + return 0xD800 <= c && c <= 0xDBFF; + } + + private static bool IsLowSurrogate(char c) + { + return 0xDC00 <= c && c <= 0xDFFF; + } + + #endregion + + /// + /// Expect SEQUENCE-START. + /// + private void EmitSequenceStart(ParsingEvent evt) + { + ProcessAnchor(); + ProcessTag(); + + var sequenceStart = (SequenceStart)evt; + + if (flowLevel != 0 || isCanonical || sequenceStart.Style == SequenceStyle.Flow || CheckEmptySequence()) + { + state = EmitterState.FlowSequenceFirstItem; + } + else + { + state = EmitterState.BlockSequenceFirstItem; + } + } + + /// + /// Expect MAPPING-START. + /// + private void EmitMappingStart(ParsingEvent evt) + { + ProcessAnchor(); + ProcessTag(); + + var mappingStart = (MappingStart)evt; + + if (flowLevel != 0 || isCanonical || mappingStart.Style == MappingStyle.Flow || CheckEmptyMapping()) + { + state = EmitterState.FlowMappingFirstKey; + } + else + { + state = EmitterState.BlockMappingFirstKey; + } + } + + private void ProcessAnchor() + { + if (!anchorData.Anchor.IsEmpty && !skipAnchorName) + { + WriteIndicator(anchorData.IsAlias ? "*" : "&", true, false, false); + WriteAnchor(anchorData.Anchor); + } + } + + private void ProcessTag() + { + if (tagData.Handle == null && tagData.Suffix == null) + { + return; + } + + if (tagData.Handle != null) + { + WriteTagHandle(tagData.Handle); + if (tagData.Suffix != null) + { + WriteTagContent(tagData.Suffix, false); + } + } + else + { + WriteIndicator("!<", true, false, false); + WriteTagContent(tagData.Suffix!, false); + WriteIndicator(">", false, false, false); + } + } + + /// + /// Expect DOCUMENT-END. + /// + private void EmitDocumentEnd(ParsingEvent evt) + { + if (evt is DocumentEnd documentEnd) + { + WriteIndent(); + if (!documentEnd.IsImplicit) + { + WriteIndicator("...", true, false, false); + WriteIndent(); + isDocumentEndWritten = true; + } + + state = EmitterState.DocumentStart; + + tagDirectives.Clear(); + } + else + { + throw new YamlException("Expected DOCUMENT-END."); + } + } + + /// + /// Expect a flow item node. + /// + private void EmitFlowSequenceItem(ParsingEvent evt, bool isFirst) + { + if (isFirst) + { + WriteIndicator("[", true, true, false); + IncreaseIndent(true, false); + ++flowLevel; + } + + if (evt is SequenceEnd) + { + --flowLevel; + indent = indents.Pop(); + if (isCanonical && !isFirst) + { + WriteIndicator(",", false, false, false); + WriteIndent(); + } + WriteIndicator("]", false, false, false); + state = states.Pop(); + return; + } + + if (!isFirst) + { + WriteIndicator(",", false, false, false); + } + + if (isCanonical || column > bestWidth) + { + WriteIndent(); + } + + states.Push(EmitterState.FlowSequenceItem); + + EmitNode(evt, false, false); + } + + /// + /// Expect a flow key node. + /// + private void EmitFlowMappingKey(ParsingEvent evt, bool isFirst) + { + if (isFirst) + { + WriteIndicator("{", true, true, false); + IncreaseIndent(true, false); + ++flowLevel; + } + + if (evt is MappingEnd) + { + --flowLevel; + indent = indents.Pop(); + if (isCanonical && !isFirst) + { + WriteIndicator(",", false, false, false); + WriteIndent(); + } + WriteIndicator("}", false, false, false); + state = states.Pop(); + return; + } + + if (!isFirst) + { + WriteIndicator(",", false, false, false); + } + if (isCanonical || column > bestWidth) + { + WriteIndent(); + } + + if (!isCanonical && CheckSimpleKey()) + { + states.Push(EmitterState.FlowMappingSimpleValue); + EmitNode(evt, true, true); + } + else + { + WriteIndicator("?", true, false, false); + states.Push(EmitterState.FlowMappingValue); + EmitNode(evt, true, false); + } + } + + /// + /// Expect a flow value node. + /// + private void EmitFlowMappingValue(ParsingEvent evt, bool isSimple) + { + if (isSimple) + { + WriteIndicator(":", false, false, false); + } + else + { + if (isCanonical || column > bestWidth) + { + WriteIndent(); + } + WriteIndicator(":", true, false, false); + } + states.Push(EmitterState.FlowMappingKey); + EmitNode(evt, true, false); + } + + /// + /// Expect a block item node. + /// + private void EmitBlockSequenceItem(ParsingEvent evt, bool isFirst) + { + if (isFirst) + { + IncreaseIndent(false, (isMappingContext && !isIndentation)); + } + + if (evt is SequenceEnd) + { + indent = indents.Pop(); + state = states.Pop(); + return; + } + + WriteIndent(); + WriteIndicator("-", true, false, true); + states.Push(EmitterState.BlockSequenceItem); + + EmitNode(evt, false, false); + } + + /// + /// Expect a block key node. + /// + private void EmitBlockMappingKey(ParsingEvent evt, bool isFirst) + { + if (isFirst) + { + IncreaseIndent(false, false); + } + + if (evt is MappingEnd) + { + indent = indents.Pop(); + state = states.Pop(); + return; + } + + WriteIndent(); + + if (CheckSimpleKey()) + { + states.Push(EmitterState.BlockMappingSimpleValue); + EmitNode(evt, true, true); + } + else + { + WriteIndicator("?", true, false, true); + states.Push(EmitterState.BlockMappingValue); + EmitNode(evt, true, false); + } + } + + /// + /// Expect a block value node. + /// + private void EmitBlockMappingValue(ParsingEvent evt, bool isSimple) + { + if (isSimple) + { + WriteIndicator(":", false, false, false); + } + else + { + WriteIndent(); + WriteIndicator(":", true, false, true); + } + states.Push(EmitterState.BlockMappingKey); + EmitNode(evt, true, false); + } + + private void IncreaseIndent(bool isFlow, bool isIndentless) + { + indents.Push(indent); + + if (indent < 0) + { + indent = isFlow ? bestIndent : 0; + } + else if (!isIndentless || !forceIndentLess) + { + indent += bestIndent; + } + } + + #region Check Methods + + /// + /// Check if the document content is an empty scalar. + /// + private bool CheckEmptyDocument() + { + var index = 0; + foreach (var parsingEvent in events) + { + index++; + if (index == 2) + { + if (parsingEvent is Scalar scalar) + { + return string.IsNullOrEmpty(scalar.Value); + } + break; + } + } + + return false; + } + + /// + /// Check if the next node can be expressed as a simple key. + /// + private bool CheckSimpleKey() + { + if (events.Count < 1) + { + return false; + } + + int length; + switch (events.Peek().Type) + { + case EventType.Alias: + length = AnchorNameLength(anchorData.Anchor); + break; + + case EventType.Scalar: + if (scalarData.IsMultiline) + { + return false; + } + + length = + AnchorNameLength(anchorData.Anchor) + + SafeStringLength(tagData.Handle) + + SafeStringLength(tagData.Suffix) + + SafeStringLength(scalarData.Value); + break; + + case EventType.SequenceStart: + if (!CheckEmptySequence()) + { + return false; + } + length = + AnchorNameLength(anchorData.Anchor) + + SafeStringLength(tagData.Handle) + + SafeStringLength(tagData.Suffix); + break; + + case EventType.MappingStart: + if (!CheckEmptySequence()) + { + return false; + } + length = + AnchorNameLength(anchorData.Anchor) + + SafeStringLength(tagData.Handle) + + SafeStringLength(tagData.Suffix); + break; + + default: + return false; + } + + return length <= maxSimpleKeyLength; + } + + private int AnchorNameLength(AnchorName value) + { + return value.IsEmpty ? 0 : value.Value.Length; + } + + private int SafeStringLength(string? value) + { + return value == null ? 0 : value.Length; + } + + private bool CheckEmptySequence() => CheckEmptyStructure(); + private bool CheckEmptyMapping() => CheckEmptyStructure(); + + private bool CheckEmptyStructure() + where TStart : NodeEvent + where TEnd : ParsingEvent + { + if (events.Count < 2) + { + return false; + } + + using var enumerator = events.GetEnumerator(); + return enumerator.MoveNext() + && enumerator.Current is TStart + && enumerator.MoveNext() + && enumerator.Current is TEnd; + } + #endregion + + #region Write Methods + + private void WriteBlockScalarHints(string value) + { + var analyzer = new CharacterAnalyzer(new StringLookAheadBuffer(value)); + + if (analyzer.IsSpace() || analyzer.IsBreak()) + { + var indentHint = bestIndent.ToString(CultureInfo.InvariantCulture); + WriteIndicator(indentHint, false, false, false); + } + + string? chompHint = null; + if (value.Length == 0 || !analyzer.IsBreak(value.Length - 1)) + { + chompHint = "-"; + } + else if (value.Length >= 2 && analyzer.IsBreak(value.Length - 2)) + { + chompHint = "+"; + } + + if (chompHint != null) + { + WriteIndicator(chompHint, false, false, false); + } + } + + private void WriteIndicator(string indicator, bool needWhitespace, bool whitespace, bool indentation) + { + if (needWhitespace && !isWhitespace) + { + Write(' '); + } + + Write(indicator); + + isWhitespace = whitespace; + isIndentation &= indentation; + } + + private void WriteIndent() + { + var currentIndent = Math.Max(indent, 0); + + var isBreakRequired = !isIndentation + || column > currentIndent + || (column == currentIndent && !isWhitespace); + + if (isBreakRequired) + { + WriteBreak(); + } + + while (column < currentIndent) + { + Write(' '); + } + + isWhitespace = true; + isIndentation = true; + } + + private void WriteAnchor(AnchorName value) + { + Write(value.Value); + + isWhitespace = false; + isIndentation = false; + } + + private void WriteTagHandle(string value) + { + if (!isWhitespace) + { + Write(' '); + } + + Write(value); + + isWhitespace = false; + isIndentation = false; + } + + private void WriteTagContent(string value, bool needsWhitespace) + { + if (needsWhitespace && !isWhitespace) + { + Write(' '); + } + + Write(UrlEncode(value)); + + isWhitespace = false; + isIndentation = false; + } + + private string UrlEncode(string text) + { + return UriReplacer.Replace(text, delegate (Match match) + { + var buffer = new StringBuilder(); + foreach (var toEncode in Encoding.UTF8.GetBytes(match.Value)) + { + buffer.AppendFormat("%{0:X02}", toEncode); + } + return buffer.ToString(); + }); + } + + private void Write(char value) + { + output.Write(value); + ++column; + } + + private void Write(string value) + { + output.Write(value); + column += value.Length; + } + + private void WriteBreak(char breakCharacter = '\n') + { + if (breakCharacter == '\n') + { + output.WriteLine(); + } + else + { + output.Write(breakCharacter); + } + column = 0; + } + + #endregion + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Emitter.cs.meta b/namedropper/Assets/YamlDotNet/Core/Emitter.cs.meta new file mode 100644 index 0000000..f08bcf6 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Emitter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f526134efcd8e424c86e492f85fc56ba +timeCreated: 1427145267 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/EmitterSettings.cs b/namedropper/Assets/YamlDotNet/Core/EmitterSettings.cs new file mode 100644 index 0000000..ee6c853 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/EmitterSettings.cs @@ -0,0 +1,159 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core +{ + public sealed class EmitterSettings + { + /// + /// The preferred indentation. + /// + public int BestIndent { get; } = 2; + + /// + /// The preferred text width. + /// + public int BestWidth { get; } = int.MaxValue; + + /// + /// If true, write the output in canonical form. + /// + public bool IsCanonical { get; } = false; + + /// + /// If true, write output without anchor names. + /// + public bool SkipAnchorName { get; private set; } + + /// + /// The maximum allowed length for simple keys. + /// + /// + /// The specifiction mandates 1024 characters, but any desired value may be used. + /// + public int MaxSimpleKeyLength { get; } = 1024; + + /// + /// Indent sequences. The default is to not indent. + /// + public bool IndentSequences { get; } = false; + + public static readonly EmitterSettings Default = new EmitterSettings(); + + public EmitterSettings() + { + } + + public EmitterSettings(int bestIndent, int bestWidth, bool isCanonical, int maxSimpleKeyLength, bool skipAnchorName = false, bool indentSequences = false) + { + if (bestIndent < 2 || bestIndent > 9) + { + throw new ArgumentOutOfRangeException(nameof(bestIndent), $"BestIndent must be between 2 and 9, inclusive"); + } + + if (bestWidth <= bestIndent * 2) + { + throw new ArgumentOutOfRangeException(nameof(bestWidth), "BestWidth must be greater than BestIndent x 2."); + } + + if (maxSimpleKeyLength < 0) + { + throw new ArgumentOutOfRangeException(nameof(maxSimpleKeyLength), "MaxSimpleKeyLength must be >= 0"); + } + + BestIndent = bestIndent; + BestWidth = bestWidth; + IsCanonical = isCanonical; + MaxSimpleKeyLength = maxSimpleKeyLength; + SkipAnchorName = skipAnchorName; + IndentSequences = indentSequences; + } + + public EmitterSettings WithBestIndent(int bestIndent) + { + return new EmitterSettings( + bestIndent, + BestWidth, + IsCanonical, + MaxSimpleKeyLength, + SkipAnchorName + ); + } + + public EmitterSettings WithBestWidth(int bestWidth) + { + return new EmitterSettings( + BestIndent, + bestWidth, + IsCanonical, + MaxSimpleKeyLength, + SkipAnchorName + ); + } + + public EmitterSettings WithMaxSimpleKeyLength(int maxSimpleKeyLength) + { + return new EmitterSettings( + BestIndent, + BestWidth, + IsCanonical, + maxSimpleKeyLength, + SkipAnchorName + ); + } + + public EmitterSettings Canonical() + { + return new EmitterSettings( + BestIndent, + BestWidth, + true, + MaxSimpleKeyLength, + SkipAnchorName + ); + } + + public EmitterSettings WithoutAnchorName() + { + return new EmitterSettings( + BestIndent, + BestWidth, + IsCanonical, + MaxSimpleKeyLength, + true + ); + } + + public EmitterSettings WithIndentedSequences() + { + return new EmitterSettings( + BestIndent, + BestWidth, + IsCanonical, + MaxSimpleKeyLength, + SkipAnchorName, + true + ); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/EmitterSettings.cs.meta b/namedropper/Assets/YamlDotNet/Core/EmitterSettings.cs.meta new file mode 100644 index 0000000..e1befb8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/EmitterSettings.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7496371f913cd4a4aa6e1d7009a88169 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/EmitterState.cs b/namedropper/Assets/YamlDotNet/Core/EmitterState.cs new file mode 100644 index 0000000..45ba5ae --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/EmitterState.cs @@ -0,0 +1,45 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core +{ + internal enum EmitterState + { + StreamStart, + StreamEnd, + FirstDocumentStart, + DocumentStart, + DocumentContent, + DocumentEnd, + FlowSequenceFirstItem, + FlowSequenceItem, + FlowMappingFirstKey, + FlowMappingKey, + FlowMappingSimpleValue, + FlowMappingValue, + BlockSequenceFirstItem, + BlockSequenceItem, + BlockMappingFirstKey, + BlockMappingKey, + BlockMappingSimpleValue, + BlockMappingValue + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/EmitterState.cs.meta b/namedropper/Assets/YamlDotNet/Core/EmitterState.cs.meta new file mode 100644 index 0000000..7fd64ed --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/EmitterState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7127212075b19ce4f99a370f02d26037 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events.meta b/namedropper/Assets/YamlDotNet/Core/Events.meta new file mode 100644 index 0000000..a8f34b4 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 2dd1df9756078164587ab6fc3579145d +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/AnchorAlias.cs b/namedropper/Assets/YamlDotNet/Core/Events/AnchorAlias.cs new file mode 100644 index 0000000..2ed9a1c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/AnchorAlias.cs @@ -0,0 +1,85 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + /// + /// Represents an alias event. + /// + public sealed class AnchorAlias : ParsingEvent + { + /// + /// Gets the event type, which allows for simpler type comparisons. + /// + internal override EventType Type => EventType.Alias; + + /// + /// Gets the value of the alias. + /// + public AnchorName Value { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The value of the alias. + /// The start position of the event. + /// The end position of the event. + public AnchorAlias(AnchorName value, Mark start, Mark end) + : base(start, end) + { + if (value.IsEmpty) + { + throw new YamlException(start, end, "Anchor value must not be empty."); + } + + this.Value = value; + } + + /// + /// Initializes a new instance of the class. + /// + /// The value of the alias. + public AnchorAlias(AnchorName value) + : this(value, Mark.Empty, Mark.Empty) + { + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// + public override string ToString() + { + return $"Alias [value = {Value}]"; + } + + /// + /// Invokes run-time type specific Visit() method of the specified visitor. + /// + /// visitor, may not be null. + public override void Accept(IParsingEventVisitor visitor) + { + visitor.Visit(this); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/AnchorAlias.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/AnchorAlias.cs.meta new file mode 100644 index 0000000..861492d --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/AnchorAlias.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 09b29b54793d9644398fe8e4da326353 +timeCreated: 1427145262 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/Comment.cs b/namedropper/Assets/YamlDotNet/Core/Events/Comment.cs new file mode 100644 index 0000000..907d258 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/Comment.cs @@ -0,0 +1,59 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + public sealed class Comment : ParsingEvent + { + public string Value { get; } + public bool IsInline { get; } + + public Comment(string value, bool isInline) + : this(value, isInline, Mark.Empty, Mark.Empty) + { + } + + public Comment(string value, bool isInline, Mark start, Mark end) + : base(start, end) + { + Value = value; + IsInline = isInline; + } + + internal override EventType Type => EventType.Comment; + + public override void Accept(IParsingEventVisitor visitor) + { + visitor.Visit(this); + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// + public override string ToString() + { + return $"{(IsInline ? "Inline" : "Block")} Comment [{Value}]"; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/Comment.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/Comment.cs.meta new file mode 100644 index 0000000..6c0e75c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/Comment.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e96511072ac5a30488623987ca605570 +timeCreated: 1427145267 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/DocumentEnd.cs b/namedropper/Assets/YamlDotNet/Core/Events/DocumentEnd.cs new file mode 100644 index 0000000..e802e62 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/DocumentEnd.cs @@ -0,0 +1,90 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + /// + /// Represents a document end event. + /// + public sealed class DocumentEnd : ParsingEvent + { + /// + /// Gets a value indicating the variation of depth caused by this event. + /// The value can be either -1, 0 or 1. For start events, it will be 1, + /// for end events, it will be -1, and for the remaining events, it will be 0. + /// + public override int NestingIncrease => -1; + + /// + /// Gets the event type, which allows for simpler type comparisons. + /// + internal override EventType Type => EventType.DocumentEnd; + + /// + /// Gets a value indicating whether this instance is implicit. + /// + /// + /// true if this instance is implicit; otherwise, false. + /// + public bool IsImplicit { get; } + + /// + /// Initializes a new instance of the class. + /// + /// Indicates whether the event is implicit. + /// The start position of the event. + /// The end position of the event. + public DocumentEnd(bool isImplicit, Mark start, Mark end) + : base(start, end) + { + this.IsImplicit = isImplicit; + } + + /// + /// Initializes a new instance of the class. + /// + /// Indicates whether the event is implicit. + public DocumentEnd(bool isImplicit) + : this(isImplicit, Mark.Empty, Mark.Empty) + { + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// + public override string ToString() + { + return $"Document end [isImplicit = {IsImplicit}]"; + } + + /// + /// Invokes run-time type specific Visit() method of the specified visitor. + /// + /// visitor, may not be null. + public override void Accept(IParsingEventVisitor visitor) + { + visitor.Visit(this); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/DocumentEnd.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/DocumentEnd.cs.meta new file mode 100644 index 0000000..700d967 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/DocumentEnd.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 99b4ea3b75d2e754cb5fea7cc0f1a4d3 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/DocumentStart.cs b/namedropper/Assets/YamlDotNet/Core/Events/DocumentStart.cs new file mode 100644 index 0000000..394ffff --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/DocumentStart.cs @@ -0,0 +1,128 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using YamlDotNet.Core.Tokens; + +namespace YamlDotNet.Core.Events +{ + /// + /// Represents a document start event. + /// + public sealed class DocumentStart : ParsingEvent + { + /// + /// Gets a value indicating the variation of depth caused by this event. + /// The value can be either -1, 0 or 1. For start events, it will be 1, + /// for end events, it will be -1, and for the remaining events, it will be 0. + /// + public override int NestingIncrease => 1; + + /// + /// Gets the event type, which allows for simpler type comparisons. + /// + internal override EventType Type => EventType.DocumentStart; + + /// + /// Gets the tags. + /// + /// The tags. + public TagDirectiveCollection? Tags { get; } + + /// + /// Gets the version. + /// + /// The version. + public VersionDirective? Version { get; } + + /// + /// Gets a value indicating whether this instance is implicit. + /// + /// + /// true if this instance is implicit; otherwise, false. + /// + public bool IsImplicit { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The version. + /// The tags. + /// Indicates whether the event is implicit. + /// The start position of the event. + /// The end position of the event. + public DocumentStart(VersionDirective? version, TagDirectiveCollection? tags, bool isImplicit, Mark start, Mark end) + : base(start, end) + { + this.Version = version; + this.Tags = tags; + this.IsImplicit = isImplicit; + } + + /// + /// Initializes a new instance of the class. + /// + /// The version. + /// The tags. + /// Indicates whether the event is implicit. + public DocumentStart(VersionDirective? version, TagDirectiveCollection? tags, bool isImplicit) + : this(version, tags, isImplicit, Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the event. + /// The end position of the event. + public DocumentStart(Mark start, Mark end) + : this(null, null, true, start, end) + { + } + + /// + /// Initializes a new instance of the class. + /// + public DocumentStart() + : this(null, null, true, Mark.Empty, Mark.Empty) + { + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// + public override string ToString() + { + return $"Document start [isImplicit = {IsImplicit}]"; + } + + /// + /// Invokes run-time type specific Visit() method of the specified visitor. + /// + /// visitor, may not be null. + public override void Accept(IParsingEventVisitor visitor) + { + visitor.Visit(this); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/DocumentStart.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/DocumentStart.cs.meta new file mode 100644 index 0000000..731c733 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/DocumentStart.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 06cc13f1bc1622246924546d044eede9 +timeCreated: 1427145262 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/EventType.cs b/namedropper/Assets/YamlDotNet/Core/Events/EventType.cs new file mode 100644 index 0000000..944131e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/EventType.cs @@ -0,0 +1,39 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + internal enum EventType + { + None, + StreamStart, + StreamEnd, + DocumentStart, + DocumentEnd, + Alias, + Scalar, + SequenceStart, + SequenceEnd, + MappingStart, + MappingEnd, + Comment, + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/EventType.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/EventType.cs.meta new file mode 100644 index 0000000..9db1133 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/EventType.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3a7e249b62575e048929c7a3e0420470 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/IParsingEventVisitor.cs b/namedropper/Assets/YamlDotNet/Core/Events/IParsingEventVisitor.cs new file mode 100644 index 0000000..afe0360 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/IParsingEventVisitor.cs @@ -0,0 +1,41 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + /// + /// Callback interface for external event Visitor. + /// + public interface IParsingEventVisitor + { + void Visit(AnchorAlias e); + void Visit(StreamStart e); + void Visit(StreamEnd e); + void Visit(DocumentStart e); + void Visit(DocumentEnd e); + void Visit(Scalar e); + void Visit(SequenceStart e); + void Visit(SequenceEnd e); + void Visit(MappingStart e); + void Visit(MappingEnd e); + void Visit(Comment e); + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/IParsingEventVisitor.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/IParsingEventVisitor.cs.meta new file mode 100644 index 0000000..1413c5a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/IParsingEventVisitor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 34cdef8e5d4918149bf7185da865504b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/MappingEnd.cs b/namedropper/Assets/YamlDotNet/Core/Events/MappingEnd.cs new file mode 100644 index 0000000..ea2d781 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/MappingEnd.cs @@ -0,0 +1,79 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + /// + /// Represents a mapping end event. + /// + public class MappingEnd : ParsingEvent + { + /// + /// Gets a value indicating the variation of depth caused by this event. + /// The value can be either -1, 0 or 1. For start events, it will be 1, + /// for end events, it will be -1, and for the remaining events, it will be 0. + /// + public override int NestingIncrease => -1; + + /// + /// Gets the event type, which allows for simpler type comparisons. + /// + internal override EventType Type => EventType.MappingEnd; + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the event. + /// The end position of the event. + public MappingEnd(Mark start, Mark end) + : base(start, end) + { + } + + /// + /// Initializes a new instance of the class. + /// + public MappingEnd() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// + public override string ToString() + { + return "Mapping end"; + } + + /// + /// Invokes run-time type specific Visit() method of the specified visitor. + /// + /// visitor, may not be null. + public override void Accept(IParsingEventVisitor visitor) + { + visitor.Visit(this); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/MappingEnd.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/MappingEnd.cs.meta new file mode 100644 index 0000000..b2d10bf --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/MappingEnd.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 32f12dd96a8cb4d4792ed76749f67b38 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/MappingStart.cs b/namedropper/Assets/YamlDotNet/Core/Events/MappingStart.cs new file mode 100644 index 0000000..701c551 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/MappingStart.cs @@ -0,0 +1,116 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + /// + /// Represents a mapping start event. + /// + public sealed class MappingStart : NodeEvent + { + /// + /// Gets a value indicating the variation of depth caused by this event. + /// The value can be either -1, 0 or 1. For start events, it will be 1, + /// for end events, it will be -1, and for the remaining events, it will be 0. + /// + public override int NestingIncrease => 1; + + /// + /// Gets the event type, which allows for simpler type comparisons. + /// + internal override EventType Type => EventType.MappingStart; + + /// + /// Gets a value indicating whether this instance is implicit. + /// + /// + /// true if this instance is implicit; otherwise, false. + /// + public bool IsImplicit { get; } + + /// + /// Gets a value indicating whether this instance is canonical. + /// + /// + public override bool IsCanonical => !IsImplicit; + + /// + /// Gets the style of the mapping. + /// + public MappingStyle Style { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The anchor. + /// The tag. + /// Indicates whether the event is implicit. + /// The style of the mapping. + /// The start position of the event. + /// The end position of the event. + public MappingStart(AnchorName anchor, TagName tag, bool isImplicit, MappingStyle style, Mark start, Mark end) + : base(anchor, tag, start, end) + { + this.IsImplicit = isImplicit; + this.Style = style; + } + + /// + /// Initializes a new instance of the class. + /// + /// The anchor. + /// The tag. + /// Indicates whether the event is implicit. + /// The style of the mapping. + public MappingStart(AnchorName anchor, TagName tag, bool isImplicit, MappingStyle style) + : this(anchor, tag, isImplicit, style, Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + public MappingStart() + : this(AnchorName.Empty, TagName.Empty, true, MappingStyle.Any, Mark.Empty, Mark.Empty) + { + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// + public override string ToString() + { + return $"Mapping start [anchor = {Anchor}, tag = {Tag}, isImplicit = {IsImplicit}, style = {Style}]"; + } + + /// + /// Invokes run-time type specific Visit() method of the specified visitor. + /// + /// visitor, may not be null. + public override void Accept(IParsingEventVisitor visitor) + { + visitor.Visit(this); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/MappingStart.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/MappingStart.cs.meta new file mode 100644 index 0000000..a018077 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/MappingStart.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 79e25e33bd9642a4ca1c8c5280b30984 +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/MappingStyle.cs b/namedropper/Assets/YamlDotNet/Core/Events/MappingStyle.cs new file mode 100644 index 0000000..f6b6a89 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/MappingStyle.cs @@ -0,0 +1,44 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + /// + /// Specifies the style of a mapping. + /// + public enum MappingStyle + { + /// + /// Let the emitter choose the style. + /// + Any, + + /// + /// The block mapping style. + /// + Block, + + /// + /// The flow mapping style. + /// + Flow + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/MappingStyle.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/MappingStyle.cs.meta new file mode 100644 index 0000000..0f1cc19 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/MappingStyle.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7bc885bebca1fac428d7482f06b4f41e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/NodeEvent.cs b/namedropper/Assets/YamlDotNet/Core/Events/NodeEvent.cs new file mode 100644 index 0000000..331dbc0 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/NodeEvent.cs @@ -0,0 +1,72 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + /// + /// Contains the behavior that is common between node events. + /// + public abstract class NodeEvent : ParsingEvent + { + /// + /// Gets the anchor. + /// + /// + public AnchorName Anchor { get; } + + /// + /// Gets the tag. + /// + /// + public TagName Tag { get; } + + /// + /// Gets a value indicating whether this instance is canonical. + /// + /// + public abstract bool IsCanonical + { + get; + } + + /// + /// Initializes a new instance of the class. + /// + /// The anchor. + /// The tag. + /// The start position of the event. + /// The end position of the event. + protected NodeEvent(AnchorName anchor, TagName tag, Mark start, Mark end) + : base(start, end) + { + this.Anchor = anchor; + this.Tag = tag; + } + + /// + /// Initializes a new instance of the class. + /// + protected NodeEvent(AnchorName anchor, TagName tag) + : this(anchor, tag, Mark.Empty, Mark.Empty) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/NodeEvent.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/NodeEvent.cs.meta new file mode 100644 index 0000000..ff67e3b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/NodeEvent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4fa0681239f68a3468223fe925e01d33 +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/ParsingEvent.cs b/namedropper/Assets/YamlDotNet/Core/Events/ParsingEvent.cs new file mode 100644 index 0000000..5b599f8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/ParsingEvent.cs @@ -0,0 +1,68 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + /// + /// Base class for parsing events. + /// + public abstract class ParsingEvent + { + /// + /// Gets a value indicating the variation of depth caused by this event. + /// The value can be either -1, 0 or 1. For start events, it will be 1, + /// for end events, it will be -1, and for the remaining events, it will be 0. + /// + public virtual int NestingIncrease => 0; + + /// + /// Gets the event type, which allows for simpler type comparisons. + /// + internal abstract EventType Type { get; } + + /// + /// Gets the position in the input stream where the event starts. + /// + public Mark Start { get; } + + /// + /// Gets the position in the input stream where the event ends. + /// + public Mark End { get; } + + /// + /// Accepts the specified visitor. + /// + /// Visitor to accept, may not be null + public abstract void Accept(IParsingEventVisitor visitor); + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the event. + /// The end position of the event. + internal ParsingEvent(Mark start, Mark end) + { + this.Start = start ?? throw new System.ArgumentNullException(nameof(start)); + this.End = end ?? throw new System.ArgumentNullException(nameof(end)); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/ParsingEvent.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/ParsingEvent.cs.meta new file mode 100644 index 0000000..b6dc77a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/ParsingEvent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5dcecbbabc813c74bb16837d87a36f7e +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/Scalar.cs b/namedropper/Assets/YamlDotNet/Core/Events/Scalar.cs new file mode 100644 index 0000000..747086b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/Scalar.cs @@ -0,0 +1,143 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + /// + /// Represents a scalar event. + /// + public sealed class Scalar : NodeEvent + { + /// + /// Gets the event type, which allows for simpler type comparisons. + /// + internal override EventType Type => EventType.Scalar; + + /// + /// Gets the value. + /// + /// The value. + public string Value { get; } + + /// + /// Gets the style of the scalar. + /// + /// The style. + public ScalarStyle Style { get; } + + /// + /// Gets a value indicating whether the tag is optional for the plain style. + /// + public bool IsPlainImplicit { get; } + + /// + /// Gets a value indicating whether the tag is optional for any non-plain style. + /// + public bool IsQuotedImplicit { get; } + + /// + /// Gets a value indicating whether this instance is canonical. + /// + /// + public override bool IsCanonical => !IsPlainImplicit && !IsQuotedImplicit; + + /// + /// Initializes a new instance of the class. + /// + /// The anchor. + /// The tag. + /// The value. + /// The style. + /// . + /// . + /// The start position of the event. + /// The end position of the event. + public Scalar(AnchorName anchor, TagName tag, string value, ScalarStyle style, bool isPlainImplicit, bool isQuotedImplicit, Mark start, Mark end) + : base(anchor, tag, start, end) + { + this.Value = value; + this.Style = style; + this.IsPlainImplicit = isPlainImplicit; + this.IsQuotedImplicit = isQuotedImplicit; + } + + /// + /// Initializes a new instance of the class. + /// + /// The anchor. + /// The tag. + /// The value. + /// The style. + /// . + /// . + public Scalar(AnchorName anchor, TagName tag, string value, ScalarStyle style, bool isPlainImplicit, bool isQuotedImplicit) + : this(anchor, tag, value, style, isPlainImplicit, isQuotedImplicit, Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The value. + public Scalar(string value) + : this(AnchorName.Empty, TagName.Empty, value, ScalarStyle.Any, true, true, Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The tag. + /// The value. + public Scalar(TagName tag, string value) + : this(AnchorName.Empty, tag, value, ScalarStyle.Any, true, true, Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + public Scalar(AnchorName anchor, TagName tag, string value) + : this(anchor, tag, value, ScalarStyle.Any, true, true, Mark.Empty, Mark.Empty) + { + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// + public override string ToString() + { + return $"Scalar [anchor = {Anchor}, tag = {Tag}, value = {Value}, style = {Style}, isPlainImplicit = {IsPlainImplicit}, isQuotedImplicit = {IsQuotedImplicit}]"; + } + + /// + /// Invokes run-time type specific Visit() method of the specified visitor. + /// + /// visitor, may not be null. + public override void Accept(IParsingEventVisitor visitor) + { + visitor.Visit(this); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/Scalar.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/Scalar.cs.meta new file mode 100644 index 0000000..7008241 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/Scalar.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7c9ef7a4a2cc85b40aea8fda0d00cb33 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/SequenceEnd.cs b/namedropper/Assets/YamlDotNet/Core/Events/SequenceEnd.cs new file mode 100644 index 0000000..298c27b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/SequenceEnd.cs @@ -0,0 +1,79 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + /// + /// Represents a sequence end event. + /// + public sealed class SequenceEnd : ParsingEvent + { + /// + /// Gets a value indicating the variation of depth caused by this event. + /// The value can be either -1, 0 or 1. For start events, it will be 1, + /// for end events, it will be -1, and for the remaining events, it will be 0. + /// + public override int NestingIncrease => -1; + + /// + /// Gets the event type, which allows for simpler type comparisons. + /// + internal override EventType Type => EventType.SequenceEnd; + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the event. + /// The end position of the event. + public SequenceEnd(Mark start, Mark end) + : base(start, end) + { + } + + /// + /// Initializes a new instance of the class. + /// + public SequenceEnd() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// + public override string ToString() + { + return "Sequence end"; + } + + /// + /// Invokes run-time type specific Visit() method of the specified visitor. + /// + /// visitor, may not be null. + public override void Accept(IParsingEventVisitor visitor) + { + visitor.Visit(this); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/SequenceEnd.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/SequenceEnd.cs.meta new file mode 100644 index 0000000..5bec23e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/SequenceEnd.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 37a7a63228a311b46ae903ea604105df +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/SequenceStart.cs b/namedropper/Assets/YamlDotNet/Core/Events/SequenceStart.cs new file mode 100644 index 0000000..93808c6 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/SequenceStart.cs @@ -0,0 +1,105 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + /// + /// Represents a sequence start event. + /// + public sealed class SequenceStart : NodeEvent + { + /// + /// Gets a value indicating the variation of depth caused by this event. + /// The value can be either -1, 0 or 1. For start events, it will be 1, + /// for end events, it will be -1, and for the remaining events, it will be 0. + /// + public override int NestingIncrease => 1; + + /// + /// Gets the event type, which allows for simpler type comparisons. + /// + internal override EventType Type => EventType.SequenceStart; + + /// + /// Gets a value indicating whether this instance is implicit. + /// + /// + /// true if this instance is implicit; otherwise, false. + /// + public bool IsImplicit { get; } + + /// + /// Gets a value indicating whether this instance is canonical. + /// + /// + public override bool IsCanonical => !IsImplicit; + + /// + /// Gets the style. + /// + /// The style. + public SequenceStyle Style { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The anchor. + /// The tag. + /// if set to true [is implicit]. + /// The style. + /// The start position of the event. + /// The end position of the event. + public SequenceStart(AnchorName anchor, TagName tag, bool isImplicit, SequenceStyle style, Mark start, Mark end) + : base(anchor, tag, start, end) + { + this.IsImplicit = isImplicit; + this.Style = style; + } + + /// + /// Initializes a new instance of the class. + /// + public SequenceStart(AnchorName anchor, TagName tag, bool isImplicit, SequenceStyle style) + : this(anchor, tag, isImplicit, style, Mark.Empty, Mark.Empty) + { + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// + public override string ToString() + { + return $"Sequence start [anchor = {Anchor}, tag = {Tag}, isImplicit = {IsImplicit}, style = {Style}]"; + } + + /// + /// Invokes run-time type specific Visit() method of the specified visitor. + /// + /// visitor, may not be null. + public override void Accept(IParsingEventVisitor visitor) + { + visitor.Visit(this); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/SequenceStart.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/SequenceStart.cs.meta new file mode 100644 index 0000000..f981f04 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/SequenceStart.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d0414698332e0c643ad3fddd1b907b5e +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/SequenceStyle.cs b/namedropper/Assets/YamlDotNet/Core/Events/SequenceStyle.cs new file mode 100644 index 0000000..702147c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/SequenceStyle.cs @@ -0,0 +1,44 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + /// + /// Specifies the style of a sequence. + /// + public enum SequenceStyle + { + /// + /// Let the emitter choose the style. + /// + Any, + + /// + /// The block sequence style. + /// + Block, + + /// + /// The flow sequence style. + /// + Flow + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/SequenceStyle.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/SequenceStyle.cs.meta new file mode 100644 index 0000000..151e602 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/SequenceStyle.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f66466d1eedabbe4db084d2d0e64415b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/StreamEnd.cs b/namedropper/Assets/YamlDotNet/Core/Events/StreamEnd.cs new file mode 100644 index 0000000..2b87662 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/StreamEnd.cs @@ -0,0 +1,91 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + /// + /// Represents a stream end event. + /// + public sealed class StreamEnd : ParsingEvent + { + /// + /// Gets a value indicating the variation of depth caused by this event. + /// The value can be either -1, 0 or 1. For start events, it will be 1, + /// for end events, it will be -1, and for the remaining events, it will be 0. + /// + public override int NestingIncrease + { + get + { + return -1; + } + } + + /// + /// Gets the event type, which allows for simpler type comparisons. + /// + internal override EventType Type + { + get + { + return EventType.StreamEnd; + } + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the event. + /// The end position of the event. + public StreamEnd(Mark start, Mark end) + : base(start, end) + { + } + + /// + /// Initializes a new instance of the class. + /// + public StreamEnd() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// + public override string ToString() + { + return "Stream end"; + } + + /// + /// Invokes run-time type specific Visit() method of the specified visitor. + /// + /// visitor, may not be null. + public override void Accept(IParsingEventVisitor visitor) + { + visitor.Visit(this); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/StreamEnd.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/StreamEnd.cs.meta new file mode 100644 index 0000000..3ca648e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/StreamEnd.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 703673d959fca474691646e24e9ccedb +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Events/StreamStart.cs b/namedropper/Assets/YamlDotNet/Core/Events/StreamStart.cs new file mode 100644 index 0000000..600d5de --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/StreamStart.cs @@ -0,0 +1,91 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Events +{ + /// + /// Represents a stream start event. + /// + public sealed class StreamStart : ParsingEvent + { + /// + /// Gets a value indicating the variation of depth caused by this event. + /// The value can be either -1, 0 or 1. For start events, it will be 1, + /// for end events, it will be -1, and for the remaining events, it will be 0. + /// + public override int NestingIncrease + { + get + { + return 1; + } + } + + /// + /// Gets the event type, which allows for simpler type comparisons. + /// + internal override EventType Type + { + get + { + return EventType.StreamStart; + } + } + + /// + /// Initializes a new instance of the class. + /// + public StreamStart() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the event. + /// The end position of the event. + public StreamStart(Mark start, Mark end) + : base(start, end) + { + } + + /// + /// Returns a that represents the current . + /// + /// + /// A that represents the current . + /// + public override string ToString() + { + return "Stream start"; + } + + /// + /// Invokes run-time type specific Visit() method of the specified visitor. + /// + /// visitor, may not be null. + public override void Accept(IParsingEventVisitor visitor) + { + visitor.Visit(this); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Events/StreamStart.cs.meta b/namedropper/Assets/YamlDotNet/Core/Events/StreamStart.cs.meta new file mode 100644 index 0000000..c9dbf3d --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Events/StreamStart.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8127a5c9cbbe94547a9c1d39fee327db +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/ForwardAnchorNotSupportedException.cs b/namedropper/Assets/YamlDotNet/Core/ForwardAnchorNotSupportedException.cs new file mode 100644 index 0000000..f106a17 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/ForwardAnchorNotSupportedException.cs @@ -0,0 +1,59 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core +{ + /// + /// The exception that is thrown when an alias references an anchor + /// that has not yet been defined in a context that does not support forward references. + /// + public sealed class ForwardAnchorNotSupportedException : YamlException + { + /// + /// Initializes a new instance of the class. + /// + /// The message. + public ForwardAnchorNotSupportedException(string message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class. + /// + public ForwardAnchorNotSupportedException(Mark start, Mark end, string message) + : base(start, end, message) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The message. + /// The inner. + public ForwardAnchorNotSupportedException(string message, Exception inner) + : base(message, inner) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/ForwardAnchorNotSupportedException.cs.meta b/namedropper/Assets/YamlDotNet/Core/ForwardAnchorNotSupportedException.cs.meta new file mode 100644 index 0000000..a0ad999 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/ForwardAnchorNotSupportedException.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4a2bedb057911514fb2a96c1cc2db68d +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/HashCode.cs b/namedropper/Assets/YamlDotNet/Core/HashCode.cs new file mode 100644 index 0000000..9b697c9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/HashCode.cs @@ -0,0 +1,60 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core +{ + /// + /// Supports implementations of by providing methods to combine two hash codes. + /// + internal static class HashCode + { + /// + /// Combines two hash codes. + /// + /// The first hash code. + /// The second hash code. + /// + public static int CombineHashCodes(int h1, int h2) + { + return ((h1 << 5) + h1) ^ h2; + } + + public static int CombineHashCodes(int h1, object? o2) + { + return CombineHashCodes(h1, GetHashCode(o2)); + } + + public static int CombineHashCodes(object? first, params object?[] others) + { + var hashCode = GetHashCode(first); + foreach (var other in others) + { + hashCode = CombineHashCodes(hashCode, other); + } + return hashCode; + } + + private static int GetHashCode(object? obj) + { + return obj != null ? obj.GetHashCode() : 0; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/HashCode.cs.meta b/namedropper/Assets/YamlDotNet/Core/HashCode.cs.meta new file mode 100644 index 0000000..ca0ef95 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/HashCode.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2cb3fe21d8ebcf0458b6008e1ba2ac08 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/IEmitter.cs b/namedropper/Assets/YamlDotNet/Core/IEmitter.cs new file mode 100644 index 0000000..c51a06f --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/IEmitter.cs @@ -0,0 +1,36 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Core +{ + /// + /// Represents a YAML stream emitter. + /// + public interface IEmitter + { + /// + /// Emits an event. + /// + void Emit(ParsingEvent @event); + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/IEmitter.cs.meta b/namedropper/Assets/YamlDotNet/Core/IEmitter.cs.meta new file mode 100644 index 0000000..8efe0c3 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/IEmitter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ea595b7247a52d84796adae58a272de0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/ILookAheadBuffer.cs b/namedropper/Assets/YamlDotNet/Core/ILookAheadBuffer.cs new file mode 100644 index 0000000..717f1cc --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/ILookAheadBuffer.cs @@ -0,0 +1,42 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core +{ + internal interface ILookAheadBuffer + { + /// + /// Gets a value indicating whether the end of the input reader has been reached. + /// + bool EndOfInput { get; } + + /// + /// Gets the character at the specified offset. + /// + char Peek(int offset); + + /// + /// Skips the next characters. Those characters must have been + /// obtained first by calling the method. + /// + void Skip(int length); + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/ILookAheadBuffer.cs.meta b/namedropper/Assets/YamlDotNet/Core/ILookAheadBuffer.cs.meta new file mode 100644 index 0000000..a5090d6 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/ILookAheadBuffer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 574e18619ff79614f83b7fbaec47ae8c +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/IParser.cs b/namedropper/Assets/YamlDotNet/Core/IParser.cs new file mode 100644 index 0000000..84c53eb --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/IParser.cs @@ -0,0 +1,43 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Core +{ + /// + /// Represents a YAML stream parser. + /// + public interface IParser + { + /// + /// Gets the current event. Returns null before the first call to , + /// and also after returns false. + /// + ParsingEvent? Current { get; } + + /// + /// Moves to the next event. + /// + /// Returns true if there are more events available, otherwise returns false. + bool MoveNext(); + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/IParser.cs.meta b/namedropper/Assets/YamlDotNet/Core/IParser.cs.meta new file mode 100644 index 0000000..53649ad --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/IParser.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fc2416e849d87aa4598d335c421f7117 +timeCreated: 1427145267 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/IScanner.cs b/namedropper/Assets/YamlDotNet/Core/IScanner.cs new file mode 100644 index 0000000..8636f47 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/IScanner.cs @@ -0,0 +1,58 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using YamlDotNet.Core.Tokens; + +namespace YamlDotNet.Core +{ + /// + /// Defines the interface for a stand-alone YAML scanner that + /// converts a sequence of characters into a sequence of YAML tokens. + /// + public interface IScanner + { + /// + /// Gets the current position inside the input stream. + /// + /// The current position. + Mark CurrentPosition { get; } + + /// + /// Gets the current token. + /// + Token? Current { get; } + + /// + /// Moves to the next token and consumes the current token. + /// + bool MoveNext(); + + /// + /// Moves to the next token without consuming the current token. + /// + bool MoveNextWithoutConsuming(); + + /// + /// Consumes the current token. + /// + void ConsumeCurrent(); + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/IScanner.cs.meta b/namedropper/Assets/YamlDotNet/Core/IScanner.cs.meta new file mode 100644 index 0000000..f646478 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/IScanner.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f5c28b5ab2d236944a6f5f2858aa75d8 +timeCreated: 1427145267 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/InsertionQueue.cs b/namedropper/Assets/YamlDotNet/Core/InsertionQueue.cs new file mode 100644 index 0000000..2e1b097 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/InsertionQueue.cs @@ -0,0 +1,216 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using YamlDotNet.Helpers; + +namespace YamlDotNet.Core +{ + /// + /// Generic queue on which items may be inserted + /// + public sealed class InsertionQueue : IEnumerable + { + private const int DefaultInitialCapacity = 1 << 7; // Must be a power of 2 + + // Circular buffer + private T[] items; + private int readPtr; + private int writePtr; + private int mask; + private int count = 0; + + public InsertionQueue(int initialCapacity = DefaultInitialCapacity) + { + if (initialCapacity <= 0) + { + throw new ArgumentOutOfRangeException(nameof(initialCapacity), "The initial capacity must be a positive number."); + } + + if (!initialCapacity.IsPowerOfTwo()) + { + throw new ArgumentException("The initial capacity must be a power of 2.", nameof(initialCapacity)); + } + + items = new T[initialCapacity]; + readPtr = initialCapacity / 2; + writePtr = initialCapacity / 2; + mask = initialCapacity - 1; + } + + /// + /// Gets the number of items that are contained by the queue. + /// + public int Count => count; + public int Capacity => items.Length; + + /// + /// Enqueues the specified item. + /// + /// The item to be enqueued. + public void Enqueue(T item) + { + ResizeIfNeeded(); + + items[writePtr] = item; + writePtr = (writePtr - 1) & mask; + ++count; + } + + /// + /// Dequeues an item. + /// + /// Returns the item that been dequeued. + public T Dequeue() + { + if (count == 0) + { + throw new InvalidOperationException("The queue is empty"); + } + + var item = items[readPtr]; + readPtr = (readPtr - 1) & mask; + --count; + return item; + } + + /// + /// Inserts an item at the specified index. + /// + /// The index where to insert the item. + /// The item to be inserted. + public void Insert(int index, T item) + { + if (index > count) + { + throw new InvalidOperationException("Cannot insert outside of the bounds of the queue"); + } + + ResizeIfNeeded(); + + CalculateInsertionParameters( + mask, count, index, + ref readPtr, ref writePtr, + out var insertPtr, + out var copyIndex, out var copyOffset, out var copyLength + ); + + if (copyLength != 0) + { + Array.Copy(items, copyIndex, items, copyIndex + copyOffset, copyLength); + } + + items[insertPtr] = item; + ++count; + } + + private void ResizeIfNeeded() + { + var capacity = items.Length; + if (count == capacity) + { + Debug.Assert(readPtr == writePtr); + + var newItems = new T[capacity * 2]; + + var beginCount = readPtr + 1; + if (beginCount > 0) + { + Array.Copy(items, 0, newItems, 0, beginCount); + } + + writePtr += capacity; + var endCount = capacity - beginCount; + if (endCount > 0) + { + Array.Copy(items, readPtr + 1, newItems, writePtr + 1, endCount); + } + + items = newItems; + mask = mask * 2 + 1; + } + } + + internal static void CalculateInsertionParameters(int mask, int count, int index, ref int readPtr, ref int writePtr, out int insertPtr, out int copyIndex, out int copyOffset, out int copyLength) + { + var indexOfLastElement = (readPtr + 1) & mask; + if (index == 0) + { + insertPtr = readPtr = indexOfLastElement; + + // No copy is needed + copyIndex = 0; + copyOffset = 0; + copyLength = 0; + return; + } + + insertPtr = (readPtr - index) & mask; + if (index == count) + { + writePtr = (writePtr - 1) & mask; + + // No copy is needed + copyIndex = 0; + copyOffset = 0; + copyLength = 0; + return; + } + + var canMoveRight = indexOfLastElement >= insertPtr; + var moveRightCost = canMoveRight ? readPtr - insertPtr : int.MaxValue; + + var canMoveLeft = writePtr <= insertPtr; + var moveLeftCost = canMoveLeft ? insertPtr - writePtr : int.MaxValue; + + if (moveRightCost <= moveLeftCost) + { + ++insertPtr; + ++readPtr; + copyIndex = insertPtr; + copyOffset = 1; + copyLength = moveRightCost; + } + else + { + copyIndex = writePtr + 1; + copyOffset = -1; + copyLength = moveLeftCost; + writePtr = (writePtr - 1) & mask; + } + } + + public IEnumerator GetEnumerator() + { + var ptr = readPtr; + for (var i = 0; i < Count; i++) + { + yield return items[ptr]; + ptr = (ptr - 1) & mask; + } + } + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/InsertionQueue.cs.meta b/namedropper/Assets/YamlDotNet/Core/InsertionQueue.cs.meta new file mode 100644 index 0000000..5f0eed1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/InsertionQueue.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d5ebdfa25d33598469684afe6f672277 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/LookAheadBuffer.cs b/namedropper/Assets/YamlDotNet/Core/LookAheadBuffer.cs new file mode 100644 index 0000000..0d4491c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/LookAheadBuffer.cs @@ -0,0 +1,170 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Diagnostics; +using System.IO; +using YamlDotNet.Helpers; + +namespace YamlDotNet.Core +{ + /// + /// Provides access to a stream and allows to peek at the next characters, + /// up to the buffer's capacity. + /// + /// + /// This class implements a circular buffer with a fixed capacity. + /// + public sealed class LookAheadBuffer : ILookAheadBuffer + { + private readonly TextReader input; + private readonly char[] buffer; + private readonly int blockSize; + private readonly int mask; + private int firstIndex; + private int writeOffset; + private int count; + private bool endOfInput; + + /// + /// Initializes a new instance of the class. + /// + /// The input. + /// The capacity. + public LookAheadBuffer(TextReader input, int capacity) + { + if (capacity < 1) + { + throw new ArgumentOutOfRangeException(nameof(capacity), "The capacity must be positive."); + } + + if (!capacity.IsPowerOfTwo()) + { + throw new ArgumentException("The capacity must be a power of 2.", nameof(capacity)); + } + + this.input = input ?? throw new ArgumentNullException(nameof(input)); + + blockSize = capacity; + + // Allocate twice the required capacity to ensure that + buffer = new char[capacity * 2]; + mask = capacity * 2 - 1; + } + + /// + /// Gets a value indicating whether the end of the input reader has been reached. + /// + public bool EndOfInput => endOfInput && count == 0; + + /// + /// Gets the index of the character for the specified offset. + /// + private int GetIndexForOffset(int offset) + { + return (firstIndex + offset) & mask; + } + + /// + /// Gets the character at the specified offset. + /// + public char Peek(int offset) + { +#if DEBUG + if (offset < 0 || offset >= blockSize) + { + throw new ArgumentOutOfRangeException(nameof(offset), "The offset must be between zero and the capacity of the buffer."); + } +#endif + if (offset >= count) + { + FillBuffer(); + } + + if (offset < count) + { + return buffer[(firstIndex + offset) & mask]; + } + else + { + return '\0'; + } + } + + /// + /// Reads characters until at least characters are in the buffer. + /// + /// + /// Number of characters to cache. + /// + public void Cache(int length) + { + if (length >= count) + { + FillBuffer(); + } + } + + private void FillBuffer() + { + if (endOfInput) + { + return; + } + + var remainingSize = blockSize; + do + { + var readCount = input.Read(buffer, writeOffset, remainingSize); + if (readCount == 0) + { + endOfInput = true; + return; + } + + remainingSize -= readCount; + writeOffset += readCount; + count += readCount; + } while (remainingSize > 0); + + if (writeOffset == buffer.Length) + { + writeOffset = 0; + } + + Debug.Assert(writeOffset == 0 || writeOffset == blockSize); + } + + /// + /// Skips the next characters. Those characters must have been + /// obtained first by calling the or methods. + /// + public void Skip(int length) + { + if (length < 1 || length > blockSize) + { + throw new ArgumentOutOfRangeException(nameof(length), "The length must be between 1 and the number of characters in the buffer. Use the Peek() and / or Cache() methods to fill the buffer."); + } + firstIndex = GetIndexForOffset(length); + count -= length; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/LookAheadBuffer.cs.meta b/namedropper/Assets/YamlDotNet/Core/LookAheadBuffer.cs.meta new file mode 100644 index 0000000..cdb1ab5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/LookAheadBuffer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4d909b1f8d7468e4188667b8b706d225 +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Mark.cs b/namedropper/Assets/YamlDotNet/Core/Mark.cs new file mode 100644 index 0000000..47e9b6f --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Mark.cs @@ -0,0 +1,141 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core +{ + /// + /// Represents a location inside a file + /// + public sealed class Mark : IEquatable, IComparable, IComparable + { + /// + /// Gets a with empty values. + /// + public static readonly Mark Empty = new Mark(); + + /// + /// Gets / sets the absolute offset in the file + /// + public int Index { get; } + + /// + /// Gets / sets the number of the line + /// + public int Line { get; } + + /// + /// Gets / sets the index of the column + /// + public int Column { get; } + + public Mark() + { + Line = 1; + Column = 1; + } + + public Mark(int index, int line, int column) + { + if (index < 0) + { + throw new ArgumentOutOfRangeException(nameof(index), "Index must be greater than or equal to zero."); + } + if (line < 1) + { + throw new ArgumentOutOfRangeException(nameof(line), "Line must be greater than or equal to 1."); + } + if (column < 1) + { + throw new ArgumentOutOfRangeException(nameof(column), "Column must be greater than or equal to 1."); + } + + Index = index; + Line = line; + Column = column; + } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + public override string ToString() + { + return $"Line: {Line}, Col: {Column}, Idx: {Index}"; + } + + /// + public override bool Equals(object? obj) + { + return Equals(obj as Mark); + } + + /// + public bool Equals(Mark? other) + { + return other != null + && Index == other.Index + && Line == other.Line + && Column == other.Column; + } + + /// + public override int GetHashCode() + { + return HashCode.CombineHashCodes( + Index.GetHashCode(), + HashCode.CombineHashCodes( + Line.GetHashCode(), + Column.GetHashCode() + ) + ); + } + + /// + public int CompareTo(object? obj) + { + if (obj == null) + { + throw new ArgumentNullException(nameof(obj)); + } + return CompareTo(obj as Mark); + } + + /// + public int CompareTo(Mark? other) + { + if (other == null) + { + throw new ArgumentNullException(nameof(other)); + } + + var cmp = Line.CompareTo(other.Line); + if (cmp == 0) + { + cmp = Column.CompareTo(other.Column); + } + return cmp; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Mark.cs.meta b/namedropper/Assets/YamlDotNet/Core/Mark.cs.meta new file mode 100644 index 0000000..20bc281 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Mark.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9a02d917bb4d2164ea20caaafce2bb0b +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/MaximumRecursionLevelReachedException.cs b/namedropper/Assets/YamlDotNet/Core/MaximumRecursionLevelReachedException.cs new file mode 100644 index 0000000..96f95f5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/MaximumRecursionLevelReachedException.cs @@ -0,0 +1,58 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core +{ + /// + /// Exception that is thrown when an infinite recursion is detected. + /// + public sealed class MaximumRecursionLevelReachedException : YamlException + { + /// + /// Initializes a new instance of the class. + /// + /// The message. + public MaximumRecursionLevelReachedException(string message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class. + /// + public MaximumRecursionLevelReachedException(Mark start, Mark end, string message) + : base(start, end, message) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The message. + /// The inner. + public MaximumRecursionLevelReachedException(string message, Exception inner) + : base(message, inner) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/MaximumRecursionLevelReachedException.cs.meta b/namedropper/Assets/YamlDotNet/Core/MaximumRecursionLevelReachedException.cs.meta new file mode 100644 index 0000000..7d8afb5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/MaximumRecursionLevelReachedException.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fea998d14aab96d4cb7654c8cc75afdf +timeCreated: 1427145269 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/MergingParser.cs b/namedropper/Assets/YamlDotNet/Core/MergingParser.cs new file mode 100644 index 0000000..2bde3d3 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/MergingParser.cs @@ -0,0 +1,311 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Core +{ + /// + /// Simple implementation of that implements merging: http://yaml.org/type/merge.html + /// + public sealed class MergingParser : IParser + { + private readonly ParsingEventCollection events; + private readonly IParser innerParser; + private IEnumerator> iterator; + private bool merged; + + public MergingParser(IParser innerParser) + { + events = new ParsingEventCollection(); + merged = false; + iterator = events.GetEnumerator(); + this.innerParser = innerParser; + } + + public ParsingEvent? Current => iterator.Current?.Value; + + public bool MoveNext() + { + if (!merged) + { + Merge(); + events.CleanMarked(); + iterator = events.GetEnumerator(); + merged = true; + } + + return iterator.MoveNext(); + } + + private void Merge() + { + while (innerParser.MoveNext()) + { + events.Add(innerParser.Current!); + } + + foreach (var node in events) + { + if (IsMergeToken(node)) + { + events.MarkDeleted(node); + if (!HandleMerge(node.Next)) + { + throw new SemanticErrorException(node.Value.Start, node.Value.End, "Unrecognized merge key pattern"); + } + } + } + } + + private bool HandleMerge(LinkedListNode? node) + { + if (node == null) + { + return false; + } + + if (node.Value is AnchorAlias anchorAlias) + { + return HandleAnchorAlias(node, node, anchorAlias); + } + + if (node.Value is SequenceStart) + { + return HandleSequence(node); + } + + return false; + } + + private bool HandleMergeSequence(LinkedListNode sequenceStart, LinkedListNode? node) + { + if (node is null) + { + return false; + } + if (node.Value is AnchorAlias anchorAlias) + { + return HandleAnchorAlias(sequenceStart, node, anchorAlias); + } + if (node.Value is SequenceStart) + { + return HandleSequence(node); + } + return false; + } + + private bool IsMergeToken(LinkedListNode node) + { + return node.Value is Scalar merge && merge.Value == "<<"; + } + + private bool HandleAnchorAlias(LinkedListNode node, LinkedListNode anchorNode, AnchorAlias anchorAlias) + { + var mergedEvents = GetMappingEvents(anchorAlias.Value); + + events.AddAfter(node, mergedEvents); + events.MarkDeleted(anchorNode); + + return true; + } + + private bool HandleSequence(LinkedListNode node) + { + var sequenceStart = node; + events.MarkDeleted(node); + + var current = node; + while (current != null) + { + if (current.Value is SequenceEnd) + { + events.MarkDeleted(current); + return true; + } + + var next = current.Next; + HandleMergeSequence(sequenceStart, next); + current = next; + } + + return true; + } + + private IEnumerable GetMappingEvents(AnchorName anchor) + { + var cloner = new ParsingEventCloner(); + var nesting = 0; + + return events.FromAnchor(anchor) + .Select(e => e.Value) + .TakeWhile(e => (nesting += e.NestingIncrease) >= 0) + .Select(e => cloner.Clone(e)); + } + + private sealed class ParsingEventCollection : IEnumerable> + { + private readonly LinkedList events; + private readonly HashSet> deleted; + private readonly Dictionary> references; + + public ParsingEventCollection() + { + events = new LinkedList(); + deleted = new HashSet>(); + references = new Dictionary>(); + } + + public void AddAfter(LinkedListNode node, IEnumerable items) + { + foreach (var item in items) + { + node = events.AddAfter(node, item); + } + } + + public void Add(ParsingEvent item) + { + var node = events.AddLast(item); + AddReference(item, node); + } + + public void MarkDeleted(LinkedListNode node) + { + deleted.Add(node); + } + + public void CleanMarked() + { + foreach (var node in deleted) + { + events.Remove(node); + } + } + + public IEnumerable> FromAnchor(AnchorName anchor) + { + var node = references[anchor].Next; + return Enumerate(node); + } + + public IEnumerator> GetEnumerator() => Enumerate(events.First).GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + private IEnumerable> Enumerate(LinkedListNode? node) + { + while (node != null) + { + yield return node; + node = node.Next; + } + } + + private void AddReference(ParsingEvent item, LinkedListNode node) + { + if (item is MappingStart mappingStart) + { + var anchor = mappingStart.Anchor; + if (!anchor.IsEmpty) + { + references[anchor] = node; + } + } + } + } + + private sealed class ParsingEventCloner : IParsingEventVisitor + { + private ParsingEvent? clonedEvent; + + public ParsingEvent Clone(ParsingEvent e) + { + e.Accept(this); + if (clonedEvent == null) + { + throw new InvalidOperationException($"Could not clone event of type '{e.Type}'"); + } + + return clonedEvent; + } + + void IParsingEventVisitor.Visit(AnchorAlias e) + { + clonedEvent = new AnchorAlias(e.Value, e.Start, e.End); + } + + void IParsingEventVisitor.Visit(StreamStart e) + { + throw new NotSupportedException(); + } + + void IParsingEventVisitor.Visit(StreamEnd e) + { + throw new NotSupportedException(); + } + + void IParsingEventVisitor.Visit(DocumentStart e) + { + throw new NotSupportedException(); + } + + void IParsingEventVisitor.Visit(DocumentEnd e) + { + throw new NotSupportedException(); + } + + void IParsingEventVisitor.Visit(Scalar e) + { + clonedEvent = new Scalar(AnchorName.Empty, e.Tag, e.Value, e.Style, e.IsPlainImplicit, e.IsQuotedImplicit, e.Start, e.End); + } + + void IParsingEventVisitor.Visit(SequenceStart e) + { + clonedEvent = new SequenceStart(AnchorName.Empty, e.Tag, e.IsImplicit, e.Style, e.Start, e.End); + } + + void IParsingEventVisitor.Visit(SequenceEnd e) + { + clonedEvent = new SequenceEnd(e.Start, e.End); + } + + void IParsingEventVisitor.Visit(MappingStart e) + { + clonedEvent = new MappingStart(AnchorName.Empty, e.Tag, e.IsImplicit, e.Style, e.Start, e.End); + } + + void IParsingEventVisitor.Visit(MappingEnd e) + { + clonedEvent = new MappingEnd(e.Start, e.End); + } + + void IParsingEventVisitor.Visit(Comment e) + { + throw new NotSupportedException(); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/MergingParser.cs.meta b/namedropper/Assets/YamlDotNet/Core/MergingParser.cs.meta new file mode 100644 index 0000000..6828069 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/MergingParser.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2aee5019246749c40a971ff855ffba79 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Parser.cs b/namedropper/Assets/YamlDotNet/Core/Parser.cs new file mode 100644 index 0000000..0f28f5b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Parser.cs @@ -0,0 +1,1103 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using YamlDotNet.Core.Tokens; +using MappingStyle = YamlDotNet.Core.Events.MappingStyle; +using ParsingEvent = YamlDotNet.Core.Events.ParsingEvent; +using SequenceStyle = YamlDotNet.Core.Events.SequenceStyle; + +namespace YamlDotNet.Core +{ + /// + /// Parses YAML streams. + /// + public class Parser : IParser + { + private readonly Stack states = new Stack(); + private readonly TagDirectiveCollection tagDirectives = new TagDirectiveCollection(); + private ParserState state; + + private readonly IScanner scanner; + private Token? currentToken; + private VersionDirective? version; + + private Token? GetCurrentToken() + { + if (currentToken == null) + { + while (scanner.MoveNextWithoutConsuming()) + { + currentToken = scanner.Current; + + if (currentToken is Comment commentToken) + { + pendingEvents.Enqueue(new Events.Comment(commentToken.Value, commentToken.IsInline, commentToken.Start, commentToken.End)); + scanner.ConsumeCurrent(); + } + else + { + break; + } + } + } + return currentToken; + } + + /// + /// Initializes a new instance of the class. + /// + /// The input where the YAML stream is to be read. + public Parser(TextReader input) + : this(new Scanner(input)) + { + } + + /// + /// Initializes a new instance of the class. + /// + public Parser(IScanner scanner) + { + this.scanner = scanner; + } + + /// + /// Gets the current event. + /// + public ParsingEvent? Current { get; private set; } + + private readonly EventQueue pendingEvents = new EventQueue(); + + /// + /// Moves to the next event. + /// + /// Returns true if there are more events available, otherwise returns false. + public bool MoveNext() + { + // No events after the end of the stream or error. + if (state == ParserState.StreamEnd) + { + Current = null; + return false; + } + else if (pendingEvents.Count == 0) + { + // Generate the next event. + pendingEvents.Enqueue(StateMachine()); + } + + Current = pendingEvents.Dequeue(); + return true; + } + + private ParsingEvent StateMachine() + { + switch (state) + { + case ParserState.StreamStart: + return ParseStreamStart(); + + case ParserState.ImplicitDocumentStart: + return ParseDocumentStart(true); + + case ParserState.DocumentStart: + return ParseDocumentStart(false); + + case ParserState.DocumentContent: + return ParseDocumentContent(); + + case ParserState.DocumentEnd: + return ParseDocumentEnd(); + + case ParserState.BlockNode: + return ParseNode(true, false); + + case ParserState.BlockNodeOrIndentlessSequence: + return ParseNode(true, true); + + case ParserState.FlowNode: + return ParseNode(false, false); + + case ParserState.BlockSequenceFirstEntry: + return ParseBlockSequenceEntry(true); + + case ParserState.BlockSequenceEntry: + return ParseBlockSequenceEntry(false); + + case ParserState.IndentlessSequenceEntry: + return ParseIndentlessSequenceEntry(); + + case ParserState.BlockMappingFirstKey: + return ParseBlockMappingKey(true); + + case ParserState.BlockMappingKey: + return ParseBlockMappingKey(false); + + case ParserState.BlockMappingValue: + return ParseBlockMappingValue(); + + case ParserState.FlowSequenceFirstEntry: + return ParseFlowSequenceEntry(true); + + case ParserState.FlowSequenceEntry: + return ParseFlowSequenceEntry(false); + + case ParserState.FlowSequenceEntryMappingKey: + return ParseFlowSequenceEntryMappingKey(); + + case ParserState.FlowSequenceEntryMappingValue: + return ParseFlowSequenceEntryMappingValue(); + + case ParserState.FlowSequenceEntryMappingEnd: + return ParseFlowSequenceEntryMappingEnd(); + + case ParserState.FlowMappingFirstKey: + return ParseFlowMappingKey(true); + + case ParserState.FlowMappingKey: + return ParseFlowMappingKey(false); + + case ParserState.FlowMappingValue: + return ParseFlowMappingValue(false); + + case ParserState.FlowMappingEmptyValue: + return ParseFlowMappingValue(true); + + default: + Debug.Assert(false, "Invalid state"); // Invalid state. + throw new InvalidOperationException(); + } + } + + private void Skip() + { + if (currentToken != null) + { + currentToken = null; + scanner.ConsumeCurrent(); + } + } + + /// + /// Parse the production: + /// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END + /// ************ + /// + private ParsingEvent ParseStreamStart() + { + var current = GetCurrentToken(); + + if (!(current is StreamStart streamStart)) + { + throw new SemanticErrorException(current?.Start ?? Mark.Empty, current?.End ?? Mark.Empty, "Did not find expected ."); + } + Skip(); + + state = ParserState.ImplicitDocumentStart; + return new Events.StreamStart(streamStart.Start, streamStart.End); + } + + /// + /// Parse the productions: + /// implicit_document ::= block_node DOCUMENT-END* + /// * + /// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* + /// ************************* + /// + private ParsingEvent ParseDocumentStart(bool isImplicit) + { + if (currentToken is VersionDirective) + { + // EB22 + throw new SyntaxErrorException("While parsing a document start node, could not find document end marker before version directive."); + } + + // Parse extra document end indicators. + + var current = GetCurrentToken(); + if (!isImplicit) + { + while (current is DocumentEnd) + { + Skip(); + current = GetCurrentToken(); + } + } + + if (current == null) + { + throw new SyntaxErrorException("Reached the end of the stream while parsing a document start."); + } + + if (current is Scalar && (state == ParserState.ImplicitDocumentStart || state == ParserState.DocumentStart)) + { + isImplicit = true; + } + + // Parse an isImplicit document. + + if (isImplicit && !(current is VersionDirective || current is TagDirective || current is DocumentStart || current is StreamEnd || current is DocumentEnd) || current is BlockMappingStart) + { + var directives = new TagDirectiveCollection(); + ProcessDirectives(directives); + + states.Push(ParserState.DocumentEnd); + + state = ParserState.BlockNode; + + return new Events.DocumentStart(null, directives, true, current.Start, current.End); + } + + // Parse an explicit document. + + else if (!(current is StreamEnd || current is DocumentEnd)) + { + var start = current.Start; + var directives = new TagDirectiveCollection(); + var versionDirective = ProcessDirectives(directives); + + current = GetCurrentToken() ?? throw new SemanticErrorException("Reached the end of the stream while parsing a document start"); + + if (!(current is DocumentStart)) + { + throw new SemanticErrorException(current.Start, current.End, "Did not find expected ."); + } + + states.Push(ParserState.DocumentEnd); + + state = ParserState.DocumentContent; + + var end = current.End; + Skip(); + return new Events.DocumentStart(versionDirective, directives, false, start, end); + } + + // Parse the stream end. + + else + { + if (current is DocumentEnd) + { + Skip(); + } + state = ParserState.StreamEnd; + + current = GetCurrentToken() ?? throw new SemanticErrorException("Reached the end of the stream while parsing a document start"); + + var evt = new Events.StreamEnd(current.Start, current.End); + // Do not call skip here because that would throw an exception + if (scanner.MoveNextWithoutConsuming()) + { + throw new InvalidOperationException("The scanner should contain no more tokens."); + } + return evt; + } + } + + /// + /// Parse directives. + /// + private VersionDirective? ProcessDirectives(TagDirectiveCollection tags) + { + var hasOwnDirectives = false; + VersionDirective? localVersion = null; + + while (true) + { + if (GetCurrentToken() is VersionDirective currentVersion) + { + if (version != null) + { + throw new SemanticErrorException(currentVersion.Start, currentVersion.End, "Found duplicate %YAML directive."); + } + + if (currentVersion.Version.Major != Constants.MajorVersion || currentVersion.Version.Minor > Constants.MinorVersion) + { + throw new SemanticErrorException(currentVersion.Start, currentVersion.End, "Found incompatible YAML document."); + } + + localVersion = version = currentVersion; + hasOwnDirectives = true; + } + else if (GetCurrentToken() is TagDirective tag) + { + if (tags.Contains(tag.Handle)) + { + throw new SemanticErrorException(tag.Start, tag.End, "Found duplicate %TAG directive."); + } + tags.Add(tag); + hasOwnDirectives = true; + } + + // Starting from v1.2, it is not permitted to use tag shorthands for multiple documents in a stream. + else if (GetCurrentToken() is DocumentStart && (version == null || (version.Version.Major == 1 && version.Version.Minor > 1))) + { + if (GetCurrentToken() is DocumentStart && (version == null)) + { + version = new VersionDirective(new Version(1, 2)); + } + + hasOwnDirectives = true; + break; + } + else + { + break; + } + + Skip(); + } + + AddTagDirectives(tags, Constants.DefaultTagDirectives); + + if (hasOwnDirectives) + { + tagDirectives.Clear(); + } + + AddTagDirectives(tagDirectives, tags); + + return localVersion; + } + + private static void AddTagDirectives(TagDirectiveCollection directives, IEnumerable source) + { + foreach (var directive in source) + { + if (!directives.Contains(directive)) + { + directives.Add(directive); + } + } + } + + /// + /// Parse the productions: + /// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* + /// *********** + /// + private ParsingEvent ParseDocumentContent() + { + if ( + GetCurrentToken() is VersionDirective || + GetCurrentToken() is TagDirective || + GetCurrentToken() is DocumentStart || + GetCurrentToken() is DocumentEnd || + GetCurrentToken() is StreamEnd + ) + { + state = states.Pop(); + return ProcessEmptyScalar(scanner.CurrentPosition); + } + else + { + return ParseNode(true, false); + } + } + + /// + /// Generate an empty scalar event. + /// + private static ParsingEvent ProcessEmptyScalar(Mark position) + { + return new Events.Scalar(AnchorName.Empty, TagName.Empty, string.Empty, ScalarStyle.Plain, true, false, position, position); + } + + /// + /// Parse the productions: + /// block_node_or_indentless_sequence ::= + /// ALIAS + /// ***** + /// | properties (block_content | indentless_block_sequence)? + /// ********** * + /// | block_content | indentless_block_sequence + /// * + /// block_node ::= ALIAS + /// ***** + /// | properties block_content? + /// ********** * + /// | block_content + /// * + /// flow_node ::= ALIAS + /// ***** + /// | properties flow_content? + /// ********** * + /// | flow_content + /// * + /// properties ::= TAG ANCHOR? | ANCHOR TAG? + /// ************************* + /// block_content ::= block_collection | flow_collection | SCALAR + /// ****** + /// flow_content ::= flow_collection | SCALAR + /// ****** + /// + private ParsingEvent ParseNode(bool isBlock, bool isIndentlessSequence) + { + if (GetCurrentToken() is Error errorToken) + { + throw new SemanticErrorException(errorToken.Start, errorToken.End, errorToken.Value); + } + + var current = GetCurrentToken() ?? throw new SemanticErrorException("Reached the end of the stream while parsing a node"); + if (current is AnchorAlias alias) + { + state = states.Pop(); + ParsingEvent evt = new Events.AnchorAlias(alias.Value, alias.Start, alias.End); + Skip(); + return evt; + } + + var start = current.Start; + + var anchorName = AnchorName.Empty; + var tagName = TagName.Empty; + Anchor? lastAnchor = null; + Tag? lastTag = null; + + // The anchor and the tag can be in any order. This loop repeats at most twice. + while (true) + { + if (anchorName.IsEmpty && current is Anchor anchor) + { + lastAnchor = anchor; + anchorName = anchor.Value; + Skip(); + } + else if (tagName.IsEmpty && current is Tag tag) + { + lastTag = tag; + if (string.IsNullOrEmpty(tag.Handle)) + { + tagName = new TagName(tag.Suffix); + } + else if (tagDirectives.Contains(tag.Handle)) + { + tagName = new TagName(string.Concat(tagDirectives[tag.Handle].Prefix, tag.Suffix)); + } + else + { + throw new SemanticErrorException(tag.Start, tag.End, "While parsing a node, found undefined tag handle."); + } + + Skip(); + } + else if (current is Anchor secondAnchor) + { + throw new SemanticErrorException(secondAnchor.Start, secondAnchor.End, "While parsing a node, found more than one anchor."); + } + else if (current is AnchorAlias anchorAlias) + { + throw new SemanticErrorException(anchorAlias.Start, anchorAlias.End, "While parsing a node, did not find expected token."); + } + else if (current is Error error) + { + if (lastTag != null && lastAnchor != null && !anchorName.IsEmpty) + { + return new Events.Scalar(anchorName, default, string.Empty, default, false, false, lastAnchor.Start, lastAnchor.End); + } + throw new SemanticErrorException(error.Start, error.End, error.Value); + } + else + { + break; + } + + current = GetCurrentToken() ?? throw new SemanticErrorException("Reached the end of the stream while parsing a node"); + } + + var isImplicit = tagName.IsEmpty; + + if (isIndentlessSequence && GetCurrentToken() is BlockEntry) + { + state = ParserState.IndentlessSequenceEntry; + + return new Events.SequenceStart( + anchorName, + tagName, + isImplicit, + SequenceStyle.Block, + start, + current.End + ); + } + else + { + if (current is Scalar scalar) + { + var isPlainImplicit = false; + var isQuotedImplicit = false; + if ((scalar.Style == ScalarStyle.Plain && tagName.IsEmpty) || tagName.IsNonSpecific) + { + isPlainImplicit = true; + } + else if (tagName.IsEmpty) + { + isQuotedImplicit = true; + } + + state = states.Pop(); + Skip(); + + ParsingEvent evt = new Events.Scalar(anchorName, tagName, scalar.Value, scalar.Style, isPlainImplicit, isQuotedImplicit, start, scalar.End); + + // Read next token to ensure the error case spec test 'CXX2': + // "Mapping with anchor on document start line". + + if (!anchorName.IsEmpty && scanner.MoveNextWithoutConsuming()) + { + currentToken = scanner.Current; + if (currentToken is Error) + { + errorToken = (currentToken as Error)!; + throw new SemanticErrorException(errorToken.Start, errorToken.End, errorToken.Value); + } + } + + // Read next token to ensure the error case spec test 'T833': + // "Flow mapping missing a separating comma". + + if (state == ParserState.FlowMappingKey && scanner.MoveNextWithoutConsuming()) + { + currentToken = scanner.Current; + if (currentToken != null && !(currentToken is FlowEntry) && !(currentToken is FlowMappingEnd)) + { + throw new SemanticErrorException(currentToken.Start, currentToken.End, "While parsing a flow mapping, did not find expected ',' or '}'."); + } + } + + return evt; + } + + if (current is FlowSequenceStart flowSequenceStart) + { + state = ParserState.FlowSequenceFirstEntry; + return new Events.SequenceStart(anchorName, tagName, isImplicit, SequenceStyle.Flow, start, flowSequenceStart.End); + } + + if (current is FlowMappingStart flowMappingStart) + { + state = ParserState.FlowMappingFirstKey; + return new Events.MappingStart(anchorName, tagName, isImplicit, MappingStyle.Flow, start, flowMappingStart.End); + } + + if (isBlock) + { + if (current is BlockSequenceStart blockSequenceStart) + { + state = ParserState.BlockSequenceFirstEntry; + return new Events.SequenceStart(anchorName, tagName, isImplicit, SequenceStyle.Block, start, blockSequenceStart.End); + } + + if (current is BlockMappingStart blockMappingStart) + { + state = ParserState.BlockMappingFirstKey; + return new Events.MappingStart(anchorName, tagName, isImplicit, MappingStyle.Block, start, blockMappingStart.End); + } + } + + if (!anchorName.IsEmpty || !tagName.IsEmpty) + { + state = states.Pop(); + return new Events.Scalar(anchorName, tagName, string.Empty, ScalarStyle.Plain, isImplicit, false, start, current.End); + } + + throw new SemanticErrorException(current.Start, current.End, "While parsing a node, did not find expected node content."); + } + } + + /// + /// Parse the productions: + /// implicit_document ::= block_node DOCUMENT-END* + /// ************* + /// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* + /// ************* + /// + + private ParsingEvent ParseDocumentEnd() + { + var current = GetCurrentToken() ?? throw new SemanticErrorException("Reached the end of the stream while parsing a document end"); + + var isImplicit = true; + var start = current.Start; + var end = start; + + if (current is DocumentEnd) + { + end = current.End; + Skip(); + isImplicit = false; + } + else if (!(currentToken is StreamEnd || currentToken is DocumentStart || currentToken is FlowSequenceEnd || currentToken is VersionDirective || + (Current is Events.Scalar && currentToken is Error))) + { + throw new SemanticErrorException(start, end, "Did not find expected ."); + } + + if (version != null && version.Version.Major == 1 && version.Version.Minor > 1) + { + version = null; + } + state = ParserState.DocumentStart; + return new Events.DocumentEnd(isImplicit, start, end); + } + + /// + /// Parse the productions: + /// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END + /// ******************** *********** * ********* + /// + + private ParsingEvent ParseBlockSequenceEntry(bool isFirst) + { + if (isFirst) + { + GetCurrentToken(); + Skip(); + } + + var current = GetCurrentToken(); + if (current is BlockEntry blockEntry) + { + var mark = blockEntry.End; + + Skip(); + current = GetCurrentToken(); + if (!(current is BlockEntry || current is BlockEnd)) + { + states.Push(ParserState.BlockSequenceEntry); + return ParseNode(true, false); + } + else + { + state = ParserState.BlockSequenceEntry; + return ProcessEmptyScalar(mark); + } + } + else if (current is BlockEnd blockEnd) + { + state = states.Pop(); + ParsingEvent evt = new Events.SequenceEnd(blockEnd.Start, blockEnd.End); + Skip(); + return evt; + } + else + { + throw new SemanticErrorException(current?.Start ?? Mark.Empty, current?.End ?? Mark.Empty, "While parsing a block collection, did not find expected '-' indicator."); + } + } + + /// + /// Parse the productions: + /// indentless_sequence ::= (BLOCK-ENTRY block_node?)+ + /// *********** * + /// + private ParsingEvent ParseIndentlessSequenceEntry() + { + var current = GetCurrentToken(); + if (current is BlockEntry blockEntry) + { + var mark = blockEntry.End; + Skip(); + + current = GetCurrentToken(); + if (!(current is BlockEntry || current is Key || current is Value || current is BlockEnd)) + { + states.Push(ParserState.IndentlessSequenceEntry); + return ParseNode(true, false); + } + else + { + state = ParserState.IndentlessSequenceEntry; + return ProcessEmptyScalar(mark); + } + } + else + { + state = states.Pop(); + return new Events.SequenceEnd(current?.Start ?? Mark.Empty, current?.End ?? Mark.Empty); + } + } + + /// + /// Parse the productions: + /// block_mapping ::= BLOCK-MAPPING_START + /// ******************* + /// ((KEY block_node_or_indentless_sequence?)? + /// *** * + /// (VALUE block_node_or_indentless_sequence?)?)* + /// + /// BLOCK-END + /// ********* + /// + private ParsingEvent ParseBlockMappingKey(bool isFirst) + { + if (isFirst) + { + GetCurrentToken(); + Skip(); + } + + var current = GetCurrentToken(); + if (current is Key key) + { + var mark = key.End; + Skip(); + current = GetCurrentToken(); + if (!(current is Key || current is Value || current is BlockEnd)) + { + states.Push(ParserState.BlockMappingValue); + return ParseNode(true, true); + } + else + { + state = ParserState.BlockMappingValue; + return ProcessEmptyScalar(mark); + } + } + + else if (current is Value value) + { + Skip(); + return ProcessEmptyScalar(value.End); + } + + else if (current is AnchorAlias anchorAlias) + { + Skip(); + return new Events.AnchorAlias(anchorAlias.Value, anchorAlias.Start, anchorAlias.End); + } + + else if (current is BlockEnd blockEnd) + { + state = states.Pop(); + ParsingEvent evt = new Events.MappingEnd(blockEnd.Start, blockEnd.End); + Skip(); + return evt; + } + + else if (GetCurrentToken() is Error error) + { + throw new SyntaxErrorException(error.Start, error.End, error.Value); + } + + else + { + throw new SemanticErrorException(current?.Start ?? Mark.Empty, current?.End ?? Mark.Empty, "While parsing a block mapping, did not find expected key."); + } + } + + /// + /// Parse the productions: + /// block_mapping ::= BLOCK-MAPPING_START + /// + /// ((KEY block_node_or_indentless_sequence?)? + /// + /// (VALUE block_node_or_indentless_sequence?)?)* + /// ***** * + /// BLOCK-END + /// + /// + private ParsingEvent ParseBlockMappingValue() + { + var current = GetCurrentToken(); + if (current is Value value) + { + var mark = value.End; + Skip(); + + current = GetCurrentToken(); + if (!(current is Key || current is Value || current is BlockEnd)) + { + states.Push(ParserState.BlockMappingKey); + return ParseNode(true, true); + } + else + { + state = ParserState.BlockMappingKey; + return ProcessEmptyScalar(mark); + } + } + else if (current is Error error) + { + throw new SemanticErrorException(error.Start, error.End, error.Value); + } + else + { + state = ParserState.BlockMappingKey; + return ProcessEmptyScalar(current?.Start ?? Mark.Empty); + } + } + + /// + /// Parse the productions: + /// flow_sequence ::= FLOW-SEQUENCE-START + /// ******************* + /// (flow_sequence_entry FLOW-ENTRY)* + /// * ********** + /// flow_sequence_entry? + /// * + /// FLOW-SEQUENCE-END + /// ***************** + /// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? + /// * + /// + private ParsingEvent ParseFlowSequenceEntry(bool isFirst) + { + if (isFirst) + { + GetCurrentToken(); + Skip(); + } + + ParsingEvent evt; + var current = GetCurrentToken(); + if (!(current is FlowSequenceEnd)) + { + if (!isFirst) + { + if (current is FlowEntry) + { + Skip(); + current = GetCurrentToken(); + } + else + { + throw new SemanticErrorException(current?.Start ?? Mark.Empty, current?.End ?? Mark.Empty, "While parsing a flow sequence, did not find expected ',' or ']'."); + } + } + + if (current is Key) + { + state = ParserState.FlowSequenceEntryMappingKey; + evt = new Events.MappingStart(AnchorName.Empty, TagName.Empty, true, MappingStyle.Flow); + Skip(); + return evt; + } + else if (!(current is FlowSequenceEnd)) + { + states.Push(ParserState.FlowSequenceEntry); + return ParseNode(false, false); + } + } + + state = states.Pop(); + evt = new Events.SequenceEnd(current?.Start ?? Mark.Empty, current?.End ?? Mark.Empty); + Skip(); + return evt; + } + + /// + /// Parse the productions: + /// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? + /// *** * + /// + private ParsingEvent ParseFlowSequenceEntryMappingKey() + { + var current = GetCurrentToken(); + if (!(current is Value || current is FlowEntry || current is FlowSequenceEnd)) + { + states.Push(ParserState.FlowSequenceEntryMappingValue); + return ParseNode(false, false); + } + else + { + var mark = current?.End ?? Mark.Empty; + Skip(); + state = ParserState.FlowSequenceEntryMappingValue; + return ProcessEmptyScalar(mark); + } + } + + /// + /// Parse the productions: + /// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? + /// ***** * + /// + private ParsingEvent ParseFlowSequenceEntryMappingValue() + { + var current = GetCurrentToken(); + if (current is Value) + { + Skip(); + current = GetCurrentToken(); + if (!(current is FlowEntry || current is FlowSequenceEnd)) + { + states.Push(ParserState.FlowSequenceEntryMappingEnd); + return ParseNode(false, false); + } + } + state = ParserState.FlowSequenceEntryMappingEnd; + return ProcessEmptyScalar(current?.Start ?? Mark.Empty); + } + + /// + /// Parse the productions: + /// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? + /// * + /// + private ParsingEvent ParseFlowSequenceEntryMappingEnd() + { + state = ParserState.FlowSequenceEntry; + var current = GetCurrentToken(); + return new Events.MappingEnd(current?.Start ?? Mark.Empty, current?.End ?? Mark.Empty); + } + + /// + /// Parse the productions: + /// flow_mapping ::= FLOW-MAPPING-START + /// ****************** + /// (flow_mapping_entry FLOW-ENTRY)* + /// * ********** + /// flow_mapping_entry? + /// ****************** + /// FLOW-MAPPING-END + /// **************** + /// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? + /// * *** * + /// + private ParsingEvent ParseFlowMappingKey(bool isFirst) + { + if (isFirst) + { + GetCurrentToken(); + Skip(); + } + + var current = GetCurrentToken(); + if (!(current is FlowMappingEnd)) + { + if (!isFirst) + { + if (current is FlowEntry) + { + Skip(); + current = GetCurrentToken(); + } + else + { + throw new SemanticErrorException(current?.Start ?? Mark.Empty, current?.End ?? Mark.Empty, "While parsing a flow mapping, did not find expected ',' or '}'."); + } + } + + if (current is Key) + { + Skip(); + + current = GetCurrentToken(); + if (!(current is Value || current is FlowEntry || current is FlowMappingEnd)) + { + states.Push(ParserState.FlowMappingValue); + return ParseNode(false, false); + } + else + { + state = ParserState.FlowMappingValue; + return ProcessEmptyScalar(current?.Start ?? Mark.Empty); + } + } + else if (current is Scalar) + { + states.Push(ParserState.FlowMappingValue); + return ParseNode(false, false); + } + else if (!(current is FlowMappingEnd)) + { + states.Push(ParserState.FlowMappingEmptyValue); + return ParseNode(false, false); + } + } + + state = states.Pop(); + Skip(); + return new Events.MappingEnd(current?.Start ?? Mark.Empty, current?.End ?? Mark.Empty); + } + + /// + /// Parse the productions: + /// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? + /// * ***** * + /// + private ParsingEvent ParseFlowMappingValue(bool isEmpty) + { + var current = GetCurrentToken(); + if (isEmpty) + { + state = ParserState.FlowMappingKey; + return ProcessEmptyScalar(current?.Start ?? Mark.Empty); + } + + if (current is Value) + { + Skip(); + current = GetCurrentToken(); + if (!(current is FlowEntry || current is FlowMappingEnd)) + { + states.Push(ParserState.FlowMappingKey); + return ParseNode(false, false); + } + } + + state = ParserState.FlowMappingKey; + return ProcessEmptyScalar(current?.Start ?? Mark.Empty); + } + + private class EventQueue + { + // This class is specialized for our specific use case where there are exactly two priority levels. + // If more levels are required, a more generic implementation should be used instead. + private readonly Queue highPriorityEvents = new Queue(); + private readonly Queue normalPriorityEvents = new Queue(); + + public void Enqueue(ParsingEvent @event) + { + switch (@event.Type) + { + case Events.EventType.StreamStart: + case Events.EventType.DocumentStart: + highPriorityEvents.Enqueue(@event); + break; + + default: + normalPriorityEvents.Enqueue(@event); + break; + } + } + + public ParsingEvent Dequeue() + { + return highPriorityEvents.Count > 0 + ? highPriorityEvents.Dequeue() + : normalPriorityEvents.Dequeue(); + } + + public int Count + { + get + { + return highPriorityEvents.Count + normalPriorityEvents.Count; + } + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Parser.cs.meta b/namedropper/Assets/YamlDotNet/Core/Parser.cs.meta new file mode 100644 index 0000000..38edd72 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Parser.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 26cca4bc9fdfb2d429b2181c273ab7b7 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/ParserExtensions.cs b/namedropper/Assets/YamlDotNet/Core/ParserExtensions.cs new file mode 100644 index 0000000..0ab4ea2 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/ParserExtensions.cs @@ -0,0 +1,151 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Core +{ + /// + /// Extension methods that provide useful abstractions over . + /// + public static class ParserExtensions + { + /// + /// Ensures that the current event is of the specified type, returns it and moves to the next event. + /// + /// Type of the . + /// Returns the current event. + /// If the current event is not of the specified type. + public static T Consume(this IParser parser) where T : ParsingEvent + { + var required = parser.Require(); + parser.MoveNext(); + return required; + } + + /// + /// Checks whether the current event is of the specified type. + /// If the event is of the specified type, returns it and moves to the next event. + /// Otherwise returns null. + /// + /// Type of the . + /// Returns true if the current event is of type T; otherwise returns null. + public static bool TryConsume(this IParser parser, [MaybeNullWhen(false)] out T @event) where T : ParsingEvent + { + if (parser.Accept(out @event!)) + { + parser.MoveNext(); + return true; + } + return false; + } + + /// + /// Enforces that the current event is of the specified type. + /// + /// Type of the . + /// Returns the current event. + /// If the current event is not of the specified type. + public static T Require(this IParser parser) where T : ParsingEvent + { + if (!parser.Accept(out var required)) + { + var @event = parser.Current; + if (@event == null) + { + throw new YamlException($"Expected '{typeof(T).Name}', got nothing."); + } + throw new YamlException(@event.Start, @event.End, $"Expected '{typeof(T).Name}', got '{@event.GetType().Name}' (at {@event.Start})."); + } + return required; + } + + /// + /// Checks whether the current event is of the specified type. + /// + /// Type of the event. + /// Returns true if the current event is of type . Otherwise returns false. + public static bool Accept(this IParser parser, [MaybeNullWhen(false)] out T @event) where T : ParsingEvent + { + if (parser.Current == null) + { + if (!parser.MoveNext()) + { + throw new EndOfStreamException(); + } + } + + if (parser.Current is T evt) + { + @event = evt; + return true; + } + else + { + @event = default!; + return false; + } + } + + /// + /// Skips the current event and any nested event. + /// + public static void SkipThisAndNestedEvents(this IParser parser) + { + var depth = 0; + do + { + var next = parser.Consume(); + depth += next.NestingIncrease; + } + while (depth > 0); + } + + [Obsolete("Please use Consume() instead")] + public static T Expect(this IParser parser) where T : ParsingEvent + { + return parser.Consume(); + } + + [Obsolete("Please use TryConsume(out var evt) instead")] + [return: MaybeNull] + public static T Allow(this IParser parser) where T : ParsingEvent + { + return parser.TryConsume(out var @event) ? @event : default; + } + + [Obsolete("Please use Accept(out var evt) instead")] + [return: MaybeNull] + public static T Peek(this IParser parser) where T : ParsingEvent + { + return parser.Accept(out var @event) ? @event : default; + } + + [Obsolete("Please use TryConsume(out var evt) or Accept(out var evt) instead")] + public static bool Accept(this IParser parser) where T : ParsingEvent + { + return Accept(parser, out var _); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/ParserExtensions.cs.meta b/namedropper/Assets/YamlDotNet/Core/ParserExtensions.cs.meta new file mode 100644 index 0000000..e355993 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/ParserExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ba6ee956c0cbe3f4587cc00d433dfa5a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/ParserState.cs b/namedropper/Assets/YamlDotNet/Core/ParserState.cs new file mode 100644 index 0000000..4508082 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/ParserState.cs @@ -0,0 +1,51 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core +{ + internal enum ParserState + { + StreamStart, + StreamEnd, + ImplicitDocumentStart, + DocumentStart, + DocumentContent, + DocumentEnd, + BlockNode, + BlockNodeOrIndentlessSequence, + FlowNode, + BlockSequenceFirstEntry, + BlockSequenceEntry, + IndentlessSequenceEntry, + BlockMappingFirstKey, + BlockMappingKey, + BlockMappingValue, + FlowSequenceFirstEntry, + FlowSequenceEntry, + FlowSequenceEntryMappingKey, + FlowSequenceEntryMappingValue, + FlowSequenceEntryMappingEnd, + FlowMappingFirstKey, + FlowMappingKey, + FlowMappingValue, + FlowMappingEmptyValue + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/ParserState.cs.meta b/namedropper/Assets/YamlDotNet/Core/ParserState.cs.meta new file mode 100644 index 0000000..7431891 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/ParserState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4c73f39f4ccd4a644bd851bffd5afa20 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/RecursionLevel.cs b/namedropper/Assets/YamlDotNet/Core/RecursionLevel.cs new file mode 100644 index 0000000..e255bd5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/RecursionLevel.cs @@ -0,0 +1,80 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core +{ + /// + /// Keeps track of the recursion level, + /// and throws + /// whenever is reached. + /// + internal sealed class RecursionLevel + { + private int current; + public int Maximum { get; } + + public RecursionLevel(int maximum) + { + Maximum = maximum; + } + + /// + /// Increments the recursion level, + /// and throws + /// if is reached. + /// + public void Increment() + { + if (!TryIncrement()) + { + throw new MaximumRecursionLevelReachedException("Maximum level of recursion reached"); + } + } + + /// + /// Increments the recursion level, + /// and returns whether is still less than . + /// + public bool TryIncrement() + { + if (current < Maximum) + { + ++current; + return true; + } + return false; + } + + /// + /// Decrements the recursion level. + /// + public void Decrement() + { + if (current == 0) + { + throw new InvalidOperationException("Attempted to decrement RecursionLevel to a negative value"); + } + --current; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/RecursionLevel.cs.meta b/namedropper/Assets/YamlDotNet/Core/RecursionLevel.cs.meta new file mode 100644 index 0000000..5ce6e25 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/RecursionLevel.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 87346082332b7a2469719bddad64afd5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/ScalarStyle.cs b/namedropper/Assets/YamlDotNet/Core/ScalarStyle.cs new file mode 100644 index 0000000..6cef414 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/ScalarStyle.cs @@ -0,0 +1,59 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core +{ + /// + /// Specifies the style of a YAML scalar. + /// + public enum ScalarStyle + { + /// + /// Let the emitter choose the style. + /// + Any, + + /// + /// The plain scalar style. + /// + Plain, + + /// + /// The single-quoted scalar style. + /// + SingleQuoted, + + /// + /// The double-quoted scalar style. + /// + DoubleQuoted, + + /// + /// The literal scalar style. + /// + Literal, + + /// + /// The folded scalar style. + /// + Folded, + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/ScalarStyle.cs.meta b/namedropper/Assets/YamlDotNet/Core/ScalarStyle.cs.meta new file mode 100644 index 0000000..cd9d45c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/ScalarStyle.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d8499f656f1f893409f937b46c386cf2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Scanner.cs b/namedropper/Assets/YamlDotNet/Core/Scanner.cs new file mode 100644 index 0000000..c376fcb --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Scanner.cs @@ -0,0 +1,2566 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Text; +using YamlDotNet.Core.Tokens; + +namespace YamlDotNet.Core +{ + /// + /// Converts a sequence of characters into a sequence of YAML tokens. + /// + public class Scanner : IScanner + { + private const int MaxVersionNumberLength = 9; + + private static readonly IDictionary SimpleEscapeCodes = new SortedDictionary + { + { '0', '\0' }, + { 'a', '\x07' }, + { 'b', '\x08' }, + { 't', '\x09' }, + { '\t', '\x09' }, + { 'n', '\x0A' }, + { 'v', '\x0B' }, + { 'f', '\x0C' }, + { 'r', '\x0D' }, + { 'e', '\x1B' }, + { ' ', '\x20' }, + { '"', '"' }, + { '\\', '\\' }, + { '/', '/' }, + { 'N', '\x85' }, + { '_', '\xA0' }, + { 'L', '\x2028' }, + { 'P', '\x2029' } + }; + + private readonly Stack indents = new Stack(); + private readonly InsertionQueue tokens = new InsertionQueue(); + private readonly Stack simpleKeys = new Stack(); + private readonly CharacterAnalyzer analyzer; + + private readonly Cursor cursor; + private bool streamStartProduced; + private bool streamEndProduced; + private bool plainScalarFollowedByComment; + private int flowSequenceStartLine; + private int indent = -1; + private bool simpleKeyAllowed; + private int flowLevel; + private int tokensParsed; + private bool tokenAvailable; + private Token? previous; + private Anchor? previousAnchor; + + private bool IsDocumentStart() => + !analyzer.EndOfInput && + cursor.LineOffset == 0 && + analyzer.Check('-', 0) && + analyzer.Check('-', 1) && + analyzer.Check('-', 2) && + analyzer.IsWhiteBreakOrZero(3); + + private bool IsDocumentEnd() => + !analyzer.EndOfInput && + cursor.LineOffset == 0 && + analyzer.Check('.', 0) && + analyzer.Check('.', 1) && + analyzer.Check('.', 2) && + analyzer.IsWhiteBreakOrZero(3); + + private bool IsDocumentIndicator() => IsDocumentStart() || IsDocumentEnd(); + + public bool SkipComments + { + get; private set; + } + + /// + /// Gets the current token. + /// + public Token? Current + { + get; private set; + } + + /// + /// Initializes a new instance of the class. + /// + /// The input. + /// Indicates whether comments should be ignored + public Scanner(TextReader input, bool skipComments = true) + { + analyzer = new CharacterAnalyzer(new LookAheadBuffer(input, 1024)); + cursor = new Cursor(); + SkipComments = skipComments; + } + + /// + /// Gets the current position inside the input stream. + /// + /// The current position. + public Mark CurrentPosition + { + get + { + return cursor.Mark(); + } + } + + /// + /// Moves to the next token. + /// + /// + public bool MoveNext() + { + if (Current != null) + { + ConsumeCurrent(); + } + + return MoveNextWithoutConsuming(); + } + + public bool MoveNextWithoutConsuming() + { + if (!tokenAvailable && !streamEndProduced) + { + FetchMoreTokens(); + } + if (tokens.Count > 0) + { + Current = tokens.Dequeue(); + tokenAvailable = false; + return true; + } + else + { + Current = null; + return false; + } + } + + /// + /// Consumes the current token and increments the parsed token count + /// + public void ConsumeCurrent() + { + ++tokensParsed; + tokenAvailable = false; + previous = Current; + Current = null; + } + + private char ReadCurrentCharacter() + { + var currentCharacter = analyzer.Peek(0); + Skip(); + return currentCharacter; + } + + private char ReadLine() + { + if (analyzer.Check("\r\n\x85")) // CR LF -> LF --- CR|LF|NEL -> LF + { + SkipLine(); + return '\n'; + } + + var nextChar = analyzer.Peek(0); // LS|PS -> LS|PS + SkipLine(); + return nextChar; + } + + private void FetchMoreTokens() + { + // While we need more tokens to fetch, do it. + + while (true) + { + // Check if we really need to fetch more tokens. + + var needsMoreTokens = false; + + if (tokens.Count == 0) + { + // Queue is empty. + + needsMoreTokens = true; + } + else + { + // Check if any potential simple key may occupy the head position. + + foreach (var simpleKey in simpleKeys) + { + if (simpleKey.IsPossible && simpleKey.TokenNumber == tokensParsed) + { + needsMoreTokens = true; + break; + } + } + } + + // We are finished. + if (!needsMoreTokens) + { + break; + } + + // Fetch the next token. + + FetchNextToken(); + } + tokenAvailable = true; + } + + private static bool StartsWith(StringBuilder what, char start) + { + return what.Length > 0 && what[0] == start; + } + + /// + /// Check the list of potential simple keys and remove the positions that + /// cannot contain simple keys anymore. + /// + + private void StaleSimpleKeys() + { + // Check for a potential simple key for each flow level. + + foreach (var key in simpleKeys) + { + + // The specification requires that a simple key + + // - is limited to a single line, + // - is shorter than 1024 characters. + + + if (key.IsPossible && (key.Line < cursor.Line || key.Index + 1024 < cursor.Index)) + { + + // Check if the potential simple key to be removed is required. + + if (key.IsRequired) + { + var mark = cursor.Mark(); + tokens.Enqueue(new Error("While scanning a simple key, could not find expected ':'.", mark, mark)); + } + + key.MarkAsImpossible(); + } + } + } + + private void FetchNextToken() + { + // Check if we just started scanning. Fetch STREAM-START then. + + if (!streamStartProduced) + { + FetchStreamStart(); + return; + } + + // Eat whitespaces and comments until we reach the next token. + + ScanToNextToken(); + + // Remove obsolete potential simple keys. + + StaleSimpleKeys(); + + // Check the indentation level against the current column. + + UnrollIndent(cursor.LineOffset); + + + // Ensure that the buffer contains at least 4 characters. 4 is the length + // of the longest indicators ('--- ' and '... '). + + + analyzer.Buffer.Cache(4); + + // Is it the end of the stream? + + if (analyzer.Buffer.EndOfInput) + { + FetchStreamEnd(); + return; + } + + // Is it a directive? + + if (cursor.LineOffset == 0 && analyzer.Check('%')) + { + FetchDirective(); + return; + } + + // Is it the document start indicator? + + if (IsDocumentStart()) + { + FetchDocumentIndicator(true); + return; + } + + // Is it the document end indicator? + + if (IsDocumentEnd()) + { + FetchDocumentIndicator(false); + return; + } + + // Is it the flow sequence start indicator? + + if (analyzer.Check('[')) + { + FetchFlowCollectionStart(true); + return; + } + + // Is it the flow mapping start indicator? + + if (analyzer.Check('{')) + { + FetchFlowCollectionStart(false); + return; + } + + // Is it the flow sequence end indicator? + + if (analyzer.Check(']')) + { + FetchFlowCollectionEnd(true); + return; + } + + // Is it the flow mapping end indicator? + + if (analyzer.Check('}')) + { + FetchFlowCollectionEnd(false); + return; + } + + // Is it the flow entry indicator? + + if (analyzer.Check(',')) + { + FetchFlowEntry(); + return; + } + + // Is it the block entry indicator? + + if (analyzer.Check('-') && analyzer.IsWhiteBreakOrZero(1)) + { + FetchBlockEntry(); + return; + } + + // Is it the key indicator? + + if (analyzer.Check('?') && (flowLevel > 0 || analyzer.IsWhiteBreakOrZero(1))) + { + FetchKey(); + return; + } + + // Is it the value indicator? + + if (analyzer.Check(':') && (flowLevel > 0 || analyzer.IsWhiteBreakOrZero(1)) && + !(simpleKeyAllowed && flowLevel > 0)) + { + FetchValue(); + return; + } + + // Is it an alias? + + if (analyzer.Check('*')) + { + FetchAnchor(true); + return; + } + + // Is it an anchor? + + if (analyzer.Check('&')) + { + FetchAnchor(false); + return; + } + + // Is it a tag? + + if (analyzer.Check('!')) + { + FetchTag(); + return; + } + + // Is it a literal scalar? + + if (analyzer.Check('|') && flowLevel == 0) + { + FetchBlockScalar(true); + return; + } + + // Is it a folded scalar? + + if (analyzer.Check('>') && flowLevel == 0) + { + FetchBlockScalar(false); + return; + } + + // Is it a single-quoted scalar? + + if (analyzer.Check('\'')) + { + FetchFlowScalar(true); + return; + } + + // Is it a double-quoted scalar? + + if (analyzer.Check('"')) + { + FetchFlowScalar(false); + return; + } + + + // Is it a plain scalar? + + // A plain scalar may start with any non-blank characters except + + // '-', '?', ':', ',', '[', ']', '{', '}', + // '#', '&', '*', '!', '|', '>', '\'', '\"', + // '%', '@', '`'. + + // In the block context (and, for the '-' indicator, in the flow context + // too), it may also start with the characters + + // '-', '?', ':' + + // if it is followed by a non-space character. + + // The last rule is more restrictive than the specification requires. + + + var isInvalidPlainScalarCharacter = analyzer.IsWhiteBreakOrZero() || analyzer.Check("-?:,[]{}#&*!|>'\"%@`"); + + var isPlainScalar = + !isInvalidPlainScalarCharacter || + (analyzer.Check('-') && !analyzer.IsWhite(1)) || + (flowLevel == 0 && analyzer.Check("?:") && !analyzer.IsWhiteBreakOrZero(1)) || + (simpleKeyAllowed && flowLevel > 0 && analyzer.Check("?:")); + + if (isPlainScalar) + { + if (plainScalarFollowedByComment) + { + var startMark = cursor.Mark(); + tokens.Enqueue(new Error("While scanning plain scalar, found a comment between adjacent scalars.", startMark, startMark)); + } + + plainScalarFollowedByComment = false; + + FetchPlainScalar(); + return; + } + + if (simpleKeyAllowed && indent >= cursor.LineOffset && analyzer.IsTab()) + { + throw new SyntaxErrorException("While scanning a mapping, found invalid tab as indentation."); + } + + if (analyzer.IsWhiteBreakOrZero()) + { + Skip(); + return; + } + + // If we don't determine the token type so far, it is an error. + var start = cursor.Mark(); + Skip(); + var end = cursor.Mark(); + + throw new SyntaxErrorException(start, end, "While scanning for the next token, found character that cannot start any token."); + } + + private bool CheckWhiteSpace() + { + return analyzer.Check(' ') || ((flowLevel > 0 || !simpleKeyAllowed) && analyzer.Check('\t')); + } + + private void Skip() + { + cursor.Skip(); + analyzer.Buffer.Skip(1); + } + + private void SkipLine() + { + if (analyzer.IsCrLf()) + { + cursor.SkipLineByOffset(2); + analyzer.Buffer.Skip(2); + } + else if (analyzer.IsBreak()) + { + cursor.SkipLineByOffset(1); + analyzer.Buffer.Skip(1); + } + else if (!analyzer.IsZero()) + { + throw new InvalidOperationException("Not at a break."); + } + } + + private void ScanToNextToken() + { + // Until the next token is not find. + + while (true) + { + + // Eat whitespaces. + + // Tabs are allowed: + + // - in the flow context; + // - in the block context, but not at the beginning of the line or + // after '-', '?', or ':' (complex value). + + + while (CheckWhiteSpace()) + { + Skip(); + } + + ProcessComment(); + + // If it is a line break, eat it. + + if (analyzer.IsBreak()) + { + SkipLine(); + + // In the block context, a new line may start a simple key. + + if (flowLevel == 0) + { + simpleKeyAllowed = true; + } + } + else + { + // We have find a token. + + break; + } + } + } + + private void ProcessComment() + { + if (analyzer.Check('#')) + { + var start = cursor.Mark(); + + // Eat '#' + Skip(); + + // Eat leading whitespace + while (analyzer.IsSpace()) + { + Skip(); + } + + var text = new StringBuilder(); + while (!analyzer.IsBreakOrZero()) + { + text.Append(ReadCurrentCharacter()); + } + + if (!SkipComments) + { + var isInline = previous != null + && previous.End.Line == start.Line + && previous.End.Column != 1 + && !(previous is StreamStart); + + tokens.Enqueue(new Comment(text.ToString(), isInline, start, cursor.Mark())); + } + } + } + + private void FetchStreamStart() + { + // Initialize the simple key stack. + + simpleKeys.Push(new SimpleKey()); + + // A simple key is allowed at the beginning of the stream. + + simpleKeyAllowed = true; + + // We have started. + + streamStartProduced = true; + + // Create the STREAM-START token and append it to the queue. + + var mark = cursor.Mark(); + tokens.Enqueue(new StreamStart(mark, mark)); + } + + /// + /// Pop indentation levels from the indents stack until the current level + /// becomes less or equal to the column. For each indentation level, append + /// the BLOCK-END token. + /// + + private void UnrollIndent(int column) + { + // In the flow context, do nothing. + + if (flowLevel != 0) + { + return; + } + + // Loop through the indentation levels in the stack. + + while (indent > column) + { + // Create a token and append it to the queue. + + var mark = cursor.Mark(); + tokens.Enqueue(new BlockEnd(mark, mark)); + + // Pop the indentation level. + + indent = indents.Pop(); + } + } + + /// + /// Produce the STREAM-END token and shut down the scanner. + /// + private void FetchStreamEnd() + { + cursor.ForceSkipLineAfterNonBreak(); + + // Reset the indentation level. + + UnrollIndent(-1); + + // Reset simple keys. + + RemoveSimpleKey(); + + simpleKeyAllowed = false; + + // Create the STREAM-END token and append it to the queue. + + streamEndProduced = true; + var mark = cursor.Mark(); + tokens.Enqueue(new StreamEnd(mark, mark)); + } + + private void FetchDirective() + { + // Reset the indentation level. + + UnrollIndent(-1); + + // Reset simple keys. + + RemoveSimpleKey(); + + simpleKeyAllowed = false; + + // Create the YAML-DIRECTIVE or TAG-DIRECTIVE token. + + var token = ScanDirective(); + + // Append the token to the queue. + if (token != null) + { + tokens.Enqueue(token); + } + } + + /// + /// Scan a YAML-DIRECTIVE or TAG-DIRECTIVE token. + /// + /// Scope: + /// %YAML 1.1 # a comment \n + /// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + /// %TAG !yaml! tag:yaml.org,2002: \n + /// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + /// + private Token? ScanDirective() + { + // Eat '%'. + + var start = cursor.Mark(); + + Skip(); + + // Scan the directive name. + + var name = ScanDirectiveName(start); + + // Is it a YAML directive? + + Token directive; + switch (name) + { + case "YAML": + if (previous is DocumentStart || previous is StreamStart || previous is DocumentEnd) + { + directive = ScanVersionDirectiveValue(start); + } + else + { + throw new SemanticErrorException(start, cursor.Mark(), "While scanning a version directive, did not find preceding ."); + } + break; + + case "TAG": + directive = ScanTagDirectiveValue(start); + break; + + default: + // warning: skipping reserved directive line + while (!analyzer.Check('#') && !analyzer.IsBreak()) + { + Skip(); + } + return null; + } + + // Eat the rest of the line including any comments. + + while (analyzer.IsWhite()) + { + Skip(); + } + + ProcessComment(); + + // Check if we are at the end of the line. + + if (!analyzer.IsBreakOrZero()) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a directive, did not find expected comment or line break."); + } + + // Eat a line break. + + if (analyzer.IsBreak()) + { + SkipLine(); + } + + return directive; + } + + /// + /// Produce the DOCUMENT-START or DOCUMENT-END token. + /// + + private void FetchDocumentIndicator(bool isStartToken) + { + // Reset the indentation level. + + UnrollIndent(-1); + + // Reset simple keys. + + RemoveSimpleKey(); + + simpleKeyAllowed = false; + + // Consume the token. + + var start = cursor.Mark(); + + Skip(); + Skip(); + Skip(); + + if (isStartToken) + { + tokens.Enqueue(new DocumentStart(start, cursor.Mark())); + } + else + { + Token? errorToken = null; + while (!analyzer.EndOfInput && !analyzer.IsBreak() && !analyzer.Check('#')) + { + if (!analyzer.IsWhite()) + { + errorToken = new Error("While scanning a document end, found invalid content after '...' marker.", start, cursor.Mark()); + break; + } + Skip(); + } + tokens.Enqueue(new DocumentEnd(start, start)); + if (errorToken != null) + { + tokens.Enqueue(errorToken); + } + } + } + + /// + /// Produce the FLOW-SEQUENCE-START or FLOW-MAPPING-START token. + /// + + private void FetchFlowCollectionStart(bool isSequenceToken) + { + // The indicators '[' and '{' may start a simple key. + + SaveSimpleKey(); + + // Increase the flow level. + + IncreaseFlowLevel(); + + // A simple key may follow the indicators '[' and '{'. + + simpleKeyAllowed = true; + + // Consume the token. + + var start = cursor.Mark(); + Skip(); + + // Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token. + + Token token; + if (isSequenceToken) + { + token = new FlowSequenceStart(start, start); + flowSequenceStartLine = token.Start.Line; + } + else + { + token = new FlowMappingStart(start, start); + } + + tokens.Enqueue(token); + } + + /// + /// Increase the flow level and resize the simple key list if needed. + /// + + private void IncreaseFlowLevel() + { + // Reset the simple key on the next level. + + simpleKeys.Push(new SimpleKey()); + + // Increase the flow level. + + ++flowLevel; + } + + /// + /// Produce the FLOW-SEQUENCE-END or FLOW-MAPPING-END token. + /// + + private void FetchFlowCollectionEnd(bool isSequenceToken) + { + // Reset any potential simple key on the current flow level. + + RemoveSimpleKey(); + + // Decrease the flow level. + + DecreaseFlowLevel(); + + // No simple keys after the indicators ']' and '}'. + + simpleKeyAllowed = false; + + // Consume the token. + + var start = cursor.Mark(); + Skip(); + + Token? token, errorToken = null; + if (isSequenceToken) + { + if (analyzer.Check('#')) + { + errorToken = new Error("While scanning a flow sequence end, found invalid comment after ']'.", start, start); + } + + if (previous is StreamStart && flowSequenceStartLine != start.Line) + { + tokens.Enqueue(new Error("While scanning a flow sequence end, found mapping key spanning across multiple lines.", start, start)); + } + + token = new FlowSequenceEnd(start, start); + } + else + { + token = new FlowMappingEnd(start, start); + } + + tokens.Enqueue(token); + if (errorToken != null) + { + tokens.Enqueue(errorToken); + } + } + + /// + /// Decrease the flow level. + /// + + private void DecreaseFlowLevel() + { + // flowLevel could be zero in case of malformed YAML. + // Since this is handled elsewhere, just ignore it. + if (flowLevel > 0) + { + --flowLevel; + simpleKeys.Pop(); + } + } + + /// + /// Produce the FLOW-ENTRY token. + /// + + private void FetchFlowEntry() + { + // Reset any potential simple keys on the current flow level. + + RemoveSimpleKey(); + + // Simple keys are allowed after ','. + + simpleKeyAllowed = true; + + // Consume the token. + + var start = cursor.Mark(); + Skip(); + + var end = cursor.Mark(); + if (analyzer.Check('#')) + { + tokens.Enqueue(new Error("While scanning a flow entry, found invalid comment after comma.", start, end)); + return; + } + + // Create the FLOW-ENTRY token and append it to the queue. + + tokens.Enqueue(new FlowEntry(start, end)); + } + + /// + /// Produce the BLOCK-ENTRY token. + /// + + private void FetchBlockEntry() + { + // Check if the scanner is in the block context. + + if (flowLevel == 0) + { + // Check if we are allowed to start a new entry. + + if (!simpleKeyAllowed) + { + if (previousAnchor != null) + { + if (previousAnchor.End.Line == cursor.Line) + { + throw new SemanticErrorException(previousAnchor.Start, previousAnchor.End, "Anchor before sequence entry on same line is not allowed."); + } + } + var mark = cursor.Mark(); + tokens.Enqueue(new Error("Block sequence entries are not allowed in this context.", mark, mark)); + } + + // Add the BLOCK-SEQUENCE-START token if needed. + RollIndent(cursor.LineOffset, -1, true, cursor.Mark()); + } + else + { + + // It is an error for the '-' indicator to occur in the flow context, + // but we let the Parser detect and report about it because the Parser + // is able to point to the context. + + } + + // Reset any potential simple keys on the current flow level. + + RemoveSimpleKey(); + + // Simple keys are allowed after '-'. + + simpleKeyAllowed = true; + + // Consume the token. + + var start = cursor.Mark(); + Skip(); + + // Create the BLOCK-ENTRY token and append it to the queue. + + tokens.Enqueue(new BlockEntry(start, cursor.Mark())); + } + + /// + /// Produce the KEY token. + /// + + private void FetchKey() + { + // In the block context, additional checks are required. + + if (flowLevel == 0) + { + // Check if we are allowed to start a new key (not necessary simple). + + if (!simpleKeyAllowed) + { + var mark = cursor.Mark(); + throw new SyntaxErrorException(mark, mark, "Mapping keys are not allowed in this context."); + } + + // Add the BLOCK-MAPPING-START token if needed. + + RollIndent(cursor.LineOffset, -1, false, cursor.Mark()); + } + + // Reset any potential simple keys on the current flow level. + + RemoveSimpleKey(); + + // Simple keys are allowed after '?' in the block context. + + simpleKeyAllowed = flowLevel == 0; + + // Consume the token. + + var start = cursor.Mark(); + Skip(); + + // Create the KEY token and append it to the queue. + + tokens.Enqueue(new Key(start, cursor.Mark())); + } + + /// + /// Produce the VALUE token. + /// + + private void FetchValue() + { + var simpleKey = simpleKeys.Peek(); + + // Have we find a simple key? + + if (simpleKey.IsPossible) + { + // Create the KEY token and insert it into the queue. + + tokens.Insert(simpleKey.TokenNumber - tokensParsed, new Key(simpleKey.Mark, simpleKey.Mark)); + + // In the block context, we may need to add the BLOCK-MAPPING-START token. + + RollIndent(simpleKey.LineOffset, simpleKey.TokenNumber, false, simpleKey.Mark); + + // Remove the simple key. + + simpleKey.MarkAsImpossible(); + + // A simple key cannot follow another simple key. + + simpleKeyAllowed = false; + } + else + { + // The ':' indicator follows a complex key. + + // Simple keys after ':' are allowed in the block context. + + var localSimpleKeyAllowed = flowLevel == 0; + + // In the block context, extra checks are required. + + if (localSimpleKeyAllowed) + { + // Check if we are allowed to start a complex value. + + if (!simpleKeyAllowed) + { + var mark = cursor.Mark(); + tokens.Enqueue(new Error("Mapping values are not allowed in this context.", mark, mark)); + return; + } + + // Add the BLOCK-MAPPING-START token if needed. + + RollIndent(cursor.LineOffset, -1, false, cursor.Mark()); + + // Check if we are dealing with empty key. + + if (cursor.LineOffset == 0 && simpleKey.LineOffset == 0) + { + // Create the KEY token and insert it into the queue. + + tokens.Insert(tokens.Count, new Key(simpleKey.Mark, simpleKey.Mark)); + + // A simple key cannot follow another simple key. + + localSimpleKeyAllowed = false; + } + } + + simpleKeyAllowed = localSimpleKeyAllowed; + } + + // Consume the token. + + var start = cursor.Mark(); + Skip(); + + // Create the VALUE token and append it to the queue. + + tokens.Enqueue(new Value(start, cursor.Mark())); + } + + /// + /// Push the current indentation level to the stack and set the new level + /// the current column is greater than the indentation level. In this case, + /// append or insert the specified token into the token queue. + /// + private void RollIndent(int column, int number, bool isSequence, Mark position) + { + // In the flow context, do nothing. + + if (flowLevel > 0) + { + return; + } + + if (indent < column) + { + + // Push the current indentation level to the stack and set the new + // indentation level. + + + indents.Push(indent); + + indent = column; + + // Create a token and insert it into the queue. + + Token token; + if (isSequence) + { + token = new BlockSequenceStart(position, position); + } + else + { + token = new BlockMappingStart(position, position); + } + + if (number == -1) + { + tokens.Enqueue(token); + } + else + { + tokens.Insert(number - tokensParsed, token); + } + } + } + + /// + /// Produce the ALIAS or ANCHOR token. + /// + + private void FetchAnchor(bool isAlias) + { + // An anchor or an alias could be a simple key. + + SaveSimpleKey(); + + // A simple key cannot follow an anchor or an alias. + + simpleKeyAllowed = false; + + // Create the ALIAS or ANCHOR token and append it to the queue. + + tokens.Enqueue(ScanAnchor(isAlias)); + } + + private Token ScanAnchor(bool isAlias) + { + // Eat the indicator character. + + var start = cursor.Mark(); + + Skip(); + + var isAliasKey = false; + if (isAlias) + { + var key = simpleKeys.Peek(); + isAliasKey = key.IsRequired && key.IsPossible; + } + + // Consume the value. + // YAML 1.2 - section 6.9.2."Node Anchors" specifies disallowed characters + // in the anchor name as follows: + // '[', ']', '{', '}' and ',' + // ref: https://yaml.org/spec/1.2/spec.html#id2785586 + + var value = new StringBuilder(); + while (!analyzer.IsWhiteBreakOrZero()) + { + // Anchor: read all allowed characters + + // Alias: read all allowed characters except colon (':'); read colon when token is: + // * not used in key OR + // * used in key and colon is not last character + + if (!analyzer.Check("[]{},") && + !(isAliasKey && analyzer.Check(':') && analyzer.IsWhiteBreakOrZero(1))) + { + value.Append(ReadCurrentCharacter()); + } + else + { + break; + } + } + + // Check if length of the anchor is greater than 0 and it is followed by + // a whitespace character or one of the indicators: + + // '?', ':', ',', ']', '}', '%', '@', '`'. + + + if (value.Length == 0 || !(analyzer.IsWhiteBreakOrZero() || analyzer.Check("?:,]}%@`"))) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning an anchor or alias, found value containing disallowed: []{},"); + } + + // Create a token. + var name = new AnchorName(value.ToString()); + if (isAlias) + { + return new AnchorAlias(name, start, cursor.Mark()); + } + else + { + return previousAnchor = new Anchor(name, start, cursor.Mark()); + } + } + + /// + /// Produce the TAG token. + /// + + private void FetchTag() + { + // A tag could be a simple key. + + SaveSimpleKey(); + + // A simple key cannot follow a tag. + + simpleKeyAllowed = false; + + // Create the TAG token and append it to the queue. + + tokens.Enqueue(ScanTag()); + } + + /// + /// Scan a TAG token. + /// + + Token ScanTag() + { + var start = cursor.Mark(); + + // Check if the tag is in the canonical form. + + string handle; + string suffix; + + if (analyzer.Check('<', 1)) + { + // Set the handle to '' + + handle = string.Empty; + + // Eat '!<' + + Skip(); + Skip(); + + // Consume the tag value. + + suffix = ScanTagUri(null, start); + + // Check for '>' and eat it. + + if (!analyzer.Check('>')) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a tag, did not find the expected '>'."); + } + + Skip(); + } + else + { + // The tag has either the '!suffix' or the '!handle!suffix' form. + + // First, try to scan a handle. + + var firstPart = ScanTagHandle(false, start); + + // Check if it is, indeed, handle. + + if (firstPart.Length > 1 && firstPart[0] == '!' && firstPart[firstPart.Length - 1] == '!') + { + handle = firstPart; + + // Scan the suffix now. + + suffix = ScanTagUri(null, start); + } + else + { + // It wasn't a handle after all. Scan the rest of the tag. + + suffix = ScanTagUri(firstPart, start); + + // Set the handle to '!'. + + handle = "!"; + + + // A special case: the '!' tag. Set the handle to '' and the + // suffix to '!'. + + + if (suffix.Length == 0) + { + suffix = handle; + handle = string.Empty; + } + } + } + + // Check the character which ends the tag. + + if (!analyzer.IsWhiteBreakOrZero() && !analyzer.Check(',')) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a tag, did not find expected whitespace, comma or line break."); + } + + // Create a token. + + return new Tag(handle, suffix, start, cursor.Mark()); + } + + /// + /// Produce the SCALAR(...,literal) or SCALAR(...,folded) tokens. + /// + + private void FetchBlockScalar(bool isLiteral) + { + // Remove any potential simple keys. + + RemoveSimpleKey(); + + // A simple key may follow a block scalar. + + simpleKeyAllowed = true; + + // Create the SCALAR token and append it to the queue. + + tokens.Enqueue(ScanBlockScalar(isLiteral)); + } + + /// + /// Scan a block scalar. + /// + + Token ScanBlockScalar(bool isLiteral) + { + var value = new StringBuilder(); + var leadingBreak = new StringBuilder(); + var trailingBreaks = new StringBuilder(); + + var chomping = 0; + var increment = 0; + var currentIndent = 0; + var leadingBlank = false; + bool? isFirstLine = null; + + // Eat the indicator '|' or '>'. + + var start = cursor.Mark(); + + Skip(); + + // Check for a chomping indicator. + + if (analyzer.Check("+-")) + { + // Set the chomping method and eat the indicator. + + chomping = analyzer.Check('+') ? +1 : -1; + + Skip(); + + // Check for an indentation indicator. + + if (analyzer.IsDigit()) + { + // Check that the indentation is greater than 0. + + if (analyzer.Check('0')) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a block scalar, found an indentation indicator equal to 0."); + } + + // Get the indentation level and eat the indicator. + + increment = analyzer.AsDigit(); + + Skip(); + } + } + + // Do the same as above, but in the opposite order. + + else if (analyzer.IsDigit()) + { + if (analyzer.Check('0')) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a block scalar, found an indentation indicator equal to 0."); + } + + increment = analyzer.AsDigit(); + + Skip(); + + if (analyzer.Check("+-")) + { + chomping = analyzer.Check('+') ? +1 : -1; + + Skip(); + } + } + + // Check if there is a comment without whitespace after block scalar indicator (yaml-test-suite: X4QW). + + if (analyzer.Check('#')) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a block scalar, found a comment without whtespace after '>' indicator."); + } + + // Eat whitespaces and comments to the end of the line. + + while (analyzer.IsWhite()) + { + Skip(); + } + + ProcessComment(); + + // Check if we are at the end of the line. + + if (!analyzer.IsBreakOrZero()) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a block scalar, did not find expected comment or line break."); + } + + // Eat a line break. + + if (analyzer.IsBreak()) + { + SkipLine(); + if (!isFirstLine.HasValue) + { + isFirstLine = true; + } + else if (isFirstLine == true) + { + isFirstLine = false; + } + } + + var end = cursor.Mark(); + + // Set the indentation level if it was specified. + + if (increment != 0) + { + currentIndent = indent >= 0 ? indent + increment : increment; + } + + // Scan the leading line breaks and determine the indentation level if needed. + + currentIndent = ScanBlockScalarBreaks(currentIndent, trailingBreaks, isLiteral, ref end, ref isFirstLine); + isFirstLine = false; + + // Scan the block scalar content. + + while (cursor.LineOffset == currentIndent && !analyzer.IsZero() && !IsDocumentEnd()) + { + // We are at the beginning of a non-empty line. + + // Is it a trailing whitespace? + + var trailingBlank = analyzer.IsWhite(); + + // Check if we need to fold the leading line break. + + if (!isLiteral && StartsWith(leadingBreak, '\n') && !leadingBlank && !trailingBlank) + { + // Do we need to join the lines by space? + + if (trailingBreaks.Length == 0) + { + value.Append(' '); + } + + leadingBreak.Length = 0; + } + else + { + value.Append(leadingBreak.ToString()); + leadingBreak.Length = 0; + } + + // Append the remaining line breaks. + + value.Append(trailingBreaks.ToString()); + trailingBreaks.Length = 0; + + // Is it a leading whitespace? + + leadingBlank = analyzer.IsWhite(); + + // Consume the current line. + + while (!analyzer.IsBreakOrZero()) + { + value.Append(ReadCurrentCharacter()); + } + + // Consume the line break. + var lineBreak = ReadLine(); + if (lineBreak != '\0') + { + leadingBreak.Append(lineBreak); + } + + // Eat the following indentation spaces and line breaks. + + currentIndent = ScanBlockScalarBreaks(currentIndent, trailingBreaks, isLiteral, ref end, ref isFirstLine); + } + + // Chomp the tail. + + if (chomping != -1) + { + value.Append(leadingBreak); + } + if (chomping == 1) + { + value.Append(trailingBreaks); + } + + // Create a token. + + var style = isLiteral ? ScalarStyle.Literal : ScalarStyle.Folded; + return new Scalar(value.ToString(), style, start, end); + } + + /// + /// Scan indentation spaces and line breaks for a block scalar. Determine the + /// indentation level if needed. + /// + + private int ScanBlockScalarBreaks(int currentIndent, StringBuilder breaks, bool isLiteral, ref Mark end, ref bool? isFirstLine) + { + var maxIndent = 0; + var indentOfFirstLine = -1; + + end = cursor.Mark(); + + // Eat the indentation spaces and line breaks. + + while (true) + { + // Eat the indentation spaces. + + while ((currentIndent == 0 || cursor.LineOffset < currentIndent) && analyzer.IsSpace()) + { + Skip(); + } + + if (cursor.LineOffset > maxIndent) + { + maxIndent = cursor.LineOffset; + } + + // Have we find a non-empty line? + + if (!analyzer.IsBreak()) + { + if (isLiteral && isFirstLine == true) + { + var localIndent = cursor.LineOffset; + var i = 0; + while (!analyzer.IsBreak(i) && analyzer.IsSpace(i)) + { + ++i; + ++localIndent; + } + + if (analyzer.IsBreak(i) && localIndent > cursor.LineOffset) + { + isFirstLine = false; + indentOfFirstLine = localIndent; + } + } + break; + } + + if (isFirstLine == true) + { + isFirstLine = false; + indentOfFirstLine = cursor.LineOffset; + } + + // Consume the line break. + + breaks.Append(ReadLine()); + + end = cursor.Mark(); + } + + // Check if first line after literal is all spaces and count of spaces is more than "1 + currentIndent". + + if (isLiteral && indentOfFirstLine > 1 && currentIndent < indentOfFirstLine - 1) + { + // W9L4 + throw new SemanticErrorException(end, cursor.Mark(), "While scanning a literal block scalar, found extra spaces in first line."); + } + + if (!isLiteral && maxIndent > cursor.LineOffset && indentOfFirstLine > -1) + { + // S98Z + throw new SemanticErrorException(end, cursor.Mark(), "While scanning a literal block scalar, found more spaces in lines above first content line."); + } + + // Determine the indentation level if needed. + + if (currentIndent == 0 && (cursor.LineOffset > 0 || indent > -1)) + { + currentIndent = Math.Max(maxIndent, Math.Max(indent + 1, 1)); + } + + return currentIndent; + } + + /// + /// Produce the SCALAR(...,single-quoted) or SCALAR(...,double-quoted) tokens. + /// + + private void FetchFlowScalar(bool isSingleQuoted) + { + // A plain scalar could be a simple key. + + SaveSimpleKey(); + + // A simple key cannot follow a flow scalar. + + simpleKeyAllowed = false; + + // Create the SCALAR token and append it to the queue. + + tokens.Enqueue(ScanFlowScalar(isSingleQuoted)); + + // Check if there is a comment subsequently after double-quoted scalar without space. + + if (!isSingleQuoted && analyzer.Check('#')) + { + var start = cursor.Mark(); + tokens.Enqueue(new Error("While scanning a flow sequence end, found invalid comment after double-quoted scalar.", start, start)); + } + } + + /// + /// Scan a quoted scalar. + /// + + private Token ScanFlowScalar(bool isSingleQuoted) + { + // Eat the left quote. + + var start = cursor.Mark(); + + Skip(); + + // Consume the content of the quoted scalar. + + var value = new StringBuilder(); + var whitespaces = new StringBuilder(); + var leadingBreak = new StringBuilder(); + var trailingBreaks = new StringBuilder(); + var hasLeadingBlanks = false; + + while (true) + { + // Check that there are no document indicators at the beginning of the line. + + if (IsDocumentIndicator()) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a quoted scalar, found unexpected document indicator."); + } + + // Check for EOF. + + if (analyzer.IsZero()) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a quoted scalar, found unexpected end of stream."); + } + + if (hasLeadingBlanks && !isSingleQuoted && indent >= cursor.LineOffset) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a multi-line double-quoted scalar, found wrong indentation."); + } + + hasLeadingBlanks = false; + + // Consume non-blank characters. + + while (!analyzer.IsWhiteBreakOrZero()) + { + // Check for an escaped single quote. + + if (isSingleQuoted && analyzer.Check('\'', 0) && analyzer.Check('\'', 1)) + { + value.Append('\''); + Skip(); + Skip(); + } + + // Check for the right quote. + + else if (analyzer.Check(isSingleQuoted ? '\'' : '"')) + { + break; + } + + // Check for an escaped line break. + + else if (!isSingleQuoted && analyzer.Check('\\') && analyzer.IsBreak(1)) + { + Skip(); + SkipLine(); + hasLeadingBlanks = true; + break; + } + + // Check for an escape sequence. + + else if (!isSingleQuoted && analyzer.Check('\\')) + { + var codeLength = 0; + + // Check the escape character. + + var escapeCharacter = analyzer.Peek(1); + switch (escapeCharacter) + { + case 'x': + codeLength = 2; + break; + + case 'u': + codeLength = 4; + break; + + case 'U': + codeLength = 8; + break; + + default: + char unescapedCharacter; + if (SimpleEscapeCodes.TryGetValue(escapeCharacter, out unescapedCharacter)) + { + value.Append(unescapedCharacter); + } + else + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a quoted scalar, found unknown escape character."); + } + break; + } + + Skip(); + Skip(); + + // Consume an arbitrary escape code. + + if (codeLength > 0) + { + var character = 0; + + // Scan the character value. + + for (var k = 0; k < codeLength; ++k) + { + if (!analyzer.IsHex(k)) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a quoted scalar, did not find expected hexadecimal number."); + } + character = ((character << 4) + analyzer.AsHex(k)); + } + + // Check the value and write the character. + + if ((character >= 0xD800 && character <= 0xDFFF) || character > 0x10FFFF) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a quoted scalar, found invalid Unicode character escape code."); + } + + value.Append(char.ConvertFromUtf32(character)); + + // Advance the pointer. + + for (var k = 0; k < codeLength; ++k) + { + Skip(); + } + } + } + else + { + // It is a non-escaped non-blank character. + + value.Append(ReadCurrentCharacter()); + } + } + + // Check if we are at the end of the scalar. + + if (analyzer.Check(isSingleQuoted ? '\'' : '"')) + { + break; + } + + // Consume blank characters. + + while (analyzer.IsWhite() || analyzer.IsBreak()) + { + if (analyzer.IsWhite()) + { + // Consume a space or a tab character. + + if (!hasLeadingBlanks) + { + whitespaces.Append(ReadCurrentCharacter()); + } + else + { + Skip(); + } + } + else + { + // Check if it is a first line break. + + if (!hasLeadingBlanks) + { + whitespaces.Length = 0; + leadingBreak.Append(ReadLine()); + hasLeadingBlanks = true; + } + else + { + trailingBreaks.Append(ReadLine()); + } + } + } + + // Join the whitespaces or fold line breaks. + + if (hasLeadingBlanks) + { + // Do we need to fold line breaks? + + if (StartsWith(leadingBreak, '\n')) + { + if (trailingBreaks.Length == 0) + { + value.Append(' '); + } + else + { + value.Append(trailingBreaks.ToString()); + } + } + else + { + value.Append(leadingBreak.ToString()); + value.Append(trailingBreaks.ToString()); + } + leadingBreak.Length = 0; + trailingBreaks.Length = 0; + } + else + { + value.Append(whitespaces.ToString()); + whitespaces.Length = 0; + } + } + + // Eat the right quote. + + Skip(); + + return new Scalar(value.ToString(), isSingleQuoted ? ScalarStyle.SingleQuoted : ScalarStyle.DoubleQuoted, start, cursor.Mark()); + } + + /// + /// Produce the SCALAR(...,plain) token. + /// + + private void FetchPlainScalar() + { + // A plain scalar could be a simple key. + + SaveSimpleKey(); + + // A simple key cannot follow a flow scalar. + + simpleKeyAllowed = false; + + // Create the SCALAR token and append it to the queue. + var isMultiline = false; + var scalar = ScanPlainScalar(ref isMultiline); + + if (isMultiline && analyzer.Check(':') && flowLevel == 0 && indent < cursor.LineOffset) + { + tokens.Enqueue(new Error("While scanning a multiline plain scalar, found invalid mapping.", cursor.Mark(), cursor.Mark())); + } + tokens.Enqueue(scalar); + } + + /// + /// Scan a plain scalar. + /// + + private Scalar ScanPlainScalar(ref bool isMultiline) + { + var value = new StringBuilder(); + var whitespaces = new StringBuilder(); + var leadingBreak = new StringBuilder(); + var trailingBreaks = new StringBuilder(); + + var hasLeadingBlanks = false; + var currentIndent = indent + 1; + + var start = cursor.Mark(); + var end = start; + + var key = simpleKeys.Peek(); + + // Consume the content of the plain scalar. + + while (true) + { + // Check for a document indicator. + + if (IsDocumentIndicator()) + { + break; + } + + // Check for a comment. + + if (analyzer.Check('#')) + { + if (indent < 0 && flowLevel == 0) + { + plainScalarFollowedByComment = true; + } + break; + } + + var isAliasValue = analyzer.Check('*') && !(key.IsPossible && key.IsRequired); + + // Consume non-blank characters. + while (!analyzer.IsWhiteBreakOrZero()) + { + // Check for indicators that may end a plain scalar. + + if (analyzer.Check(':') && !isAliasValue && (analyzer.IsWhiteBreakOrZero(1) || (flowLevel > 0 && analyzer.Check(',', 1))) || (flowLevel > 0 && analyzer.Check(",?[]{}"))) + { + if (flowLevel == 0 && !key.IsPossible) + { + tokens.Enqueue(new Error("While scanning a plain scalar value, found invalid mapping.", cursor.Mark(), cursor.Mark())); + } + break; + } + + // Check if we need to join whitespaces and breaks. + + if (hasLeadingBlanks || whitespaces.Length > 0) + { + if (hasLeadingBlanks) + { + // Do we need to fold line breaks? + + if (StartsWith(leadingBreak, '\n')) + { + if (trailingBreaks.Length == 0) + { + value.Append(' '); + } + else + { + value.Append(trailingBreaks); + } + } + else + { + value.Append(leadingBreak); + value.Append(trailingBreaks); + } + + leadingBreak.Length = 0; + trailingBreaks.Length = 0; + + hasLeadingBlanks = false; + } + else + { + value.Append(whitespaces); + whitespaces.Length = 0; + } + } + if (flowLevel > 0 && cursor.LineOffset < currentIndent) + { + throw new Exception(); + } + // Copy the character. + + value.Append(ReadCurrentCharacter()); + + end = cursor.Mark(); + } + + // Is it the end? + + if (!(analyzer.IsWhite() || analyzer.IsBreak())) + { + break; + } + + // Consume blank characters. + + while (analyzer.IsWhite() || analyzer.IsBreak()) + { + if (analyzer.IsWhite()) + { + // Check for tab character that abuse indentation. + + if (hasLeadingBlanks && cursor.LineOffset < currentIndent && analyzer.IsTab()) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a plain scalar, found a tab character that violate indentation."); + } + + // Consume a space or a tab character. + + if (!hasLeadingBlanks) + { + whitespaces.Append(ReadCurrentCharacter()); + } + else + { + Skip(); + } + } + else + { + isMultiline = true; + + // Check if it is a first line break. + + if (!hasLeadingBlanks) + { + whitespaces.Length = 0; + leadingBreak.Append(ReadLine()); + hasLeadingBlanks = true; + } + else + { + trailingBreaks.Append(ReadLine()); + } + } + } + + // Check indentation level. + + if (flowLevel == 0 && cursor.LineOffset < currentIndent) + { + break; + } + } + + // Note that we change the 'simple_key_allowed' flag. + + if (hasLeadingBlanks) + { + simpleKeyAllowed = true; + } + + // Create a token. + + return new Scalar(value.ToString(), ScalarStyle.Plain, start, end); + } + + + /// + /// Remove a potential simple key at the current flow level. + /// + + private void RemoveSimpleKey() + { + var key = simpleKeys.Peek(); + + if (key.IsPossible && key.IsRequired) + { + // If the key is required, it is an error. + + throw new SyntaxErrorException(key.Mark, key.Mark, "While scanning a simple key, could not find expected ':'."); + } + + // Remove the key from the stack. + + key.MarkAsImpossible(); + } + + /// + /// Scan the directive name. + /// + /// Scope: + /// %YAML 1.1 # a comment \n + /// ^^^^ + /// %TAG !yaml! tag:yaml.org,2002: \n + /// ^^^ + /// + private string ScanDirectiveName(Mark start) + { + var name = new StringBuilder(); + + // Consume the directive name. + + while (analyzer.IsAlphaNumericDashOrUnderscore()) + { + name.Append(ReadCurrentCharacter()); + } + + // Check if the name is empty. + + if (name.Length == 0) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a directive, could not find expected directive name."); + } + + // Check for an blank character after the name. + + if (!analyzer.IsWhiteBreakOrZero()) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a directive, found unexpected non-alphabetical character."); + } + + return name.ToString(); + } + + private void SkipWhitespaces() + { + // Eat whitespaces. + + while (analyzer.IsWhite()) + { + Skip(); + } + } + + /// + /// Scan the value of VERSION-DIRECTIVE. + /// + /// Scope: + /// %YAML 1.1 # a comment \n + /// ^^^^^^ + /// + private Token ScanVersionDirectiveValue(Mark start) + { + SkipWhitespaces(); + + // Consume the major version number. + + var major = ScanVersionDirectiveNumber(start); + + // Eat '.'. + + if (!analyzer.Check('.')) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a %YAML directive, did not find expected digit or '.' character."); + } + + Skip(); + + // Consume the minor version number. + + var minor = ScanVersionDirectiveNumber(start); + + return new VersionDirective(new Version(major, minor), start, start); + } + + /// + /// Scan the value of a TAG-DIRECTIVE token. + /// + /// Scope: + /// %TAG !yaml! tag:yaml.org,2002: \n + /// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + /// + private Token ScanTagDirectiveValue(Mark start) + { + SkipWhitespaces(); + + // Scan a handle. + + var handle = ScanTagHandle(true, start); + + // Expect a whitespace. + + if (!analyzer.IsWhite()) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a %TAG directive, did not find expected whitespace."); + } + + SkipWhitespaces(); + + // Scan a prefix. + + var prefix = ScanTagUri(null, start); + + // Expect a whitespace or line break. + + if (!analyzer.IsWhiteBreakOrZero()) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a %TAG directive, did not find expected whitespace or line break."); + } + + return new TagDirective(handle, prefix, start, start); + } + + /// + /// Scan a tag. + /// + + private string ScanTagUri(string? head, Mark start) + { + var tag = new StringBuilder(); + if (head != null && head.Length > 1) + { + tag.Append(head.Substring(1)); + } + + // Scan the tag. + + // The set of characters that may appear in URI is as follows: + + // '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&', + // '=', '+', '$', ',', '.', '!', '~', '*', '\'', '(', ')', '[', ']', + // '%'. + + + while (analyzer.IsAlphaNumericDashOrUnderscore() || analyzer.Check(";/?:@&=+$.!~*'()[]%") || + (analyzer.Check(',') && !analyzer.IsBreak(1))) + { + // Check if it is a URI-escape sequence. + + if (analyzer.Check('%')) + { + tag.Append(ScanUriEscapes(start)); + } + else if (analyzer.Check('+')) + { + tag.Append(' '); + Skip(); + } + else + { + tag.Append(ReadCurrentCharacter()); + } + } + + // Check if the tag is non-empty. + + if (tag.Length == 0) + { + return string.Empty; + } + + return tag.ToString(); + } + + private static readonly byte[] EmptyBytes = new byte[0]; + + /// + /// Decode an URI-escape sequence corresponding to a single UTF-8 character. + /// + + private string ScanUriEscapes(Mark start) + { + // Decode the required number of characters. + + var charBytes = EmptyBytes; + var nextInsertionIndex = 0; + var width = 0; + do + { + // Check for a URI-escaped octet. + + if (!(analyzer.Check('%') && analyzer.IsHex(1) && analyzer.IsHex(2))) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a tag, did not find URI escaped octet."); + } + + // Get the octet. + + var octet = (analyzer.AsHex(1) << 4) + analyzer.AsHex(2); + + // If it is the leading octet, determine the length of the UTF-8 sequence. + + if (width == 0) + { + width = (octet & 0x80) == 0x00 ? 1 : + (octet & 0xE0) == 0xC0 ? 2 : + (octet & 0xF0) == 0xE0 ? 3 : + (octet & 0xF8) == 0xF0 ? 4 : 0; + + if (width == 0) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a tag, found an incorrect leading UTF-8 octet."); + } + + charBytes = new byte[width]; + } + else + { + // Check if the trailing octet is correct. + + if ((octet & 0xC0) != 0x80) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a tag, found an incorrect trailing UTF-8 octet."); + } + } + + // Copy the octet and move the pointers. + + charBytes[nextInsertionIndex++] = (byte)octet; + + Skip(); + Skip(); + Skip(); + } + while (--width > 0); + + var result = Encoding.UTF8.GetString(charBytes, 0, nextInsertionIndex); + + if (result.Length == 0 || result.Length > 2) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a tag, found an incorrect UTF-8 sequence."); + } + + return result; + } + + /// + /// Scan a tag handle. + /// + + private string ScanTagHandle(bool isDirective, Mark start) + { + + // Check the initial '!' character. + + if (!analyzer.Check('!')) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a tag, did not find expected '!'."); + } + + // Copy the '!' character. + + var tagHandle = new StringBuilder(); + tagHandle.Append(ReadCurrentCharacter()); + + // Copy all subsequent alphabetical and numerical characters. + + while (analyzer.IsAlphaNumericDashOrUnderscore()) + { + tagHandle.Append(ReadCurrentCharacter()); + } + + // Check if the trailing character is '!' and copy it. + + if (analyzer.Check('!')) + { + tagHandle.Append(ReadCurrentCharacter()); + } + else + { + + // It's either the '!' tag or not really a tag handle. If it's a %TAG + // directive, it's an error. If it's a tag token, it must be a part of + // URI. + + + if (isDirective && (tagHandle.Length != 1 || tagHandle[0] != '!')) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a tag directive, did not find expected '!'."); + } + } + + return tagHandle.ToString(); + } + + /// + /// Scan the version number of VERSION-DIRECTIVE. + /// + /// Scope: + /// %YAML 1.1 # a comment \n + /// ^ + /// %YAML 1.1 # a comment \n + /// ^ + /// + private int ScanVersionDirectiveNumber(Mark start) + { + var value = 0; + var length = 0; + + // Repeat while the next character is digit. + + while (analyzer.IsDigit()) + { + // Check if the number is too long. + + if (++length > MaxVersionNumberLength) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a %YAML directive, found extremely long version number."); + } + + value = value * 10 + analyzer.AsDigit(); + + Skip(); + } + + // Check if the number was present. + + if (length == 0) + { + throw new SyntaxErrorException(start, cursor.Mark(), "While scanning a %YAML directive, did not find expected version number."); + } + + return value; + } + + /// + /// Check if a simple key may start at the current position and add it if + /// needed. + /// + + private void SaveSimpleKey() + { + + // A simple key is required at the current position if the scanner is in + // the block context and the current column coincides with the indentation + // level. + + + var isRequired = (flowLevel == 0 && indent == cursor.LineOffset); + + + // A simple key is required only when it is the first token in the current + // line. Therefore it is always allowed. But we add a check anyway. + + + Debug.Assert(simpleKeyAllowed || !isRequired, "Can't require a simple key and disallow it at the same time."); // Impossible. + + + // If the current position may start a simple key, save it. + + + if (simpleKeyAllowed) + { + var key = new SimpleKey(isRequired, tokensParsed + tokens.Count, cursor); + + RemoveSimpleKey(); + + simpleKeys.Pop(); + simpleKeys.Push(key); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Scanner.cs.meta b/namedropper/Assets/YamlDotNet/Core/Scanner.cs.meta new file mode 100644 index 0000000..bcdc2a1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Scanner.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c0682a65176cd1c42807d5c990f0cc8f +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/SemanticErrorException.cs b/namedropper/Assets/YamlDotNet/Core/SemanticErrorException.cs new file mode 100644 index 0000000..526f1c6 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/SemanticErrorException.cs @@ -0,0 +1,58 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core +{ + /// + /// Exception that is thrown when a semantic error is detected on a YAML stream. + /// + public class SemanticErrorException : YamlException + { + /// + /// Initializes a new instance of the class. + /// + /// The message. + public SemanticErrorException(string message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class. + /// + public SemanticErrorException(Mark start, Mark end, string message) + : base(start, end, message) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The message. + /// The inner. + public SemanticErrorException(string message, Exception inner) + : base(message, inner) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/SemanticErrorException.cs.meta b/namedropper/Assets/YamlDotNet/Core/SemanticErrorException.cs.meta new file mode 100644 index 0000000..75d3846 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/SemanticErrorException.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ce6eb4a71fe0a504cb2efded3a4ad217 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/SimpleKey.cs b/namedropper/Assets/YamlDotNet/Core/SimpleKey.cs new file mode 100644 index 0000000..f7f31ad --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/SimpleKey.cs @@ -0,0 +1,56 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core +{ + internal sealed class SimpleKey + { + private readonly Cursor cursor; + + public bool IsPossible { get; private set; } + + public void MarkAsImpossible() + { + IsPossible = false; + } + + public bool IsRequired { get; } + public int TokenNumber { get; } + public int Index => cursor.Index; + public int Line => cursor.Line; + public int LineOffset => cursor.LineOffset; + + public Mark Mark => cursor.Mark(); + + public SimpleKey() + { + cursor = new Cursor(); + } + + public SimpleKey(bool isRequired, int tokenNumber, Cursor cursor) + { + IsPossible = true; + IsRequired = isRequired; + TokenNumber = tokenNumber; + this.cursor = new Cursor(cursor); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/SimpleKey.cs.meta b/namedropper/Assets/YamlDotNet/Core/SimpleKey.cs.meta new file mode 100644 index 0000000..60f23e7 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/SimpleKey.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 98526770a341dd64aaf15fb3fe79a6c1 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/StringLookAheadBuffer.cs b/namedropper/Assets/YamlDotNet/Core/StringLookAheadBuffer.cs new file mode 100644 index 0000000..38640c7 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/StringLookAheadBuffer.cs @@ -0,0 +1,61 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core +{ + internal sealed class StringLookAheadBuffer : ILookAheadBuffer + { + private readonly string value; + + public int Position { get; private set; } + + public StringLookAheadBuffer(string value) + { + this.value = value; + } + + public int Length => value.Length; + + public bool EndOfInput => IsOutside(Position); + + public char Peek(int offset) + { + var index = Position + offset; + return IsOutside(index) ? '\0' : value[index]; + } + + private bool IsOutside(int index) + { + return index >= value.Length; + } + + public void Skip(int length) + { + if (length < 0) + { + throw new ArgumentOutOfRangeException(nameof(length), "The length must be positive."); + } + Position += length; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/StringLookAheadBuffer.cs.meta b/namedropper/Assets/YamlDotNet/Core/StringLookAheadBuffer.cs.meta new file mode 100644 index 0000000..ed006f9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/StringLookAheadBuffer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b821a24261c0caf46b4f2267068dfa19 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/SyntaxErrorException.cs b/namedropper/Assets/YamlDotNet/Core/SyntaxErrorException.cs new file mode 100644 index 0000000..343e35d --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/SyntaxErrorException.cs @@ -0,0 +1,58 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core +{ + /// + /// Exception that is thrown when a syntax error is detected on a YAML stream. + /// + public sealed class SyntaxErrorException : YamlException + { + /// + /// Initializes a new instance of the class. + /// + /// The message. + public SyntaxErrorException(string message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class. + /// + public SyntaxErrorException(Mark start, Mark end, string message) + : base(start, end, message) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The message. + /// The inner. + public SyntaxErrorException(string message, Exception inner) + : base(message, inner) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/SyntaxErrorException.cs.meta b/namedropper/Assets/YamlDotNet/Core/SyntaxErrorException.cs.meta new file mode 100644 index 0000000..64413af --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/SyntaxErrorException.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fd15bbcb74a3b3c49bcbbc67093b631d +timeCreated: 1427145267 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/TagDirectiveCollection.cs b/namedropper/Assets/YamlDotNet/Core/TagDirectiveCollection.cs new file mode 100644 index 0000000..7c79a4a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/TagDirectiveCollection.cs @@ -0,0 +1,63 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Collections.Generic; +using System.Collections.ObjectModel; +using YamlDotNet.Core.Tokens; + +namespace YamlDotNet.Core +{ + /// + /// Collection of . + /// + public sealed class TagDirectiveCollection : KeyedCollection + { + /// + /// Initializes a new instance of the class. + /// + public TagDirectiveCollection() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Initial content of the collection. + public TagDirectiveCollection(IEnumerable tagDirectives) + { + foreach (var tagDirective in tagDirectives) + { + Add(tagDirective); + } + } + + /// + protected override string GetKeyForItem(TagDirective item) => item.Handle; + + /// + /// Gets a value indicating whether the collection contains a directive with the same handle + /// + public new bool Contains(TagDirective directive) + { + return Contains(GetKeyForItem(directive)); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/TagDirectiveCollection.cs.meta b/namedropper/Assets/YamlDotNet/Core/TagDirectiveCollection.cs.meta new file mode 100644 index 0000000..e5595d9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/TagDirectiveCollection.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c5901f69158709e4395e0e73e80c1fc2 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/TagName.cs b/namedropper/Assets/YamlDotNet/Core/TagName.cs new file mode 100644 index 0000000..029a126 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/TagName.cs @@ -0,0 +1,91 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core +{ + public struct TagName : IEquatable + { + public static readonly TagName Empty = default; + + private readonly string? value; + + public string Value => value ?? throw new InvalidOperationException("Cannot read the Value of a non-specific tag"); + + public bool IsEmpty => value is null; + public bool IsNonSpecific => !IsEmpty && (value == "!" || value == "?"); + + public bool IsLocal => !IsEmpty && Value[0] == '!'; + public bool IsGlobal => !IsEmpty && !IsLocal; + + public TagName(string value) + { + this.value = value ?? throw new ArgumentNullException(nameof(value)); + + if (value.Length == 0) + { + throw new ArgumentException("Tag value must not be empty.", nameof(value)); + } + + if (IsGlobal && !Uri.IsWellFormedUriString(value, UriKind.RelativeOrAbsolute)) + { + throw new ArgumentException("Global tags must be valid URIs.", nameof(value)); + } + } + + public override string ToString() => value ?? "?"; + + public bool Equals(TagName other) => Equals(value, other.value); + + public override bool Equals(object? obj) + { + return obj is TagName other && Equals(other); + } + + public override int GetHashCode() + { + return value?.GetHashCode() ?? 0; + } + + public static bool operator ==(TagName left, TagName right) + { + return left.Equals(right); + } + + public static bool operator !=(TagName left, TagName right) + { + return !(left == right); + } + + public static bool operator ==(TagName left, string right) + { + return Equals(left.value, right); + } + + public static bool operator !=(TagName left, string right) + { + return !(left == right); + } + + public static implicit operator TagName(string? value) => value == null ? Empty : new TagName(value); + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/TagName.cs.meta b/namedropper/Assets/YamlDotNet/Core/TagName.cs.meta new file mode 100644 index 0000000..37cc45e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/TagName.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e15a0d535bb828c44a4c8f100a295d0a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens.meta b/namedropper/Assets/YamlDotNet/Core/Tokens.meta new file mode 100644 index 0000000..542e99e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ae5f76f5c7a9e1849837fbe903e177c2 +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Anchor.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/Anchor.cs new file mode 100644 index 0000000..630211c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Anchor.cs @@ -0,0 +1,62 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents an anchor token. + /// + public class Anchor : Token + { + /// + /// Gets the value. + /// + /// The value. + public AnchorName Value { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The value. + public Anchor(AnchorName value) + : this(value, Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The value. + /// The start position of the token. + /// The end position of the token. + public Anchor(AnchorName value, Mark start, Mark end) + : base(start, end) + { + if (value.IsEmpty) + { + throw new ArgumentNullException(nameof(value)); + } + this.Value = value; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Anchor.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/Anchor.cs.meta new file mode 100644 index 0000000..ecf6119 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Anchor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 20dff0ad997e6bf4fb74167f52869056 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/AnchorAlias.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/AnchorAlias.cs new file mode 100644 index 0000000..d542d81 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/AnchorAlias.cs @@ -0,0 +1,61 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents an alias token. + /// + public sealed class AnchorAlias : Token + { + /// + /// Gets the value of the alias. + /// + public AnchorName Value { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The value of the anchor. + public AnchorAlias(AnchorName value) + : this(value, Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The value of the anchor. + /// The start position of the event. + /// The end position of the event. + public AnchorAlias(AnchorName value, Mark start, Mark end) + : base(start, end) + { + if (value.IsEmpty) + { + throw new ArgumentNullException(nameof(value)); + } + this.Value = value; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/AnchorAlias.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/AnchorAlias.cs.meta new file mode 100644 index 0000000..ce4e5aa --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/AnchorAlias.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5888a3fb8858cd9419759f27390f4801 +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/BlockEnd.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockEnd.cs new file mode 100644 index 0000000..9eda394 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockEnd.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a block end token. + /// + public sealed class BlockEnd : Token + { + /// + /// Initializes a new instance of the class. + /// + public BlockEnd() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public BlockEnd(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/BlockEnd.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockEnd.cs.meta new file mode 100644 index 0000000..4233d42 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockEnd.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0ac69775d00ee4d4ba4b918c06086302 +timeCreated: 1427145262 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/BlockEntry.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockEntry.cs new file mode 100644 index 0000000..26a0e29 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockEntry.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a block entry event. + /// + public sealed class BlockEntry : Token + { + /// + /// Initializes a new instance of the class. + /// + public BlockEntry() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public BlockEntry(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/BlockEntry.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockEntry.cs.meta new file mode 100644 index 0000000..9c5e1e2 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockEntry.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c3a1850190300d5479da07fdb53767f0 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/BlockMappingStart.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockMappingStart.cs new file mode 100644 index 0000000..022671e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockMappingStart.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a block mapping start token. + /// + public sealed class BlockMappingStart : Token + { + /// + /// Initializes a new instance of the class. + /// + public BlockMappingStart() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public BlockMappingStart(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/BlockMappingStart.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockMappingStart.cs.meta new file mode 100644 index 0000000..b620483 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockMappingStart.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9f8bc35d16193164aaee492bc767e9f8 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/BlockSequenceStart.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockSequenceStart.cs new file mode 100644 index 0000000..8b574c7 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockSequenceStart.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a block sequence start token. + /// + public sealed class BlockSequenceStart : Token + { + /// + /// Initializes a new instance of the class. + /// + public BlockSequenceStart() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public BlockSequenceStart(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/BlockSequenceStart.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockSequenceStart.cs.meta new file mode 100644 index 0000000..fc4ef44 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/BlockSequenceStart.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 827b4413642f10d4891e4b1771c5ad45 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Comment.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/Comment.cs new file mode 100644 index 0000000..9d77b19 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Comment.cs @@ -0,0 +1,59 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a comment + /// + public sealed class Comment : Token + { + /// + /// Gets the value of the comment + /// + public string Value { get; } + + /// + /// Gets a value indicating whether the comment appears other tokens on that line. + /// + public bool IsInline { get; } + + /// + /// Initializes a new instance of the class. + /// + public Comment(string value, bool isInline) + : this(value, isInline, Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + public Comment(string value, bool isInline, Mark start, Mark end) + : base(start, end) + { + Value = value ?? throw new ArgumentNullException(nameof(value)); + IsInline = isInline; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Comment.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/Comment.cs.meta new file mode 100644 index 0000000..4dc0be9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Comment.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7faa8193237a87f41aa6e2a84836b348 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/DocumentEnd.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/DocumentEnd.cs new file mode 100644 index 0000000..357d8d3 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/DocumentEnd.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a document end token. + /// + public sealed class DocumentEnd : Token + { + /// + /// Initializes a new instance of the class. + /// + public DocumentEnd() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public DocumentEnd(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/DocumentEnd.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/DocumentEnd.cs.meta new file mode 100644 index 0000000..8cec158 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/DocumentEnd.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b70a27ee4c4c7c24e9df5b0ec3a2c6da +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/DocumentStart.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/DocumentStart.cs new file mode 100644 index 0000000..b1a6651 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/DocumentStart.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a document start token. + /// + public sealed class DocumentStart : Token + { + /// + /// Initializes a new instance of the class. + /// + public DocumentStart() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public DocumentStart(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/DocumentStart.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/DocumentStart.cs.meta new file mode 100644 index 0000000..c490ffa --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/DocumentStart.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2c86a143ce13faf4e90cece89b865c8a +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Error.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/Error.cs new file mode 100644 index 0000000..1f924f5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Error.cs @@ -0,0 +1,40 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Base class for YAML tokens. + /// + internal class Error : Token + { + /// + /// Gets the value of the comment + /// + internal string Value { get; } + + internal Error(string value, Mark start, Mark end) + : base(start, end) + { + Value = value; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Error.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/Error.cs.meta new file mode 100644 index 0000000..d228ead --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Error.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e436b2b70e29aee4eb8759edbc3303de +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/FlowEntry.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowEntry.cs new file mode 100644 index 0000000..5f9f191 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowEntry.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a flow entry event. + /// + public sealed class FlowEntry : Token + { + /// + /// Initializes a new instance of the class. + /// + public FlowEntry() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public FlowEntry(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/FlowEntry.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowEntry.cs.meta new file mode 100644 index 0000000..0c22fad --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowEntry.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f6de9d5d89c756c49882403cf8b79eed +timeCreated: 1427145267 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingEnd.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingEnd.cs new file mode 100644 index 0000000..18f11a3 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingEnd.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a flow mapping end token. + /// + public sealed class FlowMappingEnd : Token + { + /// + /// Initializes a new instance of the class. + /// + public FlowMappingEnd() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public FlowMappingEnd(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingEnd.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingEnd.cs.meta new file mode 100644 index 0000000..b3c7d58 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingEnd.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6e66c86850cf7a545bfa90d7c9b1831a +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingStart.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingStart.cs new file mode 100644 index 0000000..32e4f9f --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingStart.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a flow mapping start token. + /// + public sealed class FlowMappingStart : Token + { + /// + /// Initializes a new instance of the class. + /// + public FlowMappingStart() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public FlowMappingStart(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingStart.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingStart.cs.meta new file mode 100644 index 0000000..24f8528 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowMappingStart.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d357652b21a405949a837dbef084c7e3 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceEnd.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceEnd.cs new file mode 100644 index 0000000..94b00eb --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceEnd.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a flow sequence end token. + /// + public sealed class FlowSequenceEnd : Token + { + /// + /// Initializes a new instance of the class. + /// + public FlowSequenceEnd() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public FlowSequenceEnd(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceEnd.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceEnd.cs.meta new file mode 100644 index 0000000..14a5fb8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceEnd.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5338410489b921f4c873cbed0c5b7754 +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceStart.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceStart.cs new file mode 100644 index 0000000..5bb2cf2 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceStart.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a flow sequence start token. + /// + public sealed class FlowSequenceStart : Token + { + /// + /// Initializes a new instance of the class. + /// + public FlowSequenceStart() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public FlowSequenceStart(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceStart.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceStart.cs.meta new file mode 100644 index 0000000..54f8b33 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/FlowSequenceStart.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8248df61d7f1e7e4fbd6db14a760c5cd +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Key.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/Key.cs new file mode 100644 index 0000000..ca984b2 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Key.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a key token. + /// + public sealed class Key : Token + { + /// + /// Initializes a new instance of the class. + /// + public Key() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public Key(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Key.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/Key.cs.meta new file mode 100644 index 0000000..68d9568 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Key.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d3197efde30ce804d81b7698c3c9c5a6 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Scalar.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/Scalar.cs new file mode 100644 index 0000000..9bce4be --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Scalar.cs @@ -0,0 +1,77 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + + +using System; + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a scalar token. + /// + public sealed class Scalar : Token + { + /// + /// Gets the value. + /// + /// The value. + public string Value { get; } + + /// + /// Gets the style. + /// + /// The style. + public ScalarStyle Style { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The value. + public Scalar(string value) + : this(value, ScalarStyle.Any) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The value. + /// The style. + public Scalar(string value, ScalarStyle style) + : this(value, style, Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The value. + /// The style. + /// The start position of the token. + /// The end position of the token. + public Scalar(string value, ScalarStyle style, Mark start, Mark end) + : base(start, end) + { + this.Value = value ?? throw new ArgumentNullException(nameof(value)); + this.Style = style; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Scalar.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/Scalar.cs.meta new file mode 100644 index 0000000..6c2c716 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Scalar.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d8a37767e1f6b1949b357766c6f98776 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/StreamEnd.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/StreamEnd.cs new file mode 100644 index 0000000..8dd97e0 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/StreamEnd.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a stream end event. + /// + public sealed class StreamEnd : Token + { + /// + /// Initializes a new instance of the class. + /// + public StreamEnd() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public StreamEnd(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/StreamEnd.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/StreamEnd.cs.meta new file mode 100644 index 0000000..cae53ef --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/StreamEnd.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7f214337aa3dd71439c3a1ee6e5ef79d +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/StreamStart.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/StreamStart.cs new file mode 100644 index 0000000..e420d4b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/StreamStart.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a stream start token. + /// + public sealed class StreamStart : Token + { + /// + /// Initializes a new instance of the class. + /// + public StreamStart() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public StreamStart(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/StreamStart.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/StreamStart.cs.meta new file mode 100644 index 0000000..3caeefa --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/StreamStart.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c0787d33a81177840836ef7dba3d0b75 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Tag.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/Tag.cs new file mode 100644 index 0000000..edf698c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Tag.cs @@ -0,0 +1,67 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a tag token. + /// + public sealed class Tag : Token + { + /// + /// Gets the handle. + /// + /// The handle. + public string Handle { get; } + + /// + /// Gets the suffix. + /// + /// The suffix. + public string Suffix { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The handle. + /// The suffix. + public Tag(string handle, string suffix) + : this(handle, suffix, Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The handle. + /// The suffix. + /// The start position of the token. + /// The end position of the token. + public Tag(string handle, string suffix, Mark start, Mark end) + : base(start, end) + { + this.Handle = handle ?? throw new ArgumentNullException(nameof(handle)); + this.Suffix = suffix ?? throw new ArgumentNullException(nameof(suffix)); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Tag.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/Tag.cs.meta new file mode 100644 index 0000000..2197cbd --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Tag.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2c6cb793327f6a349964aa8538bc1e33 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/TagDirective.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/TagDirective.cs new file mode 100644 index 0000000..0ee08e9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/TagDirective.cs @@ -0,0 +1,118 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Text.RegularExpressions; + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a tag directive token. + /// + public class TagDirective : Token + { + + /// + /// Gets the handle. + /// + /// The handle. + public string Handle { get; } + + /// + /// Gets the prefix. + /// + /// The prefix. + public string Prefix { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The handle. + /// The prefix. + public TagDirective(string handle, string prefix) + : this(handle, prefix, Mark.Empty, Mark.Empty) + { + } + + private static readonly Regex TagHandlePattern = new Regex(@"^!([0-9A-Za-z_\-]*!)?$", StandardRegexOptions.Compiled); + + /// + /// Initializes a new instance of the class. + /// + /// The handle. + /// The prefix. + /// The start position of the token. + /// The end position of the token. + public TagDirective(string handle, string prefix, Mark start, Mark end) + : base(start, end) + { + if (string.IsNullOrEmpty(handle)) + { + throw new ArgumentNullException(nameof(handle), "Tag handle must not be empty."); + } + + if (!TagHandlePattern.IsMatch(handle)) + { + throw new ArgumentException("Tag handle must start and end with '!' and contain alphanumerical characters only.", nameof(handle)); + } + + this.Handle = handle; + + if (string.IsNullOrEmpty(prefix)) + { + throw new ArgumentNullException(nameof(prefix), "Tag prefix must not be empty."); + } + + this.Prefix = prefix; + } + + /// + /// Determines whether the specified System.Object is equal to the current System.Object. + /// + /// The System.Object to compare with the current System.Object. + /// + /// true if the specified System.Object is equal to the current System.Object; otherwise, false. + /// + public override bool Equals(object? obj) + { + return obj is TagDirective other + && Handle.Equals(other.Handle) + && Prefix.Equals(other.Prefix); + } + + /// + /// Serves as a hash function for a particular type. + /// + /// + /// A hash code for the current . + /// + public override int GetHashCode() + { + return Handle.GetHashCode() ^ Prefix.GetHashCode(); + } + + /// + public override string ToString() + { + return $"{Handle} => {Prefix}"; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/TagDirective.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/TagDirective.cs.meta new file mode 100644 index 0000000..bb2a6b1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/TagDirective.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: dc25c68d7148e424ba5d875871c1aec8 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Token.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/Token.cs new file mode 100644 index 0000000..1f33573 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Token.cs @@ -0,0 +1,52 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Base class for YAML tokens. + /// + public abstract class Token + { + /// + /// Gets the start of the token in the input stream. + /// + public Mark Start { get; } + + /// + /// Gets the end of the token in the input stream. + /// + public Mark End { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + protected Token(Mark start, Mark end) + { + this.Start = start ?? throw new ArgumentNullException(nameof(start)); + this.End = end ?? throw new ArgumentNullException(nameof(end)); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Token.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/Token.cs.meta new file mode 100644 index 0000000..76a6fe9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Token.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9674e003fb73bba4cbf5ab487614a0d8 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Value.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/Value.cs new file mode 100644 index 0000000..ab10411 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Value.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a value token. + /// + public sealed class Value : Token + { + /// + /// Initializes a new instance of the class. + /// + public Value() + : this(Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The start position of the token. + /// The end position of the token. + public Value(Mark start, Mark end) + : base(start, end) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/Value.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/Value.cs.meta new file mode 100644 index 0000000..b4923ec --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/Value.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0fe0dfc9c858f2248a691e2f52bdfdff +timeCreated: 1427145262 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/VersionDirective.cs b/namedropper/Assets/YamlDotNet/Core/Tokens/VersionDirective.cs new file mode 100644 index 0000000..4b648ca --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/VersionDirective.cs @@ -0,0 +1,80 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Core.Tokens +{ + /// + /// Represents a version directive token. + /// + public sealed class VersionDirective : Token + { + /// + /// Gets the version. + /// + /// The version. + public Version Version { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The version. + public VersionDirective(Version version) + : this(version, Mark.Empty, Mark.Empty) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The version. + /// The start position of the token. + /// The end position of the token. + public VersionDirective(Version version, Mark start, Mark end) + : base(start, end) + { + this.Version = version; + } + + /// + /// Determines whether the specified System.Object is equal to the current System.Object. + /// + /// The System.Object to compare with the current System.Object. + /// + /// true if the specified System.Object is equal to the current System.Object; otherwise, false. + /// + public override bool Equals(object? obj) + { + return obj is VersionDirective other + && Version.Equals(other.Version); + } + + /// + /// Serves as a hash function for a particular type. + /// + /// + /// A hash code for the current . + /// + public override int GetHashCode() + { + return Version.GetHashCode(); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Tokens/VersionDirective.cs.meta b/namedropper/Assets/YamlDotNet/Core/Tokens/VersionDirective.cs.meta new file mode 100644 index 0000000..89b5f8f --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Tokens/VersionDirective.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5e236aab8cd03d94295778001f592ec1 +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/Version.cs b/namedropper/Assets/YamlDotNet/Core/Version.cs new file mode 100644 index 0000000..4a93c6e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Version.cs @@ -0,0 +1,82 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core +{ + /// + /// Specifies the version of the YAML language. + /// + public sealed class Version + { + /// + /// Gets the major version number. + /// + public int Major { get; } + + /// + /// Gets the minor version number. + /// + public int Minor { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The major version number. + /// The minor version number. + public Version(int major, int minor) + { + Major = major >= 0 + ? major + : throw new ArgumentOutOfRangeException(nameof(major), $"{major} should be >= 0"); + + Minor = minor >= 0 + ? minor + : throw new ArgumentOutOfRangeException(nameof(minor), $"{minor} should be >= 0"); + } + + /// + /// Determines whether the specified System.Object is equal to the current System.Object. + /// + /// The System.Object to compare with the current System.Object. + /// + /// true if the specified System.Object is equal to the current System.Object; otherwise, false. + /// + public override bool Equals(object? obj) + { + return obj is Version other + && Major == other.Major + && Minor == other.Minor; + } + + /// + /// Serves as a hash function for a particular type. + /// + /// + /// A hash code for the current . + /// + public override int GetHashCode() + { + return HashCode.CombineHashCodes(Major.GetHashCode(), Minor.GetHashCode()); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/Version.cs.meta b/namedropper/Assets/YamlDotNet/Core/Version.cs.meta new file mode 100644 index 0000000..1b08246 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/Version.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 03439ca56e1dbbc4882676e8255f06c1 +timeCreated: 1427145262 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Core/YamlException.cs b/namedropper/Assets/YamlDotNet/Core/YamlException.cs new file mode 100644 index 0000000..a151a62 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/YamlException.cs @@ -0,0 +1,83 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Core +{ + /// + /// Base exception that is thrown when the a problem occurs in the YamlDotNet library. + /// + public class YamlException : Exception + { + /// + /// Gets the position in the input stream where the event that originated the exception starts. + /// + public Mark Start { get; } + + /// + /// Gets the position in the input stream where the event that originated the exception ends. + /// + public Mark End { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The message. + public YamlException(string message) + : this(Mark.Empty, Mark.Empty, message) + { + } + + /// + /// Initializes a new instance of the class. + /// + public YamlException(Mark start, Mark end, string message) + : this(start, end, message, null) + { + } + + /// + /// Initializes a new instance of the class. + /// + public YamlException(Mark start, Mark end, string message, Exception? innerException) + : base(message, innerException) + { + Start = start; + End = end; + } + + /// + /// Initializes a new instance of the class. + /// + /// The message. + /// The inner. + public YamlException(string message, Exception inner) + : this(Mark.Empty, Mark.Empty, message, inner) + { + } + + public override string ToString() + { + return $"({Start}) - ({End}): {Message}"; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Core/YamlException.cs.meta b/namedropper/Assets/YamlDotNet/Core/YamlException.cs.meta new file mode 100644 index 0000000..f3e1948 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Core/YamlException.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 18ae75fcd5b1676418d42ac4d2c824c5 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Examples.meta b/namedropper/Assets/YamlDotNet/Examples.meta new file mode 100644 index 0000000..88c04bf --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f44c0df627c830e4d8e60525feb0c5a9 +folderAsset: yes +timeCreated: 1429640505 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Examples.unity b/namedropper/Assets/YamlDotNet/Examples.unity new file mode 100644 index 0000000..3497880 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples.unity @@ -0,0 +1,406 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641258, b: 0.5748172, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 0 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_MixedBakeMode: 1 + m_BakeBackend: 0 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 512 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 0 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 97992989} +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!850595691 &97992989 +LightingSettings: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Settings.lighting + serializedVersion: 3 + m_GIWorkflowMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_RealtimeEnvironmentLighting: 1 + m_BounceScale: 1 + m_AlbedoBoost: 1 + m_IndirectOutputScale: 1 + m_UsingShadowmask: 0 + m_BakeBackend: 0 + m_LightmapMaxSize: 1024 + m_BakeResolution: 40 + m_Padding: 2 + m_TextureCompression: 1 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 0 + m_CompAOExponentDirect: 0 + m_ExtractAO: 0 + m_MixedBakeMode: 1 + m_LightmapsBakeMode: 1 + m_FilterMode: 1 + m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0} + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_RealtimeResolution: 2 + m_ForceWhiteAlbedo: 0 + m_ForceUpdates: 0 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_FinalGatherFiltering: 1 + m_PVRCulling: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVREnvironmentSampleCount: 512 + m_PVREnvironmentReferencePointCount: 2048 + m_LightProbeSampleCountMultiplier: 4 + m_PVRBounces: 2 + m_PVRMinBounces: 2 + m_PVREnvironmentMIS: 0 + m_PVRFilteringMode: 0 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 +--- !u!1 &194276658 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 194276661} + - component: {fileID: 194276660} + - component: {fileID: 194276659} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &194276659 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 194276658} + m_Enabled: 1 +--- !u!20 &194276660 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 194276658} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &194276661 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 194276658} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &234401415 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 234401416} + - component: {fileID: 234401417} + m_Layer: 0 + m_Name: Play to run tests + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &234401416 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 234401415} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &234401417 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 234401415} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c7b67eba0ebbcd6418a881e3028c9901, type: 3} + m_Name: + m_EditorClassIdentifier: + disabledTests: [] +--- !u!1 &2047485421 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2047485423} + - component: {fileID: 2047485422} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &2047485422 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2047485421} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &2047485423 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2047485421} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} diff --git a/namedropper/Assets/YamlDotNet/Examples.unity.meta b/namedropper/Assets/YamlDotNet/Examples.unity.meta new file mode 100644 index 0000000..ad2de9a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a5b20befc03909345bd7d08158c02462 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Examples/ConvertYamlToJson.cs b/namedropper/Assets/YamlDotNet/Examples/ConvertYamlToJson.cs new file mode 100644 index 0000000..9a67d5b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/ConvertYamlToJson.cs @@ -0,0 +1,63 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.IO; +using Xunit.Abstractions; +using YamlDotNet.Samples.Helpers; +using YamlDotNet.Serialization; + +namespace YamlDotNet.Samples +{ + public class ConvertYamlToJson + { + private readonly ITestOutputHelper output; + + public ConvertYamlToJson(ITestOutputHelper output) + { + this.output = output; + } + + [Sample( + DisplayName = "Convert YAML to JSON", + Description = "Shows how to convert a YAML document to JSON." + )] + public void Main() + { + // convert string/file to YAML object + var r = new StringReader(@" +scalar: a scalar +sequence: + - one + - two +"); + var deserializer = new DeserializerBuilder().Build(); + var yamlObject = deserializer.Deserialize(r); + + var serializer = new SerializerBuilder() + .JsonCompatible() + .Build(); + + var json = serializer.Serialize(yamlObject); + + output.WriteLine(json); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Examples/ConvertYamlToJson.cs.meta b/namedropper/Assets/YamlDotNet/Examples/ConvertYamlToJson.cs.meta new file mode 100644 index 0000000..d8ec920 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/ConvertYamlToJson.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8614a029d313e6344a3ac93ddbd92dd2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Examples/DeserializeObjectGraph.cs b/namedropper/Assets/YamlDotNet/Examples/DeserializeObjectGraph.cs new file mode 100644 index 0000000..19b7593 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/DeserializeObjectGraph.cs @@ -0,0 +1,165 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.IO; +using Xunit.Abstractions; +using YamlDotNet.Samples.Helpers; +using YamlDotNet.Serialization; +using YamlDotNet.Serialization.NamingConventions; + +namespace YamlDotNet.Samples +{ + public class DeserializeObjectGraph + { + private readonly ITestOutputHelper output; + + public DeserializeObjectGraph(ITestOutputHelper output) + { + this.output = output; + } + + [Sample( + DisplayName = "Deserializing an object graph", + Description = "Shows how to convert a YAML document to an object graph." + )] + public void Main() + { + var input = new StringReader(Document); + + var deserializer = new DeserializerBuilder() + .WithNamingConvention(CamelCaseNamingConvention.Instance) + .Build(); + + var order = deserializer.Deserialize(input); + + output.WriteLine("Order"); + output.WriteLine("-----"); + output.WriteLine(); + foreach (var item in order.Items) + { + output.WriteLine("{0}\t{1}\t{2}\t{3}", item.PartNo, item.Quantity, item.Price, item.Descrip); + } + output.WriteLine(); + + output.WriteLine("Shipping"); + output.WriteLine("--------"); + output.WriteLine(); + output.WriteLine(order.ShipTo.Street); + output.WriteLine(order.ShipTo.City); + output.WriteLine(order.ShipTo.State); + output.WriteLine(); + + output.WriteLine("Billing"); + output.WriteLine("-------"); + output.WriteLine(); + if (order.BillTo == order.ShipTo) + { + output.WriteLine("*same as shipping address*"); + } + else + { + output.WriteLine(order.ShipTo.Street); + output.WriteLine(order.ShipTo.City); + output.WriteLine(order.ShipTo.State); + } + output.WriteLine(); + + output.WriteLine("Delivery instructions"); + output.WriteLine("---------------------"); + output.WriteLine(); + output.WriteLine(order.SpecialDelivery); + } + + public class Order + { + public string Receipt { get; set; } + public DateTime Date { get; set; } + public Customer Customer { get; set; } + public List Items { get; set; } + + [YamlMember(Alias = "bill-to", ApplyNamingConventions = false)] + public Address BillTo { get; set; } + + [YamlMember(Alias = "ship-to", ApplyNamingConventions = false)] + public Address ShipTo { get; set; } + + public string SpecialDelivery { get; set; } + } + + public class Customer + { + public string Given { get; set; } + public string Family { get; set; } + } + + public class OrderItem + { + [YamlMember(Alias = "part_no", ApplyNamingConventions = false)] + public string PartNo { get; set; } + public string Descrip { get; set; } + public decimal Price { get; set; } + public int Quantity { get; set; } + } + + public class Address + { + public string Street { get; set; } + public string City { get; set; } + public string State { get; set; } + } + + private const string Document = @"--- + receipt: Oz-Ware Purchase Invoice + date: 2007-08-06 + customer: + given: Dorothy + family: Gale + + items: + - part_no: A4786 + descrip: Water Bucket (Filled) + price: 1.47 + quantity: 4 + + - part_no: E1628 + descrip: High Heeled ""Ruby"" Slippers + price: 100.27 + quantity: 1 + + bill-to: &id001 + street: |- + 123 Tornado Alley + Suite 16 + city: East Westville + state: KS + + ship-to: *id001 + + specialDelivery: > + Follow the Yellow Brick + Road to the Emerald City. + Pay no attention to the + man behind the curtain. +..."; + } +} diff --git a/namedropper/Assets/YamlDotNet/Examples/DeserializeObjectGraph.cs.meta b/namedropper/Assets/YamlDotNet/Examples/DeserializeObjectGraph.cs.meta new file mode 100644 index 0000000..e0e1bb0 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/DeserializeObjectGraph.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e214dfed74d68a24d86a603072744b69 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Examples/DeserializingMultipleDocuments.cs b/namedropper/Assets/YamlDotNet/Examples/DeserializingMultipleDocuments.cs new file mode 100644 index 0000000..f1af6c3 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/DeserializingMultipleDocuments.cs @@ -0,0 +1,79 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Collections.Generic; +using System.IO; +using Xunit.Abstractions; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Samples.Helpers; +using YamlDotNet.Serialization; + +namespace YamlDotNet.Samples +{ + public class DeserializingMultipleDocuments + { + private readonly ITestOutputHelper output; + + public DeserializingMultipleDocuments(ITestOutputHelper output) + { + this.output = output; + } + + [Sample( + DisplayName = "Deserializing multiple documents", + Description = "Explains how to load multiple YAML documents from a stream." + )] + public void Main() + { + var input = new StringReader(Document); + + var deserializer = new DeserializerBuilder().Build(); + + var parser = new Parser(input); + + // Consume the stream start event "manually" + parser.Consume(); + + while (parser.Accept(out var _)) + { + // Deserialize the document + var doc = deserializer.Deserialize>(parser); + + output.WriteLine("## Document"); + foreach (var item in doc) + { + output.WriteLine(item); + } + } + } + + private const string Document = @"--- +- Prisoner +- Goblet +- Phoenix +--- +- Memoirs +- Snow +- Ghost +..."; + } +} diff --git a/namedropper/Assets/YamlDotNet/Examples/DeserializingMultipleDocuments.cs.meta b/namedropper/Assets/YamlDotNet/Examples/DeserializingMultipleDocuments.cs.meta new file mode 100644 index 0000000..df931fe --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/DeserializingMultipleDocuments.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bc4609a10c8a43549a1ec4dfdb0990a4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Examples/Helpers.meta b/namedropper/Assets/YamlDotNet/Examples/Helpers.meta new file mode 100644 index 0000000..1469b29 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/Helpers.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: daabd28f177eb0946b93b026e9d6e738 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Examples/Helpers/ExampleRunner.cs b/namedropper/Assets/YamlDotNet/Examples/Helpers/ExampleRunner.cs new file mode 100644 index 0000000..d52fda4 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/Helpers/ExampleRunner.cs @@ -0,0 +1,147 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using Xunit.Abstractions; + +using UnityEngine; +using UnityEngine.Serialization; + +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace YamlDotNet.Samples.Helpers { + public class ExampleRunner : MonoBehaviour { + + private StringTestOutputHelper helper = new StringTestOutputHelper(); + + public string[] disabledTests = new string[] {}; + + private class StringTestOutputHelper : ITestOutputHelper { + private StringBuilder output = new StringBuilder(); + public void WriteLine() { + output.AppendLine(); + } + public void WriteLine(string value) { + output.AppendLine(value); + } + public void WriteLine(string format, params object[] args) { + output.AppendFormat(format, args); + output.AppendLine(); + } + + public override string ToString() { return output.ToString(); } + public void Clear() { output = new StringBuilder(); } + } + + public static string[] GetAllTestNames() { + bool skipMethods; + var results = new List(); + foreach (Type t in Assembly.GetExecutingAssembly().GetTypes()) { + if (t.Namespace == "YamlDotNet.Samples" && t.IsClass) { + skipMethods = false; + foreach (MethodInfo mi in t.GetMethods()) { + if (mi.Name == "Main") { + SampleAttribute sa = (SampleAttribute) Attribute.GetCustomAttribute(mi, typeof(SampleAttribute)); + if (sa != null) { + results.Add(t.Name); + skipMethods = true; + break; + } + } + if (skipMethods) break; + } + } + } + return results.ToArray(); + } + + public static string[] GetAllTestDisplayNames() { + bool skipMethods; + var results = new List(); + foreach (Type t in Assembly.GetExecutingAssembly().GetTypes()) { + if (t.Namespace == "YamlDotNet.Samples" && t.IsClass) { + skipMethods = false; + foreach (MethodInfo mi in t.GetMethods()) { + if (mi.Name == "Main") { + SampleAttribute sa = (SampleAttribute) Attribute.GetCustomAttribute(mi, typeof(SampleAttribute)); + if (sa != null) { + results.Add(sa.DisplayName); + skipMethods = true; + break; + } + } + if (skipMethods) break; + } + } + } + return results.ToArray(); + } + + private void Start() { + bool skipMethods; + foreach (Type t in Assembly.GetExecutingAssembly().GetTypes()) { + if (t.Namespace == "YamlDotNet.Samples" && t.IsClass && Array.IndexOf(disabledTests, t.Name) == -1) { + skipMethods = false; + foreach (MethodInfo mi in t.GetMethods()) { + if (mi.Name == "Main") { + SampleAttribute sa = (SampleAttribute) Attribute.GetCustomAttribute(mi, typeof(SampleAttribute)); + if (sa != null) { + helper.WriteLine("{0} - {1}", sa.DisplayName, sa.Description); + var testObject = t.GetConstructor(new Type[] { typeof(StringTestOutputHelper) }).Invoke(new object[] { helper }); + mi.Invoke(testObject, new object[] {}); + Debug.Log(helper.ToString()); + helper.Clear(); + skipMethods = true; + break; + } + } + if (skipMethods) break; + } + } + } + } + } + +#if UNITY_EDITOR + [CustomEditor(typeof(ExampleRunner))] + public class ExampleRunnerEditor : Editor { + private ExampleRunner runner; + private string[] allTests; + private string[] allDisplayNames; + private bool[] enabledTests; + + public void OnEnable() { + runner = (ExampleRunner) target; + + allTests = ExampleRunner.GetAllTestNames(); + allDisplayNames = ExampleRunner.GetAllTestDisplayNames(); + enabledTests = new bool[allTests.Length]; + for (int i = 0; i < allTests.Length; i++) + enabledTests[i] = Array.IndexOf(runner.disabledTests, allTests[i]) == -1; + } + + public override void OnInspectorGUI() { + int nextDisabledIndex = 0; + for (int i = 0; i < allTests.Length; i++) { + EditorGUI.BeginChangeCheck(); + if (!enabledTests[i]) + nextDisabledIndex++; + enabledTests[i] = EditorGUILayout.Toggle(allDisplayNames[i], enabledTests[i]); + if (EditorGUI.EndChangeCheck()) { + if (enabledTests[i]) { + var l = new List(runner.disabledTests); + l.Remove(allTests[i]); + runner.disabledTests = l.ToArray(); + } else { + var l = new List(runner.disabledTests); + l.Insert(nextDisabledIndex, allTests[i]); + runner.disabledTests = l.ToArray(); + } + } + } + } + } +#endif +} diff --git a/namedropper/Assets/YamlDotNet/Examples/Helpers/ExampleRunner.cs.meta b/namedropper/Assets/YamlDotNet/Examples/Helpers/ExampleRunner.cs.meta new file mode 100644 index 0000000..f6e0177 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/Helpers/ExampleRunner.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c7b67eba0ebbcd6418a881e3028c9901 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Examples/Helpers/ITestOutputHelper.cs b/namedropper/Assets/YamlDotNet/Examples/Helpers/ITestOutputHelper.cs new file mode 100644 index 0000000..4b3943c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/Helpers/ITestOutputHelper.cs @@ -0,0 +1,8 @@ +namespace Xunit.Abstractions +{ + public interface ITestOutputHelper { + void WriteLine(); + void WriteLine(string value); + void WriteLine(string format, params object[] args); + } +} diff --git a/namedropper/Assets/YamlDotNet/Examples/Helpers/ITestOutputHelper.cs.meta b/namedropper/Assets/YamlDotNet/Examples/Helpers/ITestOutputHelper.cs.meta new file mode 100644 index 0000000..81cf805 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/Helpers/ITestOutputHelper.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8bf0bb99b386041429154edb2eec127f +timeCreated: 1485606138 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Examples/Helpers/SampleAttribute.cs b/namedropper/Assets/YamlDotNet/Examples/Helpers/SampleAttribute.cs new file mode 100644 index 0000000..517093f --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/Helpers/SampleAttribute.cs @@ -0,0 +1,11 @@ +namespace YamlDotNet.Samples.Helpers +{ + /// + /// Marks a test as being a code sample. + /// + internal class SampleAttribute : System.Attribute + { + public string DisplayName { get; set; } + public string Description { get; set; } + } +} diff --git a/namedropper/Assets/YamlDotNet/Examples/Helpers/SampleAttribute.cs.meta b/namedropper/Assets/YamlDotNet/Examples/Helpers/SampleAttribute.cs.meta new file mode 100644 index 0000000..df431e4 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/Helpers/SampleAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: de45c0081a4f5e7478f400ebc2446ce5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Examples/LoadingAYamlStream.cs b/namedropper/Assets/YamlDotNet/Examples/LoadingAYamlStream.cs new file mode 100644 index 0000000..a546c3e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/LoadingAYamlStream.cs @@ -0,0 +1,106 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.IO; +using Xunit.Abstractions; +using YamlDotNet.RepresentationModel; +using YamlDotNet.Samples.Helpers; + +namespace YamlDotNet.Samples +{ + public class LoadingAYamlStream + { + private readonly ITestOutputHelper output; + + public LoadingAYamlStream(ITestOutputHelper output) + { + this.output = output; + } + + [Sample( + DisplayName = "Loading a YAML Stream", + Description = "Explains how to load YAML using the representation model." + )] + public void Main() + { + // Setup the input + var input = new StringReader(Document); + + // Load the stream + var yaml = new YamlStream(); + yaml.Load(input); + + // Examine the stream + var mapping = + (YamlMappingNode)yaml.Documents[0].RootNode; + + foreach (var entry in mapping.Children) + { + output.WriteLine(((YamlScalarNode)entry.Key).Value); + } + + // List all the items + var items = (YamlSequenceNode)mapping.Children[new YamlScalarNode("items")]; + foreach (YamlMappingNode item in items) + { + output.WriteLine( + "{0}\t{1}", + item.Children[new YamlScalarNode("part_no")], + item.Children[new YamlScalarNode("descrip")] + ); + } + } + + private const string Document = @"--- + receipt: Oz-Ware Purchase Invoice + date: 2007-08-06 + customer: + given: Dorothy + family: Gale + + items: + - part_no: A4786 + descrip: Water Bucket (Filled) + price: 1.47 + quantity: 4 + + - part_no: E1628 + descrip: High Heeled ""Ruby"" Slippers + price: 100.27 + quantity: 1 + + bill-to: &id001 + street: | + 123 Tornado Alley + Suite 16 + city: East Westville + state: KS + + ship-to: *id001 + + specialDelivery: > + Follow the Yellow Brick + Road to the Emerald City. + Pay no attention to the + man behind the curtain. +..."; + } +} diff --git a/namedropper/Assets/YamlDotNet/Examples/LoadingAYamlStream.cs.meta b/namedropper/Assets/YamlDotNet/Examples/LoadingAYamlStream.cs.meta new file mode 100644 index 0000000..69f370e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/LoadingAYamlStream.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 28fd354d37e1bcb43baaff38988830a4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Examples/SerializeObjectGraph.cs b/namedropper/Assets/YamlDotNet/Examples/SerializeObjectGraph.cs new file mode 100644 index 0000000..4642307 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/SerializeObjectGraph.cs @@ -0,0 +1,124 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using Xunit.Abstractions; +using YamlDotNet.Samples.Helpers; +using YamlDotNet.Serialization; + +namespace YamlDotNet.Samples +{ + public class SerializeObjectGraph + { + private readonly ITestOutputHelper output; + + public SerializeObjectGraph(ITestOutputHelper output) + { + this.output = output; + } + + [Sample( + DisplayName = "Serializing an object graph", + Description = "Shows how to convert an object to its YAML representation." + )] + public void Main() + { + var address = new Address + { + street = "123 Tornado Alley\nSuite 16", + city = "East Westville", + state = "KS" + }; + + var receipt = new Receipt + { + receipt = "Oz-Ware Purchase Invoice", + date = new DateTime(2007, 8, 6), + customer = new Customer + { + given = "Dorothy", + family = "Gale" + }, + items = new Item[] + { + new Item + { + part_no = "A4786", + descrip = "Water Bucket (Filled)", + price = 1.47M, + quantity = 4 + }, + new Item + { + part_no = "E1628", + descrip = "High Heeled \"Ruby\" Slippers", + price = 100.27M, + quantity = 1 + } + }, + bill_to = address, + ship_to = address, + specialDelivery = "Follow the Yellow Brick\n" + + "Road to the Emerald City.\n" + + "Pay no attention to the\n" + + "man behind the curtain." + }; + + var serializer = new SerializerBuilder().Build(); + var yaml = serializer.Serialize(receipt); + output.WriteLine(yaml); + } + } + +#pragma warning disable IDE1006 // Naming Styles + public class Address + { + public string street { get; set; } + public string city { get; set; } + public string state { get; set; } + } + + public class Receipt + { + public string receipt { get; set; } + public DateTime date { get; set; } + public Customer customer { get; set; } + public Item[] items { get; set; } + public Address bill_to { get; set; } + public Address ship_to { get; set; } + public string specialDelivery { get; set; } + } + + public class Customer + { + public string given { get; set; } + public string family { get; set; } + } + + public class Item + { + public string part_no { get; set; } + public string descrip { get; set; } + public decimal price { get; set; } + public int quantity { get; set; } + } +#pragma warning restore IDE1006 // Naming Styles +} diff --git a/namedropper/Assets/YamlDotNet/Examples/SerializeObjectGraph.cs.meta b/namedropper/Assets/YamlDotNet/Examples/SerializeObjectGraph.cs.meta new file mode 100644 index 0000000..2001daa --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/SerializeObjectGraph.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dc19598abe764044f9baf52c06f5b8c9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Examples/YamlDotNet.Examples.asmdef b/namedropper/Assets/YamlDotNet/Examples/YamlDotNet.Examples.asmdef new file mode 100644 index 0000000..b68814b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/YamlDotNet.Examples.asmdef @@ -0,0 +1,15 @@ +{ + "name": "YamlDotNet.Examples", + "references": [ + "YamlDotNet" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [], + "autoReferenced": false, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/namedropper/Assets/YamlDotNet/Examples/YamlDotNet.Examples.asmdef.meta b/namedropper/Assets/YamlDotNet/Examples/YamlDotNet.Examples.asmdef.meta new file mode 100644 index 0000000..fcf6a07 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Examples/YamlDotNet.Examples.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c23d1189efdcccd43ba976c73f20fa1d +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Helpers.meta b/namedropper/Assets/YamlDotNet/Helpers.meta new file mode 100644 index 0000000..72069ff --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Helpers.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 184057bfc1c4c1f4680fad31ff1eb68a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Helpers/ExpressionExtensions.cs b/namedropper/Assets/YamlDotNet/Helpers/ExpressionExtensions.cs new file mode 100644 index 0000000..73596f1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Helpers/ExpressionExtensions.cs @@ -0,0 +1,85 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#if !NET20 + +using System; +using System.Diagnostics.CodeAnalysis; +using System.Linq.Expressions; +using System.Reflection; + +namespace YamlDotNet.Helpers +{ + public static class ExpressionExtensions + { + /// + /// Returns the that describes the property that + /// is being returned in an expression in the form: + /// + /// x => x.SomeProperty + /// + /// + public static PropertyInfo AsProperty(this LambdaExpression propertyAccessor) + { + var property = TryGetMemberExpression(propertyAccessor); + if (property == null) + { + throw new ArgumentException("Expected a lambda expression in the form: x => x.SomeProperty", nameof(propertyAccessor)); + } + + return property; + } + + [return: MaybeNull] + private static TMemberInfo TryGetMemberExpression(LambdaExpression lambdaExpression) + where TMemberInfo : MemberInfo + { + if (lambdaExpression.Parameters.Count != 1) + { + return null; + } + + var body = lambdaExpression.Body; + + if (body is UnaryExpression castExpression) + { + if (castExpression.NodeType != ExpressionType.Convert) + { + return null; + } + + body = castExpression.Operand; + } + + if (body is MemberExpression memberExpression) + { + if (memberExpression.Expression != lambdaExpression.Parameters[0]) + { + return null; + } + + return memberExpression.Member as TMemberInfo; + } + return null; + } + } +} +#endif diff --git a/namedropper/Assets/YamlDotNet/Helpers/ExpressionExtensions.cs.meta b/namedropper/Assets/YamlDotNet/Helpers/ExpressionExtensions.cs.meta new file mode 100644 index 0000000..73ccdb7 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Helpers/ExpressionExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 793a46d362345d548970ee537e488bfe +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Helpers/GenericCollectionToNonGenericAdapter.cs b/namedropper/Assets/YamlDotNet/Helpers/GenericCollectionToNonGenericAdapter.cs new file mode 100644 index 0000000..b2be200 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Helpers/GenericCollectionToNonGenericAdapter.cs @@ -0,0 +1,125 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace YamlDotNet.Helpers +{ + /// + /// Adapts an to + /// because not all generic collections implement . + /// + internal sealed class GenericCollectionToNonGenericAdapter : IList + { + private readonly ICollection genericCollection; + + public GenericCollectionToNonGenericAdapter(ICollection genericCollection) + { + this.genericCollection = genericCollection ?? throw new ArgumentNullException(nameof(genericCollection)); + } + + public int Add(object? value) + { + var index = genericCollection.Count; + genericCollection.Add((T)value!); + return index; + } + + public void Clear() + { + genericCollection.Clear(); + } + + public bool Contains(object? value) + { + throw new NotSupportedException(); + } + + public int IndexOf(object? value) + { + throw new NotSupportedException(); + } + + public void Insert(int index, object? value) + { + throw new NotSupportedException(); + } + + public bool IsFixedSize + { + get { throw new NotSupportedException(); } + } + + public bool IsReadOnly + { + get { throw new NotSupportedException(); } + } + + public void Remove(object? value) + { + throw new NotSupportedException(); + } + + public void RemoveAt(int index) + { + throw new NotSupportedException(); + } + + public object? this[int index] + { + get + { + throw new NotSupportedException(); + } + set + { + ((IList)genericCollection)[index] = (T)value!; + } + } + + public void CopyTo(Array array, int index) + { + throw new NotSupportedException(); + } + + public int Count + { + get { throw new NotSupportedException(); } + } + + public bool IsSynchronized + { + get { throw new NotSupportedException(); } + } + + public object SyncRoot + { + get { throw new NotSupportedException(); } + } + + public IEnumerator GetEnumerator() + { + return genericCollection.GetEnumerator(); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Helpers/GenericCollectionToNonGenericAdapter.cs.meta b/namedropper/Assets/YamlDotNet/Helpers/GenericCollectionToNonGenericAdapter.cs.meta new file mode 100644 index 0000000..2b79ca5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Helpers/GenericCollectionToNonGenericAdapter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9fd433108de12ac4486d0acd3a98635f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Helpers/GenericDictionaryToNonGenericAdapter.cs b/namedropper/Assets/YamlDotNet/Helpers/GenericDictionaryToNonGenericAdapter.cs new file mode 100644 index 0000000..fc8eee4 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Helpers/GenericDictionaryToNonGenericAdapter.cs @@ -0,0 +1,167 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace YamlDotNet.Helpers +{ + /// + /// Adapts an to + /// because not all generic dictionaries implement . + /// + internal sealed class GenericDictionaryToNonGenericAdapter : IDictionary + where TKey : notnull + { + private readonly IDictionary genericDictionary; + + public GenericDictionaryToNonGenericAdapter(IDictionary genericDictionary) + { + this.genericDictionary = genericDictionary ?? throw new ArgumentNullException(nameof(genericDictionary)); + } + + public void Add(object key, object? value) + { + throw new NotSupportedException(); + } + + public void Clear() + { + throw new NotSupportedException(); + } + + public bool Contains(object key) + { + throw new NotSupportedException(); + } + + public IDictionaryEnumerator GetEnumerator() + { + return new DictionaryEnumerator(genericDictionary.GetEnumerator()); + } + + public bool IsFixedSize + { + get { throw new NotSupportedException(); } + } + + public bool IsReadOnly + { + get { throw new NotSupportedException(); } + } + + public ICollection Keys + { + get { throw new NotSupportedException(); } + } + + public void Remove(object key) + { + throw new NotSupportedException(); + } + + public ICollection Values + { + get { throw new NotSupportedException(); } + } + + public object? this[object key] + { + get + { + throw new NotSupportedException(); + } + set + { + genericDictionary[(TKey)key] = (TValue)value!; + } + } + + public void CopyTo(Array array, int index) + { + throw new NotSupportedException(); + } + + public int Count + { + get { throw new NotSupportedException(); } + } + + public bool IsSynchronized + { + get { throw new NotSupportedException(); } + } + + public object SyncRoot + { + get { throw new NotSupportedException(); } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + private class DictionaryEnumerator : IDictionaryEnumerator + { + private readonly IEnumerator> enumerator; + + public DictionaryEnumerator(IEnumerator> enumerator) + { + this.enumerator = enumerator; + } + + public DictionaryEntry Entry + { + get + { + return new DictionaryEntry(Key, Value); + } + } + + public object Key + { + get { return enumerator.Current.Key!; } + } + + public object? Value + { + get { return enumerator.Current.Value; } + } + + public object Current + { + get { return Entry; } + } + + public bool MoveNext() + { + return enumerator.MoveNext(); + } + + public void Reset() + { + enumerator.Reset(); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Helpers/GenericDictionaryToNonGenericAdapter.cs.meta b/namedropper/Assets/YamlDotNet/Helpers/GenericDictionaryToNonGenericAdapter.cs.meta new file mode 100644 index 0000000..7029199 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Helpers/GenericDictionaryToNonGenericAdapter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7beef75a3a31dfc478917341adcf708d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Helpers/IOrderedDictionary.cs b/namedropper/Assets/YamlDotNet/Helpers/IOrderedDictionary.cs new file mode 100644 index 0000000..a5d44aa --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Helpers/IOrderedDictionary.cs @@ -0,0 +1,55 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Collections.Generic; + +namespace YamlDotNet.Helpers +{ + public interface IOrderedDictionary : IDictionary + where TKey : notnull + { + /// + /// Gets or sets the element with the specified index. + /// + /// The index of the element to get or set. + /// The element with the specified index. + KeyValuePair this[int index] + { + get; + set; + } + + /// + /// Adds an element with the provided key and value to the + /// at the given index. + /// + /// The zero-based index at which the item should be inserted. + /// The object to use as the key of the element to add. + /// The object to use as the value of the element to add. + void Insert(int index, TKey key, TValue value); + + /// + /// Removes the element at the specified index. + /// + /// The zero-based index of the element to remove. + void RemoveAt(int index); + } +} diff --git a/namedropper/Assets/YamlDotNet/Helpers/IOrderedDictionary.cs.meta b/namedropper/Assets/YamlDotNet/Helpers/IOrderedDictionary.cs.meta new file mode 100644 index 0000000..e421ee3 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Helpers/IOrderedDictionary.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: de2ae2f3fa506fa47b93048ac0bdcb7e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Helpers/NumberExtensions.cs b/namedropper/Assets/YamlDotNet/Helpers/NumberExtensions.cs new file mode 100644 index 0000000..6925ec1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Helpers/NumberExtensions.cs @@ -0,0 +1,31 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Helpers +{ + internal static class NumberExtensions + { + public static bool IsPowerOfTwo(this int value) + { + return (value & (value - 1)) == 0; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Helpers/NumberExtensions.cs.meta b/namedropper/Assets/YamlDotNet/Helpers/NumberExtensions.cs.meta new file mode 100644 index 0000000..6e06a60 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Helpers/NumberExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ed9bc129662cfc5439b271df577d9537 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Helpers/OrderedDictionary.cs b/namedropper/Assets/YamlDotNet/Helpers/OrderedDictionary.cs new file mode 100644 index 0000000..f1c90e1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Helpers/OrderedDictionary.cs @@ -0,0 +1,234 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Runtime.Serialization; + +namespace YamlDotNet.Helpers +{ + [Serializable] + internal class OrderedDictionary : IOrderedDictionary + where TKey : notnull + { + [NonSerialized] + private Dictionary dictionary; + private readonly List> list; + private readonly IEqualityComparer comparer; + + public TValue this[TKey key] + { + get => dictionary[key]; + set + { + if (dictionary.ContainsKey(key)) + { + var index = list.FindIndex(kvp => comparer.Equals(kvp.Key, key)); + dictionary[key] = value; + list[index] = new KeyValuePair(key, value); + } + else + { + Add(key, value); + } + } + } + + public ICollection Keys => new KeyCollection(this); + + public ICollection Values => new ValueCollection(this); + + public int Count => dictionary.Count; + + public bool IsReadOnly => false; + + public KeyValuePair this[int index] + { + get => list[index]; + set => list[index] = value; + } + + public OrderedDictionary() : this(EqualityComparer.Default) + { + } + + public OrderedDictionary(IEqualityComparer comparer) + { + list = new List>(); + dictionary = new Dictionary(comparer); + this.comparer = comparer; + } + + public void Add(TKey key, TValue value) => Add(new KeyValuePair(key, value)); + + public void Add(KeyValuePair item) + { + dictionary.Add(item.Key, item.Value); + list.Add(item); + } + + public void Clear() + { + dictionary.Clear(); + list.Clear(); + } + + public bool Contains(KeyValuePair item) => dictionary.Contains(item); + + public bool ContainsKey(TKey key) => dictionary.ContainsKey(key); + + public void CopyTo(KeyValuePair[] array, int arrayIndex) => + list.CopyTo(array, arrayIndex); + + public IEnumerator> GetEnumerator() => list.GetEnumerator(); + + public void Insert(int index, TKey key, TValue value) + { + dictionary.Add(key, value); + list.Insert(index, new KeyValuePair(key, value)); + } + + public bool Remove(TKey key) + { + if (dictionary.ContainsKey(key)) + { + var index = list.FindIndex(kvp => comparer.Equals(kvp.Key, key)); + list.RemoveAt(index); + if (!dictionary.Remove(key)) + { + throw new InvalidOperationException(); + } + return true; + } + else + { + return false; + } + } + + public bool Remove(KeyValuePair item) => Remove(item.Key); + + public void RemoveAt(int index) + { + var key = list[index].Key; + dictionary.Remove(key); + list.RemoveAt(index); + } + +#if !(NETCOREAPP3_1) +#pragma warning disable 8767 // Nullability of reference types in type of parameter ... doesn't match implicitly implemented member +#endif + + public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) => + dictionary.TryGetValue(key, out value); + +#if !(NETCOREAPP3_1) +#pragma warning restore 8767 +#endif + + IEnumerator IEnumerable.GetEnumerator() => list.GetEnumerator(); + + + [OnDeserialized] + internal void OnDeserializedMethod(StreamingContext context) + { + // Reconstruct the dictionary from the serialized list + dictionary = new Dictionary(); + foreach (var kvp in list) + { + dictionary[kvp.Key] = kvp.Value; + } + } + + private class KeyCollection : ICollection + { + private readonly OrderedDictionary orderedDictionary; + + public int Count => orderedDictionary.list.Count; + + public bool IsReadOnly => true; + + public void Add(TKey item) => throw new NotSupportedException(); + + public void Clear() => throw new NotSupportedException(); + + public bool Contains(TKey item) => orderedDictionary.dictionary.Keys.Contains(item); + + public KeyCollection(OrderedDictionary orderedDictionary) + { + this.orderedDictionary = orderedDictionary; + } + + public void CopyTo(TKey[] array, int arrayIndex) + { + for (var i = 0; i < orderedDictionary.list.Count; i++) + { + array[i] = orderedDictionary.list[i + arrayIndex].Key; + } + } + + public IEnumerator GetEnumerator() => + orderedDictionary.list.Select(kvp => kvp.Key).GetEnumerator(); + + public bool Remove(TKey item) => throw new NotSupportedException(); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + } + + private class ValueCollection : ICollection + { + private readonly OrderedDictionary orderedDictionary; + + public int Count => orderedDictionary.list.Count; + + public bool IsReadOnly => true; + + public void Add(TValue item) => throw new NotSupportedException(); + + public void Clear() => throw new NotSupportedException(); + + public bool Contains(TValue item) => orderedDictionary.dictionary.Values.Contains(item); + + public ValueCollection(OrderedDictionary orderedDictionary) + { + this.orderedDictionary = orderedDictionary; + } + + public void CopyTo(TValue[] array, int arrayIndex) + { + for (var i = 0; i < orderedDictionary.list.Count; i++) + { + array[i] = orderedDictionary.list[i + arrayIndex].Value; + } + } + + public IEnumerator GetEnumerator() => + orderedDictionary.list.Select(kvp => kvp.Value).GetEnumerator(); + + public bool Remove(TValue item) => throw new NotSupportedException(); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Helpers/OrderedDictionary.cs.meta b/namedropper/Assets/YamlDotNet/Helpers/OrderedDictionary.cs.meta new file mode 100644 index 0000000..da0091e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Helpers/OrderedDictionary.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fd92f9e9502203346aad33fd2d86c46a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Portability.meta b/namedropper/Assets/YamlDotNet/Portability.meta new file mode 100644 index 0000000..ab0c8f0 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Portability.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7ac880b702dadf24183b628b2243ab7d +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Portability/NullableReferences.cs b/namedropper/Assets/YamlDotNet/Portability/NullableReferences.cs new file mode 100644 index 0000000..948f980 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Portability/NullableReferences.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors + +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace System.Diagnostics.CodeAnalysis +{ + [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] + internal sealed class NotNullWhenAttribute : Attribute + { + public NotNullWhenAttribute(bool returnValue) { } + } + + [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] + internal sealed class MaybeNullWhenAttribute : Attribute + { + public MaybeNullWhenAttribute(bool returnValue) { } + } + + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)] + internal sealed class MaybeNullAttribute : Attribute + { + public MaybeNullAttribute() { } + } + + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)] + internal sealed class AllowNullAttribute : Attribute + { + public AllowNullAttribute() { } + } +} \ No newline at end of file diff --git a/namedropper/Assets/YamlDotNet/Portability/NullableReferences.cs.meta b/namedropper/Assets/YamlDotNet/Portability/NullableReferences.cs.meta new file mode 100644 index 0000000..e934b67 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Portability/NullableReferences.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 27b4cc9905862e44ebfcea2e376c18c3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Portability/netstandard1.3.meta b/namedropper/Assets/YamlDotNet/Portability/netstandard1.3.meta new file mode 100644 index 0000000..139fc87 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Portability/netstandard1.3.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: afa0f7aa07140a84b8965f0ed8650262 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Portability/netstandard1.3/CultureInfoAdapter.cs b/namedropper/Assets/YamlDotNet/Portability/netstandard1.3/CultureInfoAdapter.cs new file mode 100644 index 0000000..15018f5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Portability/netstandard1.3/CultureInfoAdapter.cs @@ -0,0 +1,42 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Globalization; + +namespace YamlDotNet +{ + internal sealed class CultureInfoAdapter : CultureInfo + { + private readonly IFormatProvider provider; + + public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider) + : base(baseCulture.LCID) + { + this.provider = provider; + } + + public override object? GetFormat(Type? formatType) + { + return provider.GetFormat(formatType); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Portability/netstandard1.3/CultureInfoAdapter.cs.meta b/namedropper/Assets/YamlDotNet/Portability/netstandard1.3/CultureInfoAdapter.cs.meta new file mode 100644 index 0000000..ef913bf --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Portability/netstandard1.3/CultureInfoAdapter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3b57d4cc1492d5f47a8e2be5142d8e92 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Portability/netstandard1.3/ReflectionExtensions.cs b/namedropper/Assets/YamlDotNet/Portability/netstandard1.3/ReflectionExtensions.cs new file mode 100644 index 0000000..37a087a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Portability/netstandard1.3/ReflectionExtensions.cs @@ -0,0 +1,166 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace YamlDotNet +{ + internal static class ReflectionExtensions + { + public static Type? BaseType(this Type type) + { + return type.BaseType; + } + + public static bool IsValueType(this Type type) + { + return type.IsValueType; + } + + public static bool IsGenericType(this Type type) + { + return type.IsGenericType; + } + + public static bool IsGenericTypeDefinition(this Type type) + { + return type.IsGenericTypeDefinition; + } + + public static bool IsInterface(this Type type) + { + return type.IsInterface; + } + + public static bool IsEnum(this Type type) + { + return type.IsEnum; + } + + public static bool IsDbNull(this object value) + { + return value is DBNull; + } + + /// + /// Determines whether the specified type has a default constructor. + /// + /// The type. + /// + /// true if the type has a default constructor; otherwise, false. + /// + public static bool HasDefaultConstructor(this Type type) + { + return type.IsValueType || type.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null) != null; + } + + public static TypeCode GetTypeCode(this Type type) + { + return Type.GetTypeCode(type); + } + + public static PropertyInfo? GetPublicProperty(this Type type, string name) + { + return type.GetProperty(name); + } + + public static FieldInfo? GetPublicStaticField(this Type type, string name) + { + return type.GetField(name, BindingFlags.Static | BindingFlags.Public); + } + + public static IEnumerable GetProperties(this Type type, bool includeNonPublic) + { + var bindingFlags = BindingFlags.Instance | BindingFlags.Public; + + if (includeNonPublic) + { + bindingFlags |= BindingFlags.NonPublic; + } + + return type.IsInterface + ? (new Type[] { type }) + .Concat(type.GetInterfaces()) + .SelectMany(i => i.GetProperties(bindingFlags)) + : type.GetProperties(bindingFlags); + } + + public static IEnumerable GetPublicProperties(this Type type) => GetProperties(type, false); + + public static IEnumerable GetPublicFields(this Type type) + { + return type.GetFields(BindingFlags.Instance | BindingFlags.Public); + } + + public static IEnumerable GetPublicStaticMethods(this Type type) + { + return type.GetMethods(BindingFlags.Static | BindingFlags.Public); + } + + public static MethodInfo GetPrivateStaticMethod(this Type type, string name) + { + return type.GetMethod(name, BindingFlags.Static | BindingFlags.NonPublic) + ?? throw new MissingMethodException($"Expected to find a method named '{name}' in '{type.FullName}'."); + } + + public static MethodInfo? GetPublicStaticMethod(this Type type, string name, params Type[] parameterTypes) + { + return type.GetMethod(name, BindingFlags.Public | BindingFlags.Static, null, parameterTypes, null); + } + + public static MethodInfo? GetPublicInstanceMethod(this Type type, string name) + { + return type.GetMethod(name, BindingFlags.Public | BindingFlags.Instance); + } + + private static readonly FieldInfo? RemoteStackTraceField = typeof(Exception) + .GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic); + + public static Exception Unwrap(this TargetInvocationException ex) + { + var result = ex.InnerException; + if (result == null) + { + return ex; + } + + if (RemoteStackTraceField != null) + { + RemoteStackTraceField.SetValue(result, result.StackTrace + "\r\n"); + } + return result; + } + + public static bool IsInstanceOf(this Type type, object o) + { + return type.IsInstanceOfType(o); + } + + public static Attribute[] GetAllCustomAttributes(this PropertyInfo property) + { + // Don't use IMemberInfo.GetCustomAttributes, it ignores the inherit parameter + return Attribute.GetCustomAttributes(property, typeof(TAttribute)); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Portability/netstandard1.3/ReflectionExtensions.cs.meta b/namedropper/Assets/YamlDotNet/Portability/netstandard1.3/ReflectionExtensions.cs.meta new file mode 100644 index 0000000..71b0a45 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Portability/netstandard1.3/ReflectionExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f309b2324c56de5419e209fe229d1ec3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5.meta b/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5.meta new file mode 100644 index 0000000..6294780 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b5c36140127ae7341a98c738f9d6254b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/PropertyInfoExtensions.cs b/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/PropertyInfoExtensions.cs new file mode 100644 index 0000000..eefd138 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/PropertyInfoExtensions.cs @@ -0,0 +1,33 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Reflection; + +namespace YamlDotNet +{ + internal static class PropertyInfoExtensions + { + public static object? ReadValue(this PropertyInfo property, object target) + { + return property.GetGetMethod().Invoke(target, null); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/PropertyInfoExtensions.cs.meta b/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/PropertyInfoExtensions.cs.meta new file mode 100644 index 0000000..b908f9b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/PropertyInfoExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8942d729fabed6e4e8defd6e16fbe638 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/StandardRegexOptions.cs b/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/StandardRegexOptions.cs new file mode 100644 index 0000000..da72768 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/StandardRegexOptions.cs @@ -0,0 +1,30 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Text.RegularExpressions; + +namespace YamlDotNet +{ + internal static class StandardRegexOptions + { + public const RegexOptions Compiled = RegexOptions.None; + } +} diff --git a/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/StandardRegexOptions.cs.meta b/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/StandardRegexOptions.cs.meta new file mode 100644 index 0000000..a2cb2de --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Portability/unitysubset3.5/StandardRegexOptions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 212fb3ce30a7ede4b8fd1b7af348700b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Readme.txt b/namedropper/Assets/YamlDotNet/Readme.txt new file mode 100644 index 0000000..6e87318 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Readme.txt @@ -0,0 +1,6 @@ +This is a port of the YamlDotNet library for Unity. + +Please read the example code for a quick introduction to the YamlDotNet library. + +If you get into trouble, you can browse the web for YamlDotNet information, +or you could send me an email ( post@fredrik.ludvigsen.name ). diff --git a/namedropper/Assets/YamlDotNet/Readme.txt.meta b/namedropper/Assets/YamlDotNet/Readme.txt.meta new file mode 100644 index 0000000..4466937 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Readme.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5878fe3c964cf444eae1b86940714d35 +timeCreated: 1429646563 +licenseType: Store +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel.meta b/namedropper/Assets/YamlDotNet/RepresentationModel.meta new file mode 100644 index 0000000..8d693ca --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5fc62dc1192c2f3449e48214d2e02c6a +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/DocumentLoadingState.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/DocumentLoadingState.cs new file mode 100644 index 0000000..2f506a1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/DocumentLoadingState.cs @@ -0,0 +1,111 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using YamlDotNet.Core; + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Manages the state of a while it is loading. + /// + internal class DocumentLoadingState + { + private readonly IDictionary anchors = new Dictionary(); + private readonly IList nodesWithUnresolvedAliases = new List(); + + /// + /// Adds the specified node to the anchor list. + /// + /// The node. + public void AddAnchor(YamlNode node) + { + if (node.Anchor.IsEmpty) + { + throw new ArgumentException("The specified node does not have an anchor"); + } + + if (anchors.ContainsKey(node.Anchor)) + { + anchors[node.Anchor] = node; + } + else + { + anchors.Add(node.Anchor, node); + } + } + + /// + /// Gets the node with the specified anchor. + /// + /// The anchor. + /// The start position. + /// The end position. + /// + /// if there is no node with that anchor. + public YamlNode GetNode(AnchorName anchor, Mark start, Mark end) + { + if (anchors.TryGetValue(anchor, out var target)) + { + return target; + } + else + { + throw new AnchorNotFoundException(start, end, $"The anchor '{anchor}' does not exists"); + } + } + + /// + /// Gets the node with the specified anchor. + /// + /// The anchor. + /// The node that was retrieved. + /// true if the anchor was found; otherwise false. + public bool TryGetNode(AnchorName anchor, [NotNullWhen(true)] out YamlNode? node) + { + return anchors.TryGetValue(anchor, out node); + } + + /// + /// Adds the specified node to the collection of nodes with unresolved aliases. + /// + /// + /// The that has unresolved aliases. + /// + public void AddNodeWithUnresolvedAliases(YamlNode node) + { + nodesWithUnresolvedAliases.Add(node); + } + + /// + /// Resolves the aliases that could not be resolved while loading the document. + /// + public void ResolveAliases() + { + foreach (var node in nodesWithUnresolvedAliases) + { + node.ResolveAliases(this); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/DocumentLoadingState.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/DocumentLoadingState.cs.meta new file mode 100644 index 0000000..c13c935 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/DocumentLoadingState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 76a242df6680b9742a2670bde85baa6e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/EmitterState.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/EmitterState.cs new file mode 100644 index 0000000..996c94c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/EmitterState.cs @@ -0,0 +1,38 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Collections.Generic; +using YamlDotNet.Core; + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Holds state that is used when emitting a stream. + /// + internal class EmitterState + { + /// + /// Gets the already emitted anchors. + /// + /// The emitted anchors. + public HashSet EmittedAnchors { get; } = new HashSet(); + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/EmitterState.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/EmitterState.cs.meta new file mode 100644 index 0000000..284608e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/EmitterState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c3761b6b22a04a24fade56273bbb3c5b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/IYamlVisitor.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/IYamlVisitor.cs new file mode 100644 index 0000000..57a4dca --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/IYamlVisitor.cs @@ -0,0 +1,69 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Defines the method needed to be able to visit Yaml elements. + /// + public interface IYamlVisitor + { + /// + /// Visits a . + /// + /// + /// The that is being visited. + /// + void Visit(YamlStream stream); + + /// + /// Visits a . + /// + /// + /// The that is being visited. + /// + void Visit(YamlDocument document); + + /// + /// Visits a . + /// + /// + /// The that is being visited. + /// + void Visit(YamlScalarNode scalar); + + /// + /// Visits a . + /// + /// + /// The that is being visited. + /// + void Visit(YamlSequenceNode sequence); + + /// + /// Visits a . + /// + /// + /// The that is being visited. + /// + void Visit(YamlMappingNode mapping); + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/IYamlVisitor.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/IYamlVisitor.cs.meta new file mode 100644 index 0000000..882cc42 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/IYamlVisitor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e12b6dd8690a6674696c7a997fdbd895 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/LibYamlEventStream.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/LibYamlEventStream.cs new file mode 100644 index 0000000..7d50e4f --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/LibYamlEventStream.cs @@ -0,0 +1,136 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.IO; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Represents a LibYAML event stream. + /// + public class LibYamlEventStream + { + private readonly IParser parser; + + /// + /// Initializes a new instance of the class + /// from the specified . + /// + public LibYamlEventStream(IParser iParser) + { + parser = iParser ?? throw new ArgumentNullException(nameof(iParser)); + } + + public void WriteTo(TextWriter textWriter) + { + while (parser.MoveNext()) + { + switch (parser.Current) + { + case AnchorAlias anchorAlias: + textWriter.Write("=ALI *"); + textWriter.Write(anchorAlias.Value); + break; + case DocumentEnd documentEnd: + textWriter.Write("-DOC"); + if (!documentEnd.IsImplicit) + { + textWriter.Write(" ..."); + } + break; + case DocumentStart documentStart: + textWriter.Write("+DOC"); + if (!documentStart.IsImplicit) + { + textWriter.Write(" ---"); + } + break; + case MappingEnd _: + textWriter.Write("-MAP"); + break; + case MappingStart mappingStart: + textWriter.Write("+MAP"); + WriteAnchorAndTag(textWriter, mappingStart); + break; + case Scalar scalar: + textWriter.Write("=VAL"); + WriteAnchorAndTag(textWriter, scalar); + + switch (scalar.Style) + { + case ScalarStyle.DoubleQuoted: textWriter.Write(" \""); break; + case ScalarStyle.SingleQuoted: textWriter.Write(" '"); break; + case ScalarStyle.Folded: textWriter.Write(" >"); break; + case ScalarStyle.Literal: textWriter.Write(" |"); break; + default: textWriter.Write(" :"); break; + } + + foreach (var character in scalar.Value) + { + switch (character) + { + case '\b': textWriter.Write("\\b"); break; + case '\t': textWriter.Write("\\t"); break; + case '\n': textWriter.Write("\\n"); break; + case '\r': textWriter.Write("\\r"); break; + case '\\': textWriter.Write("\\\\"); break; + default: textWriter.Write(character); break; + } + } + break; + case SequenceEnd _: + textWriter.Write("-SEQ"); + break; + case SequenceStart sequenceStart: + textWriter.Write("+SEQ"); + WriteAnchorAndTag(textWriter, sequenceStart); + break; + case StreamEnd _: + textWriter.Write("-STR"); + break; + case StreamStart _: + textWriter.Write("+STR"); + break; + } + textWriter.WriteLine(); + } + } + + private void WriteAnchorAndTag(TextWriter textWriter, NodeEvent nodeEvent) + { + if (!nodeEvent.Anchor.IsEmpty) + { + textWriter.Write(" &"); + textWriter.Write(nodeEvent.Anchor); + } + + if (!nodeEvent.Tag.IsEmpty) + { + textWriter.Write(" <"); + textWriter.Write(nodeEvent.Tag.Value); + textWriter.Write(">"); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/LibYamlEventStream.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/LibYamlEventStream.cs.meta new file mode 100644 index 0000000..8553ad5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/LibYamlEventStream.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a2468528a04d1c74f8301b7e6326e3ae +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlAliasNode.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlAliasNode.cs new file mode 100644 index 0000000..08638d8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlAliasNode.cs @@ -0,0 +1,120 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using YamlDotNet.Core; + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Represents an alias node in the YAML document. + /// + internal class YamlAliasNode : YamlNode + { + /// + /// Initializes a new instance of the class. + /// + /// The anchor. + internal YamlAliasNode(AnchorName anchor) + { + Anchor = anchor; + } + + /// + /// Resolves the aliases that could not be resolved when the node was created. + /// + /// The state of the document. + internal override void ResolveAliases(DocumentLoadingState state) + { + throw new NotSupportedException("Resolving an alias on an alias node does not make sense"); + } + + /// + /// Saves the current node to the specified emitter. + /// + /// The emitter where the node is to be saved. + /// The state. + internal override void Emit(IEmitter emitter, EmitterState state) + { + throw new NotSupportedException("A YamlAliasNode is an implementation detail and should never be saved."); + } + + /// + /// Accepts the specified visitor by calling the appropriate Visit method on it. + /// + /// + /// A . + /// + public override void Accept(IYamlVisitor visitor) + { + throw new NotSupportedException("A YamlAliasNode is an implementation detail and should never be visited."); + } + + /// + public override bool Equals(object? obj) + { + return obj is YamlAliasNode other + && Equals(other) + && Equals(Anchor, other.Anchor); + } + + /// + /// Serves as a hash function for a particular type. + /// + /// + /// A hash code for the current . + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + internal override string ToString(RecursionLevel level) + { + return "*" + Anchor; + } + + /// + /// Recursively enumerates all the nodes from the document, starting on the current node, + /// and throwing + /// if is reached. + /// + internal override IEnumerable SafeAllNodes(RecursionLevel level) + { + yield return this; + } + + /// + /// Gets the type of node. + /// + public override YamlNodeType NodeType + { + get { return YamlNodeType.Alias; } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlAliasNode.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlAliasNode.cs.meta new file mode 100644 index 0000000..24fe21c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlAliasNode.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 72c7427f0fab35849b7545d301debcd5 +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlDocument.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlDocument.cs new file mode 100644 index 0000000..c907a02 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlDocument.cs @@ -0,0 +1,211 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Represents an YAML document. + /// + public class YamlDocument + { + /// + /// Gets or sets the root node. + /// + /// The root node. + public YamlNode RootNode { get; private set; } + + /// + /// Initializes a new instance of the class. + /// + public YamlDocument(YamlNode rootNode) + { + RootNode = rootNode; + } + + /// + /// Initializes a new instance of the class with a single scalar node. + /// + public YamlDocument(string rootNode) + { + RootNode = new YamlScalarNode(rootNode); + } + + /// + /// Initializes a new instance of the class. + /// + internal YamlDocument(IParser parser) + { + var state = new DocumentLoadingState(); + + parser.Consume(); + + while (!parser.TryConsume(out var _)) + { + Debug.Assert(RootNode == null); + RootNode = YamlNode.ParseNode(parser, state); + + if (RootNode is YamlAliasNode) + { + throw new YamlException("A document cannot contain only an alias"); + } + } + + state.ResolveAliases(); + + // Throw should not happen unless the parser has a bug + RootNode = RootNode ?? throw new ArgumentException("Atempted to parse an empty document"); + } + + /// + /// Visitor that assigns anchors to nodes that are referenced more than once. + /// Existing anchors are preserved as much as possible. + /// + private class AnchorAssigningVisitor : YamlVisitorBase + { + private readonly HashSet existingAnchors = new HashSet(); + /// + /// Key: Node, Value: IsDuplicate + /// + private readonly Dictionary visitedNodes = new Dictionary(); + + public void AssignAnchors(YamlDocument document) + { + existingAnchors.Clear(); + visitedNodes.Clear(); + + document.Accept(this); + + var random = new Random(); + foreach (var visitedNode in visitedNodes) + { + if (visitedNode.Value) + { + AnchorName anchor; + // If the existing anchor is not already used, we can have it + if (!visitedNode.Key.Anchor.IsEmpty && !existingAnchors.Contains(visitedNode.Key.Anchor)) + { + anchor = visitedNode.Key.Anchor; + } + else + { + do + { + anchor = new AnchorName(random.Next().ToString(CultureInfo.InvariantCulture)); + } while (existingAnchors.Contains(anchor)); + } + + existingAnchors.Add(anchor); + visitedNode.Key.Anchor = anchor; + } + } + } + + /// + /// Returns whether the visited node is a duplicate. + /// + private bool VisitNodeAndFindDuplicates(YamlNode node) + { + if (visitedNodes.TryGetValue(node, out var isDuplicate)) + { + if (!isDuplicate) + { + visitedNodes[node] = true; + } + return !isDuplicate; + } + else + { + visitedNodes.Add(node, false); + return false; + } + } + + public override void Visit(YamlScalarNode scalar) + { + VisitNodeAndFindDuplicates(scalar); + } + + public override void Visit(YamlMappingNode mapping) + { + if (!VisitNodeAndFindDuplicates(mapping)) + { + base.Visit(mapping); + } + } + + public override void Visit(YamlSequenceNode sequence) + { + if (!VisitNodeAndFindDuplicates(sequence)) + { + base.Visit(sequence); + } + } + } + + private void AssignAnchors() + { + var visitor = new AnchorAssigningVisitor(); + visitor.AssignAnchors(this); + } + + internal void Save(IEmitter emitter, bool assignAnchors = true) + { + if (assignAnchors) + { + AssignAnchors(); + } + + emitter.Emit(new DocumentStart()); + RootNode.Save(emitter, new EmitterState()); + emitter.Emit(new DocumentEnd(false)); + } + + /// + /// Accepts the specified visitor by calling the appropriate Visit method on it. + /// + /// + /// A . + /// + public void Accept(IYamlVisitor visitor) + { + visitor.Visit(this); + } + + /// + /// Gets all nodes from the document. + /// is thrown if an infinite recursion is detected. + /// + public IEnumerable AllNodes + { + get + { + return RootNode.AllNodes; + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlDocument.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlDocument.cs.meta new file mode 100644 index 0000000..eb8d3f5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlDocument.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: aa500eae79de1e8429a325722afbf4e8 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlMappingNode.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlMappingNode.cs new file mode 100644 index 0000000..6a031c5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlMappingNode.cs @@ -0,0 +1,425 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Text; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Helpers; +using YamlDotNet.Serialization; +using static YamlDotNet.Core.HashCode; + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Represents a mapping node in the YAML document. + /// + public sealed class YamlMappingNode : YamlNode, IEnumerable>, IYamlConvertible + { + private readonly IOrderedDictionary children = new OrderedDictionary(); + + /// + /// Gets the children of the current node. + /// + /// The children. + public IOrderedDictionary Children + { + get + { + return children; + } + } + + /// + /// Gets or sets the style of the node. + /// + /// The style. + public MappingStyle Style { get; set; } + + /// + /// Initializes a new instance of the class. + /// + internal YamlMappingNode(IParser parser, DocumentLoadingState state) + { + Load(parser, state); + } + + private void Load(IParser parser, DocumentLoadingState state) + { + var mapping = parser.Consume(); + Load(mapping, state); + Style = mapping.Style; + + var hasUnresolvedAliases = false; + while (!parser.TryConsume(out var _)) + { + var key = ParseNode(parser, state); + var value = ParseNode(parser, state); + + try + { + children.Add(key, value); + } + catch (ArgumentException err) + { + throw new YamlException(key.Start, key.End, "Duplicate key", err); + } + + hasUnresolvedAliases |= key is YamlAliasNode || value is YamlAliasNode; + } + + if (hasUnresolvedAliases) + { + state.AddNodeWithUnresolvedAliases(this); + } + } + + /// + /// Initializes a new instance of the class. + /// + public YamlMappingNode() + { + } + + /// + /// Initializes a new instance of the class. + /// + public YamlMappingNode(params KeyValuePair[] children) + : this((IEnumerable>)children) + { + } + + /// + /// Initializes a new instance of the class. + /// + public YamlMappingNode(IEnumerable> children) + { + foreach (var child in children) + { + this.children.Add(child); + } + } + + /// + /// Initializes a new instance of the class. + /// + /// A sequence of where even elements are keys and odd elements are values. + public YamlMappingNode(params YamlNode[] children) + : this((IEnumerable)children) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// A sequence of where even elements are keys and odd elements are values. + public YamlMappingNode(IEnumerable children) + { + using var enumerator = children.GetEnumerator(); + while (enumerator.MoveNext()) + { + var key = enumerator.Current; + if (!enumerator.MoveNext()) + { + throw new ArgumentException("When constructing a mapping node with a sequence, the number of elements of the sequence must be even."); + } + + Add(key, enumerator.Current); + } + } + + /// + /// Adds the specified mapping to the collection. + /// + /// The key node. + /// The value node. + public void Add(YamlNode key, YamlNode value) + { + children.Add(key, value); + } + + /// + /// Adds the specified mapping to the collection. + /// + /// The key node. + /// The value node. + public void Add(string key, YamlNode value) + { + children.Add(new YamlScalarNode(key), value); + } + + /// + /// Adds the specified mapping to the collection. + /// + /// The key node. + /// The value node. + public void Add(YamlNode key, string value) + { + children.Add(key, new YamlScalarNode(value)); + } + + /// + /// Adds the specified mapping to the collection. + /// + /// The key node. + /// The value node. + public void Add(string key, string value) + { + children.Add(new YamlScalarNode(key), new YamlScalarNode(value)); + } + + /// + /// Resolves the aliases that could not be resolved when the node was created. + /// + /// The state of the document. + internal override void ResolveAliases(DocumentLoadingState state) + { + Dictionary? keysToUpdate = null; + Dictionary? valuesToUpdate = null; + foreach (var entry in children) + { + if (entry.Key is YamlAliasNode) + { + if (keysToUpdate == null) + { + keysToUpdate = new Dictionary(); + } + // TODO: The representation model should be redesigned, because here the anchor could be null but that would be invalid YAML + keysToUpdate.Add(entry.Key, state.GetNode(entry.Key.Anchor!, entry.Key.Start, entry.Key.End)); + } + if (entry.Value is YamlAliasNode) + { + if (valuesToUpdate == null) + { + valuesToUpdate = new Dictionary(); + } + // TODO: The representation model should be redesigned, because here the anchor could be null but that would be invalid YAML + valuesToUpdate.Add(entry.Key, state.GetNode(entry.Value.Anchor!, entry.Value.Start, entry.Value.End)); + } + } + if (valuesToUpdate != null) + { + foreach (var entry in valuesToUpdate) + { + children[entry.Key] = entry.Value; + } + } + if (keysToUpdate != null) + { + foreach (var entry in keysToUpdate) + { + var value = children[entry.Key]; + children.Remove(entry.Key); + children.Add(entry.Value, value); + } + } + } + + /// + /// Saves the current node to the specified emitter. + /// + /// The emitter where the node is to be saved. + /// The state. + internal override void Emit(IEmitter emitter, EmitterState state) + { + emitter.Emit(new MappingStart(Anchor, Tag, true, Style)); + foreach (var entry in children) + { + entry.Key.Save(emitter, state); + entry.Value.Save(emitter, state); + } + emitter.Emit(new MappingEnd()); + } + + /// + /// Accepts the specified visitor by calling the appropriate Visit method on it. + /// + /// + /// A . + /// + public override void Accept(IYamlVisitor visitor) + { + visitor.Visit(this); + } + + /// + public override bool Equals(object? obj) + { + var other = obj as YamlMappingNode; + var areEqual = other != null + && Equals(Tag, other.Tag) + && children.Count == other.children.Count; + + if (!areEqual) + { + return false; + } + + foreach (var entry in children) + { + if (!other!.children.TryGetValue(entry.Key, out var otherNode) || !Equals(entry.Value, otherNode)) + { + return false; + } + } + + return true; + } + + /// + /// Serves as a hash function for a particular type. + /// + /// + /// A hash code for the current . + /// + public override int GetHashCode() + { + var hashCode = base.GetHashCode(); + + foreach (var entry in children) + { + hashCode = CombineHashCodes(hashCode, entry.Key); + hashCode = CombineHashCodes(hashCode, entry.Value); + } + return hashCode; + } + + /// + /// Recursively enumerates all the nodes from the document, starting on the current node, + /// and throwing + /// if is reached. + /// + internal override IEnumerable SafeAllNodes(RecursionLevel level) + { + level.Increment(); + yield return this; + foreach (var child in children) + { + foreach (var node in child.Key.SafeAllNodes(level)) + { + yield return node; + } + foreach (var node in child.Value.SafeAllNodes(level)) + { + yield return node; + } + } + level.Decrement(); + } + + /// + /// Gets the type of node. + /// + public override YamlNodeType NodeType + { + get { return YamlNodeType.Mapping; } + } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + internal override string ToString(RecursionLevel level) + { + if (!level.TryIncrement()) + { + return MaximumRecursionLevelReachedToStringValue; + } + + var text = new StringBuilder("{ "); + + foreach (var child in children) + { + if (text.Length > 2) + { + text.Append(", "); + } + text.Append("{ ").Append(child.Key.ToString(level)).Append(", ").Append(child.Value.ToString(level)).Append(" }"); + } + + text.Append(" }"); + + level.Decrement(); + + return text.ToString(); + } + + #region IEnumerable> Members + + /// + public IEnumerator> GetEnumerator() + { + return children.GetEnumerator(); + } + + #endregion + + #region IEnumerable Members + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + + void IYamlConvertible.Read(IParser parser, Type expectedType, ObjectDeserializer nestedObjectDeserializer) + { + Load(parser, new DocumentLoadingState()); + } + + void IYamlConvertible.Write(IEmitter emitter, ObjectSerializer nestedObjectSerializer) + { + Emit(emitter, new EmitterState()); + } + + /// + /// Creates a containing a key-value pair for each property of the specified object. + /// + public static YamlMappingNode FromObject(object mapping) + { + if (mapping == null) + { + throw new ArgumentNullException(nameof(mapping)); + } + + var result = new YamlMappingNode(); + foreach (var property in mapping.GetType().GetPublicProperties()) + { + // CanRead == true => GetGetMethod() != null + if (property.CanRead && property.GetGetMethod(false)!.GetParameters().Length == 0) + { + var value = property.GetValue(mapping, null); + if (!(value is YamlNode valueNode)) + { + var valueAsString = Convert.ToString(value); + valueNode = valueAsString ?? string.Empty; + } + result.Add(property.Name, valueNode); + } + } + return result; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlMappingNode.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlMappingNode.cs.meta new file mode 100644 index 0000000..62ec437 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlMappingNode.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 283c72dc1a159584988a79dd9d0a0a93 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNode.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNode.cs new file mode 100644 index 0000000..4c7885d --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNode.cs @@ -0,0 +1,236 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Represents a single node in the YAML document. + /// + public abstract class YamlNode + { + private const int MaximumRecursionLevel = 1000; + internal const string MaximumRecursionLevelReachedToStringValue = "WARNING! INFINITE RECURSION!"; + + /// + /// Gets or sets the anchor of the node. + /// + /// The anchor. + public AnchorName Anchor { get; set; } + + /// + /// Gets or sets the tag of the node. + /// + /// The tag. + public TagName Tag { get; set; } + + /// + /// Gets the position in the input stream where the event that originated the node starts. + /// + public Mark Start { get; private set; } = Mark.Empty; + + /// + /// Gets the position in the input stream where the event that originated the node ends. + /// + public Mark End { get; private set; } = Mark.Empty; + + /// + /// Loads the specified event. + /// + /// The event. + /// The state of the document. + internal void Load(NodeEvent yamlEvent, DocumentLoadingState state) + { + Tag = yamlEvent.Tag; + if (!yamlEvent.Anchor.IsEmpty) + { + Anchor = yamlEvent.Anchor; + state.AddAnchor(this); + } + Start = yamlEvent.Start; + End = yamlEvent.End; + } + + /// + /// Parses the node represented by the next event in . + /// + /// Returns the node that has been parsed. + internal static YamlNode ParseNode(IParser parser, DocumentLoadingState state) + { + if (parser.Accept(out var _)) + { + return new YamlScalarNode(parser, state); + } + + if (parser.Accept(out var _)) + { + return new YamlSequenceNode(parser, state); + } + + if (parser.Accept(out var _)) + { + return new YamlMappingNode(parser, state); + } + + if (parser.TryConsume(out var alias)) + { + return state.TryGetNode(alias.Value, out var node) ? node : new YamlAliasNode(alias.Value); + } + + throw new ArgumentException("The current event is of an unsupported type.", nameof(parser)); + } + + /// + /// Resolves the aliases that could not be resolved when the node was created. + /// + /// The state of the document. + internal abstract void ResolveAliases(DocumentLoadingState state); + + /// + /// Saves the current node to the specified emitter. + /// + /// The emitter where the node is to be saved. + /// The state. + internal void Save(IEmitter emitter, EmitterState state) + { + if (!Anchor.IsEmpty && !state.EmittedAnchors.Add(Anchor)) + { + emitter.Emit(new AnchorAlias(Anchor)); + } + else + { + Emit(emitter, state); + } + } + + /// + /// Saves the current node to the specified emitter. + /// + /// The emitter where the node is to be saved. + /// The state. + internal abstract void Emit(IEmitter emitter, EmitterState state); + + /// + /// Accepts the specified visitor by calling the appropriate Visit method on it. + /// + /// + /// A . + /// + public abstract void Accept(IYamlVisitor visitor); + + public override string ToString() + { + var level = new RecursionLevel(MaximumRecursionLevel); + return ToString(level); + } + + internal abstract string ToString(RecursionLevel level); + + /// + /// Gets all nodes from the document, starting on the current node. + /// is thrown if an infinite recursion is detected. + /// + public IEnumerable AllNodes + { + get + { + var level = new RecursionLevel(MaximumRecursionLevel); + return SafeAllNodes(level); + } + } + + /// + /// When implemented, recursively enumerates all the nodes from the document, starting on the current node. + /// If is reached, a is thrown + /// instead of continuing and crashing with a . + /// + internal abstract IEnumerable SafeAllNodes(RecursionLevel level); + + /// + /// Gets the type of node. + /// + public abstract YamlNodeType NodeType + { + get; + } + + /// + /// Performs an implicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static implicit operator YamlNode(string value) + { + return new YamlScalarNode(value); + } + + /// + /// Performs an implicit conversion from string[] to . + /// + /// The value. + /// The result of the conversion. + public static implicit operator YamlNode(string[] sequence) + { + return new YamlSequenceNode(sequence.Select(i => (YamlNode)i)); + } + + /// + /// Converts a to a string by returning its value. + /// + public static explicit operator string?(YamlNode node) + { + return node is YamlScalarNode scalar + ? scalar.Value + : throw new ArgumentException($"Attempted to convert a '{node.NodeType}' to string. This conversion is valid only for Scalars."); + } + + /// + /// Gets the nth element in a . + /// + public YamlNode this[int index] + { + get + { + return this is YamlSequenceNode sequence + ? sequence.Children[index] + : throw new ArgumentException($"Accessed '{NodeType}' with an invalid index: {index}. Only Sequences can be indexed by number."); + } + } + + /// + /// Gets the value associated with a key in a . + /// + public YamlNode this[YamlNode key] + { + get + { + return this is YamlMappingNode mapping + ? mapping.Children[key] + : throw new ArgumentException($"Accessed '{NodeType}' with an invalid index: {key}. Only Mappings can be indexed by key."); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNode.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNode.cs.meta new file mode 100644 index 0000000..f12ddbe --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNode.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b80625eae8f97124f832aed15c4c6b57 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeIdentityEqualityComparer.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeIdentityEqualityComparer.cs new file mode 100644 index 0000000..47744c8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeIdentityEqualityComparer.cs @@ -0,0 +1,48 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Comparer that is based on identity comparisons. + /// + public sealed class YamlNodeIdentityEqualityComparer : IEqualityComparer + { + #region IEqualityComparer Members + + /// + public bool Equals([AllowNull] YamlNode x, [AllowNull] YamlNode y) + { + return ReferenceEquals(x, y); + } + + /// + public int GetHashCode(YamlNode obj) + { + return obj.GetHashCode(); + } + + #endregion + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeIdentityEqualityComparer.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeIdentityEqualityComparer.cs.meta new file mode 100644 index 0000000..1eded75 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeIdentityEqualityComparer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 70ec622c4d503a448ba4d5410c55d8bd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeType.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeType.cs new file mode 100644 index 0000000..70d78a7 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeType.cs @@ -0,0 +1,49 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Specifies the type of node in the representation model. + /// + public enum YamlNodeType + { + /// + /// The node is a . + /// + Alias, + + /// + /// The node is a . + /// + Mapping, + + /// + /// The node is a . + /// + Scalar, + + /// + /// The node is a . + /// + Sequence + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeType.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeType.cs.meta new file mode 100644 index 0000000..6243f29 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlNodeType.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6fedd304363f0ee4a9d32ea69940e2c9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlScalarNode.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlScalarNode.cs new file mode 100644 index 0000000..c2e0957 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlScalarNode.cs @@ -0,0 +1,180 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Serialization; +using static YamlDotNet.Core.HashCode; + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Represents a scalar node in the YAML document. + /// + [DebuggerDisplay("{Value}")] + public sealed class YamlScalarNode : YamlNode, IYamlConvertible + { + /// + /// Gets or sets the value of the node. + /// + /// The value. + public string? Value { get; set; } + + /// + /// Gets or sets the style of the node. + /// + /// The style. + public ScalarStyle Style { get; set; } + + /// + /// Initializes a new instance of the class. + /// + internal YamlScalarNode(IParser parser, DocumentLoadingState state) + { + Load(parser, state); + } + + private void Load(IParser parser, DocumentLoadingState state) + { + var scalar = parser.Consume(); + Load(scalar, state); + Value = scalar.Value; + Style = scalar.Style; + } + + /// + /// Initializes a new instance of the class. + /// + public YamlScalarNode() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The value. + public YamlScalarNode(string? value) + { + this.Value = value; + } + + /// + /// Resolves the aliases that could not be resolved when the node was created. + /// + /// The state of the document. + internal override void ResolveAliases(DocumentLoadingState state) + { + throw new NotSupportedException("Resolving an alias on a scalar node does not make sense"); + } + + /// + /// Saves the current node to the specified emitter. + /// + /// The emitter where the node is to be saved. + /// The state. + internal override void Emit(IEmitter emitter, EmitterState state) + { + emitter.Emit(new Scalar(Anchor, Tag, Value ?? string.Empty, Style, Tag.IsEmpty, false)); + } + + /// + /// Accepts the specified visitor by calling the appropriate Visit method on it. + /// + /// + /// A . + /// + public override void Accept(IYamlVisitor visitor) + { + visitor.Visit(this); + } + + /// + public override bool Equals(object? obj) + { + return obj is YamlScalarNode other + && Equals(Tag, other.Tag) + && Equals(Value, other.Value); + } + + /// + /// Serves as a hash function for a particular type. + /// + /// + /// A hash code for the current . + /// + public override int GetHashCode() + { + return CombineHashCodes(Tag, Value); + } + + /// + /// Performs an explicit conversion from to . + /// + /// The value. + /// The result of the conversion. + public static explicit operator string?(YamlScalarNode value) + { + return value.Value; + } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + internal override string ToString(RecursionLevel level) + { + return Value ?? string.Empty; + } + + /// + /// Recursively enumerates all the nodes from the document, starting on the current node, + /// and throwing + /// if is reached. + /// + internal override IEnumerable SafeAllNodes(RecursionLevel level) + { + yield return this; + } + + /// + /// Gets the type of node. + /// + public override YamlNodeType NodeType + { + get { return YamlNodeType.Scalar; } + } + + void IYamlConvertible.Read(IParser parser, Type expectedType, ObjectDeserializer nestedObjectDeserializer) + { + Load(parser, new DocumentLoadingState()); + } + + void IYamlConvertible.Write(IEmitter emitter, ObjectSerializer nestedObjectSerializer) + { + Emit(emitter, new EmitterState()); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlScalarNode.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlScalarNode.cs.meta new file mode 100644 index 0000000..97f9795 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlScalarNode.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d8152305d4536da4c91eb19aa04b401c +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlSequenceNode.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlSequenceNode.cs new file mode 100644 index 0000000..c9fd9c1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlSequenceNode.cs @@ -0,0 +1,301 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Serialization; +using static YamlDotNet.Core.HashCode; + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Represents a sequence node in the YAML document. + /// + [DebuggerDisplay("Count = {children.Count}")] + public sealed class YamlSequenceNode : YamlNode, IEnumerable, IYamlConvertible + { + private readonly IList children = new List(); + + /// + /// Gets the collection of child nodes. + /// + /// The children. + public IList Children + { + get + { + return children; + } + } + + /// + /// Gets or sets the style of the node. + /// + /// The style. + public SequenceStyle Style { get; set; } + + + /// + /// Initializes a new instance of the class. + /// + internal YamlSequenceNode(IParser parser, DocumentLoadingState state) + { + Load(parser, state); + } + + private void Load(IParser parser, DocumentLoadingState state) + { + var sequence = parser.Consume(); + Load(sequence, state); + Style = sequence.Style; + + var hasUnresolvedAliases = false; + while (!parser.TryConsume(out var _)) + { + var child = ParseNode(parser, state); + children.Add(child); + hasUnresolvedAliases |= child is YamlAliasNode; + } + + if (hasUnresolvedAliases) + { + state.AddNodeWithUnresolvedAliases(this); + } + } + + /// + /// Initializes a new instance of the class. + /// + public YamlSequenceNode() + { + } + + /// + /// Initializes a new instance of the class. + /// + public YamlSequenceNode(params YamlNode[] children) + : this((IEnumerable)children) + { + } + + /// + /// Initializes a new instance of the class. + /// + public YamlSequenceNode(IEnumerable children) + { + foreach (var child in children) + { + this.children.Add(child); + } + } + + /// + /// Adds the specified child to the collection. + /// + /// The child. + public void Add(YamlNode child) + { + children.Add(child); + } + + /// + /// Adds a scalar node to the collection. + /// + /// The child. + public void Add(string child) + { + children.Add(new YamlScalarNode(child)); + } + + /// + /// Resolves the aliases that could not be resolved when the node was created. + /// + /// The state of the document. + internal override void ResolveAliases(DocumentLoadingState state) + { + for (var i = 0; i < children.Count; ++i) + { + if (children[i] is YamlAliasNode) + { + children[i] = state.GetNode(children[i].Anchor!, children[i].Start, children[i].End); + } + } + } + + /// + /// Saves the current node to the specified emitter. + /// + /// The emitter where the node is to be saved. + /// The state. + internal override void Emit(IEmitter emitter, EmitterState state) + { + emitter.Emit(new SequenceStart(Anchor, Tag, Tag.IsEmpty, Style)); + foreach (var node in children) + { + node.Save(emitter, state); + } + emitter.Emit(new SequenceEnd()); + } + + /// + /// Accepts the specified visitor by calling the appropriate Visit method on it. + /// + /// + /// A . + /// + public override void Accept(IYamlVisitor visitor) + { + visitor.Visit(this); + } + + /// + public override bool Equals(object? obj) + { + var other = obj as YamlSequenceNode; + var areEqual = other != null + && Equals(Tag, other.Tag) + && children.Count == other.children.Count; + + if (!areEqual) + { + return false; + } + + for (var i = 0; i < children.Count; ++i) + { + if (!Equals(children[i], other!.children[i])) + { + return false; + } + } + + return true; + } + + /// + /// Serves as a hash function for a particular type. + /// + /// + /// A hash code for the current . + /// + public override int GetHashCode() + { + var hashCode = 0; + foreach (var item in children) + { + hashCode = CombineHashCodes(hashCode, item); + } + hashCode = CombineHashCodes(hashCode, Tag); + return hashCode; + } + + /// + /// Recursively enumerates all the nodes from the document, starting on the current node, + /// and throwing + /// if is reached. + /// + internal override IEnumerable SafeAllNodes(RecursionLevel level) + { + level.Increment(); + yield return this; + foreach (var child in children) + { + foreach (var node in child.SafeAllNodes(level)) + { + yield return node; + } + } + level.Decrement(); + } + + /// + /// Gets the type of node. + /// + public override YamlNodeType NodeType + { + get { return YamlNodeType.Sequence; } + } + + /// + /// Returns a that represents this instance. + /// + /// + /// A that represents this instance. + /// + internal override string ToString(RecursionLevel level) + { + if (!level.TryIncrement()) + { + return MaximumRecursionLevelReachedToStringValue; + } + + var text = new StringBuilder("[ "); + + foreach (var child in children) + { + if (text.Length > 2) + { + text.Append(", "); + } + text.Append(child.ToString(level)); + } + + text.Append(" ]"); + + level.Decrement(); + + return text.ToString(); + } + + #region IEnumerable Members + + /// + public IEnumerator GetEnumerator() + { + return Children.GetEnumerator(); + } + + #endregion + + #region IEnumerable Members + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + + void IYamlConvertible.Read(IParser parser, Type expectedType, ObjectDeserializer nestedObjectDeserializer) + { + Load(parser, new DocumentLoadingState()); + } + + void IYamlConvertible.Write(IEmitter emitter, ObjectSerializer nestedObjectSerializer) + { + Emit(emitter, new EmitterState()); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlSequenceNode.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlSequenceNode.cs.meta new file mode 100644 index 0000000..26255b6 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlSequenceNode.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 58e9eea9b495b2f478b639f1d20a8951 +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlStream.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlStream.cs new file mode 100644 index 0000000..9a74424 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlStream.cs @@ -0,0 +1,172 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Collections.Generic; +using System.IO; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Represents an YAML stream. + /// + public class YamlStream : IEnumerable + { + private readonly IList documents = new List(); + + /// + /// Gets the documents inside the stream. + /// + /// The documents. + public IList Documents + { + get + { + return documents; + } + } + + /// + /// Initializes a new instance of the class. + /// + public YamlStream() + { + } + + /// + /// Initializes a new instance of the class. + /// + public YamlStream(params YamlDocument[] documents) + : this((IEnumerable)documents) + { + } + + /// + /// Initializes a new instance of the class. + /// + public YamlStream(IEnumerable documents) + { + foreach (var document in documents) + { + this.documents.Add(document); + } + } + + /// + /// Adds the specified document to the collection. + /// + /// The document. + public void Add(YamlDocument document) + { + documents.Add(document); + } + + /// + /// Loads the stream from the specified input. + /// + /// The input. + public void Load(TextReader input) + { + Load(new Parser(input)); + } + + /// + /// Loads the stream from the specified . + /// + public void Load(IParser parser) + { + documents.Clear(); + parser.Consume(); + while (!parser.TryConsume(out var _)) + { + var document = new YamlDocument(parser); + documents.Add(document); + } + } + + /// + /// Saves the stream to the specified output. + /// + /// The output. + public void Save(TextWriter output) + { + Save(output, true); + } + + /// + /// Saves the stream to the specified output. + /// + /// The output. + /// Indicates whether or not to assign node anchors. + public void Save(TextWriter output, bool assignAnchors) + { + Save(new Emitter(output), assignAnchors); + } + + /// + /// Saves the stream to the specified emitter. + /// + /// The emitter. + /// Indicates whether or not to assign node anchors. + public void Save(IEmitter emitter, bool assignAnchors) + { + emitter.Emit(new StreamStart()); + + foreach (var document in documents) + { + document.Save(emitter, assignAnchors); + } + + emitter.Emit(new StreamEnd()); + } + + /// + /// Accepts the specified visitor by calling the appropriate Visit method on it. + /// + /// + /// A . + /// + public void Accept(IYamlVisitor visitor) + { + visitor.Visit(this); + } + + #region IEnumerable Members + + /// + public IEnumerator GetEnumerator() + { + return documents.GetEnumerator(); + } + + #endregion + + #region IEnumerable Members + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + #endregion + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlStream.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlStream.cs.meta new file mode 100644 index 0000000..527ef40 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlStream.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8da956833fe9bb440be293c2b18b1e29 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitor.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitor.cs new file mode 100644 index 0000000..0514fa5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitor.cs @@ -0,0 +1,233 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Abstract implementation of that knows how to walk a complete Yaml object model. + /// + [Obsolete("Use YamlVisitorBase")] + public abstract class YamlVisitor : IYamlVisitor + { + /// + /// Called when this object is visiting a . + /// + /// + /// The that is being visited. + /// + protected virtual void Visit(YamlStream stream) + { + // Do nothing. + } + + /// + /// Called after this object finishes visiting a . + /// + /// + /// The that has been visited. + /// + protected virtual void Visited(YamlStream stream) + { + // Do nothing. + } + + /// + /// Called when this object is visiting a . + /// + /// + /// The that is being visited. + /// + protected virtual void Visit(YamlDocument document) + { + // Do nothing. + } + + /// + /// Called after this object finishes visiting a . + /// + /// + /// The that has been visited. + /// + protected virtual void Visited(YamlDocument document) + { + // Do nothing. + } + + /// + /// Called when this object is visiting a . + /// + /// + /// The that is being visited. + /// + protected virtual void Visit(YamlScalarNode scalar) + { + // Do nothing. + } + + /// + /// Called after this object finishes visiting a . + /// + /// + /// The that has been visited. + /// + protected virtual void Visited(YamlScalarNode scalar) + { + // Do nothing. + } + + /// + /// Called when this object is visiting a . + /// + /// + /// The that is being visited. + /// + protected virtual void Visit(YamlSequenceNode sequence) + { + // Do nothing. + } + + /// + /// Called after this object finishes visiting a . + /// + /// + /// The that has been visited. + /// + protected virtual void Visited(YamlSequenceNode sequence) + { + // Do nothing. + } + + /// + /// Called when this object is visiting a . + /// + /// + /// The that is being visited. + /// + protected virtual void Visit(YamlMappingNode mapping) + { + // Do nothing. + } + + /// + /// Called after this object finishes visiting a . + /// + /// + /// The that has been visited. + /// + protected virtual void Visited(YamlMappingNode mapping) + { + // Do nothing. + } + + /// + /// Visits every child of a . + /// + /// + /// The that is being visited. + /// + protected virtual void VisitChildren(YamlStream stream) + { + foreach (var document in stream.Documents) + { + document.Accept(this); + } + } + + /// + /// Visits every child of a . + /// + /// + /// The that is being visited. + /// + protected virtual void VisitChildren(YamlDocument document) + { + if (document.RootNode != null) + { + document.RootNode.Accept(this); + } + } + + /// + /// Visits every child of a . + /// + /// + /// The that is being visited. + /// + protected virtual void VisitChildren(YamlSequenceNode sequence) + { + foreach (var node in sequence.Children) + { + node.Accept(this); + } + } + + /// + /// Visits every child of a . + /// + /// + /// The that is being visited. + /// + protected virtual void VisitChildren(YamlMappingNode mapping) + { + foreach (var pair in mapping.Children) + { + pair.Key.Accept(this); + pair.Value.Accept(this); + } + } + + void IYamlVisitor.Visit(YamlStream stream) + { + Visit(stream); + VisitChildren(stream); + Visited(stream); + } + + void IYamlVisitor.Visit(YamlDocument document) + { + Visit(document); + VisitChildren(document); + Visited(document); + } + + void IYamlVisitor.Visit(YamlScalarNode scalar) + { + Visit(scalar); + Visited(scalar); + } + + void IYamlVisitor.Visit(YamlSequenceNode sequence) + { + Visit(sequence); + VisitChildren(sequence); + Visited(sequence); + } + + void IYamlVisitor.Visit(YamlMappingNode mapping) + { + Visit(mapping); + VisitChildren(mapping); + Visited(mapping); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitor.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitor.cs.meta new file mode 100644 index 0000000..477bad5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f0c6d456c0cd3544f98e1dac39bf17ed +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitorBase.cs b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitorBase.cs new file mode 100644 index 0000000..088526e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitorBase.cs @@ -0,0 +1,151 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.RepresentationModel +{ + /// + /// Abstract implementation of that knows how to walk a complete YAML object model. + /// + public abstract class YamlVisitorBase : IYamlVisitor + { + /// + /// Called when this object is visiting a . + /// + /// + /// The that is being visited. + /// + public virtual void Visit(YamlStream stream) + { + VisitChildren(stream); + } + + /// + /// Called when this object is visiting a . + /// + /// + /// The that is being visited. + /// + public virtual void Visit(YamlDocument document) + { + VisitChildren(document); + } + + /// + /// Called when this object is visiting a . + /// + /// + /// The that is being visited. + /// + public virtual void Visit(YamlScalarNode scalar) + { + // Do nothing. + } + + /// + /// Called when this object is visiting a . + /// + /// + /// The that is being visited. + /// + public virtual void Visit(YamlSequenceNode sequence) + { + VisitChildren(sequence); + } + + /// + /// Called when this object is visiting a . + /// + /// + /// The that is being visited. + /// + public virtual void Visit(YamlMappingNode mapping) + { + VisitChildren(mapping); + } + + /// + /// Called when this object is visiting a key-value pair. + /// + /// The left (key) that is being visited. + /// The right (value) that is being visited. + protected virtual void VisitPair(YamlNode key, YamlNode value) + { + key.Accept(this); + value.Accept(this); + } + + /// + /// Visits every child of a . + /// + /// + /// The that is being visited. + /// + protected virtual void VisitChildren(YamlStream stream) + { + foreach (var document in stream.Documents) + { + document.Accept(this); + } + } + + /// + /// Visits every child of a . + /// + /// + /// The that is being visited. + /// + protected virtual void VisitChildren(YamlDocument document) + { + if (document.RootNode != null) + { + document.RootNode.Accept(this); + } + } + + /// + /// Visits every child of a . + /// + /// + /// The that is being visited. + /// + protected virtual void VisitChildren(YamlSequenceNode sequence) + { + foreach (var node in sequence.Children) + { + node.Accept(this); + } + } + + /// + /// Visits every child of a . + /// + /// + /// The that is being visited. + /// + protected virtual void VisitChildren(YamlMappingNode mapping) + { + foreach (var pair in mapping.Children) + { + VisitPair(pair.Key, pair.Value); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitorBase.cs.meta b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitorBase.cs.meta new file mode 100644 index 0000000..7967156 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/RepresentationModel/YamlVisitorBase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2776bd25d70b784469150ddda10b614e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization.meta b/namedropper/Assets/YamlDotNet/Serialization.meta new file mode 100644 index 0000000..2d19244 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 921c26b7d8a14f44784b5de7fa74bba0 +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/BuilderSkeleton.cs b/namedropper/Assets/YamlDotNet/Serialization/BuilderSkeleton.cs new file mode 100644 index 0000000..dfe23a7 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/BuilderSkeleton.cs @@ -0,0 +1,326 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using YamlDotNet.Core; +using YamlDotNet.Serialization.Converters; +using YamlDotNet.Serialization.NamingConventions; +using YamlDotNet.Serialization.TypeInspectors; + +namespace YamlDotNet.Serialization +{ + /// + /// Common implementation of and . + /// + public abstract class BuilderSkeleton + where TBuilder : BuilderSkeleton + { + internal INamingConvention namingConvention = NullNamingConvention.Instance; + internal ITypeResolver typeResolver; + internal readonly YamlAttributeOverrides overrides; + internal readonly LazyComponentRegistrationList typeConverterFactories; + internal readonly LazyComponentRegistrationList typeInspectorFactories; + private bool ignoreFields; + private bool includeNonPublicProperties = false; + + internal BuilderSkeleton(ITypeResolver typeResolver) + { + overrides = new YamlAttributeOverrides(); + + typeConverterFactories = new LazyComponentRegistrationList + { + { typeof(GuidConverter), _ => new GuidConverter(false) }, + { typeof(SystemTypeConverter), _ => new SystemTypeConverter() } + }; + + typeInspectorFactories = new LazyComponentRegistrationList(); + this.typeResolver = typeResolver ?? throw new ArgumentNullException(nameof(typeResolver)); + } + + protected abstract TBuilder Self { get; } + + internal ITypeInspector BuildTypeInspector() + { + ITypeInspector innerInspector = new ReadablePropertiesTypeInspector(typeResolver, includeNonPublicProperties); + if (!ignoreFields) + { + innerInspector = new CompositeTypeInspector( + new ReadableFieldsTypeInspector(typeResolver), + innerInspector + ); + } + + return typeInspectorFactories.BuildComponentChain(innerInspector); + } + + /// + /// Prevents serialization and deserialization of fields. + /// + /// + public TBuilder IgnoreFields() + { + ignoreFields = true; + return Self; + } + + /// + /// Allows serialization and deserialization of non-public properties. + /// + public TBuilder IncludeNonPublicProperties() + { + includeNonPublicProperties = true; + return Self; + } + + /// + /// Sets the that will be used by the (de)serializer. + /// + public TBuilder WithNamingConvention(INamingConvention namingConvention) + { + this.namingConvention = namingConvention ?? throw new ArgumentNullException(nameof(namingConvention)); + return Self; + } + + /// + /// Sets the that will be used by the (de)serializer. + /// + public TBuilder WithTypeResolver(ITypeResolver typeResolver) + { + this.typeResolver = typeResolver ?? throw new ArgumentNullException(nameof(typeResolver)); + return Self; + } + + public abstract TBuilder WithTagMapping(TagName tag, Type type); + +#if !NET20 + /// + /// Register an for a given property. + /// + /// + /// An expression in the form: x => x.SomeProperty + /// The attribute to register. + /// + public TBuilder WithAttributeOverride(System.Linq.Expressions.Expression> propertyAccessor, Attribute attribute) + { + overrides.Add(propertyAccessor, attribute); + return Self; + } +#endif + + /// + /// Register an for a given property. + /// + public TBuilder WithAttributeOverride(Type type, string member, Attribute attribute) + { + overrides.Add(type, member, attribute); + return Self; + } + + /// + /// Registers an additional to be used by the (de)serializer. + /// + public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter) + { + return WithTypeConverter(typeConverter, w => w.OnTop()); + } + + /// + /// Registers an additional to be used by the (de)serializer. + /// + /// + /// Configures the location where to insert the + public TBuilder WithTypeConverter( + IYamlTypeConverter typeConverter, + Action> where + ) + { + if (typeConverter == null) + { + throw new ArgumentNullException(nameof(typeConverter)); + } + + if (where == null) + { + throw new ArgumentNullException(nameof(where)); + } + + where(typeConverterFactories.CreateRegistrationLocationSelector(typeConverter.GetType(), _ => typeConverter)); + return Self; + } + + /// + /// Registers an additional to be used by the (de)serializer. + /// + /// A factory that creates the based on a previously registered . + /// Configures the location where to insert the + public TBuilder WithTypeConverter( + WrapperFactory typeConverterFactory, + Action> where + ) + where TYamlTypeConverter : IYamlTypeConverter + { + if (typeConverterFactory == null) + { + throw new ArgumentNullException(nameof(typeConverterFactory)); + } + + if (where == null) + { + throw new ArgumentNullException(nameof(where)); + } + + where(typeConverterFactories.CreateTrackingRegistrationLocationSelector(typeof(TYamlTypeConverter), (wrapped, _) => typeConverterFactory(wrapped))); + return Self; + } + + /// + /// Unregisters an existing of type . + /// + public TBuilder WithoutTypeConverter() + where TYamlTypeConverter : IYamlTypeConverter + { + return WithoutTypeConverter(typeof(TYamlTypeConverter)); + } + + /// + /// Unregisters an existing of type . + /// + public TBuilder WithoutTypeConverter(Type converterType) + { + if (converterType == null) + { + throw new ArgumentNullException(nameof(converterType)); + } + + typeConverterFactories.Remove(converterType); + return Self; + } + + /// + /// Registers an additional to be used by the (de)serializer. + /// + /// A function that instantiates the type inspector. + public TBuilder WithTypeInspector(Func typeInspectorFactory) + where TTypeInspector : ITypeInspector + { + return WithTypeInspector(typeInspectorFactory, w => w.OnTop()); + } + + /// + /// Registers an additional to be used by the (de)serializer. + /// + /// A function that instantiates the type inspector. + /// Configures the location where to insert the + public TBuilder WithTypeInspector( + Func typeInspectorFactory, + Action> where + ) + where TTypeInspector : ITypeInspector + { + if (typeInspectorFactory == null) + { + throw new ArgumentNullException(nameof(typeInspectorFactory)); + } + + if (where == null) + { + throw new ArgumentNullException(nameof(where)); + } + + where(typeInspectorFactories.CreateRegistrationLocationSelector(typeof(TTypeInspector), inner => typeInspectorFactory(inner))); + return Self; + } + + /// + /// Registers an additional to be used by the (de)serializer. + /// + /// A function that instantiates the type inspector based on a previously registered .. + /// Configures the location where to insert the + public TBuilder WithTypeInspector( + WrapperFactory typeInspectorFactory, + Action> where + ) + where TTypeInspector : ITypeInspector + { + if (typeInspectorFactory == null) + { + throw new ArgumentNullException(nameof(typeInspectorFactory)); + } + + if (where == null) + { + throw new ArgumentNullException(nameof(where)); + } + + where(typeInspectorFactories.CreateTrackingRegistrationLocationSelector(typeof(TTypeInspector), (wrapped, inner) => typeInspectorFactory(wrapped, inner))); + return Self; + } + + /// + /// Unregisters an existing of type . + /// + public TBuilder WithoutTypeInspector() + where TTypeInspector : ITypeInspector + { + return WithoutTypeInspector(typeof(TTypeInspector)); + } + + /// + /// Unregisters an existing of type . + /// + public TBuilder WithoutTypeInspector(Type inspectorType) + { + if (inspectorType == null) + { + throw new ArgumentNullException(nameof(inspectorType)); + } + + typeInspectorFactories.Remove(inspectorType); + return Self; + } + + protected IEnumerable BuildTypeConverters() + { + return typeConverterFactories.BuildComponentList(); + } + } + + /// + /// A factory that creates instances of based on an existing . + /// + /// The type of the wrapped component. + /// The type of the component that this factory creates. + /// The component that is to be wrapped. + /// Returns a new instance of that is based on . + public delegate TComponent WrapperFactory(TComponentBase wrapped) where TComponent : TComponentBase; + + /// + /// A factory that creates instances of based on an existing and an argument. + /// + /// The type of the argument. + /// The type of the wrapped component. + /// The type of the component that this factory creates. + /// The component that is to be wrapped. + /// The argument of the factory. + /// Returns a new instance of that is based on and . + public delegate TComponent WrapperFactory(TComponentBase wrapped, TArgument argument) where TComponent : TComponentBase; +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/BuilderSkeleton.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/BuilderSkeleton.cs.meta new file mode 100644 index 0000000..a254bb8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/BuilderSkeleton.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7d3f73aa22328f342ab53072ea83da7d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Converters.meta b/namedropper/Assets/YamlDotNet/Serialization/Converters.meta new file mode 100644 index 0000000..0e08b11 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Converters.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 272f43609d820fd4aa820cc0636fe694 +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Converters/DateTimeConverter.cs b/namedropper/Assets/YamlDotNet/Serialization/Converters/DateTimeConverter.cs new file mode 100644 index 0000000..3de9b9d --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Converters/DateTimeConverter.cs @@ -0,0 +1,115 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Globalization; +using System.Linq; + +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization.Converters +{ + /// + /// This represents the YAML converter entity for . + /// + public class DateTimeConverter : IYamlTypeConverter + { + private readonly DateTimeKind kind; + private readonly IFormatProvider provider; + private readonly string[] formats; + + /// + /// Initializes a new instance of the class. + /// + /// value. Default value is . is considered as . + /// instance. Default value is . + /// List of date/time formats for parsing. Default value is "G". + /// On deserializing, all formats in the list are used for conversion, while on serializing, the first format in the list is used. + public DateTimeConverter(DateTimeKind kind = DateTimeKind.Utc, IFormatProvider? provider = null, params string[] formats) + { + this.kind = kind == DateTimeKind.Unspecified ? DateTimeKind.Utc : kind; + this.provider = provider ?? CultureInfo.InvariantCulture; + this.formats = formats.DefaultIfEmpty("G").ToArray(); + } + + /// + /// Gets a value indicating whether the current converter supports converting the specified type. + /// + /// to check. + /// Returns True, if the current converter supports; otherwise returns False. + public bool Accepts(Type type) + { + return type == typeof(DateTime); + } + + /// + /// Reads an object's state from a YAML parser. + /// + /// instance. + /// to convert. + /// Returns the instance converted. + /// On deserializing, all formats in the list are used for conversion. + public object ReadYaml(IParser parser, Type type) + { + var value = parser.Consume().Value; + var style = this.kind == DateTimeKind.Local ? DateTimeStyles.AssumeLocal : DateTimeStyles.AssumeUniversal; + + var dt = DateTime.ParseExact(value, this.formats, this.provider, style); + dt = EnsureDateTimeKind(dt, this.kind); + return dt; + } + + /// + /// Writes the specified object's state to a YAML emitter. + /// + /// instance. + /// Value to write. + /// to convert. + /// On serializing, the first format in the list is used. + public void WriteYaml(IEmitter emitter, object? value, Type type) + { + var dt = (DateTime)value!; + var adjusted = this.kind == DateTimeKind.Local ? dt.ToLocalTime() : dt.ToUniversalTime(); + var formatted = adjusted.ToString(this.formats.First(), this.provider); // Always take the first format of the list. + + emitter.Emit(new Scalar(AnchorName.Empty, TagName.Empty, formatted, ScalarStyle.Any, true, false)); + } + + private static DateTime EnsureDateTimeKind(DateTime dt, DateTimeKind kind) + { + DateTime ensured; + if (dt.Kind == DateTimeKind.Local && kind == DateTimeKind.Utc) + { + ensured = dt.ToUniversalTime(); + return ensured; + } + + if (dt.Kind == DateTimeKind.Utc && kind == DateTimeKind.Local) + { + ensured = dt.ToLocalTime(); + return ensured; + } + + return dt; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/Converters/DateTimeConverter.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/Converters/DateTimeConverter.cs.meta new file mode 100644 index 0000000..df979d3 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Converters/DateTimeConverter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 59f426f3754afee449a7e275b7a0c119 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Converters/GuidConverter.cs b/namedropper/Assets/YamlDotNet/Serialization/Converters/GuidConverter.cs new file mode 100644 index 0000000..e93707b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Converters/GuidConverter.cs @@ -0,0 +1,57 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization.Converters +{ + /// + /// Converter for System.Guid. + /// + public class GuidConverter : IYamlTypeConverter + { + private readonly bool jsonCompatible; + + public GuidConverter(bool jsonCompatible) + { + this.jsonCompatible = jsonCompatible; + } + + public bool Accepts(Type type) + { + return type == typeof(Guid); + } + + public object ReadYaml(IParser parser, Type type) + { + var value = parser.Consume().Value; + return new Guid(value); + } + + public void WriteYaml(IEmitter emitter, object? value, Type type) + { + var guid = (Guid)value!; + emitter.Emit(new Scalar(AnchorName.Empty, TagName.Empty, guid.ToString("D"), jsonCompatible ? ScalarStyle.DoubleQuoted : ScalarStyle.Any, true, false)); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/Converters/GuidConverter.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/Converters/GuidConverter.cs.meta new file mode 100644 index 0000000..78d0b23 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Converters/GuidConverter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2034b2a36cbe85a438addb075cff648b +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Converters/SystemTypeConverter.cs b/namedropper/Assets/YamlDotNet/Serialization/Converters/SystemTypeConverter.cs new file mode 100644 index 0000000..c819b0b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Converters/SystemTypeConverter.cs @@ -0,0 +1,53 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization.Converters +{ + /// + /// Converter for System.Type. + /// + /// + /// Converts to a scalar containing the assembly qualified name of the type. + /// + public class SystemTypeConverter : IYamlTypeConverter + { + public bool Accepts(Type type) + { + return typeof(Type).IsAssignableFrom(type); + } + + public object ReadYaml(IParser parser, Type type) + { + var value = parser.Consume().Value; + return Type.GetType(value, throwOnError: true)!; // Will throw instead of returning null + } + + public void WriteYaml(IEmitter emitter, object? value, Type type) + { + var systemType = (Type)value!; + emitter.Emit(new Scalar(AnchorName.Empty, TagName.Empty, systemType.AssemblyQualifiedName!, ScalarStyle.Any, true, false)); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/Converters/SystemTypeConverter.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/Converters/SystemTypeConverter.cs.meta new file mode 100644 index 0000000..531c3e1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Converters/SystemTypeConverter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eb56a8270f28ae3438392cb2cfebe3b6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/DefaultValuesHandling.cs b/namedropper/Assets/YamlDotNet/Serialization/DefaultValuesHandling.cs new file mode 100644 index 0000000..f1ecab8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/DefaultValuesHandling.cs @@ -0,0 +1,52 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Serialization +{ + /// + /// Specifies the strategy to handle default and null values during serialization of properties. + /// + [Flags] + public enum DefaultValuesHandling + { + /// + /// Specifies that all properties are to be emitted regardless of their value. This is the default behavior. + /// + Preserve = 0, + + /// + /// Specifies that properties that contain null references or a null Nullable<T> are to be omitted. + /// + OmitNull = 1, + + /// + /// Specifies that properties that that contain their default value, either default(T) or the value specified in DefaultValueAttribute are to be omitted. + /// + OmitDefaults = 2, + + /// + /// Specifies that properties that that contain collections/arrays/enumerations that are empty are to be omitted. + /// + OmitEmptyCollections = 4, + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/DefaultValuesHandling.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/DefaultValuesHandling.cs.meta new file mode 100644 index 0000000..60a4e10 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/DefaultValuesHandling.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 16ab81ef49026d74abc0c7d9dd2addf1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Deserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/Deserializer.cs new file mode 100644 index 0000000..1c94d9c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Deserializer.cs @@ -0,0 +1,149 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.IO; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization +{ + /// + /// Deserializes objects from the YAML format. + /// To customize the behavior of , + /// use the class. + /// + public sealed class Deserializer : IDeserializer + { + private readonly IValueDeserializer valueDeserializer; + + /// + /// Initializes a new instance of using the default configuration. + /// + /// + /// To customize the behavior of the deserializer, use . + /// + public Deserializer() + : this(new DeserializerBuilder().BuildValueDeserializer()) + { + } + + /// + /// This constructor is private to discourage its use. + /// To invoke it, call the method. + /// + private Deserializer(IValueDeserializer valueDeserializer) + { + this.valueDeserializer = valueDeserializer ?? throw new ArgumentNullException(nameof(valueDeserializer)); + } + + /// + /// Creates a new that uses the specified . + /// This method is available for advanced scenarios. The preferred way to customize the behavior of the + /// deserializer is to use . + /// + public static Deserializer FromValueDeserializer(IValueDeserializer valueDeserializer) + { + return new Deserializer(valueDeserializer); + } + + public T Deserialize(string input) + { + using var reader = new StringReader(input); + return Deserialize(reader); + } + + public T Deserialize(TextReader input) + { + return Deserialize(new Parser(input)); + } + + public object? Deserialize(TextReader input) + { + return Deserialize(input, typeof(object)); + } + + public object? Deserialize(string input, Type type) + { + using var reader = new StringReader(input); + return Deserialize(reader, type); + } + + public object? Deserialize(TextReader input, Type type) + { + return Deserialize(new Parser(input), type); + } + + public T Deserialize(IParser parser) + { + return (T)Deserialize(parser, typeof(T))!; // We really want an exception if we are trying to deserialize null into a non-nullable type + } + + public object? Deserialize(IParser parser) + { + return Deserialize(parser, typeof(object)); + } + + /// + /// Deserializes an object of the specified type. + /// + /// The from where to deserialize the object. + /// The static type of the object to deserialize. + /// Returns the deserialized object. + public object? Deserialize(IParser parser, Type type) + { + if (parser == null) + { + throw new ArgumentNullException(nameof(parser)); + } + + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + + var hasStreamStart = parser.TryConsume(out var _); + + var hasDocumentStart = parser.TryConsume(out var _); + + object? result = null; + if (!parser.Accept(out var _) && !parser.Accept(out var _)) + { + using var state = new SerializerState(); + result = valueDeserializer.DeserializeValue(parser, type, state, valueDeserializer); + state.OnDeserialization(); + } + + if (hasDocumentStart) + { + parser.Consume(); + } + + if (hasStreamStart) + { + parser.Consume(); + } + + return result; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/Deserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/Deserializer.cs.meta new file mode 100644 index 0000000..173f3ee --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Deserializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cee7b8e2c23b44c4c9d8b6fa9029e350 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/DeserializerBuilder.cs b/namedropper/Assets/YamlDotNet/Serialization/DeserializerBuilder.cs new file mode 100644 index 0000000..2eabb3b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/DeserializerBuilder.cs @@ -0,0 +1,389 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using YamlDotNet.Core; +using YamlDotNet.Serialization.NamingConventions; +using YamlDotNet.Serialization.NodeDeserializers; +using YamlDotNet.Serialization.NodeTypeResolvers; +using YamlDotNet.Serialization.ObjectFactories; +using YamlDotNet.Serialization.Schemas; +using YamlDotNet.Serialization.TypeInspectors; +using YamlDotNet.Serialization.TypeResolvers; +using YamlDotNet.Serialization.ValueDeserializers; + +namespace YamlDotNet.Serialization +{ + /// + /// Creates and configures instances of . + /// This class is used to customize the behavior of . Use the relevant methods + /// to apply customizations, then call to create an instance of the deserializer + /// with the desired customizations. + /// + public sealed class DeserializerBuilder : BuilderSkeleton + { + private Lazy objectFactory; + private readonly LazyComponentRegistrationList nodeDeserializerFactories; + private readonly LazyComponentRegistrationList nodeTypeResolverFactories; + private readonly Dictionary tagMappings; + private readonly Dictionary typeMappings; + private bool ignoreUnmatched; + + /// + /// Initializes a new using the default component registrations. + /// + public DeserializerBuilder() + : base(new StaticTypeResolver()) + { + typeMappings = new Dictionary(); + objectFactory = new Lazy(() => new DefaultObjectFactory(typeMappings), true); + + tagMappings = new Dictionary + { + { FailsafeSchema.Tags.Map, typeof(Dictionary) }, + { FailsafeSchema.Tags.Str, typeof(string) }, + { JsonSchema.Tags.Bool, typeof(bool) }, + { JsonSchema.Tags.Float, typeof(double) }, + { JsonSchema.Tags.Int, typeof(int) }, + { DefaultSchema.Tags.Timestamp, typeof(DateTime) } + }; + + typeInspectorFactories.Add(typeof(CachedTypeInspector), inner => new CachedTypeInspector(inner)); + typeInspectorFactories.Add(typeof(NamingConventionTypeInspector), inner => namingConvention is NullNamingConvention ? inner : new NamingConventionTypeInspector(inner, namingConvention)); + typeInspectorFactories.Add(typeof(YamlAttributesTypeInspector), inner => new YamlAttributesTypeInspector(inner)); + typeInspectorFactories.Add(typeof(YamlAttributeOverridesInspector), inner => overrides != null ? new YamlAttributeOverridesInspector(inner, overrides.Clone()) : inner); + typeInspectorFactories.Add(typeof(ReadableAndWritablePropertiesTypeInspector), inner => new ReadableAndWritablePropertiesTypeInspector(inner)); + + nodeDeserializerFactories = new LazyComponentRegistrationList + { + { typeof(YamlConvertibleNodeDeserializer), _ => new YamlConvertibleNodeDeserializer(objectFactory.Value) }, + { typeof(YamlSerializableNodeDeserializer), _ => new YamlSerializableNodeDeserializer(objectFactory.Value) }, + { typeof(TypeConverterNodeDeserializer), _ => new TypeConverterNodeDeserializer(BuildTypeConverters()) }, + { typeof(NullNodeDeserializer), _ => new NullNodeDeserializer() }, + { typeof(ScalarNodeDeserializer), _ => new ScalarNodeDeserializer() }, + { typeof(ArrayNodeDeserializer), _ => new ArrayNodeDeserializer() }, + { typeof(DictionaryNodeDeserializer), _ => new DictionaryNodeDeserializer(objectFactory.Value) }, + { typeof(CollectionNodeDeserializer), _ => new CollectionNodeDeserializer(objectFactory.Value) }, + { typeof(EnumerableNodeDeserializer), _ => new EnumerableNodeDeserializer() }, + { typeof(ObjectNodeDeserializer), _ => new ObjectNodeDeserializer(objectFactory.Value, BuildTypeInspector(), ignoreUnmatched) } + }; + + nodeTypeResolverFactories = new LazyComponentRegistrationList + { + { typeof(MappingNodeTypeResolver), _ => new MappingNodeTypeResolver(typeMappings) }, + { typeof(YamlConvertibleTypeResolver), _ => new YamlConvertibleTypeResolver() }, + { typeof(YamlSerializableTypeResolver), _ => new YamlSerializableTypeResolver() }, + { typeof(TagNodeTypeResolver), _ => new TagNodeTypeResolver(tagMappings) }, + { typeof(PreventUnknownTagsNodeTypeResolver), _ => new PreventUnknownTagsNodeTypeResolver() }, + { typeof(DefaultContainersNodeTypeResolver), _ => new DefaultContainersNodeTypeResolver() } + }; + } + + protected override DeserializerBuilder Self { get { return this; } } + + /// + /// Sets the that will be used by the deserializer. + /// + public DeserializerBuilder WithObjectFactory(IObjectFactory objectFactory) + { + if (objectFactory == null) + { + throw new ArgumentNullException(nameof(objectFactory)); + } + + this.objectFactory = new Lazy(() => objectFactory, true); + return this; + } + + /// + /// Sets the that will be used by the deserializer. + /// + public DeserializerBuilder WithObjectFactory(Func objectFactory) + { + if (objectFactory == null) + { + throw new ArgumentNullException(nameof(objectFactory)); + } + + return WithObjectFactory(new LambdaObjectFactory(objectFactory)); + } + + /// + /// Registers an additional to be used by the deserializer. + /// + public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer) + { + return WithNodeDeserializer(nodeDeserializer, w => w.OnTop()); + } + + /// + /// Registers an additional to be used by the deserializer. + /// + /// + /// Configures the location where to insert the + public DeserializerBuilder WithNodeDeserializer( + INodeDeserializer nodeDeserializer, + Action> where + ) + { + if (nodeDeserializer == null) + { + throw new ArgumentNullException(nameof(nodeDeserializer)); + } + + if (where == null) + { + throw new ArgumentNullException(nameof(where)); + } + + where(nodeDeserializerFactories.CreateRegistrationLocationSelector(nodeDeserializer.GetType(), _ => nodeDeserializer)); + return this; + } + + /// + /// Registers an additional to be used by the deserializer. + /// + /// A factory that creates the based on a previously registered . + /// Configures the location where to insert the + public DeserializerBuilder WithNodeDeserializer( + WrapperFactory nodeDeserializerFactory, + Action> where + ) + where TNodeDeserializer : INodeDeserializer + { + if (nodeDeserializerFactory == null) + { + throw new ArgumentNullException(nameof(nodeDeserializerFactory)); + } + + if (where == null) + { + throw new ArgumentNullException(nameof(where)); + } + + where(nodeDeserializerFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeDeserializer), (wrapped, _) => nodeDeserializerFactory(wrapped))); + return this; + } + + /// + /// Unregisters an existing of type . + /// + public DeserializerBuilder WithoutNodeDeserializer() + where TNodeDeserializer : INodeDeserializer + { + return WithoutNodeDeserializer(typeof(TNodeDeserializer)); + } + + /// + /// Unregisters an existing of type . + /// + public DeserializerBuilder WithoutNodeDeserializer(Type nodeDeserializerType) + { + if (nodeDeserializerType == null) + { + throw new ArgumentNullException(nameof(nodeDeserializerType)); + } + + nodeDeserializerFactories.Remove(nodeDeserializerType); + return this; + } + + /// + /// Registers an additional to be used by the deserializer. + /// + public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver) + { + return WithNodeTypeResolver(nodeTypeResolver, w => w.OnTop()); + } + + /// + /// Registers an additional to be used by the deserializer. + /// + /// + /// Configures the location where to insert the + public DeserializerBuilder WithNodeTypeResolver( + INodeTypeResolver nodeTypeResolver, + Action> where + ) + { + if (nodeTypeResolver == null) + { + throw new ArgumentNullException(nameof(nodeTypeResolver)); + } + + if (where == null) + { + throw new ArgumentNullException(nameof(where)); + } + + where(nodeTypeResolverFactories.CreateRegistrationLocationSelector(nodeTypeResolver.GetType(), _ => nodeTypeResolver)); + return this; + } + + /// + /// Registers an additional to be used by the deserializer. + /// + /// A factory that creates the based on a previously registered . + /// Configures the location where to insert the + public DeserializerBuilder WithNodeTypeResolver( + WrapperFactory nodeTypeResolverFactory, + Action> where + ) + where TNodeTypeResolver : INodeTypeResolver + { + if (nodeTypeResolverFactory == null) + { + throw new ArgumentNullException(nameof(nodeTypeResolverFactory)); + } + + if (where == null) + { + throw new ArgumentNullException(nameof(where)); + } + + where(nodeTypeResolverFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeTypeResolver), (wrapped, _) => nodeTypeResolverFactory(wrapped))); + return this; + } + + /// + /// Unregisters an existing of type . + /// + public DeserializerBuilder WithoutNodeTypeResolver() + where TNodeTypeResolver : INodeTypeResolver + { + return WithoutNodeTypeResolver(typeof(TNodeTypeResolver)); + } + + /// + /// Unregisters an existing of type . + /// + public DeserializerBuilder WithoutNodeTypeResolver(Type nodeTypeResolverType) + { + if (nodeTypeResolverType == null) + { + throw new ArgumentNullException(nameof(nodeTypeResolverType)); + } + + nodeTypeResolverFactories.Remove(nodeTypeResolverType); + return this; + } + + /// + /// Registers a tag mapping. + /// + public override DeserializerBuilder WithTagMapping(TagName tag, Type type) + { + if (tag.IsEmpty) + { + throw new ArgumentException("Non-specific tags cannot be maped"); + } + + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + + if (tagMappings.TryGetValue(tag, out var alreadyRegisteredType)) + { + throw new ArgumentException($"Type already has a registered type '{alreadyRegisteredType.FullName}' for tag '{tag}'", nameof(tag)); + } + + tagMappings.Add(tag, type); + return this; + } + + /// + /// Registers a type mapping using the default object factory. + /// + public DeserializerBuilder WithTypeMapping() + where TConcrete : TInterface + { + var interfaceType = typeof(TInterface); + var concreteType = typeof(TConcrete); + + if (!interfaceType.IsAssignableFrom(concreteType)) + { + throw new InvalidOperationException($"The type '{concreteType.Name}' does not implement interface '{interfaceType.Name}'."); + } + + if (typeMappings.ContainsKey(interfaceType)) + { + typeMappings[interfaceType] = concreteType; + } + else + { + typeMappings.Add(interfaceType, concreteType); + } + + return this; + } + + /// + /// Unregisters an existing tag mapping. + /// + public DeserializerBuilder WithoutTagMapping(TagName tag) + { + if (tag.IsEmpty) + { + throw new ArgumentException("Non-specific tags cannot be maped"); + } + + if (!tagMappings.Remove(tag)) + { + throw new KeyNotFoundException($"Tag '{tag}' is not registered"); + } + return this; + } + + /// + /// Instructs the deserializer to ignore unmatched properties instead of throwing an exception. + /// + public DeserializerBuilder IgnoreUnmatchedProperties() + { + ignoreUnmatched = true; + return this; + } + + /// + /// Creates a new according to the current configuration. + /// + public IDeserializer Build() + { + return Deserializer.FromValueDeserializer(BuildValueDeserializer()); + } + + /// + /// Creates a new that implements the current configuration. + /// This method is available for advanced scenarios. The preferred way to customize the behavior of the + /// deserializer is to use the method. + /// + public IValueDeserializer BuildValueDeserializer() + { + return new AliasValueDeserializer( + new NodeValueDeserializer( + nodeDeserializerFactories.BuildComponentList(), + nodeTypeResolverFactories.BuildComponentList() + ) + ); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/DeserializerBuilder.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/DeserializerBuilder.cs.meta new file mode 100644 index 0000000..bd74ec2 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/DeserializerBuilder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0ef2383a78598ce4b921ed59f9cbbceb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/EmissionPhaseObjectGraphVisitorArgs.cs b/namedropper/Assets/YamlDotNet/Serialization/EmissionPhaseObjectGraphVisitorArgs.cs new file mode 100644 index 0000000..c2a5d1e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/EmissionPhaseObjectGraphVisitorArgs.cs @@ -0,0 +1,82 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + public sealed class EmissionPhaseObjectGraphVisitorArgs + { + /// + /// Gets the next visitor that should be called by the current visitor. + /// + public IObjectGraphVisitor InnerVisitor { get; private set; } + + /// + /// Gets the that is to be used for serialization. + /// + public IEventEmitter EventEmitter { get; private set; } + + /// + /// Gets a function that, when called, serializes the specified object. + /// + public ObjectSerializer NestedObjectSerializer { get; private set; } + + public IEnumerable TypeConverters { get; private set; } + + private readonly IEnumerable> preProcessingPhaseVisitors; + + public EmissionPhaseObjectGraphVisitorArgs( + IObjectGraphVisitor innerVisitor, + IEventEmitter eventEmitter, + IEnumerable> preProcessingPhaseVisitors, + IEnumerable typeConverters, + ObjectSerializer nestedObjectSerializer + ) + { + InnerVisitor = innerVisitor ?? throw new ArgumentNullException(nameof(innerVisitor)); + EventEmitter = eventEmitter ?? throw new ArgumentNullException(nameof(eventEmitter)); + this.preProcessingPhaseVisitors = preProcessingPhaseVisitors ?? throw new ArgumentNullException(nameof(preProcessingPhaseVisitors)); + TypeConverters = typeConverters ?? throw new ArgumentNullException(nameof(typeConverters)); + NestedObjectSerializer = nestedObjectSerializer ?? throw new ArgumentNullException(nameof(nestedObjectSerializer)); + } + + /// + /// Gets the visitor of type that was used during the pre-processing phase. + /// + /// The type of the visitor.s + /// + /// + /// No visitor of that type has been registered, + /// or ore than one visitors registered are of type . + /// + public T GetPreProcessingPhaseObjectGraphVisitor() + where T : IObjectGraphVisitor + { + return preProcessingPhaseVisitors + .OfType() + .Single(); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/EmissionPhaseObjectGraphVisitorArgs.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/EmissionPhaseObjectGraphVisitorArgs.cs.meta new file mode 100644 index 0000000..641d254 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/EmissionPhaseObjectGraphVisitorArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e2a250c3185b3314da07c8ab685d5325 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/EventEmitters.meta b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters.meta new file mode 100644 index 0000000..3545ecb --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e9ef080653208014a9cc235469180344 +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/ChainedEventEmitter.cs b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/ChainedEventEmitter.cs new file mode 100644 index 0000000..6410e54 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/ChainedEventEmitter.cs @@ -0,0 +1,70 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.EventEmitters +{ + /// + /// Provided the base implementation for an IEventEmitter that is a + /// decorator for another IEventEmitter. + /// + public abstract class ChainedEventEmitter : IEventEmitter + { + protected readonly IEventEmitter nextEmitter; + + protected ChainedEventEmitter(IEventEmitter nextEmitter) + { + this.nextEmitter = nextEmitter ?? throw new ArgumentNullException(nameof(nextEmitter)); + } + + public virtual void Emit(AliasEventInfo eventInfo, IEmitter emitter) + { + nextEmitter.Emit(eventInfo, emitter); + } + + public virtual void Emit(ScalarEventInfo eventInfo, IEmitter emitter) + { + nextEmitter.Emit(eventInfo, emitter); + } + + public virtual void Emit(MappingStartEventInfo eventInfo, IEmitter emitter) + { + nextEmitter.Emit(eventInfo, emitter); + } + + public virtual void Emit(MappingEndEventInfo eventInfo, IEmitter emitter) + { + nextEmitter.Emit(eventInfo, emitter); + } + + public virtual void Emit(SequenceStartEventInfo eventInfo, IEmitter emitter) + { + nextEmitter.Emit(eventInfo, emitter); + } + + public virtual void Emit(SequenceEndEventInfo eventInfo, IEmitter emitter) + { + nextEmitter.Emit(eventInfo, emitter); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/ChainedEventEmitter.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/ChainedEventEmitter.cs.meta new file mode 100644 index 0000000..192024d --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/ChainedEventEmitter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ccb97ea0d5b5aff4d93a807363ef3ec7 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/JsonEventEmitter.cs b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/JsonEventEmitter.cs new file mode 100644 index 0000000..3d96a72 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/JsonEventEmitter.cs @@ -0,0 +1,126 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization.EventEmitters +{ + public sealed class JsonEventEmitter : ChainedEventEmitter + { + public JsonEventEmitter(IEventEmitter nextEmitter) + : base(nextEmitter) + { + } + + public override void Emit(AliasEventInfo eventInfo, IEmitter emitter) + { + eventInfo.NeedsExpansion = true; + } + + public override void Emit(ScalarEventInfo eventInfo, IEmitter emitter) + { + eventInfo.IsPlainImplicit = true; + eventInfo.Style = ScalarStyle.Plain; + + var value = eventInfo.Source.Value; + if (value == null) + { + eventInfo.RenderedValue = "null"; + } + else + { + var typeCode = eventInfo.Source.Type.GetTypeCode(); + switch (typeCode) + { + case TypeCode.Boolean: + eventInfo.RenderedValue = YamlFormatter.FormatBoolean(value); + break; + + case TypeCode.Byte: + case TypeCode.Int16: + case TypeCode.Int32: + case TypeCode.Int64: + case TypeCode.SByte: + case TypeCode.UInt16: + case TypeCode.UInt32: + case TypeCode.UInt64: + var valueIsEnum = eventInfo.Source.Type.IsEnum(); + if (valueIsEnum) + { + eventInfo.RenderedValue = value.ToString()!; + eventInfo.Style = ScalarStyle.DoubleQuoted; + break; + } + + eventInfo.RenderedValue = YamlFormatter.FormatNumber(value); + break; + + case TypeCode.Single: + case TypeCode.Double: + case TypeCode.Decimal: + eventInfo.RenderedValue = YamlFormatter.FormatNumber(value); + break; + + case TypeCode.String: + case TypeCode.Char: + eventInfo.RenderedValue = value.ToString()!; + eventInfo.Style = ScalarStyle.DoubleQuoted; + break; + + case TypeCode.DateTime: + eventInfo.RenderedValue = YamlFormatter.FormatDateTime(value); + break; + + case TypeCode.Empty: + eventInfo.RenderedValue = "null"; + break; + + default: + if (eventInfo.Source.Type == typeof(TimeSpan)) + { + eventInfo.RenderedValue = YamlFormatter.FormatTimeSpan(value); + break; + } + + throw new NotSupportedException($"TypeCode.{typeCode} is not supported."); + } + } + + base.Emit(eventInfo, emitter); + } + + public override void Emit(MappingStartEventInfo eventInfo, IEmitter emitter) + { + eventInfo.Style = MappingStyle.Flow; + + base.Emit(eventInfo, emitter); + } + + public override void Emit(SequenceStartEventInfo eventInfo, IEmitter emitter) + { + eventInfo.Style = SequenceStyle.Flow; + + base.Emit(eventInfo, emitter); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/JsonEventEmitter.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/JsonEventEmitter.cs.meta new file mode 100644 index 0000000..ac1c142 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/JsonEventEmitter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 62580a3e5f0e5314e83b62758257428e +timeCreated: 1427495771 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/TypeAssigningEventEmitter.cs b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/TypeAssigningEventEmitter.cs new file mode 100644 index 0000000..e7f2208 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/TypeAssigningEventEmitter.cs @@ -0,0 +1,155 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using YamlDotNet.Core; +using YamlDotNet.Serialization.Schemas; + +namespace YamlDotNet.Serialization.EventEmitters +{ + public sealed class TypeAssigningEventEmitter : ChainedEventEmitter + { + private readonly bool requireTagWhenStaticAndActualTypesAreDifferent; + private readonly IDictionary tagMappings; + + public TypeAssigningEventEmitter(IEventEmitter nextEmitter, bool requireTagWhenStaticAndActualTypesAreDifferent, IDictionary tagMappings) + : base(nextEmitter) + { + this.requireTagWhenStaticAndActualTypesAreDifferent = requireTagWhenStaticAndActualTypesAreDifferent; + this.tagMappings = tagMappings ?? throw new ArgumentNullException(nameof(tagMappings)); + } + + public override void Emit(ScalarEventInfo eventInfo, IEmitter emitter) + { + var suggestedStyle = ScalarStyle.Plain; + + var value = eventInfo.Source.Value; + if (value == null) + { + eventInfo.Tag = JsonSchema.Tags.Null; + eventInfo.RenderedValue = ""; + } + else + { + var typeCode = eventInfo.Source.Type.GetTypeCode(); + switch (typeCode) + { + case TypeCode.Boolean: + eventInfo.Tag = JsonSchema.Tags.Bool; + eventInfo.RenderedValue = YamlFormatter.FormatBoolean(value); + break; + + case TypeCode.Byte: + case TypeCode.Int16: + case TypeCode.Int32: + case TypeCode.Int64: + case TypeCode.SByte: + case TypeCode.UInt16: + case TypeCode.UInt32: + case TypeCode.UInt64: + eventInfo.Tag = JsonSchema.Tags.Int; + eventInfo.RenderedValue = YamlFormatter.FormatNumber(value); + break; + + case TypeCode.Single: + eventInfo.Tag = JsonSchema.Tags.Float; + eventInfo.RenderedValue = YamlFormatter.FormatNumber((float)value); + break; + + case TypeCode.Double: + eventInfo.Tag = JsonSchema.Tags.Float; + eventInfo.RenderedValue = YamlFormatter.FormatNumber((double)value); + break; + + case TypeCode.Decimal: + eventInfo.Tag = JsonSchema.Tags.Float; + eventInfo.RenderedValue = YamlFormatter.FormatNumber(value); + break; + + case TypeCode.String: + case TypeCode.Char: + eventInfo.Tag = FailsafeSchema.Tags.Str; + eventInfo.RenderedValue = value.ToString()!; + suggestedStyle = ScalarStyle.Any; + break; + + case TypeCode.DateTime: + eventInfo.Tag = DefaultSchema.Tags.Timestamp; + eventInfo.RenderedValue = YamlFormatter.FormatDateTime(value); + break; + + case TypeCode.Empty: + eventInfo.Tag = JsonSchema.Tags.Null; + eventInfo.RenderedValue = ""; + break; + + default: + if (eventInfo.Source.Type == typeof(TimeSpan)) + { + eventInfo.RenderedValue = YamlFormatter.FormatTimeSpan(value); + break; + } + + throw new NotSupportedException($"TypeCode.{typeCode} is not supported."); + } + } + + eventInfo.IsPlainImplicit = true; + if (eventInfo.Style == ScalarStyle.Any) + { + eventInfo.Style = suggestedStyle; + } + + base.Emit(eventInfo, emitter); + } + + public override void Emit(MappingStartEventInfo eventInfo, IEmitter emitter) + { + AssignTypeIfNeeded(eventInfo); + base.Emit(eventInfo, emitter); + } + + public override void Emit(SequenceStartEventInfo eventInfo, IEmitter emitter) + { + AssignTypeIfNeeded(eventInfo); + base.Emit(eventInfo, emitter); + } + + private void AssignTypeIfNeeded(ObjectEventInfo eventInfo) + { + if (tagMappings.TryGetValue(eventInfo.Source.Type, out var tag)) + { + eventInfo.Tag = tag; + } + else if (requireTagWhenStaticAndActualTypesAreDifferent && eventInfo.Source.Value != null && eventInfo.Source.Type != eventInfo.Source.StaticType) + { + throw new YamlException( + $"Cannot serialize type '{eventInfo.Source.Type.FullName}' where a '{eventInfo.Source.StaticType.FullName}' was expected " + + $"because no tag mapping has been registered for '{eventInfo.Source.Type.FullName}', " + + $"which means that it won't be possible to deserialize the document.\n" + + $"Register a tag mapping using the SerializerBuilder.WithTagMapping method.\n\n" + + $"E.g: builder.WithTagMapping(\"!{eventInfo.Source.Type.Name}\", typeof({eventInfo.Source.Type.FullName}));" + ); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/TypeAssigningEventEmitter.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/TypeAssigningEventEmitter.cs.meta new file mode 100644 index 0000000..c8f24b6 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/TypeAssigningEventEmitter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e1b82bb57f4eb7f4ba0ffad467f82555 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/WriterEventEmitter.cs b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/WriterEventEmitter.cs new file mode 100644 index 0000000..2ed2e2b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/WriterEventEmitter.cs @@ -0,0 +1,59 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization.EventEmitters +{ + public sealed class WriterEventEmitter : IEventEmitter + { + void IEventEmitter.Emit(AliasEventInfo eventInfo, IEmitter emitter) + { + emitter.Emit(new AnchorAlias(eventInfo.Alias)); + } + + void IEventEmitter.Emit(ScalarEventInfo eventInfo, IEmitter emitter) + { + emitter.Emit(new Scalar(eventInfo.Anchor, eventInfo.Tag, eventInfo.RenderedValue, eventInfo.Style, eventInfo.IsPlainImplicit, eventInfo.IsQuotedImplicit)); + } + + void IEventEmitter.Emit(MappingStartEventInfo eventInfo, IEmitter emitter) + { + emitter.Emit(new MappingStart(eventInfo.Anchor, eventInfo.Tag, eventInfo.IsImplicit, eventInfo.Style)); + } + + void IEventEmitter.Emit(MappingEndEventInfo eventInfo, IEmitter emitter) + { + emitter.Emit(new MappingEnd()); + } + + void IEventEmitter.Emit(SequenceStartEventInfo eventInfo, IEmitter emitter) + { + emitter.Emit(new SequenceStart(eventInfo.Anchor, eventInfo.Tag, eventInfo.IsImplicit, eventInfo.Style)); + } + + void IEventEmitter.Emit(SequenceEndEventInfo eventInfo, IEmitter emitter) + { + emitter.Emit(new SequenceEnd()); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/WriterEventEmitter.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/WriterEventEmitter.cs.meta new file mode 100644 index 0000000..7651c38 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/EventEmitters/WriterEventEmitter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f2ea019325fb629499443d6af969a295 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/EventInfo.cs b/namedropper/Assets/YamlDotNet/Serialization/EventInfo.cs new file mode 100644 index 0000000..3dd49a3 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/EventInfo.cs @@ -0,0 +1,117 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization +{ + public abstract class EventInfo + { + public IObjectDescriptor Source { get; } + + protected EventInfo(IObjectDescriptor source) + { + Source = source ?? throw new ArgumentNullException(nameof(source)); + } + } + + public class AliasEventInfo : EventInfo + { + public AliasEventInfo(IObjectDescriptor source, AnchorName alias) + : base(source) + { + if (alias.IsEmpty) + { + throw new ArgumentNullException(nameof(alias)); + } + Alias = alias; + } + + public AnchorName Alias { get; } + public bool NeedsExpansion { get; set; } + } + + public class ObjectEventInfo : EventInfo + { + protected ObjectEventInfo(IObjectDescriptor source) + : base(source) + { + } + + public AnchorName Anchor { get; set; } + public TagName Tag { get; set; } + } + + public sealed class ScalarEventInfo : ObjectEventInfo + { + public ScalarEventInfo(IObjectDescriptor source) + : base(source) + { + Style = source.ScalarStyle; + RenderedValue = string.Empty; + } + + public string RenderedValue { get; set; } + public ScalarStyle Style { get; set; } + public bool IsPlainImplicit { get; set; } + public bool IsQuotedImplicit { get; set; } + } + + public sealed class MappingStartEventInfo : ObjectEventInfo + { + public MappingStartEventInfo(IObjectDescriptor source) + : base(source) + { + } + + public bool IsImplicit { get; set; } + public MappingStyle Style { get; set; } + } + + public sealed class MappingEndEventInfo : EventInfo + { + public MappingEndEventInfo(IObjectDescriptor source) + : base(source) + { + } + } + + public sealed class SequenceStartEventInfo : ObjectEventInfo + { + public SequenceStartEventInfo(IObjectDescriptor source) + : base(source) + { + } + + public bool IsImplicit { get; set; } + public SequenceStyle Style { get; set; } + } + + public sealed class SequenceEndEventInfo : EventInfo + { + public SequenceEndEventInfo(IObjectDescriptor source) + : base(source) + { + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/EventInfo.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/EventInfo.cs.meta new file mode 100644 index 0000000..0ec17ef --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/EventInfo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e72f96c4049a0dc4d97ad0d44f6b766d +timeCreated: 1427145267 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IAliasProvider.cs b/namedropper/Assets/YamlDotNet/Serialization/IAliasProvider.cs new file mode 100644 index 0000000..2bba321 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IAliasProvider.cs @@ -0,0 +1,30 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + public interface IAliasProvider + { + AnchorName GetAlias(object target); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IAliasProvider.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IAliasProvider.cs.meta new file mode 100644 index 0000000..66f6768 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IAliasProvider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3a934679d1d7f204e9d25f18f7f397bb +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/IDeserializer.cs new file mode 100644 index 0000000..bc6e97e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IDeserializer.cs @@ -0,0 +1,46 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.IO; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + public interface IDeserializer + { + T Deserialize(string input); + T Deserialize(TextReader input); + object? Deserialize(TextReader input); + object? Deserialize(string input, Type type); + object? Deserialize(TextReader input, Type type); + T Deserialize(IParser parser); + object? Deserialize(IParser parser); + + /// + /// Deserializes an object of the specified type. + /// + /// The from where to deserialize the object. + /// The static type of the object to deserialize. + /// Returns the deserialized object. + object? Deserialize(IParser parser, Type type); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IDeserializer.cs.meta new file mode 100644 index 0000000..7eea681 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IDeserializer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f4ca32ff329536b43a4ba3711e5af24e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IEventEmitter.cs b/namedropper/Assets/YamlDotNet/Serialization/IEventEmitter.cs new file mode 100644 index 0000000..9ed1b7b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IEventEmitter.cs @@ -0,0 +1,35 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + public interface IEventEmitter + { + void Emit(AliasEventInfo eventInfo, IEmitter emitter); + void Emit(ScalarEventInfo eventInfo, IEmitter emitter); + void Emit(MappingStartEventInfo eventInfo, IEmitter emitter); + void Emit(MappingEndEventInfo eventInfo, IEmitter emitter); + void Emit(SequenceStartEventInfo eventInfo, IEmitter emitter); + void Emit(SequenceEndEventInfo eventInfo, IEmitter emitter); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IEventEmitter.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IEventEmitter.cs.meta new file mode 100644 index 0000000..524fb3a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IEventEmitter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 05f7588b91e030f438b48c4af7ecf613 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/INamingConvention.cs b/namedropper/Assets/YamlDotNet/Serialization/INamingConvention.cs new file mode 100644 index 0000000..ab89a7a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/INamingConvention.cs @@ -0,0 +1,32 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + + +namespace YamlDotNet.Serialization +{ + /// + /// Translates property names according to a specific convention. + /// + public interface INamingConvention + { + string Apply(string value); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/INamingConvention.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/INamingConvention.cs.meta new file mode 100644 index 0000000..8a2e412 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/INamingConvention.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f9e2e0524133523428f9f2498f7c06f7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/INodeDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/INodeDeserializer.cs new file mode 100644 index 0000000..9e691fc --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/INodeDeserializer.cs @@ -0,0 +1,31 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + public interface INodeDeserializer + { + bool Deserialize(IParser reader, Type expectedType, Func nestedObjectDeserializer, out object? value); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/INodeDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/INodeDeserializer.cs.meta new file mode 100644 index 0000000..4ac62fd --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/INodeDeserializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2f27d06ef3f08024d8a6ee848351527a +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/INodeTypeResolver.cs b/namedropper/Assets/YamlDotNet/Serialization/INodeTypeResolver.cs new file mode 100644 index 0000000..c346ac8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/INodeTypeResolver.cs @@ -0,0 +1,40 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization +{ + public interface INodeTypeResolver + { + /// + /// Determines the type of the specified node. + /// + /// The node to be deserialized. + /// The type that has been determined so far. + /// + /// true if has been resolved completely; + /// false if the next type should be invoked. + /// + bool Resolve(NodeEvent? nodeEvent, ref Type currentType); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/INodeTypeResolver.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/INodeTypeResolver.cs.meta new file mode 100644 index 0000000..15933fb --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/INodeTypeResolver.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fc7c4eab6abbae74eb74eee44a52e6a7 +timeCreated: 1427145267 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IObjectDescriptor.cs b/namedropper/Assets/YamlDotNet/Serialization/IObjectDescriptor.cs new file mode 100644 index 0000000..9864fe2 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IObjectDescriptor.cs @@ -0,0 +1,67 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + /// + /// Represents an object along with its type. + /// + public interface IObjectDescriptor + { + /// + /// A reference to the object. + /// + object? Value { get; } + + /// + /// The type that should be used when to interpret the . + /// + Type Type { get; } + + /// + /// The type of as determined by its container (e.g. a property). + /// + Type StaticType { get; } + + /// + /// The style to be used for scalars. + /// + ScalarStyle ScalarStyle { get; } + } + + public static class ObjectDescriptorExtensions + { + /// + /// Returns the Value property of the if it is not null. + /// This is useful in all places that the value must not be null. + /// + /// An object descriptor. + /// Thrown when the Value is null + /// + public static object NonNullValue(this IObjectDescriptor objectDescriptor) + { + return objectDescriptor.Value ?? throw new InvalidOperationException($"Attempted to use a IObjectDescriptor of type '{objectDescriptor.Type.FullName}' whose Value is null at a point whete it is invalid to do so. This may indicate a bug in YamlDotNet."); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IObjectDescriptor.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IObjectDescriptor.cs.meta new file mode 100644 index 0000000..02e03e4 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IObjectDescriptor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: bcb0a1a8415e8714ab58565d3f392aec +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IObjectFactory.cs b/namedropper/Assets/YamlDotNet/Serialization/IObjectFactory.cs new file mode 100644 index 0000000..a1b1def --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IObjectFactory.cs @@ -0,0 +1,39 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Serialization +{ + /// + /// Creates instances of types. + /// + /// + /// This interface allows to provide a custom logic for creating instances during deserialization. + /// + public interface IObjectFactory + { + /// + /// Creates an instance of the specified type. + /// + object Create(Type type); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IObjectFactory.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IObjectFactory.cs.meta new file mode 100644 index 0000000..1bebc86 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IObjectFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 86a19edb69863084e9364dec9fcda8c4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IObjectGraphTraversalStrategy.cs b/namedropper/Assets/YamlDotNet/Serialization/IObjectGraphTraversalStrategy.cs new file mode 100644 index 0000000..dece648 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IObjectGraphTraversalStrategy.cs @@ -0,0 +1,37 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Serialization +{ + /// + /// Defines a strategy that walks through an object graph. + /// + public interface IObjectGraphTraversalStrategy + { + /// + /// Traverses the specified object graph. + /// + /// The graph. + /// An that is to be notified during the traversal. + /// A that will be passed to the . + void Traverse(IObjectDescriptor graph, IObjectGraphVisitor visitor, TContext context); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IObjectGraphTraversalStrategy.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IObjectGraphTraversalStrategy.cs.meta new file mode 100644 index 0000000..66ab60c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IObjectGraphTraversalStrategy.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 33215c487a2a3f04cbbe41c318253ee0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IObjectGraphVisitor.cs b/namedropper/Assets/YamlDotNet/Serialization/IObjectGraphVisitor.cs new file mode 100644 index 0000000..87455f1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IObjectGraphVisitor.cs @@ -0,0 +1,99 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Serialization +{ + /// + /// Defined the interface of a type that can be notified during an object graph traversal. + /// + public interface IObjectGraphVisitor + { + /// + /// Indicates whether the specified value should be entered. This allows the visitor to + /// override the handling of a particular object or type. + /// + /// The value that is about to be entered. + /// The context that this implementation depend on. + /// If the value is to be entered, returns true; otherwise returns false; + bool Enter(IObjectDescriptor value, TContext context); + + /// + /// Indicates whether the specified mapping should be entered. This allows the visitor to + /// override the handling of a particular pair. + /// + /// The key of the mapping that is about to be entered. + /// The value of the mapping that is about to be entered. + /// The context that this implementation depend on. + /// If the mapping is to be entered, returns true; otherwise returns false; + bool EnterMapping(IObjectDescriptor key, IObjectDescriptor value, TContext context); + + /// + /// Indicates whether the specified mapping should be entered. This allows the visitor to + /// override the handling of a particular pair. This overload should be invoked when the + /// mapping is produced by an object's property. + /// + /// The that provided access to . + /// The value of the mapping that is about to be entered. + /// The context that this implementation depend on. + /// If the mapping is to be entered, returns true; otherwise returns false; + bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, TContext context); + + /// + /// Notifies the visitor that a scalar value has been encountered. + /// + /// The value of the scalar. + /// The context that this implementation depend on. + void VisitScalar(IObjectDescriptor scalar, TContext context); + + /// + /// Notifies the visitor that the traversal of a mapping is about to begin. + /// + /// The value that corresponds to the mapping. + /// The static type of the keys of the mapping. + /// The static type of the values of the mapping. + /// The context that this implementation depend on. + void VisitMappingStart(IObjectDescriptor mapping, Type keyType, Type valueType, TContext context); + + /// + /// Notifies the visitor that the traversal of a mapping has ended. + /// + /// The value that corresponds to the mapping. + /// The context that this implementation depend on. + void VisitMappingEnd(IObjectDescriptor mapping, TContext context); + + /// + /// Notifies the visitor that the traversal of a sequence is about to begin. + /// + /// The value that corresponds to the sequence. + /// The static type of the elements of the sequence. + /// The context that this implementation depend on. + void VisitSequenceStart(IObjectDescriptor sequence, Type elementType, TContext context); + + /// + /// Notifies the visitor that the traversal of a sequence has ended. + /// + /// The value that corresponds to the sequence. + /// The context that this implementation depend on. + void VisitSequenceEnd(IObjectDescriptor sequence, TContext context); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IObjectGraphVisitor.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IObjectGraphVisitor.cs.meta new file mode 100644 index 0000000..98400a1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IObjectGraphVisitor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d6232168616fce2428643fe75d1ed035 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IPropertyDescriptor.cs b/namedropper/Assets/YamlDotNet/Serialization/IPropertyDescriptor.cs new file mode 100644 index 0000000..d680684 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IPropertyDescriptor.cs @@ -0,0 +1,41 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + public interface IPropertyDescriptor + { + string Name { get; } + bool CanWrite { get; } + Type Type { get; } + Type? TypeOverride { get; set; } + int Order { get; set; } + ScalarStyle ScalarStyle { get; set; } + + T GetCustomAttribute() where T : Attribute; + + IObjectDescriptor Read(object target); + void Write(object target, object? value); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IPropertyDescriptor.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IPropertyDescriptor.cs.meta new file mode 100644 index 0000000..5cedc3a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IPropertyDescriptor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c5985b699bccf7548a76738be6b6e551 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IRegistrationLocationSelectionSyntax.cs b/namedropper/Assets/YamlDotNet/Serialization/IRegistrationLocationSelectionSyntax.cs new file mode 100644 index 0000000..d1d50fa --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IRegistrationLocationSelectionSyntax.cs @@ -0,0 +1,59 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Serialization +{ + public interface IRegistrationLocationSelectionSyntax + { + /// + /// Registers the component in place of the already registered component of type . + /// + void InsteadOf() where TRegistrationType : TBaseRegistrationType; + + /// + /// Registers the component before the already registered component of type . + /// + void Before() where TRegistrationType : TBaseRegistrationType; + + /// + /// Registers the component after the already registered component of type . + /// + void After() where TRegistrationType : TBaseRegistrationType; + + /// + /// Registers the component before every other previously registered component. + /// + void OnTop(); + + /// + /// Registers the component after every other previously registered component. + /// + void OnBottom(); + } + + public interface ITrackingRegistrationLocationSelectionSyntax + { + /// + /// Registers the component in place of the already registered component of type . + /// + void InsteadOf() where TRegistrationType : TBaseRegistrationType; + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IRegistrationLocationSelectionSyntax.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IRegistrationLocationSelectionSyntax.cs.meta new file mode 100644 index 0000000..3ac80f9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IRegistrationLocationSelectionSyntax.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a2e3d426fbc212f48b7a3b269a5ed7f1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ISerializer.cs b/namedropper/Assets/YamlDotNet/Serialization/ISerializer.cs new file mode 100644 index 0000000..b7b8847 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ISerializer.cs @@ -0,0 +1,66 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.IO; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + public interface ISerializer + { + /// + /// Serializes the specified object. + /// + /// The where to serialize the object. + /// The object to serialize. + void Serialize(TextWriter writer, object graph); + + /// + /// Serializes the specified object into a string. + /// + /// The object to serialize. + string Serialize(object graph); + + /// + /// Serializes the specified object. + /// + /// The where to serialize the object. + /// The object to serialize. + /// The static type of the object to serialize. + void Serialize(TextWriter writer, object graph, Type type); + + /// + /// Serializes the specified object. + /// + /// The where to serialize the object. + /// The object to serialize. + void Serialize(IEmitter emitter, object graph); + + /// + /// Serializes the specified object. + /// + /// The where to serialize the object. + /// The object to serialize. + /// The static type of the object to serialize. + void Serialize(IEmitter emitter, object graph, Type type); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ISerializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ISerializer.cs.meta new file mode 100644 index 0000000..d1699cf --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ISerializer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2ae1bfa2f95d7684d9c16346c9c7a4de +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ITypeInspector.cs b/namedropper/Assets/YamlDotNet/Serialization/ITypeInspector.cs new file mode 100644 index 0000000..7e73796 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ITypeInspector.cs @@ -0,0 +1,54 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace YamlDotNet.Serialization +{ + /// + /// Provides access to the properties of a type. + /// + public interface ITypeInspector + { + /// + /// Gets all properties of the specified type. + /// + /// The type whose properties are to be enumerated. + /// The actual object of type whose properties are to be enumerated. Can be null. + /// + IEnumerable GetProperties(Type type, object? container); + + /// + /// Gets the property of the type with the specified name. + /// + /// The type whose properties are to be searched. + /// The actual object of type whose properties are to be searched. Can be null. + /// The name of the property. + /// + /// Determines if an exception or null should be returned if can't be + /// found in + /// + /// + IPropertyDescriptor GetProperty(Type type, object? container, string name, [MaybeNullWhen(true)] bool ignoreUnmatched); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ITypeInspector.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ITypeInspector.cs.meta new file mode 100644 index 0000000..c7be049 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ITypeInspector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 915f534464f498641ab97a0e2c651b77 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ITypeResolver.cs b/namedropper/Assets/YamlDotNet/Serialization/ITypeResolver.cs new file mode 100644 index 0000000..24fbe06 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ITypeResolver.cs @@ -0,0 +1,33 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Serialization +{ + /// + /// Resolves the type of values. + /// + public interface ITypeResolver + { + Type Resolve(Type staticType, object? actualValue); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ITypeResolver.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ITypeResolver.cs.meta new file mode 100644 index 0000000..b3312b7 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ITypeResolver.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6c3bd4a3f0eca6e4f92ba855bc058d25 +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IValueDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/IValueDeserializer.cs new file mode 100644 index 0000000..35d64e9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IValueDeserializer.cs @@ -0,0 +1,32 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization +{ + public interface IValueDeserializer + { + object? DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IValueDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IValueDeserializer.cs.meta new file mode 100644 index 0000000..aef57e7 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IValueDeserializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c1356281a3d017849a3240d70d9cfacd +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IValuePromise.cs b/namedropper/Assets/YamlDotNet/Serialization/IValuePromise.cs new file mode 100644 index 0000000..f16ea19 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IValuePromise.cs @@ -0,0 +1,30 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Serialization +{ + public interface IValuePromise + { + event Action ValueAvailable; + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IValuePromise.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IValuePromise.cs.meta new file mode 100644 index 0000000..a1470ad --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IValuePromise.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 432dc17fcd3e2cb40990aab6122f075f +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IValueSerializer.cs b/namedropper/Assets/YamlDotNet/Serialization/IValueSerializer.cs new file mode 100644 index 0000000..a5c1ab6 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IValueSerializer.cs @@ -0,0 +1,31 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + public interface IValueSerializer + { + void SerializeValue(IEmitter emitter, object? value, Type? type); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IValueSerializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IValueSerializer.cs.meta new file mode 100644 index 0000000..79e7ede --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IValueSerializer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e24a662d1be166743945e1986cb19cb5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IYamlConvertible.cs b/namedropper/Assets/YamlDotNet/Serialization/IYamlConvertible.cs new file mode 100644 index 0000000..936773a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IYamlConvertible.cs @@ -0,0 +1,67 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + /// + /// Allows an object to customize how it is serialized and deserialized. + /// + public interface IYamlConvertible + { + /// + /// Reads this object's state from a YAML parser. + /// + /// The parser where the object's state should be read from. + /// The type that the deserializer is expecting. + /// + /// A function that will use the current deserializer + /// to read an object of the given type from the parser. + /// + void Read(IParser parser, Type expectedType, ObjectDeserializer nestedObjectDeserializer); + + /// + /// Writes this object's state to a YAML emitter. + /// + /// The emitter where the object's state should be written to. + /// A function that will use the current serializer to write an object to the emitter. + void Write(IEmitter emitter, ObjectSerializer nestedObjectSerializer); + } + + /// + /// Represents a function that is used to deserialize an object of the given type. + /// + /// The type that the deserializer should read. + /// Returns the object that was deserialized. + public delegate object? ObjectDeserializer(Type type); + + /// + /// Represents a function that is used to serialize an object of the given type. + /// + /// The object to be serialized. + /// + /// The type that should be considered when emitting the object. + /// If null, the actual type of the is used. + /// + public delegate void ObjectSerializer(object? value, Type? type = null); +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IYamlConvertible.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IYamlConvertible.cs.meta new file mode 100644 index 0000000..ce69f94 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IYamlConvertible.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0611a055d6fbe6e49bce224457ee9065 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IYamlSerializable.cs b/namedropper/Assets/YamlDotNet/Serialization/IYamlSerializable.cs new file mode 100644 index 0000000..406cac2 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IYamlSerializable.cs @@ -0,0 +1,43 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + /// + /// Allows an object to customize how it is serialized and deserialized. + /// + [Obsolete("Please use IYamlConvertible instead")] + public interface IYamlSerializable + { + /// + /// Reads this object's state from a YAML parser. + /// + void ReadYaml(IParser parser); + + /// + /// Writes this object's state to a YAML emitter. + /// + void WriteYaml(IEmitter emitter); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IYamlSerializable.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IYamlSerializable.cs.meta new file mode 100644 index 0000000..c9d8323 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IYamlSerializable.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f42bad1c9f9fdf242b696f20c2e66259 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/IYamlTypeConverter.cs b/namedropper/Assets/YamlDotNet/Serialization/IYamlTypeConverter.cs new file mode 100644 index 0000000..497657b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IYamlTypeConverter.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + /// + /// Allows to customize how a type is serialized and deserialized. + /// + public interface IYamlTypeConverter + { + /// + /// Gets a value indicating whether the current converter supports converting the specified type. + /// + bool Accepts(Type type); + + /// + /// Reads an object's state from a YAML parser. + /// + object? ReadYaml(IParser parser, Type type); + + /// + /// Writes the specified object's state to a YAML emitter. + /// + void WriteYaml(IEmitter emitter, object? value, Type type); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/IYamlTypeConverter.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/IYamlTypeConverter.cs.meta new file mode 100644 index 0000000..2469092 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/IYamlTypeConverter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f114886060e4acf46b36ac2c9f610cc3 +timeCreated: 1427145267 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationList.cs b/namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationList.cs new file mode 100644 index 0000000..12f7364 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationList.cs @@ -0,0 +1,237 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace YamlDotNet.Serialization +{ + internal sealed class LazyComponentRegistrationList : IEnumerable> + { + private readonly List entries = new List(); + + public LazyComponentRegistrationList Clone() + { + var clone = new LazyComponentRegistrationList(); + foreach (var entry in entries) + { + clone.entries.Add(entry); + } + return clone; + } + + public sealed class LazyComponentRegistration + { + public readonly Type ComponentType; + public readonly Func Factory; + + public LazyComponentRegistration(Type componentType, Func factory) + { + ComponentType = componentType; + Factory = factory; + } + } + + public sealed class TrackingLazyComponentRegistration + { + public readonly Type ComponentType; + public readonly Func Factory; + + public TrackingLazyComponentRegistration(Type componentType, Func factory) + { + ComponentType = componentType; + Factory = factory; + } + } + + public void Add(Type componentType, Func factory) + { + entries.Add(new LazyComponentRegistration(componentType, factory)); + } + + public void Remove(Type componentType) + { + for (var i = 0; i < entries.Count; ++i) + { + if (entries[i].ComponentType == componentType) + { + entries.RemoveAt(i); + return; + } + } + + throw new KeyNotFoundException($"A component registration of type '{componentType.FullName}' was not found."); + } + + public int Count => entries.Count; + + public IEnumerable> InReverseOrder + { + get + { + for (var i = entries.Count - 1; i >= 0; --i) + { + yield return entries[i].Factory; + } + } + } + + public IRegistrationLocationSelectionSyntax CreateRegistrationLocationSelector( + Type componentType, + Func factory + ) + { + return new RegistrationLocationSelector( + this, + new LazyComponentRegistration(componentType, factory) + ); + } + + public ITrackingRegistrationLocationSelectionSyntax CreateTrackingRegistrationLocationSelector( + Type componentType, + Func factory + ) + { + return new TrackingRegistrationLocationSelector( + this, + new TrackingLazyComponentRegistration(componentType, factory) + ); + } + + public IEnumerator> GetEnumerator() + { + return entries.Select(e => e.Factory).GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + private int IndexOfRegistration(Type registrationType) + { + for (var i = 0; i < entries.Count; ++i) + { + if (registrationType == entries[i].ComponentType) + { + return i; + } + } + return -1; + } + + private void EnsureNoDuplicateRegistrationType(Type componentType) + { + if (IndexOfRegistration(componentType) != -1) + { + throw new InvalidOperationException($"A component of type '{componentType.FullName}' has already been registered."); + } + } + + private int EnsureRegistrationExists() + { + var registrationIndex = IndexOfRegistration(typeof(TRegistrationType)); + if (registrationIndex == -1) + { + throw new InvalidOperationException($"A component of type '{typeof(TRegistrationType).FullName}' has not been registered."); + } + return registrationIndex; + } + + private class RegistrationLocationSelector : IRegistrationLocationSelectionSyntax + { + private readonly LazyComponentRegistrationList registrations; + private readonly LazyComponentRegistration newRegistration; + + public RegistrationLocationSelector(LazyComponentRegistrationList registrations, LazyComponentRegistration newRegistration) + { + this.registrations = registrations; + this.newRegistration = newRegistration; + } + + void IRegistrationLocationSelectionSyntax.InsteadOf() + { + if (newRegistration.ComponentType != typeof(TRegistrationType)) + { + registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType); + } + + var registrationIndex = registrations.EnsureRegistrationExists(); + registrations.entries[registrationIndex] = newRegistration; + } + + void IRegistrationLocationSelectionSyntax.After() + { + registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType); + var registrationIndex = registrations.EnsureRegistrationExists(); + registrations.entries.Insert(registrationIndex + 1, newRegistration); + } + + void IRegistrationLocationSelectionSyntax.Before() + { + registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType); + var registrationIndex = registrations.EnsureRegistrationExists(); + registrations.entries.Insert(registrationIndex, newRegistration); + } + + void IRegistrationLocationSelectionSyntax.OnBottom() + { + registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType); + registrations.entries.Add(newRegistration); + } + + void IRegistrationLocationSelectionSyntax.OnTop() + { + registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType); + registrations.entries.Insert(0, newRegistration); + } + } + + private class TrackingRegistrationLocationSelector : ITrackingRegistrationLocationSelectionSyntax + { + private readonly LazyComponentRegistrationList registrations; + private readonly TrackingLazyComponentRegistration newRegistration; + + public TrackingRegistrationLocationSelector(LazyComponentRegistrationList registrations, TrackingLazyComponentRegistration newRegistration) + { + this.registrations = registrations; + this.newRegistration = newRegistration; + } + + void ITrackingRegistrationLocationSelectionSyntax.InsteadOf() + { + if (newRegistration.ComponentType != typeof(TRegistrationType)) + { + registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType); + } + + var registrationIndex = registrations.EnsureRegistrationExists(); + var innerComponentFactory = registrations.entries[registrationIndex].Factory; + registrations.entries[registrationIndex] = new LazyComponentRegistration( + newRegistration.ComponentType, + arg => newRegistration.Factory(innerComponentFactory(arg), arg) + ); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationList.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationList.cs.meta new file mode 100644 index 0000000..78610f4 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationList.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 677d4a413af78344592ad924106c4a5a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationListExtensions.cs b/namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationListExtensions.cs new file mode 100644 index 0000000..e47810b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationListExtensions.cs @@ -0,0 +1,64 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace YamlDotNet.Serialization +{ + internal static class LazyComponentRegistrationListExtensions + { + public static TComponent BuildComponentChain(this LazyComponentRegistrationList registrations, TComponent innerComponent) + { + var outerComponent = registrations.InReverseOrder.Aggregate( + innerComponent, + (inner, factory) => factory(inner) + ); + + return outerComponent; + } + + public static TComponent BuildComponentChain(this LazyComponentRegistrationList registrations, TComponent innerComponent, Func argumentBuilder) + { + var outerComponent = registrations.InReverseOrder.Aggregate( + innerComponent, + (inner, factory) => factory(argumentBuilder(inner)) + ); + + return outerComponent; + } + + public static List BuildComponentList(this LazyComponentRegistrationList registrations) + { + return registrations + .Select(factory => factory(default)) + .ToList(); + } + + public static List BuildComponentList(this LazyComponentRegistrationList registrations, TArgument argument) + { + return registrations + .Select(factory => factory(argument)) + .ToList(); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationListExtensions.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationListExtensions.cs.meta new file mode 100644 index 0000000..89beb98 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/LazyComponentRegistrationListExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 89ef072424fd19149af14e3a2aa858aa +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NamingConventions.meta b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions.meta new file mode 100644 index 0000000..45c85fc --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 767c978518279084085a6e65bcb24a43 +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/CamelCaseNamingConvention.cs b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/CamelCaseNamingConvention.cs new file mode 100644 index 0000000..c56846f --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/CamelCaseNamingConvention.cs @@ -0,0 +1,46 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization.NamingConventions +{ + /// + /// Convert the string with underscores (this_is_a_test) or hyphens (this-is-a-test) to + /// camel case (thisIsATest). Camel case is the same as Pascal case, except the first letter + /// is lowercase. + /// + public sealed class CamelCaseNamingConvention : INamingConvention + { + [Obsolete("Use the Instance static field instead of creating new instances")] + public CamelCaseNamingConvention() { } + + public string Apply(string value) + { + return value.ToCamelCase(); + } + +#pragma warning disable CS0618 // Type or member is obsolete + public static readonly INamingConvention Instance = new CamelCaseNamingConvention(); +#pragma warning restore CS0618 // Type or member is obsolete + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/CamelCaseNamingConvention.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/CamelCaseNamingConvention.cs.meta new file mode 100644 index 0000000..5cb460e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/CamelCaseNamingConvention.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 32043fa3c3d7af6489b8238353dcf810 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/HyphenatedNamingConvention.cs b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/HyphenatedNamingConvention.cs new file mode 100644 index 0000000..78f15d5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/HyphenatedNamingConvention.cs @@ -0,0 +1,44 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization.NamingConventions +{ + /// + /// Convert the string from camelcase (thisIsATest) to a hyphenated (this-is-a-test) string + /// + public sealed class HyphenatedNamingConvention : INamingConvention + { + [Obsolete("Use the Instance static field instead of creating new instances")] + public HyphenatedNamingConvention() { } + + public string Apply(string value) + { + return value.FromCamelCase("-"); + } + +#pragma warning disable CS0618 // Type or member is obsolete + public static readonly INamingConvention Instance = new HyphenatedNamingConvention(); +#pragma warning restore CS0618 // Type or member is obsolete + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/HyphenatedNamingConvention.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/HyphenatedNamingConvention.cs.meta new file mode 100644 index 0000000..49920c8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/HyphenatedNamingConvention.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d393465f17a55814a8ecb04e77f1e25c +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/LowerCaseNamingConvention.cs b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/LowerCaseNamingConvention.cs new file mode 100644 index 0000000..39e7f92 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/LowerCaseNamingConvention.cs @@ -0,0 +1,42 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization.NamingConventions +{ + /// + /// Convert the string with underscores (this_is_a_test) or hyphens (this-is-a-test) to + /// pascal case (ThisIsATest). Pascal case is the same as camel case, except the first letter + /// is uppercase. + /// + public sealed class LowerCaseNamingConvention : INamingConvention + { + private LowerCaseNamingConvention() { } + + public string Apply(string value) + { + return value.ToCamelCase().ToLower(); + } + + public static readonly INamingConvention Instance = new LowerCaseNamingConvention(); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/LowerCaseNamingConvention.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/LowerCaseNamingConvention.cs.meta new file mode 100644 index 0000000..5bdff56 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/LowerCaseNamingConvention.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f5d44f37af8ab5940a9f28a2b2b80184 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/NullNamingConvention.cs b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/NullNamingConvention.cs new file mode 100644 index 0000000..2bddbf8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/NullNamingConvention.cs @@ -0,0 +1,44 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + + +using System; + +namespace YamlDotNet.Serialization.NamingConventions +{ + /// + /// Performs no naming conversion. + /// + public sealed class NullNamingConvention : INamingConvention + { + [Obsolete("Use the Instance static field instead of creating new instances")] + public NullNamingConvention() { } + + public string Apply(string value) + { + return value; + } + +#pragma warning disable CS0618 // Type or member is obsolete + public static readonly INamingConvention Instance = new NullNamingConvention(); +#pragma warning restore CS0618 // Type or member is obsolete + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/NullNamingConvention.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/NullNamingConvention.cs.meta new file mode 100644 index 0000000..a27ad65 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/NullNamingConvention.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1f1957c241ea377499c1656388ff9122 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/PascalCaseNamingConvention.cs b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/PascalCaseNamingConvention.cs new file mode 100644 index 0000000..5fefd96 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/PascalCaseNamingConvention.cs @@ -0,0 +1,46 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization.NamingConventions +{ + /// + /// Convert the string with underscores (this_is_a_test) or hyphens (this-is-a-test) to + /// pascal case (ThisIsATest). Pascal case is the same as camel case, except the first letter + /// is uppercase. + /// + public sealed class PascalCaseNamingConvention : INamingConvention + { + [Obsolete("Use the Instance static field instead of creating new instances")] + public PascalCaseNamingConvention() { } + + public string Apply(string value) + { + return value.ToPascalCase(); + } + +#pragma warning disable CS0618 // Type or member is obsolete + public static readonly INamingConvention Instance = new PascalCaseNamingConvention(); +#pragma warning restore CS0618 // Type or member is obsolete + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/PascalCaseNamingConvention.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/PascalCaseNamingConvention.cs.meta new file mode 100644 index 0000000..6f134d1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/PascalCaseNamingConvention.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0514b2a4f30517e42bc79c445fe75383 +timeCreated: 1427145262 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/UnderscoredNamingConvention.cs b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/UnderscoredNamingConvention.cs new file mode 100644 index 0000000..28811e7 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/UnderscoredNamingConvention.cs @@ -0,0 +1,44 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization.NamingConventions +{ + /// + /// Convert the string from camelcase (thisIsATest) to a underscored (this_is_a_test) string + /// + public sealed class UnderscoredNamingConvention : INamingConvention + { + [Obsolete("Use the Instance static field instead of creating new instances")] + public UnderscoredNamingConvention() { } + + public string Apply(string value) + { + return value.FromCamelCase("_"); + } + +#pragma warning disable CS0618 // Type or member is obsolete + public static readonly INamingConvention Instance = new UnderscoredNamingConvention(); +#pragma warning restore CS0618 // Type or member is obsolete + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/UnderscoredNamingConvention.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/UnderscoredNamingConvention.cs.meta new file mode 100644 index 0000000..9cdbd87 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NamingConventions/UnderscoredNamingConvention.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: dc07ca72c2bad00498d0cd0594f69151 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers.meta new file mode 100644 index 0000000..567bdfc --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 4a4c2b9d6803c4b44ad65cedc400e3d1 +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ArrayNodeDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ArrayNodeDeserializer.cs new file mode 100644 index 0000000..6a1d4d2 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ArrayNodeDeserializer.cs @@ -0,0 +1,119 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.NodeDeserializers +{ + public sealed class ArrayNodeDeserializer : INodeDeserializer + { + bool INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func nestedObjectDeserializer, out object? value) + { + if (!expectedType.IsArray) + { + value = false; + return false; + } + + var itemType = expectedType.GetElementType()!; // Arrays always have an element type + + var items = new ArrayList(); + CollectionNodeDeserializer.DeserializeHelper(itemType, parser, nestedObjectDeserializer, items, true); + + var array = Array.CreateInstance(itemType, items.Count); + items.CopyTo(array, 0); + + value = array; + return true; + } + + private sealed class ArrayList : IList + { + private object?[] data; + +#pragma warning disable CS8618 // Non-nullable field is uninitialized. Initialized inside Clear() + public ArrayList() +#pragma warning restore CS8618 // Non-nullable field is uninitialized. + { + Clear(); + } + + public int Add(object? value) + { + if (Count == data.Length) + { + Array.Resize(ref data, data.Length * 2); + } + data[Count] = value; + return Count++; + } + + public void Clear() + { + data = new object[10]; + Count = 0; + } + + bool IList.Contains(object? value) => throw new NotSupportedException(); + int IList.IndexOf(object? value) => throw new NotSupportedException(); + void IList.Insert(int index, object? value) => throw new NotSupportedException(); + void IList.Remove(object? value) => throw new NotSupportedException(); + void IList.RemoveAt(int index) => throw new NotSupportedException(); + + public bool IsFixedSize => false; + + public bool IsReadOnly => false; + + public object? this[int index] + { + get + { + return data[index]; + } + set + { + data[index] = value; + } + } + + public void CopyTo(Array array, int index) + { + Array.Copy(data, 0, array, index, Count); + } + + public int Count { get; private set; } + + public bool IsSynchronized => false; + public object SyncRoot => data; + + public IEnumerator GetEnumerator() + { + for (var i = 0; i < Count; ++i) + { + yield return data[i]; + } + } + } + } +} + diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ArrayNodeDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ArrayNodeDeserializer.cs.meta new file mode 100644 index 0000000..734f4df --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ArrayNodeDeserializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 20118ab09905856488b432270429ae5b +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/CollectionNodeDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/CollectionNodeDeserializer.cs new file mode 100644 index 0000000..dfc01df --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/CollectionNodeDeserializer.cs @@ -0,0 +1,111 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections; +using System.Collections.Generic; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Helpers; +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization.NodeDeserializers +{ + public sealed class CollectionNodeDeserializer : INodeDeserializer + { + private readonly IObjectFactory objectFactory; + + public CollectionNodeDeserializer(IObjectFactory objectFactory) + { + this.objectFactory = objectFactory ?? throw new ArgumentNullException(nameof(objectFactory)); + } + + bool INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func nestedObjectDeserializer, out object? value) + { + IList? list; + var canUpdate = true; + Type itemType; + var genericCollectionType = ReflectionUtility.GetImplementedGenericInterface(expectedType, typeof(ICollection<>)); + if (genericCollectionType != null) + { + var genericArguments = genericCollectionType.GetGenericArguments(); + itemType = genericArguments[0]; + + value = objectFactory.Create(expectedType); + list = value as IList; + if (list == null) + { + // Uncommon case where a type implements IList but not IList + var genericListType = ReflectionUtility.GetImplementedGenericInterface(expectedType, typeof(IList<>)); + canUpdate = genericListType != null; + list = (IList?)Activator.CreateInstance(typeof(GenericCollectionToNonGenericAdapter<>).MakeGenericType(itemType), value); + } + } + else if (typeof(IList).IsAssignableFrom(expectedType)) + { + itemType = typeof(object); + + value = objectFactory.Create(expectedType); + list = (IList)value; + } + else + { + value = null; + return false; + } + + DeserializeHelper(itemType, parser, nestedObjectDeserializer, list!, canUpdate); + + return true; + } + + internal static void DeserializeHelper(Type tItem, IParser parser, Func nestedObjectDeserializer, IList result, bool canUpdate) + { + parser.Consume(); + while (!parser.TryConsume(out var _)) + { + var current = parser.Current; + + var value = nestedObjectDeserializer(parser, tItem); + if (value is IValuePromise promise) + { + if (canUpdate) + { + var index = result.Add(tItem.IsValueType() ? Activator.CreateInstance(tItem) : null); + promise.ValueAvailable += v => result[index] = TypeConverter.ChangeType(v, tItem); + } + else + { + throw new ForwardAnchorNotSupportedException( + current?.Start ?? Mark.Empty, + current?.End ?? Mark.Empty, + "Forward alias references are not allowed because this type does not implement IList<>" + ); + } + } + else + { + result.Add(TypeConverter.ChangeType(value, tItem)); + } + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/CollectionNodeDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/CollectionNodeDeserializer.cs.meta new file mode 100644 index 0000000..93419fa --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/CollectionNodeDeserializer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a3d1d09d7ca82fa46841cf8b486dc14e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/DictionaryNodeDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/DictionaryNodeDeserializer.cs new file mode 100644 index 0000000..eccd4b2 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/DictionaryNodeDeserializer.cs @@ -0,0 +1,144 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections; +using System.Collections.Generic; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Helpers; +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization.NodeDeserializers +{ + public sealed class DictionaryNodeDeserializer : INodeDeserializer + { + private readonly IObjectFactory objectFactory; + + public DictionaryNodeDeserializer(IObjectFactory objectFactory) + { + this.objectFactory = objectFactory ?? throw new ArgumentNullException(nameof(objectFactory)); + } + + bool INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func nestedObjectDeserializer, out object? value) + { + IDictionary? dictionary; + Type keyType, valueType; + var genericDictionaryType = ReflectionUtility.GetImplementedGenericInterface(expectedType, typeof(IDictionary<,>)); + if (genericDictionaryType != null) + { + var genericArguments = genericDictionaryType.GetGenericArguments(); + keyType = genericArguments[0]; + valueType = genericArguments[1]; + + value = objectFactory.Create(expectedType); + + dictionary = value as IDictionary; + if (dictionary == null) + { + // Uncommon case where a type implements IDictionary but not IDictionary + dictionary = (IDictionary?)Activator.CreateInstance(typeof(GenericDictionaryToNonGenericAdapter<,>).MakeGenericType(keyType, valueType), value); + } + } + else if (typeof(IDictionary).IsAssignableFrom(expectedType)) + { + keyType = typeof(object); + valueType = typeof(object); + + value = objectFactory.Create(expectedType); + dictionary = (IDictionary)value; + } + else + { + value = null; + return false; + } + + DeserializeHelper(keyType, valueType, parser, nestedObjectDeserializer, dictionary!); + + return true; + } + + private static void DeserializeHelper(Type tKey, Type tValue, IParser parser, Func nestedObjectDeserializer, IDictionary result) + { + parser.Consume(); + while (!parser.TryConsume(out var _)) + { + var key = nestedObjectDeserializer(parser, tKey); + var value = nestedObjectDeserializer(parser, tValue); + var valuePromise = value as IValuePromise; + + if (key is IValuePromise keyPromise) + { + if (valuePromise == null) + { + // Key is pending, value is known + keyPromise.ValueAvailable += v => result[v!] = value!; + } + else + { + // Both key and value are pending. We need to wait until both of them become available. + var hasFirstPart = false; + + keyPromise.ValueAvailable += v => + { + if (hasFirstPart) + { + result[v!] = value!; + } + else + { + key = v!; + hasFirstPart = true; + } + }; + + valuePromise.ValueAvailable += v => + { + if (hasFirstPart) + { + result[key] = v!; + } + else + { + value = v; + hasFirstPart = true; + } + }; + } + } + else + { + if (valuePromise == null) + { + // Happy path: both key and value are known + result[key!] = value!; + } + else + { + // Key is known, value is pending + valuePromise.ValueAvailable += v => result[key!] = v!; + } + } + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/DictionaryNodeDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/DictionaryNodeDeserializer.cs.meta new file mode 100644 index 0000000..8a17ddf --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/DictionaryNodeDeserializer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0fe68add59e580848b7d981ac8f2f0a1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/EnumerableNodeDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/EnumerableNodeDeserializer.cs new file mode 100644 index 0000000..c76eba9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/EnumerableNodeDeserializer.cs @@ -0,0 +1,57 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections; +using System.Collections.Generic; +using YamlDotNet.Core; +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization.NodeDeserializers +{ + public sealed class EnumerableNodeDeserializer : INodeDeserializer + { + bool INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func nestedObjectDeserializer, out object? value) + { + Type itemsType; + if (expectedType == typeof(IEnumerable)) + { + itemsType = typeof(object); + } + else + { + var iEnumerable = ReflectionUtility.GetImplementedGenericInterface(expectedType, typeof(IEnumerable<>)); + if (iEnumerable != expectedType) + { + value = null; + return false; + } + + itemsType = iEnumerable.GetGenericArguments()[0]; + } + + var collectionType = typeof(List<>).MakeGenericType(itemsType); + value = nestedObjectDeserializer(parser, collectionType); + return true; + } + } +} + diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/EnumerableNodeDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/EnumerableNodeDeserializer.cs.meta new file mode 100644 index 0000000..00fb3b9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/EnumerableNodeDeserializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4b63af2cc4a9f5d4cbbadbdac863e5df +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/NullNodeDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/NullNodeDeserializer.cs new file mode 100644 index 0000000..d56117e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/NullNodeDeserializer.cs @@ -0,0 +1,63 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization.NodeDeserializers +{ + public sealed class NullNodeDeserializer : INodeDeserializer + { + bool INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func nestedObjectDeserializer, out object? value) + { + value = null; + if (parser.Accept(out var evt)) + { + if (NodeIsNull(evt)) + { + parser.SkipThisAndNestedEvents(); + return true; + } + } + + return false; + } + + private bool NodeIsNull(NodeEvent nodeEvent) + { + // http://yaml.org/type/null.html + + if (nodeEvent.Tag == "tag:yaml.org,2002:null") + { + return true; + } + + if (nodeEvent is Scalar scalar && scalar.Style == Core.ScalarStyle.Plain) + { + var value = scalar.Value; + return value == "" || value == "~" || value == "null" || value == "Null" || value == "NULL"; + } + + return false; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/NullNodeDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/NullNodeDeserializer.cs.meta new file mode 100644 index 0000000..dd1c119 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/NullNodeDeserializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2dc4eb3386e00254a90e737f7663d298 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ObjectNodeDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ObjectNodeDeserializer.cs new file mode 100644 index 0000000..f7b4047 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ObjectNodeDeserializer.cs @@ -0,0 +1,100 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Runtime.Serialization; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization.NodeDeserializers +{ + public sealed class ObjectNodeDeserializer : INodeDeserializer + { + private readonly IObjectFactory objectFactory; + private readonly ITypeInspector typeDescriptor; + private readonly bool ignoreUnmatched; + + public ObjectNodeDeserializer(IObjectFactory objectFactory, ITypeInspector typeDescriptor, bool ignoreUnmatched) + { + this.objectFactory = objectFactory ?? throw new ArgumentNullException(nameof(objectFactory)); + this.typeDescriptor = typeDescriptor ?? throw new ArgumentNullException(nameof(typeDescriptor)); + this.ignoreUnmatched = ignoreUnmatched; + } + + bool INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func nestedObjectDeserializer, out object? value) + { + if (!parser.TryConsume(out var mapping)) + { + value = null; + return false; + } + + // Strip off the nullable type, if present. This is needed for nullable structs. + var implementationType = Nullable.GetUnderlyingType(expectedType) ?? expectedType; + + value = objectFactory.Create(implementationType); + while (!parser.TryConsume(out var _)) + { + var propertyName = parser.Consume(); + try + { + var property = typeDescriptor.GetProperty(implementationType, null, propertyName.Value, ignoreUnmatched); + if (property == null) + { + parser.SkipThisAndNestedEvents(); + continue; + } + + var propertyValue = nestedObjectDeserializer(parser, property.Type); + if (propertyValue is IValuePromise propertyValuePromise) + { + var valueRef = value; + propertyValuePromise.ValueAvailable += v => + { + var convertedValue = TypeConverter.ChangeType(v, property.Type); + property.Write(valueRef, convertedValue); + }; + } + else + { + var convertedValue = TypeConverter.ChangeType(propertyValue, property.Type); + property.Write(value, convertedValue); + } + } + catch (SerializationException ex) + { + throw new YamlException(propertyName.Start, propertyName.End, ex.Message); + } + catch (YamlException) + { + throw; + } + catch (Exception ex) + { + throw new YamlException(propertyName.Start, propertyName.End, "Exception during deserialization", ex); + } + } + + return true; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ObjectNodeDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ObjectNodeDeserializer.cs.meta new file mode 100644 index 0000000..6dcca9f --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ObjectNodeDeserializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 203cafd2ca433854ab6bb7dcc51b861a +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ScalarNodeDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ScalarNodeDeserializer.cs new file mode 100644 index 0000000..64805e7 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ScalarNodeDeserializer.cs @@ -0,0 +1,282 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Globalization; +using System.Text; +using System.Text.RegularExpressions; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization.NodeDeserializers +{ + public sealed class ScalarNodeDeserializer : INodeDeserializer + { + private const string BooleanTruePattern = "^(true|y|yes|on)$"; + private const string BooleanFalsePattern = "^(false|n|no|off)$"; + + bool INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func nestedObjectDeserializer, out object? value) + { + if (!parser.TryConsume(out var scalar)) + { + value = null; + return false; + } + + // Strip off the nullable type, if present + var underlyingType = Nullable.GetUnderlyingType(expectedType) ?? expectedType; + + if (underlyingType.IsEnum()) + { + value = Enum.Parse(underlyingType, scalar.Value, true); + return true; + } + + var typeCode = underlyingType.GetTypeCode(); + switch (typeCode) + { + case TypeCode.Boolean: + value = DeserializeBooleanHelper(scalar.Value); + break; + + case TypeCode.Byte: + case TypeCode.Int16: + case TypeCode.Int32: + case TypeCode.Int64: + case TypeCode.SByte: + case TypeCode.UInt16: + case TypeCode.UInt32: + case TypeCode.UInt64: + value = DeserializeIntegerHelper(typeCode, scalar.Value); + break; + + case TypeCode.Single: + value = float.Parse(scalar.Value, YamlFormatter.NumberFormat); + break; + + case TypeCode.Double: + value = double.Parse(scalar.Value, YamlFormatter.NumberFormat); + break; + + case TypeCode.Decimal: + value = decimal.Parse(scalar.Value, YamlFormatter.NumberFormat); + break; + + case TypeCode.String: + value = scalar.Value; + break; + + case TypeCode.Char: + value = scalar.Value[0]; + break; + + case TypeCode.DateTime: + // TODO: This is probably incorrect. Use the correct regular expression. + value = DateTime.Parse(scalar.Value, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind); + break; + + default: + if (expectedType == typeof(object)) + { + // Default to string + value = scalar.Value; + } + else + { + value = TypeConverter.ChangeType(scalar.Value, expectedType); + } + break; + } + return true; + } + + private object DeserializeBooleanHelper(string value) + { + bool result; + + if (Regex.IsMatch(value, BooleanTruePattern, RegexOptions.IgnoreCase)) + { + result = true; + } + else if (Regex.IsMatch(value, BooleanFalsePattern, RegexOptions.IgnoreCase)) + { + result = false; + } + else + { + throw new FormatException($"The value \"{value}\" is not a valid YAML Boolean"); + } + + return result; + } + + private object DeserializeIntegerHelper(TypeCode typeCode, string value) + { + var numberBuilder = new StringBuilder(); + var currentIndex = 0; + var isNegative = false; + int numberBase; + ulong result = 0; + + if (value[0] == '-') + { + currentIndex++; + isNegative = true; + } + + else if (value[0] == '+') + { + currentIndex++; + } + + if (value[currentIndex] == '0') + { + // Could be binary, octal, hex, decimal (0) + + // If there are no characters remaining, it's a decimal zero + if (currentIndex == value.Length - 1) + { + numberBase = 10; + result = 0; + } + + else + { + // Check the next character + currentIndex++; + + if (value[currentIndex] == 'b') + { + // Binary + numberBase = 2; + + currentIndex++; + } + + else if (value[currentIndex] == 'x') + { + // Hex + numberBase = 16; + + currentIndex++; + } + + else + { + // Octal + numberBase = 8; + } + } + + // Copy remaining digits to the number buffer (skip underscores) + while (currentIndex < value.Length) + { + if (value[currentIndex] != '_') + { + numberBuilder.Append(value[currentIndex]); + } + currentIndex++; + } + + // Parse the magnitude of the number + switch (numberBase) + { + case 2: + case 8: + // TODO: how to incorporate the numberFormat? + result = Convert.ToUInt64(numberBuilder.ToString(), numberBase); + break; + + case 16: + result = ulong.Parse(numberBuilder.ToString(), NumberStyles.HexNumber, YamlFormatter.NumberFormat); + break; + + case 10: + // Result is already zero + break; + } + } + + else + { + // Could be decimal or base 60 + var chunks = value.Substring(currentIndex).Split(':'); + result = 0; + + for (var chunkIndex = 0; chunkIndex < chunks.Length; chunkIndex++) + { + result *= 60; + + // TODO: verify that chunks after the first are non-negative and less than 60 + result += ulong.Parse(chunks[chunkIndex].Replace("_", "")); + } + } + + if (isNegative) + { + return CastInteger(checked(-(long)result), typeCode); + } + else + { + return CastInteger(result, typeCode); + } + } + + private static object CastInteger(long number, TypeCode typeCode) + { + checked + { + return typeCode switch + { + TypeCode.Byte => (byte)number, + TypeCode.Int16 => (short)number, + TypeCode.Int32 => (int)number, + TypeCode.Int64 => number, + TypeCode.SByte => (sbyte)number, + TypeCode.UInt16 => (ushort)number, + TypeCode.UInt32 => (uint)number, + TypeCode.UInt64 => (ulong)number, + _ => number, + }; + } + } + + private static object CastInteger(ulong number, TypeCode typeCode) + { + checked + { + return typeCode switch + { + TypeCode.Byte => (byte)number, + TypeCode.Int16 => (short)number, + TypeCode.Int32 => (int)number, + TypeCode.Int64 => (long)number, + TypeCode.SByte => (sbyte)number, + TypeCode.UInt16 => (ushort)number, + TypeCode.UInt32 => (uint)number, + TypeCode.UInt64 => number, + _ => number, + }; + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ScalarNodeDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ScalarNodeDeserializer.cs.meta new file mode 100644 index 0000000..894f91b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/ScalarNodeDeserializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: acae7a1311005a143be6454d8b86b947 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/TypeConverterNodeDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/TypeConverterNodeDeserializer.cs new file mode 100644 index 0000000..9a5617b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/TypeConverterNodeDeserializer.cs @@ -0,0 +1,52 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.NodeDeserializers +{ + public sealed class TypeConverterNodeDeserializer : INodeDeserializer + { + private readonly IEnumerable converters; + + public TypeConverterNodeDeserializer(IEnumerable converters) + { + this.converters = converters ?? throw new ArgumentNullException(nameof(converters)); + } + + bool INodeDeserializer.Deserialize(IParser parser, Type expectedType, Func nestedObjectDeserializer, out object? value) + { + var converter = converters.FirstOrDefault(c => c.Accepts(expectedType)); + if (converter == null) + { + value = null; + return false; + } + + value = converter.ReadYaml(parser, expectedType); + return true; + } + } +} + diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/TypeConverterNodeDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/TypeConverterNodeDeserializer.cs.meta new file mode 100644 index 0000000..41a2e4d --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/TypeConverterNodeDeserializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a4dc6d0569fe722448b3d925a66e2b45 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlConvertibleNodeDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlConvertibleNodeDeserializer.cs new file mode 100644 index 0000000..da3d9e7 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlConvertibleNodeDeserializer.cs @@ -0,0 +1,50 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.NodeDeserializers +{ + public sealed class YamlConvertibleNodeDeserializer : INodeDeserializer + { + private readonly IObjectFactory objectFactory; + + public YamlConvertibleNodeDeserializer(IObjectFactory objectFactory) + { + this.objectFactory = objectFactory; + } + + public bool Deserialize(IParser parser, Type expectedType, Func nestedObjectDeserializer, out object? value) + { + if (typeof(IYamlConvertible).IsAssignableFrom(expectedType)) + { + var convertible = (IYamlConvertible)objectFactory.Create(expectedType); + convertible.Read(parser, expectedType, type => nestedObjectDeserializer(parser, type)); + value = convertible; + return true; + } + + value = null; + return false; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlConvertibleNodeDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlConvertibleNodeDeserializer.cs.meta new file mode 100644 index 0000000..d90d92a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlConvertibleNodeDeserializer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 994740f2670b0744e892638b88feb9f0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlSerializableNodeDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlSerializableNodeDeserializer.cs new file mode 100644 index 0000000..62d622b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlSerializableNodeDeserializer.cs @@ -0,0 +1,52 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.NodeDeserializers +{ + public sealed class YamlSerializableNodeDeserializer : INodeDeserializer + { + private readonly IObjectFactory objectFactory; + + public YamlSerializableNodeDeserializer(IObjectFactory objectFactory) + { + this.objectFactory = objectFactory; + } + + public bool Deserialize(IParser parser, Type expectedType, Func nestedObjectDeserializer, out object? value) + { +#pragma warning disable 0618 // IYamlSerializable is obsolete + if (typeof(IYamlSerializable).IsAssignableFrom(expectedType)) + { + var serializable = (IYamlSerializable)objectFactory.Create(expectedType); + serializable.ReadYaml(parser); + value = serializable; + return true; + } +#pragma warning restore + + value = null; + return false; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlSerializableNodeDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlSerializableNodeDeserializer.cs.meta new file mode 100644 index 0000000..fb2be66 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeDeserializers/YamlSerializableNodeDeserializer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 997309be5330da04d9bc939aad61f6e2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers.meta new file mode 100644 index 0000000..81e47f4 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: dcbf27d19b1e0ef4d8ba634760b0d3da +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/DefaultContainersNodeTypeResolver.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/DefaultContainersNodeTypeResolver.cs new file mode 100644 index 0000000..a407cc2 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/DefaultContainersNodeTypeResolver.cs @@ -0,0 +1,49 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization.NodeTypeResolvers +{ + public sealed class DefaultContainersNodeTypeResolver : INodeTypeResolver + { + bool INodeTypeResolver.Resolve(NodeEvent? nodeEvent, ref Type currentType) + { + if (currentType == typeof(object)) + { + if (nodeEvent is SequenceStart) + { + currentType = typeof(List); + return true; + } + if (nodeEvent is MappingStart) + { + currentType = typeof(Dictionary); + return true; + } + } + + return false; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/DefaultContainersNodeTypeResolver.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/DefaultContainersNodeTypeResolver.cs.meta new file mode 100644 index 0000000..d29887c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/DefaultContainersNodeTypeResolver.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a96ce7ab22cdeb245a28967001844e3f +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/MappingNodeTypeResolver.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/MappingNodeTypeResolver.cs new file mode 100644 index 0000000..5d974aa --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/MappingNodeTypeResolver.cs @@ -0,0 +1,61 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization.NodeTypeResolvers +{ + public class MappingNodeTypeResolver : INodeTypeResolver + { + private readonly IDictionary _mappings; + + public MappingNodeTypeResolver(IDictionary mappings) + { + if (mappings == null) + { + throw new ArgumentNullException(nameof(mappings)); + } + + foreach (var pair in mappings) + { + if (!pair.Key.IsAssignableFrom(pair.Value)) + { + throw new InvalidOperationException($"Type '{pair.Value}' does not implement type '{pair.Key}'."); + } + } + + _mappings = mappings; + } + + public bool Resolve(NodeEvent? nodeEvent, ref Type currentType) + { + if (_mappings.TryGetValue(currentType, out var concreteType)) + { + currentType = concreteType; + return true; + } + + return false; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/MappingNodeTypeResolver.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/MappingNodeTypeResolver.cs.meta new file mode 100644 index 0000000..19f3f6a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/MappingNodeTypeResolver.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 84eb0c03bb5432742ad4bc901c6496c2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/RejectUnknownTagsNodeTypeResolver.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/RejectUnknownTagsNodeTypeResolver.cs new file mode 100644 index 0000000..6d9637b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/RejectUnknownTagsNodeTypeResolver.cs @@ -0,0 +1,39 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization.NodeTypeResolvers +{ + public class PreventUnknownTagsNodeTypeResolver : INodeTypeResolver + { + bool INodeTypeResolver.Resolve(NodeEvent? nodeEvent, ref Type currentType) + { + if (nodeEvent != null && !nodeEvent.Tag.IsEmpty) + { + throw new YamlException(nodeEvent.Start, nodeEvent.End, $"Encountered an unresolved tag '{nodeEvent.Tag}'"); + } + return false; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/RejectUnknownTagsNodeTypeResolver.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/RejectUnknownTagsNodeTypeResolver.cs.meta new file mode 100644 index 0000000..810bfa4 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/RejectUnknownTagsNodeTypeResolver.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c167351ceb6bccb4291337e4a6e8be56 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TagNodeTypeResolver.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TagNodeTypeResolver.cs new file mode 100644 index 0000000..0852c43 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TagNodeTypeResolver.cs @@ -0,0 +1,48 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization.NodeTypeResolvers +{ + public sealed class TagNodeTypeResolver : INodeTypeResolver + { + private readonly IDictionary tagMappings; + + public TagNodeTypeResolver(IDictionary tagMappings) + { + this.tagMappings = tagMappings ?? throw new ArgumentNullException(nameof(tagMappings)); + } + + bool INodeTypeResolver.Resolve(NodeEvent? nodeEvent, ref Type currentType) + { + if (nodeEvent != null && !nodeEvent.Tag.IsEmpty && tagMappings.TryGetValue(nodeEvent.Tag, out var predefinedType)) + { + currentType = predefinedType; + return true; + } + return false; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TagNodeTypeResolver.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TagNodeTypeResolver.cs.meta new file mode 100644 index 0000000..f277a5e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TagNodeTypeResolver.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 699369e47bae32e4b87e9bcb955ee742 +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TypeNameInTagNodeTypeResolver.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TypeNameInTagNodeTypeResolver.cs new file mode 100644 index 0000000..348dcc5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TypeNameInTagNodeTypeResolver.cs @@ -0,0 +1,46 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization.NodeTypeResolvers +{ + [Obsolete("The mechanism that this class uses to specify type names is non-standard. Register the tags explicitly instead of using this convention.")] + public sealed class TypeNameInTagNodeTypeResolver : INodeTypeResolver + { + bool INodeTypeResolver.Resolve(NodeEvent? nodeEvent, ref Type currentType) + { + if (nodeEvent != null && !nodeEvent.Tag.IsEmpty) + { + // If type could not be loaded, make sure to pass resolving + // to the next resolver + var resolvedType = Type.GetType(nodeEvent.Tag.Value.Substring(1), throwOnError: false); + if (resolvedType != null) + { + currentType = resolvedType; + return true; + } + } + return false; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TypeNameInTagNodeTypeResolver.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TypeNameInTagNodeTypeResolver.cs.meta new file mode 100644 index 0000000..d24905e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/TypeNameInTagNodeTypeResolver.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: abbd2aba7e216f54a8353afcce646479 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlConvertibleTypeResolver.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlConvertibleTypeResolver.cs new file mode 100644 index 0000000..f0c77b3 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlConvertibleTypeResolver.cs @@ -0,0 +1,34 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization.NodeTypeResolvers +{ + public sealed class YamlConvertibleTypeResolver : INodeTypeResolver + { + public bool Resolve(NodeEvent? nodeEvent, ref Type currentType) + { + return typeof(IYamlConvertible).IsAssignableFrom(currentType); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlConvertibleTypeResolver.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlConvertibleTypeResolver.cs.meta new file mode 100644 index 0000000..0b278aa --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlConvertibleTypeResolver.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: db75221acfd2bb048850bcaef9b66d7c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlSerializableTypeResolver.cs b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlSerializableTypeResolver.cs new file mode 100644 index 0000000..6756545 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlSerializableTypeResolver.cs @@ -0,0 +1,36 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization.NodeTypeResolvers +{ + public sealed class YamlSerializableTypeResolver : INodeTypeResolver + { + public bool Resolve(NodeEvent? nodeEvent, ref Type currentType) + { +#pragma warning disable 0618 // IYamlSerializable is obsolete + return typeof(IYamlSerializable).IsAssignableFrom(currentType); +#pragma warning restore 0618 + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlSerializableTypeResolver.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlSerializableTypeResolver.cs.meta new file mode 100644 index 0000000..eea9883 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/NodeTypeResolvers/YamlSerializableTypeResolver.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bac41cda321c2f6488e0a5f321673e4d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Nothing.cs b/namedropper/Assets/YamlDotNet/Serialization/Nothing.cs new file mode 100644 index 0000000..ecc78c8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Nothing.cs @@ -0,0 +1,31 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + + +namespace YamlDotNet.Serialization +{ + /// + /// An empty type for cases where a type needs to be provided but won't be used. + /// + public struct Nothing + { + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/Nothing.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/Nothing.cs.meta new file mode 100644 index 0000000..cc122be --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Nothing.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 87828e3c8183f8f40b3834f62c8d41b9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectDescriptor.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectDescriptor.cs new file mode 100644 index 0000000..500f07d --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectDescriptor.cs @@ -0,0 +1,48 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + public sealed class ObjectDescriptor : IObjectDescriptor + { + public object? Value { get; private set; } + public Type Type { get; private set; } + public Type StaticType { get; private set; } + public ScalarStyle ScalarStyle { get; private set; } + + public ObjectDescriptor(object? value, Type type, Type staticType) + : this(value, type, staticType, ScalarStyle.Any) + { + } + + public ObjectDescriptor(object? value, Type type, Type staticType, ScalarStyle scalarStyle) + { + Value = value; + Type = type ?? throw new ArgumentNullException(nameof(type)); + StaticType = staticType ?? throw new ArgumentNullException(nameof(staticType)); + + ScalarStyle = scalarStyle; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectDescriptor.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectDescriptor.cs.meta new file mode 100644 index 0000000..5f29254 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectDescriptor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 13c3a8b94ac1de641806bb1733305bda +timeCreated: 1427145262 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories.meta new file mode 100644 index 0000000..345d7d4 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 755993ac40163ac47a826c22a1797745 +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/DefaultObjectFactory.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/DefaultObjectFactory.cs new file mode 100644 index 0000000..6b906ba --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/DefaultObjectFactory.cs @@ -0,0 +1,97 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace YamlDotNet.Serialization.ObjectFactories +{ + /// + /// Creates objects using Activator.CreateInstance. + /// + public sealed class DefaultObjectFactory : IObjectFactory + { + private readonly Dictionary DefaultGenericInterfaceImplementations = new Dictionary + { + { typeof(IEnumerable<>), typeof(List<>) }, + { typeof(ICollection<>), typeof(List<>) }, + { typeof(IList<>), typeof(List<>) }, + { typeof(IDictionary<,>), typeof(Dictionary<,>) } + }; + + private readonly Dictionary DefaultNonGenericInterfaceImplementations = new Dictionary + { + { typeof(IEnumerable), typeof(List) }, + { typeof(ICollection), typeof(List) }, + { typeof(IList), typeof(List) }, + { typeof(IDictionary), typeof(Dictionary) } + }; + + public DefaultObjectFactory() + { + } + + public DefaultObjectFactory(IDictionary mappings) + { + foreach (var pair in mappings) + { + if (!pair.Key.IsAssignableFrom(pair.Value)) + { + throw new InvalidOperationException($"Type '{pair.Value}' does not implement type '{pair.Key}'."); + } + + DefaultNonGenericInterfaceImplementations.Add(pair.Key, pair.Value); + } + } + + public object Create(Type type) + { + if (type.IsInterface()) + { + if (type.IsGenericType()) + { + if (DefaultGenericInterfaceImplementations.TryGetValue(type.GetGenericTypeDefinition(), out var implementationType)) + { + type = implementationType.MakeGenericType(type.GetGenericArguments()); + } + } + else + { + if (DefaultNonGenericInterfaceImplementations.TryGetValue(type, out var implementationType)) + { + type = implementationType; + } + } + } + + try + { + return Activator.CreateInstance(type)!; + } + catch (Exception err) + { + var message = $"Failed to create an instance of type '{type.FullName}'."; + throw new InvalidOperationException(message, err); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/DefaultObjectFactory.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/DefaultObjectFactory.cs.meta new file mode 100644 index 0000000..b5ba6cd --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/DefaultObjectFactory.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d85c04bcbb9823e428994436b556c0c4 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/LambdaObjectFactory.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/LambdaObjectFactory.cs new file mode 100644 index 0000000..a1fea46 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/LambdaObjectFactory.cs @@ -0,0 +1,43 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Serialization.ObjectFactories +{ + /// + /// Creates objects using a Func{Type,object}"/>. + /// + public sealed class LambdaObjectFactory : IObjectFactory + { + private readonly Func factory; + + public LambdaObjectFactory(Func factory) + { + this.factory = factory ?? throw new ArgumentNullException(nameof(factory)); + } + + public object Create(Type type) + { + return factory(type); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/LambdaObjectFactory.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/LambdaObjectFactory.cs.meta new file mode 100644 index 0000000..92e0dfe --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectFactories/LambdaObjectFactory.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2ad19c2ee12f0cd41a32cf7dfe446c07 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies.meta new file mode 100644 index 0000000..2c5a723 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a42ffc21fa040324dbd9991681d9654c +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/FullObjectGraphTraversalStrategy.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/FullObjectGraphTraversalStrategy.cs new file mode 100644 index 0000000..ba20b5e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/FullObjectGraphTraversalStrategy.cs @@ -0,0 +1,258 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using YamlDotNet.Core; +using YamlDotNet.Helpers; +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization.ObjectGraphTraversalStrategies +{ + /// + /// An implementation of that traverses + /// readable properties, collections and dictionaries. + /// + public class FullObjectGraphTraversalStrategy : IObjectGraphTraversalStrategy + { + private readonly int maxRecursion; + private readonly ITypeInspector typeDescriptor; + private readonly ITypeResolver typeResolver; + private readonly INamingConvention namingConvention; + + public FullObjectGraphTraversalStrategy(ITypeInspector typeDescriptor, ITypeResolver typeResolver, int maxRecursion, INamingConvention namingConvention) + { + if (maxRecursion <= 0) + { + throw new ArgumentOutOfRangeException(nameof(maxRecursion), maxRecursion, "maxRecursion must be greater than 1"); + } + + this.typeDescriptor = typeDescriptor ?? throw new ArgumentNullException(nameof(typeDescriptor)); + this.typeResolver = typeResolver ?? throw new ArgumentNullException(nameof(typeResolver)); + + this.maxRecursion = maxRecursion; + this.namingConvention = namingConvention ?? throw new ArgumentNullException(nameof(namingConvention)); + } + + void IObjectGraphTraversalStrategy.Traverse(IObjectDescriptor graph, IObjectGraphVisitor visitor, TContext context) + { + Traverse("", graph, visitor, context, new Stack(maxRecursion)); + } + + protected struct ObjectPathSegment + { + public readonly object Name; + public readonly IObjectDescriptor Value; + + public ObjectPathSegment(object name, IObjectDescriptor value) + { + this.Name = name; + this.Value = value; + } + } + + protected virtual void Traverse(object name, IObjectDescriptor value, IObjectGraphVisitor visitor, TContext context, Stack path) + { + if (path.Count >= maxRecursion) + { + var message = new StringBuilder(); + message.AppendLine("Too much recursion when traversing the object graph."); + message.AppendLine("The path to reach this recursion was:"); + + var lines = new Stack>(path.Count); + var maxNameLength = 0; + foreach (var segment in path) + { + var segmentName = TypeConverter.ChangeType(segment.Name); + maxNameLength = Math.Max(maxNameLength, segmentName.Length); + lines.Push(new KeyValuePair(segmentName, segment.Value.Type.FullName!)); + } + + foreach (var line in lines) + { + message + .Append(" -> ") + .Append(line.Key.PadRight(maxNameLength)) + .Append(" [") + .Append(line.Value) + .AppendLine("]"); + } + + throw new MaximumRecursionLevelReachedException(message.ToString()); + } + + if (!visitor.Enter(value, context)) + { + return; + } + + path.Push(new ObjectPathSegment(name, value)); + try + { + var typeCode = value.Type.GetTypeCode(); + switch (typeCode) + { + case TypeCode.Boolean: + case TypeCode.Byte: + case TypeCode.Int16: + case TypeCode.Int32: + case TypeCode.Int64: + case TypeCode.SByte: + case TypeCode.UInt16: + case TypeCode.UInt32: + case TypeCode.UInt64: + case TypeCode.Single: + case TypeCode.Double: + case TypeCode.Decimal: + case TypeCode.String: + case TypeCode.Char: + case TypeCode.DateTime: + visitor.VisitScalar(value, context); + break; + + case TypeCode.Empty: + throw new NotSupportedException($"TypeCode.{typeCode} is not supported."); + + default: + if (value.IsDbNull()) + { + visitor.VisitScalar(new ObjectDescriptor(null, typeof(object), typeof(object)), context); + } + + if (value.Value == null || value.Type == typeof(TimeSpan)) + { + visitor.VisitScalar(value, context); + break; + } + + var underlyingType = Nullable.GetUnderlyingType(value.Type); + if (underlyingType != null) + { + // This is a nullable type, recursively handle it with its underlying type. + // Note that if it contains null, the condition above already took care of it + Traverse("Value", new ObjectDescriptor(value.Value, underlyingType, value.Type, value.ScalarStyle), visitor, context, path); + } + else + { + TraverseObject(value, visitor, context, path); + } + break; + } + } + finally + { + path.Pop(); + } + } + + protected virtual void TraverseObject(IObjectDescriptor value, IObjectGraphVisitor visitor, TContext context, Stack path) + { + if (typeof(IDictionary).IsAssignableFrom(value.Type)) + { + TraverseDictionary(value, visitor, typeof(object), typeof(object), context, path); + return; + } + + var genericDictionaryType = ReflectionUtility.GetImplementedGenericInterface(value.Type, typeof(IDictionary<,>)); + if (genericDictionaryType != null) + { + var genericArguments = genericDictionaryType.GetGenericArguments(); + var adaptedDictionary = Activator.CreateInstance(typeof(GenericDictionaryToNonGenericAdapter<,>).MakeGenericType(genericArguments), value.Value)!; + TraverseDictionary(new ObjectDescriptor(adaptedDictionary, value.Type, value.StaticType, value.ScalarStyle), visitor, genericArguments[0], genericArguments[1], context, path); + return; + } + + if (typeof(IEnumerable).IsAssignableFrom(value.Type)) + { + TraverseList(value, visitor, context, path); + return; + } + + TraverseProperties(value, visitor, context, path); + } + + protected virtual void TraverseDictionary(IObjectDescriptor dictionary, IObjectGraphVisitor visitor, Type keyType, Type valueType, TContext context, Stack path) + { + visitor.VisitMappingStart(dictionary, keyType, valueType, context); + + var isDynamic = dictionary.Type.FullName!.Equals("System.Dynamic.ExpandoObject"); + foreach (DictionaryEntry? entry in (IDictionary)dictionary.NonNullValue()) + { + var entryValue = entry!.Value; + var keyValue = isDynamic ? namingConvention.Apply(entryValue.Key.ToString()!) : entryValue.Key; + var key = GetObjectDescriptor(keyValue, keyType); + var value = GetObjectDescriptor(entryValue.Value, valueType); + + if (visitor.EnterMapping(key, value, context)) + { + Traverse(keyValue, key, visitor, context, path); + Traverse(keyValue, value, visitor, context, path); + } + } + + visitor.VisitMappingEnd(dictionary, context); + } + + private void TraverseList(IObjectDescriptor value, IObjectGraphVisitor visitor, TContext context, Stack path) + { + var enumerableType = ReflectionUtility.GetImplementedGenericInterface(value.Type, typeof(IEnumerable<>)); + var itemType = enumerableType != null ? enumerableType.GetGenericArguments()[0] : typeof(object); + + visitor.VisitSequenceStart(value, itemType, context); + + var index = 0; + + foreach (var item in (IEnumerable)value.NonNullValue()) + { + Traverse(index, GetObjectDescriptor(item, itemType), visitor, context, path); + ++index; + } + + visitor.VisitSequenceEnd(value, context); + } + + protected virtual void TraverseProperties(IObjectDescriptor value, IObjectGraphVisitor visitor, TContext context, Stack path) + { + visitor.VisitMappingStart(value, typeof(string), typeof(object), context); + + var source = value.NonNullValue(); + foreach (var propertyDescriptor in typeDescriptor.GetProperties(value.Type, source)) + { + var propertyValue = propertyDescriptor.Read(source); + + if (visitor.EnterMapping(propertyDescriptor, propertyValue, context)) + { + Traverse(propertyDescriptor.Name, new ObjectDescriptor(propertyDescriptor.Name, typeof(string), typeof(string)), visitor, context, path); + Traverse(propertyDescriptor.Name, propertyValue, visitor, context, path); + } + } + + visitor.VisitMappingEnd(value, context); + } + + private IObjectDescriptor GetObjectDescriptor(object? value, Type staticType) + { + return new ObjectDescriptor(value, typeResolver.Resolve(staticType, value), staticType); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/FullObjectGraphTraversalStrategy.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/FullObjectGraphTraversalStrategy.cs.meta new file mode 100644 index 0000000..c48ec63 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/FullObjectGraphTraversalStrategy.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4d75872db0e63bf4e829d39ab3d05abd +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/RoundtripObjectGraphTraversalStrategy.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/RoundtripObjectGraphTraversalStrategy.cs new file mode 100644 index 0000000..0f774e9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/RoundtripObjectGraphTraversalStrategy.cs @@ -0,0 +1,53 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace YamlDotNet.Serialization.ObjectGraphTraversalStrategies +{ + /// + /// An implementation of that traverses + /// properties that are read/write, collections and dictionaries, while ensuring that + /// the graph can be regenerated from the resulting document. + /// + public class RoundtripObjectGraphTraversalStrategy : FullObjectGraphTraversalStrategy + { + private readonly IEnumerable converters; + + public RoundtripObjectGraphTraversalStrategy(IEnumerable converters, ITypeInspector typeDescriptor, ITypeResolver typeResolver, int maxRecursion, INamingConvention namingConvention) + : base(typeDescriptor, typeResolver, maxRecursion, namingConvention) + { + this.converters = converters; + } + + protected override void TraverseProperties(IObjectDescriptor value, IObjectGraphVisitor visitor, TContext context, Stack path) + { + if (!value.Type.HasDefaultConstructor() && !converters.Any(c => c.Accepts(value.Type))) + { + throw new InvalidOperationException($"Type '{value.Type}' cannot be deserialized because it does not have a default constructor or a type converter."); + } + + base.TraverseProperties(value, visitor, context, path); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/RoundtripObjectGraphTraversalStrategy.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/RoundtripObjectGraphTraversalStrategy.cs.meta new file mode 100644 index 0000000..763c65c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategies/RoundtripObjectGraphTraversalStrategy.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cc11b2a2ab4f92a4683501db76ecc278 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategyFactory.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategyFactory.cs new file mode 100644 index 0000000..29569f0 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategyFactory.cs @@ -0,0 +1,41 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Collections.Generic; + +namespace YamlDotNet.Serialization +{ + /// + /// A factory method for creating instances + /// + /// The type inspector to be used by the traversal strategy. + /// The type resolver to be used by the traversal strategy. + /// The type converters to be used by the traversal strategy. + /// The maximum object depth to be supported by the traversal strategy. + /// + public delegate IObjectGraphTraversalStrategy + ObjectGraphTraversalStrategyFactory( + ITypeInspector typeInspector, + ITypeResolver typeResolver, + IEnumerable typeConverters, + int maximumRecursion + ); +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategyFactory.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategyFactory.cs.meta new file mode 100644 index 0000000..8cb055a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphTraversalStrategyFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 12822877c3da26240a7da56993ba63fc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors.meta new file mode 100644 index 0000000..cae5c80 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8c3c32412b4e3944c9d8e8f30f4f3001 +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigner.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigner.cs new file mode 100644 index 0000000..5c91050 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigner.cs @@ -0,0 +1,105 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Globalization; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.ObjectGraphVisitors +{ + public sealed class AnchorAssigner : PreProcessingPhaseObjectGraphVisitorSkeleton, IAliasProvider + { + private class AnchorAssignment + { + public AnchorName Anchor; + } + + private readonly IDictionary assignments = new Dictionary(); + private uint nextId; + + public AnchorAssigner(IEnumerable typeConverters) + : base(typeConverters) + { + } + + protected override bool Enter(IObjectDescriptor value) + { + if (value.Value != null && assignments.TryGetValue(value.Value, out var assignment)) + { + if (assignment.Anchor.IsEmpty) + { + assignment.Anchor = new AnchorName("o" + nextId.ToString(CultureInfo.InvariantCulture)); + ++nextId; + } + return false; + } + + return true; + } + + protected override bool EnterMapping(IObjectDescriptor key, IObjectDescriptor value) + { + return true; + } + + protected override bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value) + { + return true; + } + + protected override void VisitScalar(IObjectDescriptor scalar) + { + // Do not assign anchors to scalars + } + + protected override void VisitMappingStart(IObjectDescriptor mapping, Type keyType, Type valueType) + { + VisitObject(mapping); + } + + protected override void VisitMappingEnd(IObjectDescriptor mapping) { } + + protected override void VisitSequenceStart(IObjectDescriptor sequence, Type elementType) + { + VisitObject(sequence); + } + + protected override void VisitSequenceEnd(IObjectDescriptor sequence) { } + + private void VisitObject(IObjectDescriptor value) + { + if (value.Value != null) + { + assignments.Add(value.Value, new AnchorAssignment()); + } + } + + AnchorName IAliasProvider.GetAlias(object target) + { + if (target != null && assignments.TryGetValue(target, out var assignment)) + { + return assignment.Anchor; + } + return AnchorName.Empty; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigner.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigner.cs.meta new file mode 100644 index 0000000..adff831 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigner.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c7a4420c17a267847b8d6973ad99346a +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigningObjectGraphVisitor.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigningObjectGraphVisitor.cs new file mode 100644 index 0000000..7882ac8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigningObjectGraphVisitor.cs @@ -0,0 +1,78 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.ObjectGraphVisitors +{ + public sealed class AnchorAssigningObjectGraphVisitor : ChainedObjectGraphVisitor + { + private readonly IEventEmitter eventEmitter; + private readonly IAliasProvider aliasProvider; + private readonly HashSet emittedAliases = new HashSet(); + + public AnchorAssigningObjectGraphVisitor(IObjectGraphVisitor nextVisitor, IEventEmitter eventEmitter, IAliasProvider aliasProvider) + : base(nextVisitor) + { + this.eventEmitter = eventEmitter; + this.aliasProvider = aliasProvider; + } + + public override bool Enter(IObjectDescriptor value, IEmitter context) + { + if (value.Value != null) + { + var alias = aliasProvider.GetAlias(value.Value); + if (!alias.IsEmpty && !emittedAliases.Add(alias)) + { + var aliasEventInfo = new AliasEventInfo(value, alias); + eventEmitter.Emit(aliasEventInfo, context); + return aliasEventInfo.NeedsExpansion; + } + } + return base.Enter(value, context); + } + + public override void VisitMappingStart(IObjectDescriptor mapping, Type keyType, Type valueType, IEmitter context) + { + var anchor = aliasProvider.GetAlias(mapping.NonNullValue()); + eventEmitter.Emit(new MappingStartEventInfo(mapping) { Anchor = anchor }, context); + } + + public override void VisitSequenceStart(IObjectDescriptor sequence, Type elementType, IEmitter context) + { + var anchor = aliasProvider.GetAlias(sequence.NonNullValue()); + eventEmitter.Emit(new SequenceStartEventInfo(sequence) { Anchor = anchor }, context); + } + + public override void VisitScalar(IObjectDescriptor scalar, IEmitter context) + { + var scalarInfo = new ScalarEventInfo(scalar); + if (scalar.Value != null) + { + scalarInfo.Anchor = aliasProvider.GetAlias(scalar.Value); + } + eventEmitter.Emit(scalarInfo, context); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigningObjectGraphVisitor.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigningObjectGraphVisitor.cs.meta new file mode 100644 index 0000000..091b66f --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/AnchorAssigningObjectGraphVisitor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7c8b5b39c74f14248971b3c1a4ec83b2 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/ChainedObjectGraphVisitor.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/ChainedObjectGraphVisitor.cs new file mode 100644 index 0000000..231a780 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/ChainedObjectGraphVisitor.cs @@ -0,0 +1,76 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.ObjectGraphVisitors +{ + public abstract class ChainedObjectGraphVisitor : IObjectGraphVisitor + { + private readonly IObjectGraphVisitor nextVisitor; + + protected ChainedObjectGraphVisitor(IObjectGraphVisitor nextVisitor) + { + this.nextVisitor = nextVisitor; + } + + public virtual bool Enter(IObjectDescriptor value, IEmitter context) + { + return nextVisitor.Enter(value, context); + } + + public virtual bool EnterMapping(IObjectDescriptor key, IObjectDescriptor value, IEmitter context) + { + return nextVisitor.EnterMapping(key, value, context); + } + + public virtual bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, IEmitter context) + { + return nextVisitor.EnterMapping(key, value, context); + } + + public virtual void VisitScalar(IObjectDescriptor scalar, IEmitter context) + { + nextVisitor.VisitScalar(scalar, context); + } + + public virtual void VisitMappingStart(IObjectDescriptor mapping, Type keyType, Type valueType, IEmitter context) + { + nextVisitor.VisitMappingStart(mapping, keyType, valueType, context); + } + + public virtual void VisitMappingEnd(IObjectDescriptor mapping, IEmitter context) + { + nextVisitor.VisitMappingEnd(mapping, context); + } + + public virtual void VisitSequenceStart(IObjectDescriptor sequence, Type elementType, IEmitter context) + { + nextVisitor.VisitSequenceStart(sequence, elementType, context); + } + + public virtual void VisitSequenceEnd(IObjectDescriptor sequence, IEmitter context) + { + nextVisitor.VisitSequenceEnd(sequence, context); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/ChainedObjectGraphVisitor.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/ChainedObjectGraphVisitor.cs.meta new file mode 100644 index 0000000..1a40027 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/ChainedObjectGraphVisitor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 91c55744c252b51459a0c70f40c47827 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CommentsObjectGraphVisitor.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CommentsObjectGraphVisitor.cs new file mode 100644 index 0000000..c5e9f57 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CommentsObjectGraphVisitor.cs @@ -0,0 +1,44 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.ObjectGraphVisitors +{ + public sealed class CommentsObjectGraphVisitor : ChainedObjectGraphVisitor + { + public CommentsObjectGraphVisitor(IObjectGraphVisitor nextVisitor) + : base(nextVisitor) + { + } + + public override bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, IEmitter context) + { + var yamlMember = key.GetCustomAttribute(); + if (yamlMember?.Description != null) + { + context.Emit(new Core.Events.Comment(yamlMember.Description, false)); + } + + return base.EnterMapping(key, value, context); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CommentsObjectGraphVisitor.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CommentsObjectGraphVisitor.cs.meta new file mode 100644 index 0000000..7296dbf --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CommentsObjectGraphVisitor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dbe6fcb53ec2760458af35fda5494faa +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CustomSerializationObjectGraphVisitor.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CustomSerializationObjectGraphVisitor.cs new file mode 100644 index 0000000..56e3bf6 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CustomSerializationObjectGraphVisitor.cs @@ -0,0 +1,69 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Collections.Generic; +using System.Linq; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.ObjectGraphVisitors +{ + public sealed class CustomSerializationObjectGraphVisitor : ChainedObjectGraphVisitor + { + private readonly IEnumerable typeConverters; + private readonly ObjectSerializer nestedObjectSerializer; + + public CustomSerializationObjectGraphVisitor(IObjectGraphVisitor nextVisitor, IEnumerable typeConverters, ObjectSerializer nestedObjectSerializer) + : base(nextVisitor) + { + this.typeConverters = typeConverters != null + ? typeConverters.ToList() + : Enumerable.Empty(); + + this.nestedObjectSerializer = nestedObjectSerializer; + } + + public override bool Enter(IObjectDescriptor value, IEmitter context) + { + var typeConverter = typeConverters.FirstOrDefault(t => t.Accepts(value.Type)); + if (typeConverter != null) + { + typeConverter.WriteYaml(context, value.Value, value.Type); + return false; + } + + if (value.Value is IYamlConvertible convertible) + { + convertible.Write(context, nestedObjectSerializer); + return false; + } + +#pragma warning disable 0618 // IYamlSerializable is obsolete + if (value.Value is IYamlSerializable serializable) + { + serializable.WriteYaml(context); + return false; + } +#pragma warning restore + + return base.Enter(value, context); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CustomSerializationObjectGraphVisitor.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CustomSerializationObjectGraphVisitor.cs.meta new file mode 100644 index 0000000..313e704 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/CustomSerializationObjectGraphVisitor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 180ba37056bdea24393986bdab81340d +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultExclusiveObjectGraphVisitor.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultExclusiveObjectGraphVisitor.cs new file mode 100644 index 0000000..91acd03 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultExclusiveObjectGraphVisitor.cs @@ -0,0 +1,58 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.ComponentModel; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.ObjectGraphVisitors +{ + + public sealed class DefaultExclusiveObjectGraphVisitor : ChainedObjectGraphVisitor + { + public DefaultExclusiveObjectGraphVisitor(IObjectGraphVisitor nextVisitor) + : base(nextVisitor) + { + } + + private static object? GetDefault(Type type) + { + return type.IsValueType() ? Activator.CreateInstance(type) : null; + } + + public override bool EnterMapping(IObjectDescriptor key, IObjectDescriptor value, IEmitter context) + { + return !Equals(value.Value, GetDefault(value.Type)) + && base.EnterMapping(key, value, context); + } + + public override bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, IEmitter context) + { + var defaultValueAttribute = key.GetCustomAttribute(); + var defaultValue = defaultValueAttribute != null + ? defaultValueAttribute.Value + : GetDefault(key.Type); + + return !Equals(value.Value, defaultValue) + && base.EnterMapping(key, value, context); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultExclusiveObjectGraphVisitor.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultExclusiveObjectGraphVisitor.cs.meta new file mode 100644 index 0000000..668c442 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultExclusiveObjectGraphVisitor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6f0bed3472e6485468490ba7cf5c910e +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultValuesObjectGraphVisitor.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultValuesObjectGraphVisitor.cs new file mode 100644 index 0000000..982a23e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultValuesObjectGraphVisitor.cs @@ -0,0 +1,91 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections; +using System.ComponentModel; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.ObjectGraphVisitors +{ + public sealed class DefaultValuesObjectGraphVisitor : ChainedObjectGraphVisitor + { + private readonly DefaultValuesHandling handling; + + public DefaultValuesObjectGraphVisitor(DefaultValuesHandling handling, IObjectGraphVisitor nextVisitor) + : base(nextVisitor) + { + this.handling = handling; + } + + private static object? GetDefault(Type type) + { + return type.IsValueType() ? Activator.CreateInstance(type) : null; + } + + public override bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, IEmitter context) + { + var configuration = handling; + var yamlMember = key.GetCustomAttribute(); + if (yamlMember != null && yamlMember.IsDefaultValuesHandlingSpecified) + { + configuration = yamlMember.DefaultValuesHandling; + } + + if ((configuration & DefaultValuesHandling.OmitNull) != 0) + { + if (value.Value is null) + { + return false; + } + } + + if ((configuration & DefaultValuesHandling.OmitEmptyCollections) != 0) + { + if (value.Value is IEnumerable enumerable) + { + var enumerator = enumerable.GetEnumerator(); + var canMoveNext = enumerator.MoveNext(); + if (enumerator is IDisposable disposable) + { + disposable.Dispose(); + } + + if (!canMoveNext) + { + return false; + } + } + } + + if ((configuration & DefaultValuesHandling.OmitDefaults) != 0) + { + var defaultValue = key.GetCustomAttribute()?.Value ?? GetDefault(key.Type); + if (Equals(value.Value, defaultValue)) + { + return false; + } + } + + return base.EnterMapping(key, value, context); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultValuesObjectGraphVisitor.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultValuesObjectGraphVisitor.cs.meta new file mode 100644 index 0000000..ac58721 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/DefaultValuesObjectGraphVisitor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 177b4ba5647b6a6468e0d186fd3b96e3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/EmittingObjectGraphVisitor.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/EmittingObjectGraphVisitor.cs new file mode 100644 index 0000000..76dfa22 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/EmittingObjectGraphVisitor.cs @@ -0,0 +1,76 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.ObjectGraphVisitors +{ + public sealed class EmittingObjectGraphVisitor : IObjectGraphVisitor + { + private readonly IEventEmitter eventEmitter; + + public EmittingObjectGraphVisitor(IEventEmitter eventEmitter) + { + this.eventEmitter = eventEmitter; + } + + bool IObjectGraphVisitor.Enter(IObjectDescriptor value, IEmitter context) + { + return true; + } + + bool IObjectGraphVisitor.EnterMapping(IObjectDescriptor key, IObjectDescriptor value, IEmitter context) + { + return true; + } + + bool IObjectGraphVisitor.EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, IEmitter context) + { + return true; + } + + void IObjectGraphVisitor.VisitScalar(IObjectDescriptor scalar, IEmitter context) + { + eventEmitter.Emit(new ScalarEventInfo(scalar), context); + } + + void IObjectGraphVisitor.VisitMappingStart(IObjectDescriptor mapping, Type keyType, Type valueType, IEmitter context) + { + eventEmitter.Emit(new MappingStartEventInfo(mapping), context); + } + + void IObjectGraphVisitor.VisitMappingEnd(IObjectDescriptor mapping, IEmitter context) + { + eventEmitter.Emit(new MappingEndEventInfo(mapping), context); + } + + void IObjectGraphVisitor.VisitSequenceStart(IObjectDescriptor sequence, Type elementType, IEmitter context) + { + eventEmitter.Emit(new SequenceStartEventInfo(sequence), context); + } + + void IObjectGraphVisitor.VisitSequenceEnd(IObjectDescriptor sequence, IEmitter context) + { + eventEmitter.Emit(new SequenceEndEventInfo(sequence), context); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/EmittingObjectGraphVisitor.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/EmittingObjectGraphVisitor.cs.meta new file mode 100644 index 0000000..a2788d9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/EmittingObjectGraphVisitor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 23b01227eabbc3c4eb0e2658ac27b23d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/PreProcessingPhaseObjectGraphVisitorSkeleton.cs b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/PreProcessingPhaseObjectGraphVisitorSkeleton.cs new file mode 100644 index 0000000..619de4d --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/PreProcessingPhaseObjectGraphVisitorSkeleton.cs @@ -0,0 +1,109 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace YamlDotNet.Serialization.ObjectGraphVisitors +{ + /// + /// A base class that simplifies the correct implementation of . + /// + public abstract class PreProcessingPhaseObjectGraphVisitorSkeleton : IObjectGraphVisitor + { + protected readonly IEnumerable typeConverters; + + public PreProcessingPhaseObjectGraphVisitorSkeleton(IEnumerable typeConverters) + { + this.typeConverters = typeConverters != null + ? typeConverters.ToList() + : Enumerable.Empty(); + } + + bool IObjectGraphVisitor.Enter(IObjectDescriptor value, Nothing context) + { + var typeConverter = typeConverters.FirstOrDefault(t => t.Accepts(value.Type)); + if (typeConverter != null) + { + return false; + } + + if (value.Value is IYamlConvertible convertible) + { + return false; + } + +#pragma warning disable 0618 // IYamlSerializable is obsolete + if (value.Value is IYamlSerializable serializable) + { + return false; + } +#pragma warning restore + + return Enter(value); + } + + bool IObjectGraphVisitor.EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, Nothing context) + { + return EnterMapping(key, value); + } + + bool IObjectGraphVisitor.EnterMapping(IObjectDescriptor key, IObjectDescriptor value, Nothing context) + { + return EnterMapping(key, value); + } + + void IObjectGraphVisitor.VisitMappingEnd(IObjectDescriptor mapping, Nothing context) + { + VisitMappingEnd(mapping); + } + + void IObjectGraphVisitor.VisitMappingStart(IObjectDescriptor mapping, Type keyType, Type valueType, Nothing context) + { + VisitMappingStart(mapping, keyType, valueType); + } + + void IObjectGraphVisitor.VisitScalar(IObjectDescriptor scalar, Nothing context) + { + VisitScalar(scalar); + } + + void IObjectGraphVisitor.VisitSequenceEnd(IObjectDescriptor sequence, Nothing context) + { + VisitSequenceEnd(sequence); + } + + void IObjectGraphVisitor.VisitSequenceStart(IObjectDescriptor sequence, Type elementType, Nothing context) + { + VisitSequenceStart(sequence, elementType); + } + + protected abstract bool Enter(IObjectDescriptor value); + protected abstract bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value); + protected abstract bool EnterMapping(IObjectDescriptor key, IObjectDescriptor value); + protected abstract void VisitMappingEnd(IObjectDescriptor mapping); + protected abstract void VisitMappingStart(IObjectDescriptor mapping, Type keyType, Type valueType); + protected abstract void VisitScalar(IObjectDescriptor scalar); + protected abstract void VisitSequenceEnd(IObjectDescriptor sequence); + protected abstract void VisitSequenceStart(IObjectDescriptor sequence, Type elementType); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/PreProcessingPhaseObjectGraphVisitorSkeleton.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/PreProcessingPhaseObjectGraphVisitorSkeleton.cs.meta new file mode 100644 index 0000000..ad224e4 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ObjectGraphVisitors/PreProcessingPhaseObjectGraphVisitorSkeleton.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 58f47ab50428cf64e9f17e5cf1caee3a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/PropertyDescriptor.cs b/namedropper/Assets/YamlDotNet/Serialization/PropertyDescriptor.cs new file mode 100644 index 0000000..e92a122 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/PropertyDescriptor.cs @@ -0,0 +1,75 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + public sealed class PropertyDescriptor : IPropertyDescriptor + { + private readonly IPropertyDescriptor baseDescriptor; + + public PropertyDescriptor(IPropertyDescriptor baseDescriptor) + { + this.baseDescriptor = baseDescriptor; + Name = baseDescriptor.Name; + } + + public string Name { get; set; } + + public Type Type { get { return baseDescriptor.Type; } } + + public Type? TypeOverride + { + get { return baseDescriptor.TypeOverride; } + set { baseDescriptor.TypeOverride = value; } + } + + public int Order { get; set; } + + public ScalarStyle ScalarStyle + { + get { return baseDescriptor.ScalarStyle; } + set { baseDescriptor.ScalarStyle = value; } + } + + public bool CanWrite + { + get { return baseDescriptor.CanWrite; } + } + + public void Write(object target, object? value) + { + baseDescriptor.Write(target, value); + } + + public T GetCustomAttribute() where T : Attribute + { + return baseDescriptor.GetCustomAttribute(); + } + + public IObjectDescriptor Read(object target) + { + return baseDescriptor.Read(target); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/PropertyDescriptor.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/PropertyDescriptor.cs.meta new file mode 100644 index 0000000..ebe592c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/PropertyDescriptor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f8bf6f944f8b97c42924be110365cef7 +timeCreated: 1427145267 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Schemas.meta b/namedropper/Assets/YamlDotNet/Serialization/Schemas.meta new file mode 100644 index 0000000..90ef9ad --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Schemas.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 94fe08d66cd36aa409a55e9799d65a94 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Schemas/FailsafeSchema.cs b/namedropper/Assets/YamlDotNet/Serialization/Schemas/FailsafeSchema.cs new file mode 100644 index 0000000..fd73ebc --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Schemas/FailsafeSchema.cs @@ -0,0 +1,61 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.Schemas +{ + public sealed class FailsafeSchema + { + public static class Tags + { + public static readonly TagName Map = new TagName("tag:yaml.org,2002:map"); + public static readonly TagName Seq = new TagName("tag:yaml.org,2002:seq"); + public static readonly TagName Str = new TagName("tag:yaml.org,2002:str"); + } + } + + public sealed class JsonSchema + { + public static class Tags + { + public static readonly TagName Null = new TagName("tag:yaml.org,2002:null"); + public static readonly TagName Bool = new TagName("tag:yaml.org,2002:bool"); + public static readonly TagName Int = new TagName("tag:yaml.org,2002:int"); + public static readonly TagName Float = new TagName("tag:yaml.org,2002:float"); + } + } + + public sealed class CoreSchema + { + public static class Tags + { + } + } + + public sealed class DefaultSchema + { + public static class Tags + { + public static readonly TagName Timestamp = new TagName("tag:yaml.org,2002:timestamp"); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/Schemas/FailsafeSchema.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/Schemas/FailsafeSchema.cs.meta new file mode 100644 index 0000000..2f8b9da --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Schemas/FailsafeSchema.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ab7699eedce154b43bd3f1cd45bd792c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Serializer.cs b/namedropper/Assets/YamlDotNet/Serialization/Serializer.cs new file mode 100644 index 0000000..f0fbf9b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Serializer.cs @@ -0,0 +1,144 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.IO; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization +{ + public sealed class Serializer : ISerializer + { + private readonly IValueSerializer valueSerializer; + private readonly EmitterSettings emitterSettings; + + /// + /// Initializes a new instance of using the default configuration. + /// + /// + /// To customize the behavior of the serializer, use . + /// + public Serializer() + : this(new SerializerBuilder().BuildValueSerializer(), EmitterSettings.Default) + { + } + + /// + /// This constructor is private to discourage its use. + /// To invoke it, call the method. + /// + private Serializer(IValueSerializer valueSerializer, EmitterSettings emitterSettings) + { + this.valueSerializer = valueSerializer ?? throw new ArgumentNullException(nameof(valueSerializer)); + this.emitterSettings = emitterSettings ?? throw new ArgumentNullException(nameof(emitterSettings)); + } + + /// + /// Creates a new that uses the specified . + /// This method is available for advanced scenarios. The preferred way to customize the behavior of the + /// deserializer is to use . + /// + public static Serializer FromValueSerializer(IValueSerializer valueSerializer, EmitterSettings emitterSettings) + { + return new Serializer(valueSerializer, emitterSettings); + } + + /// + /// Serializes the specified object. + /// + /// The where to serialize the object. + /// The object to serialize. + public void Serialize(TextWriter writer, object graph) + { + Serialize(new Emitter(writer, emitterSettings), graph); + } + + /// + /// Serializes the specified object into a string. + /// + /// The object to serialize. + public string Serialize(object graph) + { + using var buffer = new StringWriter(); + Serialize(buffer, graph); + return buffer.ToString(); + } + + /// + /// Serializes the specified object. + /// + /// The where to serialize the object. + /// The object to serialize. + /// The static type of the object to serialize. + public void Serialize(TextWriter writer, object graph, Type type) + { + Serialize(new Emitter(writer, emitterSettings), graph, type); + } + + /// + /// Serializes the specified object. + /// + /// The where to serialize the object. + /// The object to serialize. + public void Serialize(IEmitter emitter, object graph) + { + if (emitter == null) + { + throw new ArgumentNullException(nameof(emitter)); + } + + EmitDocument(emitter, graph, null); + } + + /// + /// Serializes the specified object. + /// + /// The where to serialize the object. + /// The object to serialize. + /// The static type of the object to serialize. + public void Serialize(IEmitter emitter, object graph, Type type) + { + if (emitter == null) + { + throw new ArgumentNullException(nameof(emitter)); + } + + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + + EmitDocument(emitter, graph, type); + } + + private void EmitDocument(IEmitter emitter, object graph, Type? type) + { + emitter.Emit(new StreamStart()); + emitter.Emit(new DocumentStart()); + + valueSerializer.SerializeValue(emitter, graph, type); + + emitter.Emit(new DocumentEnd(true)); + emitter.Emit(new StreamEnd()); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/Serializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/Serializer.cs.meta new file mode 100644 index 0000000..109e4ee --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Serializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9c67f330b01d4f341af5108e0e1c3af7 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/SerializerBuilder.cs b/namedropper/Assets/YamlDotNet/Serialization/SerializerBuilder.cs new file mode 100644 index 0000000..4ebd882 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/SerializerBuilder.cs @@ -0,0 +1,593 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using YamlDotNet.Core; +using YamlDotNet.Serialization.Converters; +using YamlDotNet.Serialization.EventEmitters; +using YamlDotNet.Serialization.NamingConventions; +using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; +using YamlDotNet.Serialization.ObjectGraphVisitors; +using YamlDotNet.Serialization.TypeInspectors; +using YamlDotNet.Serialization.TypeResolvers; + +namespace YamlDotNet.Serialization +{ + + /// + /// Creates and configures instances of . + /// This class is used to customize the behavior of . Use the relevant methods + /// to apply customizations, then call to create an instance of the serializer + /// with the desired customizations. + /// + public sealed class SerializerBuilder : BuilderSkeleton + { + private ObjectGraphTraversalStrategyFactory objectGraphTraversalStrategyFactory; + private readonly LazyComponentRegistrationList, IObjectGraphVisitor> preProcessingPhaseObjectGraphVisitorFactories; + private readonly LazyComponentRegistrationList> emissionPhaseObjectGraphVisitorFactories; + private readonly LazyComponentRegistrationList eventEmitterFactories; + private readonly IDictionary tagMappings = new Dictionary(); + private int maximumRecursion = 50; + private EmitterSettings emitterSettings = EmitterSettings.Default; + private DefaultValuesHandling defaultValuesHandlingConfiguration = DefaultValuesHandling.Preserve; + + public SerializerBuilder() + : base(new DynamicTypeResolver()) + { + typeInspectorFactories.Add(typeof(CachedTypeInspector), inner => new CachedTypeInspector(inner)); + typeInspectorFactories.Add(typeof(NamingConventionTypeInspector), inner => namingConvention is NullNamingConvention ? inner : new NamingConventionTypeInspector(inner, namingConvention)); + typeInspectorFactories.Add(typeof(YamlAttributesTypeInspector), inner => new YamlAttributesTypeInspector(inner)); + typeInspectorFactories.Add(typeof(YamlAttributeOverridesInspector), inner => overrides != null ? new YamlAttributeOverridesInspector(inner, overrides.Clone()) : inner); + + preProcessingPhaseObjectGraphVisitorFactories = new LazyComponentRegistrationList, IObjectGraphVisitor> + { + { typeof(AnchorAssigner), typeConverters => new AnchorAssigner(typeConverters) } + }; + + emissionPhaseObjectGraphVisitorFactories = new LazyComponentRegistrationList> + { + { + typeof(CustomSerializationObjectGraphVisitor), + args => new CustomSerializationObjectGraphVisitor(args.InnerVisitor, args.TypeConverters, args.NestedObjectSerializer) + }, + { + typeof(AnchorAssigningObjectGraphVisitor), + args => new AnchorAssigningObjectGraphVisitor(args.InnerVisitor, args.EventEmitter, args.GetPreProcessingPhaseObjectGraphVisitor()) + }, + { + typeof(DefaultValuesObjectGraphVisitor), + args => new DefaultValuesObjectGraphVisitor(defaultValuesHandlingConfiguration, args.InnerVisitor) + }, + { + typeof(CommentsObjectGraphVisitor), + args => new CommentsObjectGraphVisitor(args.InnerVisitor) + } + }; + + eventEmitterFactories = new LazyComponentRegistrationList + { + { typeof(TypeAssigningEventEmitter), inner => new TypeAssigningEventEmitter(inner, false, tagMappings) } + }; + + objectGraphTraversalStrategyFactory = (typeInspector, typeResolver, typeConverters, maximumRecursion) => new FullObjectGraphTraversalStrategy(typeInspector, typeResolver, maximumRecursion, namingConvention); + } + + protected override SerializerBuilder Self { get { return this; } } + + /// + /// Sets the maximum recursion that is allowed while traversing the object graph. The default value is 50. + /// + public SerializerBuilder WithMaximumRecursion(int maximumRecursion) + { + if (maximumRecursion <= 0) + { + throw new ArgumentOutOfRangeException(nameof(maximumRecursion), $"The maximum recursion specified ({maximumRecursion}) is invalid. It should be a positive integer."); + } + + this.maximumRecursion = maximumRecursion; + return this; + } + + /// + /// Registers an additional to be used by the serializer. + /// + /// A function that instantiates the event emitter. + public SerializerBuilder WithEventEmitter(Func eventEmitterFactory) + where TEventEmitter : IEventEmitter + { + return WithEventEmitter(eventEmitterFactory, w => w.OnTop()); + } + + /// + /// Registers an additional to be used by the serializer. + /// + /// A function that instantiates the event emitter. + /// Configures the location where to insert the + public SerializerBuilder WithEventEmitter( + Func eventEmitterFactory, + Action> where + ) + where TEventEmitter : IEventEmitter + { + if (eventEmitterFactory == null) + { + throw new ArgumentNullException(nameof(eventEmitterFactory)); + } + + if (where == null) + { + throw new ArgumentNullException(nameof(where)); + } + + where(eventEmitterFactories.CreateRegistrationLocationSelector(typeof(TEventEmitter), inner => eventEmitterFactory(inner))); + return Self; + } + + /// + /// Registers an additional to be used by the serializer. + /// + /// A function that instantiates the event emitter based on a previously registered . + /// Configures the location where to insert the + public SerializerBuilder WithEventEmitter( + WrapperFactory eventEmitterFactory, + Action> where + ) + where TEventEmitter : IEventEmitter + { + if (eventEmitterFactory == null) + { + throw new ArgumentNullException(nameof(eventEmitterFactory)); + } + + if (where == null) + { + throw new ArgumentNullException(nameof(where)); + } + + where(eventEmitterFactories.CreateTrackingRegistrationLocationSelector(typeof(TEventEmitter), (wrapped, inner) => eventEmitterFactory(wrapped, inner))); + return Self; + } + + /// + /// Unregisters an existing of type . + /// + public SerializerBuilder WithoutEventEmitter() + where TEventEmitter : IEventEmitter + { + return WithoutEventEmitter(typeof(TEventEmitter)); + } + + /// + /// Unregisters an existing of type . + /// + public SerializerBuilder WithoutEventEmitter(Type eventEmitterType) + { + if (eventEmitterType == null) + { + throw new ArgumentNullException(nameof(eventEmitterType)); + } + + eventEmitterFactories.Remove(eventEmitterType); + return this; + } + + /// + /// Registers a tag mapping. + /// + public override SerializerBuilder WithTagMapping(TagName tag, Type type) + { + if (tag.IsEmpty) + { + throw new ArgumentException("Non-specific tags cannot be maped"); + } + + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + + if (tagMappings.TryGetValue(type, out var alreadyRegisteredTag)) + { + throw new ArgumentException($"Type already has a registered tag '{alreadyRegisteredTag}' for type '{type.FullName}'", nameof(type)); + } + + tagMappings.Add(type, tag); + return this; + } + + /// + /// Unregisters an existing tag mapping. + /// + public SerializerBuilder WithoutTagMapping(Type type) + { + if (type == null) + { + throw new ArgumentNullException(nameof(type)); + } + + if (!tagMappings.Remove(type)) + { + throw new KeyNotFoundException($"Tag for type '{type.FullName}' is not registered"); + } + return this; + } + + /// + /// Ensures that it will be possible to deserialize the serialized objects. + /// This option will force the emission of tags and emit only properties with setters. + /// + public SerializerBuilder EnsureRoundtrip() + { + objectGraphTraversalStrategyFactory = (typeInspector, typeResolver, typeConverters, maximumRecursion) => new RoundtripObjectGraphTraversalStrategy( + typeConverters, + typeInspector, + typeResolver, + maximumRecursion, + namingConvention + ); + WithEventEmitter(inner => new TypeAssigningEventEmitter(inner, true, tagMappings), loc => loc.InsteadOf()); + return WithTypeInspector(inner => new ReadableAndWritablePropertiesTypeInspector(inner), loc => loc.OnBottom()); + } + + /// + /// Specifies that, if the same object appears more than once in the + /// serialization graph, it will be serialized each time instead of just once. + /// + /// + /// If the serialization graph contains circular references and this flag is set, + /// a StackOverflowException will be thrown. + /// If this flag is not set, there is a performance penalty because the entire + /// object graph must be walked twice. + /// + public SerializerBuilder DisableAliases() + { + preProcessingPhaseObjectGraphVisitorFactories.Remove(typeof(AnchorAssigner)); + emissionPhaseObjectGraphVisitorFactories.Remove(typeof(AnchorAssigningObjectGraphVisitor)); + return this; + } + + /// + /// Forces every value to be serialized, even if it is the default value for that type. + /// + [Obsolete("The default behavior is now to always emit default values, thefore calling this method has no effect. This behavior is now controlled by ConfigureDefaultValuesHandling.", error: true)] + public SerializerBuilder EmitDefaults() => ConfigureDefaultValuesHandling(DefaultValuesHandling.Preserve); + + /// + /// Configures how properties with default and null values should be handled. The default value is DefaultValuesHandling.Preserve + /// + /// + /// If more control is needed, create a class that extends from ChainedObjectGraphVisitor and override its EnterMapping methods. + /// Then register it as follows: + /// WithEmissionPhaseObjectGraphVisitor(args => new MyDefaultHandlingStrategy(args.InnerVisitor)); + /// + public SerializerBuilder ConfigureDefaultValuesHandling(DefaultValuesHandling configuration) + { + this.defaultValuesHandlingConfiguration = configuration; + return this; + } + + /// + /// Ensures that the result of the serialization is valid JSON. + /// + public SerializerBuilder JsonCompatible() + { + this.emitterSettings = this.emitterSettings + .WithMaxSimpleKeyLength(int.MaxValue) + .WithoutAnchorName(); + + return this + .WithTypeConverter(new GuidConverter(true), w => w.InsteadOf()) + .WithEventEmitter(inner => new JsonEventEmitter(inner), loc => loc.InsteadOf()); + } + + /// + /// Registers an additional to be used by the serializer + /// before emitting an object graph. + /// + /// + /// Registering a visitor in the pre-processing phase enables to traverse the object graph once + /// before actually emitting it. This allows a visitor to collect information about the graph that + /// can be used later by another visitor registered in the emission phase. + /// + /// The type inspector. + public SerializerBuilder WithPreProcessingPhaseObjectGraphVisitor(TObjectGraphVisitor objectGraphVisitor) + where TObjectGraphVisitor : IObjectGraphVisitor + { + return WithPreProcessingPhaseObjectGraphVisitor(objectGraphVisitor, w => w.OnTop()); + } + + /// + /// Registers an additional to be used by the serializer + /// before emitting an object graph. + /// + /// + /// Registering a visitor in the pre-processing phase enables to traverse the object graph once + /// before actually emitting it. This allows a visitor to collect information about the graph that + /// can be used later by another visitor registered in the emission phase. + /// + /// The type inspector. + /// Configures the location where to insert the + public SerializerBuilder WithPreProcessingPhaseObjectGraphVisitor( + TObjectGraphVisitor objectGraphVisitor, + Action>> where + ) + where TObjectGraphVisitor : IObjectGraphVisitor + { + if (objectGraphVisitor == null) + { + throw new ArgumentNullException(nameof(objectGraphVisitor)); + } + + if (where == null) + { + throw new ArgumentNullException(nameof(where)); + } + + where(preProcessingPhaseObjectGraphVisitorFactories.CreateRegistrationLocationSelector(typeof(TObjectGraphVisitor), _ => objectGraphVisitor)); + return this; + } + + /// + /// Registers an additional to be used by the serializer + /// before emitting an object graph. + /// + /// + /// Registering a visitor in the pre-processing phase enables to traverse the object graph once + /// before actually emitting it. This allows a visitor to collect information about the graph that + /// can be used later by another visitor registered in the emission phase. + /// + /// A factory that creates the based on a previously registered . + /// Configures the location where to insert the + public SerializerBuilder WithPreProcessingPhaseObjectGraphVisitor( + WrapperFactory, TObjectGraphVisitor> objectGraphVisitorFactory, + Action>> where + ) + where TObjectGraphVisitor : IObjectGraphVisitor + { + if (objectGraphVisitorFactory == null) + { + throw new ArgumentNullException(nameof(objectGraphVisitorFactory)); + } + + if (where == null) + { + throw new ArgumentNullException(nameof(where)); + } + + where(preProcessingPhaseObjectGraphVisitorFactories.CreateTrackingRegistrationLocationSelector(typeof(TObjectGraphVisitor), (wrapped, _) => objectGraphVisitorFactory(wrapped))); + return this; + } + + /// + /// Unregisters an existing of type . + /// + public SerializerBuilder WithoutPreProcessingPhaseObjectGraphVisitor() + where TObjectGraphVisitor : IObjectGraphVisitor + { + return WithoutPreProcessingPhaseObjectGraphVisitor(typeof(TObjectGraphVisitor)); + } + + /// + /// Unregisters an existing of type . + /// + public SerializerBuilder WithoutPreProcessingPhaseObjectGraphVisitor(Type objectGraphVisitorType) + { + if (objectGraphVisitorType == null) + { + throw new ArgumentNullException(nameof(objectGraphVisitorType)); + } + + preProcessingPhaseObjectGraphVisitorFactories.Remove(objectGraphVisitorType); + return this; + } + + /// + /// Registers an to be used by the serializer + /// while traversing the object graph. + /// + /// A function that instantiates the traversal strategy. + public SerializerBuilder WithObjectGraphTraversalStrategyFactory(ObjectGraphTraversalStrategyFactory objectGraphTraversalStrategyFactory) + { + this.objectGraphTraversalStrategyFactory = objectGraphTraversalStrategyFactory; + + return this; + } + + /// + /// Registers an additional to be used by the serializer + /// while emitting an object graph. + /// + /// A function that instantiates the type inspector. + public SerializerBuilder WithEmissionPhaseObjectGraphVisitor(Func objectGraphVisitorFactory) + where TObjectGraphVisitor : IObjectGraphVisitor + { + return WithEmissionPhaseObjectGraphVisitor(objectGraphVisitorFactory, w => w.OnTop()); + } + + /// + /// Registers an additional to be used by the serializer + /// while emitting an object graph. + /// + /// A function that instantiates the type inspector. + /// Configures the location where to insert the + public SerializerBuilder WithEmissionPhaseObjectGraphVisitor( + Func objectGraphVisitorFactory, + Action>> where + ) + where TObjectGraphVisitor : IObjectGraphVisitor + { + if (objectGraphVisitorFactory == null) + { + throw new ArgumentNullException(nameof(objectGraphVisitorFactory)); + } + + if (where == null) + { + throw new ArgumentNullException(nameof(where)); + } + + where(emissionPhaseObjectGraphVisitorFactories.CreateRegistrationLocationSelector(typeof(TObjectGraphVisitor), args => objectGraphVisitorFactory(args))); + return this; + } + + /// + /// Registers an additional to be used by the serializer + /// while emitting an object graph. + /// + /// A function that instantiates the type inspector based on a previously registered . + /// Configures the location where to insert the + public SerializerBuilder WithEmissionPhaseObjectGraphVisitor( + WrapperFactory, TObjectGraphVisitor> objectGraphVisitorFactory, + Action>> where + ) + where TObjectGraphVisitor : IObjectGraphVisitor + { + if (objectGraphVisitorFactory == null) + { + throw new ArgumentNullException(nameof(objectGraphVisitorFactory)); + } + + if (where == null) + { + throw new ArgumentNullException(nameof(where)); + } + + where(emissionPhaseObjectGraphVisitorFactories.CreateTrackingRegistrationLocationSelector(typeof(TObjectGraphVisitor), (wrapped, args) => objectGraphVisitorFactory(wrapped, args))); + return this; + } + + /// + /// Unregisters an existing of type . + /// + public SerializerBuilder WithoutEmissionPhaseObjectGraphVisitor() + where TObjectGraphVisitor : IObjectGraphVisitor + { + return WithoutEmissionPhaseObjectGraphVisitor(typeof(TObjectGraphVisitor)); + } + + /// + /// Unregisters an existing of type . + /// + public SerializerBuilder WithoutEmissionPhaseObjectGraphVisitor(Type objectGraphVisitorType) + { + if (objectGraphVisitorType == null) + { + throw new ArgumentNullException(nameof(objectGraphVisitorType)); + } + + emissionPhaseObjectGraphVisitorFactories.Remove(objectGraphVisitorType); + return this; + } + + /// + /// Creates sequences with extra indentation + /// + /// + /// list: + /// - item + /// - item + /// + /// + public SerializerBuilder WithIndentedSequences() + { + emitterSettings = emitterSettings.WithIndentedSequences(); + + return this; + } + + /// + /// Creates a new according to the current configuration. + /// + public ISerializer Build() + { + return Serializer.FromValueSerializer(BuildValueSerializer(), emitterSettings); + } + + /// + /// Creates a new that implements the current configuration. + /// This method is available for advanced scenarios. The preferred way to customize the behavior of the + /// deserializer is to use the method. + /// + public IValueSerializer BuildValueSerializer() + { + var typeConverters = BuildTypeConverters(); + var typeInspector = BuildTypeInspector(); + var traversalStrategy = objectGraphTraversalStrategyFactory(typeInspector, typeResolver, typeConverters, maximumRecursion); + var eventEmitter = eventEmitterFactories.BuildComponentChain(new WriterEventEmitter()); + + return new ValueSerializer( + traversalStrategy, + eventEmitter, + typeConverters, + preProcessingPhaseObjectGraphVisitorFactories.Clone(), + emissionPhaseObjectGraphVisitorFactories.Clone() + ); + } + + private class ValueSerializer : IValueSerializer + { + private readonly IObjectGraphTraversalStrategy traversalStrategy; + private readonly IEventEmitter eventEmitter; + private readonly IEnumerable typeConverters; + private readonly LazyComponentRegistrationList, IObjectGraphVisitor> preProcessingPhaseObjectGraphVisitorFactories; + private readonly LazyComponentRegistrationList> emissionPhaseObjectGraphVisitorFactories; + + public ValueSerializer( + IObjectGraphTraversalStrategy traversalStrategy, + IEventEmitter eventEmitter, + IEnumerable typeConverters, + LazyComponentRegistrationList, IObjectGraphVisitor> preProcessingPhaseObjectGraphVisitorFactories, + LazyComponentRegistrationList> emissionPhaseObjectGraphVisitorFactories + ) + { + this.traversalStrategy = traversalStrategy; + this.eventEmitter = eventEmitter; + this.typeConverters = typeConverters; + this.preProcessingPhaseObjectGraphVisitorFactories = preProcessingPhaseObjectGraphVisitorFactories; + this.emissionPhaseObjectGraphVisitorFactories = emissionPhaseObjectGraphVisitorFactories; + } + + public void SerializeValue(IEmitter emitter, object? value, Type? type) + { + var actualType = type ?? (value != null ? value.GetType() : typeof(object)); + var staticType = type ?? typeof(object); + + var graph = new ObjectDescriptor(value, actualType, staticType); + + var preProcessingPhaseObjectGraphVisitors = preProcessingPhaseObjectGraphVisitorFactories.BuildComponentList(typeConverters); + foreach (var visitor in preProcessingPhaseObjectGraphVisitors) + { + traversalStrategy.Traverse(graph, visitor, default); + } + + void NestedObjectSerializer(object? v, Type? t) => SerializeValue(emitter, v, t); + + var emittingVisitor = emissionPhaseObjectGraphVisitorFactories.BuildComponentChain( + new EmittingObjectGraphVisitor(eventEmitter), + inner => new EmissionPhaseObjectGraphVisitorArgs(inner, eventEmitter, preProcessingPhaseObjectGraphVisitors, typeConverters, NestedObjectSerializer) + ); + + traversalStrategy.Traverse(graph, emittingVisitor, emitter); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/SerializerBuilder.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/SerializerBuilder.cs.meta new file mode 100644 index 0000000..f2719a9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/SerializerBuilder.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7035f24326f889045a1a3c718d4d4e5d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/StreamFragment.cs b/namedropper/Assets/YamlDotNet/Serialization/StreamFragment.cs new file mode 100644 index 0000000..12d9de3 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/StreamFragment.cs @@ -0,0 +1,85 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Serialization +{ + /// + /// An object that contains part of a YAML stream. + /// + public sealed class StreamFragment : IYamlConvertible + { + private readonly List events = new List(); + + /// + /// Gets or sets the events. + /// + /// The events. + public IList Events + { + get + { + return events; + } + } + + #region IYamlConvertible Members + /// + /// Reads this object's state from a YAML parser. + /// + void IYamlConvertible.Read(IParser parser, Type expectedType, ObjectDeserializer nestedObjectDeserializer) + { + events.Clear(); + + var depth = 0; + do + { + if (!parser.MoveNext()) + { + throw new InvalidOperationException("The parser has reached the end before deserialization completed."); + } + + var current = parser.Current!; + events.Add(current); + depth += current.NestingIncrease; + } while (depth > 0); + + Debug.Assert(depth == 0); + } + + /// + /// Writes this object's state to a YAML emitter. + /// + void IYamlConvertible.Write(IEmitter emitter, ObjectSerializer nestedObjectSerializer) + { + foreach (var item in events) + { + emitter.Emit(item); + } + } + #endregion + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/StreamFragment.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/StreamFragment.cs.meta new file mode 100644 index 0000000..1f8dea7 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/StreamFragment.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ccef6dc01b4e9ac45998c14da7d14c3e +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/TagMappings.cs b/namedropper/Assets/YamlDotNet/Serialization/TagMappings.cs new file mode 100644 index 0000000..1792ea8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TagMappings.cs @@ -0,0 +1,71 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; + +namespace YamlDotNet.Serialization +{ + /// + /// Contains mappings between tags and types. + /// + public sealed class TagMappings + { + private readonly IDictionary mappings; + + /// + /// Initializes a new instance of the class. + /// + public TagMappings() + { + mappings = new Dictionary(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The mappings. + public TagMappings(IDictionary mappings) + { + this.mappings = new Dictionary(mappings); + } + + /// + /// Adds the specified tag. + /// + /// The tag. + /// The mapping. + public void Add(string tag, Type mapping) + { + mappings.Add(tag, mapping); + } + + /// + /// Gets the mapping. + /// + /// The tag. + /// + internal Type? GetMapping(string tag) + { + return mappings.TryGetValue(tag, out var mapping) ? mapping : null; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/TagMappings.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/TagMappings.cs.meta new file mode 100644 index 0000000..e336b87 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TagMappings.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2cc976dab2b9f8a43b435abbe2687e5a +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors.meta b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors.meta new file mode 100644 index 0000000..3f8cf8f --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 05e3dfde0726c3f45ae1c40309796c14 +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CachedTypeInspector.cs b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CachedTypeInspector.cs new file mode 100644 index 0000000..727b8f1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CachedTypeInspector.cs @@ -0,0 +1,47 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; + +namespace YamlDotNet.Serialization.TypeInspectors +{ + /// + /// Wraps another and applies caching. + /// + public sealed class CachedTypeInspector : TypeInspectorSkeleton + { + private readonly ITypeInspector innerTypeDescriptor; + private readonly ConcurrentDictionary> cache = new ConcurrentDictionary>(); + + public CachedTypeInspector(ITypeInspector innerTypeDescriptor) + { + this.innerTypeDescriptor = innerTypeDescriptor ?? throw new ArgumentNullException(nameof(innerTypeDescriptor)); + } + + public override IEnumerable GetProperties(Type type, object? container) + { + return cache.GetOrAdd(type, t => innerTypeDescriptor.GetProperties(t, container).ToList()); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CachedTypeInspector.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CachedTypeInspector.cs.meta new file mode 100644 index 0000000..04d4a6b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CachedTypeInspector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2cb8fafb49bb5a64db56833a18c49366 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CompositeTypeInspector.cs b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CompositeTypeInspector.cs new file mode 100644 index 0000000..825cc99 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CompositeTypeInspector.cs @@ -0,0 +1,51 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace YamlDotNet.Serialization.TypeInspectors +{ + /// + /// Aggregates the results from multiple into a single one. + /// + public sealed class CompositeTypeInspector : TypeInspectorSkeleton + { + private readonly IEnumerable typeInspectors; + + public CompositeTypeInspector(params ITypeInspector[] typeInspectors) + : this((IEnumerable)typeInspectors) + { + } + + public CompositeTypeInspector(IEnumerable typeInspectors) + { + this.typeInspectors = typeInspectors?.ToList() ?? throw new ArgumentNullException(nameof(typeInspectors)); + } + + public override IEnumerable GetProperties(Type type, object? container) + { + return typeInspectors + .SelectMany(i => i.GetProperties(type, container)); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CompositeTypeInspector.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CompositeTypeInspector.cs.meta new file mode 100644 index 0000000..6486bbd --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/CompositeTypeInspector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4c6eba3a55ca9204194aacb2502066c8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/NamingConventionTypeInspector.cs b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/NamingConventionTypeInspector.cs new file mode 100644 index 0000000..709b703 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/NamingConventionTypeInspector.cs @@ -0,0 +1,57 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace YamlDotNet.Serialization.TypeInspectors +{ + /// + /// Wraps another and applies a + /// naming convention to the names of the properties. + /// + public sealed class NamingConventionTypeInspector : TypeInspectorSkeleton + { + private readonly ITypeInspector innerTypeDescriptor; + private readonly INamingConvention namingConvention; + + public NamingConventionTypeInspector(ITypeInspector innerTypeDescriptor, INamingConvention namingConvention) + { + this.innerTypeDescriptor = innerTypeDescriptor ?? throw new ArgumentNullException(nameof(innerTypeDescriptor)); + this.namingConvention = namingConvention ?? throw new ArgumentNullException(nameof(namingConvention)); + } + + public override IEnumerable GetProperties(Type type, object? container) + { + return innerTypeDescriptor.GetProperties(type, container) + .Select(p => + { + var attribute = p.GetCustomAttribute(); + if (attribute != null && !attribute.ApplyNamingConventions) + { + return p; + } + return new PropertyDescriptor(p) { Name = namingConvention.Apply(p.Name) }; + }); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/NamingConventionTypeInspector.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/NamingConventionTypeInspector.cs.meta new file mode 100644 index 0000000..82d04c9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/NamingConventionTypeInspector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3598909e9935cc3428cc982eb6802c40 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableAndWritablePropertiesTypeInspector.cs b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableAndWritablePropertiesTypeInspector.cs new file mode 100644 index 0000000..22921e1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableAndWritablePropertiesTypeInspector.cs @@ -0,0 +1,46 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace YamlDotNet.Serialization.TypeInspectors +{ + /// + /// Returns the properties of a type that are both readable and writable. + /// + public sealed class ReadableAndWritablePropertiesTypeInspector : TypeInspectorSkeleton + { + private readonly ITypeInspector innerTypeDescriptor; + + public ReadableAndWritablePropertiesTypeInspector(ITypeInspector innerTypeDescriptor) + { + this.innerTypeDescriptor = innerTypeDescriptor ?? throw new ArgumentNullException(nameof(innerTypeDescriptor)); + } + + public override IEnumerable GetProperties(Type type, object? container) + { + return innerTypeDescriptor.GetProperties(type, container) + .Where(p => p.CanWrite); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableAndWritablePropertiesTypeInspector.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableAndWritablePropertiesTypeInspector.cs.meta new file mode 100644 index 0000000..b2342a0 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableAndWritablePropertiesTypeInspector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b92a938ba5e921c4e92072dc91a2ab2b +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableFieldsTypeInspector.cs b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableFieldsTypeInspector.cs new file mode 100644 index 0000000..9e61868 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableFieldsTypeInspector.cs @@ -0,0 +1,87 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.TypeInspectors +{ + /// + /// Returns the properties and fields of a type that are readable. + /// + public sealed class ReadableFieldsTypeInspector : TypeInspectorSkeleton + { + private readonly ITypeResolver typeResolver; + + public ReadableFieldsTypeInspector(ITypeResolver typeResolver) + { + this.typeResolver = typeResolver ?? throw new ArgumentNullException(nameof(typeResolver)); + } + + public override IEnumerable GetProperties(Type type, object? container) + { + return type + .GetPublicFields() + .Select(p => (IPropertyDescriptor)new ReflectionFieldDescriptor(p, typeResolver)); + } + + private sealed class ReflectionFieldDescriptor : IPropertyDescriptor + { + private readonly FieldInfo fieldInfo; + private readonly ITypeResolver typeResolver; + + public ReflectionFieldDescriptor(FieldInfo fieldInfo, ITypeResolver typeResolver) + { + this.fieldInfo = fieldInfo; + this.typeResolver = typeResolver; + ScalarStyle = ScalarStyle.Any; + } + + public string Name { get { return fieldInfo.Name; } } + public Type Type { get { return fieldInfo.FieldType; } } + public Type? TypeOverride { get; set; } + public int Order { get; set; } + public bool CanWrite { get { return !fieldInfo.IsInitOnly; } } + public ScalarStyle ScalarStyle { get; set; } + + public void Write(object target, object? value) + { + fieldInfo.SetValue(target, value); + } + + public T GetCustomAttribute() where T : Attribute + { + var attributes = fieldInfo.GetCustomAttributes(typeof(T), true); + return (T)attributes.FirstOrDefault(); + } + + public IObjectDescriptor Read(object target) + { + var propertyValue = fieldInfo.GetValue(target); + var actualType = TypeOverride ?? typeResolver.Resolve(Type, propertyValue); + return new ObjectDescriptor(propertyValue, actualType, Type, ScalarStyle); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableFieldsTypeInspector.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableFieldsTypeInspector.cs.meta new file mode 100644 index 0000000..bf88ef8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadableFieldsTypeInspector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: af9fd670748b3b141b7ec3d05aec7cf4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadablePropertiesTypeInspector.cs b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadablePropertiesTypeInspector.cs new file mode 100644 index 0000000..25484c9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadablePropertiesTypeInspector.cs @@ -0,0 +1,101 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.TypeInspectors +{ + /// + /// Returns the properties of a type that are readable. + /// + public sealed class ReadablePropertiesTypeInspector : TypeInspectorSkeleton + { + private readonly ITypeResolver typeResolver; + private readonly bool includeNonPublicProperties; + + public ReadablePropertiesTypeInspector(ITypeResolver typeResolver) + : this(typeResolver, false) + { + } + + public ReadablePropertiesTypeInspector(ITypeResolver typeResolver, bool includeNonPublicProperties) + { + this.typeResolver = typeResolver ?? throw new ArgumentNullException(nameof(typeResolver)); + this.includeNonPublicProperties = includeNonPublicProperties; + } + + private static bool IsValidProperty(PropertyInfo property) + { + return property.CanRead + && property.GetGetMethod(true)!.GetParameters().Length == 0; + } + + public override IEnumerable GetProperties(Type type, object? container) + { + return type + .GetProperties(includeNonPublicProperties) + .Where(IsValidProperty) + .Select(p => (IPropertyDescriptor)new ReflectionPropertyDescriptor(p, typeResolver)); + } + + private sealed class ReflectionPropertyDescriptor : IPropertyDescriptor + { + private readonly PropertyInfo propertyInfo; + private readonly ITypeResolver typeResolver; + + public ReflectionPropertyDescriptor(PropertyInfo propertyInfo, ITypeResolver typeResolver) + { + this.propertyInfo = propertyInfo ?? throw new ArgumentNullException(nameof(propertyInfo)); + this.typeResolver = typeResolver ?? throw new ArgumentNullException(nameof(typeResolver)); + ScalarStyle = ScalarStyle.Any; + } + + public string Name => propertyInfo.Name; + public Type Type => propertyInfo.PropertyType; + public Type? TypeOverride { get; set; } + public int Order { get; set; } + public bool CanWrite => propertyInfo.CanWrite; + public ScalarStyle ScalarStyle { get; set; } + + public void Write(object target, object? value) + { + propertyInfo.SetValue(target, value, null); + } + + public T GetCustomAttribute() where T : Attribute + { + var attributes = propertyInfo.GetAllCustomAttributes(); + return (T)attributes.FirstOrDefault(); + } + + public IObjectDescriptor Read(object target) + { + var propertyValue = propertyInfo.ReadValue(target); + var actualType = TypeOverride ?? typeResolver.Resolve(Type, propertyValue); + return new ObjectDescriptor(propertyValue, actualType, Type, ScalarStyle); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadablePropertiesTypeInspector.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadablePropertiesTypeInspector.cs.meta new file mode 100644 index 0000000..973695a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/ReadablePropertiesTypeInspector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c9669f90a0f2f2a41b805a174d9be97e +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/TypeInspectorSkeleton.cs b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/TypeInspectorSkeleton.cs new file mode 100644 index 0000000..ea9e00b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/TypeInspectorSkeleton.cs @@ -0,0 +1,62 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Runtime.Serialization; + +namespace YamlDotNet.Serialization.TypeInspectors +{ + public abstract class TypeInspectorSkeleton : ITypeInspector + { + public abstract IEnumerable GetProperties(Type type, object? container); + + public IPropertyDescriptor GetProperty(Type type, object? container, string name, [MaybeNullWhen(true)] bool ignoreUnmatched) + { + var candidates = GetProperties(type, container) + .Where(p => p.Name == name); + + using var enumerator = candidates.GetEnumerator(); + if (!enumerator.MoveNext()) + { + if (ignoreUnmatched) + { + return null!; + } + + throw new SerializationException($"Property '{name}' not found on type '{type.FullName}'."); + } + + var property = enumerator.Current; + + if (enumerator.MoveNext()) + { + throw new SerializationException( + $"Multiple properties with the name/alias '{name}' already exists on type '{type.FullName}', maybe you're misusing YamlAlias or maybe you are using the wrong naming convention? The matching properties are: {string.Join(", ", candidates.Select(p => p.Name).ToArray())}" + ); + } + + return property; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/TypeInspectorSkeleton.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/TypeInspectorSkeleton.cs.meta new file mode 100644 index 0000000..6c8b981 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeInspectors/TypeInspectorSkeleton.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ed437999b4d95dd4094909044396a0b2 +timeCreated: 1427145267 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers.meta b/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers.meta new file mode 100644 index 0000000..a8ce58b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 38df578a5c1d3024aa1e1052eaacbd43 +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/DynamicTypeResolver.cs b/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/DynamicTypeResolver.cs new file mode 100644 index 0000000..dcf636a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/DynamicTypeResolver.cs @@ -0,0 +1,36 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Serialization.TypeResolvers +{ + /// + /// The type returned will be the actual type of the value, if available. + /// + public sealed class DynamicTypeResolver : ITypeResolver + { + public Type Resolve(Type staticType, object? actualValue) + { + return actualValue != null ? actualValue.GetType() : staticType; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/DynamicTypeResolver.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/DynamicTypeResolver.cs.meta new file mode 100644 index 0000000..78055ef --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/DynamicTypeResolver.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 28ddf494ebac7fe4fb7704de7713a111 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/StaticTypeResolver.cs b/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/StaticTypeResolver.cs new file mode 100644 index 0000000..7bd96bc --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/StaticTypeResolver.cs @@ -0,0 +1,36 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Serialization.TypeResolvers +{ + /// + /// The type returned will always be the static type. + /// + public sealed class StaticTypeResolver : ITypeResolver + { + public Type Resolve(Type staticType, object? actualValue) + { + return staticType; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/StaticTypeResolver.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/StaticTypeResolver.cs.meta new file mode 100644 index 0000000..8810141 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/TypeResolvers/StaticTypeResolver.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 684d1820910272c41957060731567d5c +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Utilities.meta b/namedropper/Assets/YamlDotNet/Serialization/Utilities.meta new file mode 100644 index 0000000..d113c88 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Utilities.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c788194c59eb2364fad0a9b407737368 +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Utilities/IPostDeserializationCallback.cs b/namedropper/Assets/YamlDotNet/Serialization/Utilities/IPostDeserializationCallback.cs new file mode 100644 index 0000000..5f8c483 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Utilities/IPostDeserializationCallback.cs @@ -0,0 +1,32 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +namespace YamlDotNet.Serialization.Utilities +{ + /// + /// Indicates that a class used as deserialization state + /// needs to be notified after deserialization. + /// + public interface IPostDeserializationCallback + { + void OnDeserialization(); + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/Utilities/IPostDeserializationCallback.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/Utilities/IPostDeserializationCallback.cs.meta new file mode 100644 index 0000000..f80dd6f --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Utilities/IPostDeserializationCallback.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0a1b0915df335f34aa94272237836de2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Utilities/ObjectAnchorCollection.cs b/namedropper/Assets/YamlDotNet/Serialization/Utilities/ObjectAnchorCollection.cs new file mode 100644 index 0000000..1762bc5 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Utilities/ObjectAnchorCollection.cs @@ -0,0 +1,75 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization.Utilities +{ + internal sealed class ObjectAnchorCollection + { + private readonly IDictionary objectsByAnchor = new Dictionary(); + private readonly IDictionary anchorsByObject = new Dictionary(); + + /// + /// Adds the specified anchor. + /// + /// The anchor. + /// The @object. + public void Add(string anchor, object @object) + { + objectsByAnchor.Add(anchor, @object); + if (@object != null) + { + anchorsByObject.Add(@object, anchor); + } + } + + /// + /// Gets the anchor for the specified object. + /// + /// The object. + /// The anchor. + /// + public bool TryGetAnchor(object @object, [MaybeNullWhen(false)] out string? anchor) + { + return anchorsByObject.TryGetValue(@object, out anchor); + } + + /// + /// Gets the with the specified anchor. + /// + /// + public object this[string anchor] + { + get + { + if (objectsByAnchor.TryGetValue(anchor, out var value)) + { + return value; + } + + throw new AnchorNotFoundException($"The anchor '{anchor}' does not exists"); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/Utilities/ObjectAnchorCollection.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/Utilities/ObjectAnchorCollection.cs.meta new file mode 100644 index 0000000..4913861 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Utilities/ObjectAnchorCollection.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2e3d78e3d62429040a9c8ab6066499ae +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Utilities/ReflectionUtility.cs b/namedropper/Assets/YamlDotNet/Serialization/Utilities/ReflectionUtility.cs new file mode 100644 index 0000000..d993e0b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Utilities/ReflectionUtility.cs @@ -0,0 +1,54 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; + +namespace YamlDotNet.Serialization.Utilities +{ + internal static class ReflectionUtility + { + public static Type? GetImplementedGenericInterface(Type type, Type genericInterfaceType) + { + foreach (var interfacetype in GetImplementedInterfaces(type)) + { + if (interfacetype.IsGenericType() && interfacetype.GetGenericTypeDefinition() == genericInterfaceType) + { + return interfacetype; + } + } + return null; + } + + public static IEnumerable GetImplementedInterfaces(Type type) + { + if (type.IsInterface()) + { + yield return type; + } + + foreach (var implementedInterface in type.GetInterfaces()) + { + yield return implementedInterface; + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/Utilities/ReflectionUtility.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/Utilities/ReflectionUtility.cs.meta new file mode 100644 index 0000000..ec18724 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Utilities/ReflectionUtility.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a47e4ee72331a6b4aaf1b7abd7b76d6d +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Utilities/SerializerState.cs b/namedropper/Assets/YamlDotNet/Serialization/Utilities/SerializerState.cs new file mode 100644 index 0000000..085af20 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Utilities/SerializerState.cs @@ -0,0 +1,67 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace YamlDotNet.Serialization.Utilities +{ + /// + /// A generic container that is preserved during the entire deserialization process. + /// Any disposable object added to this collection will be disposed when this object is disposed. + /// + public sealed class SerializerState : IDisposable + { + private readonly IDictionary items = new Dictionary(); + + public T Get() + where T : class, new() + { + if (!items.TryGetValue(typeof(T), out var value)) + { + value = new T(); + items.Add(typeof(T), value); + } + return (T)value; + } + + /// + /// Invokes on all + /// objects added to this collection that implement . + /// + public void OnDeserialization() + { + foreach (var callback in items.Values.OfType()) + { + callback.OnDeserialization(); + } + } + + public void Dispose() + { + foreach (var disposable in items.Values.OfType()) + { + disposable.Dispose(); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/Utilities/SerializerState.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/Utilities/SerializerState.cs.meta new file mode 100644 index 0000000..1e8c202 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Utilities/SerializerState.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c783e372f00ca8e42a66fe82bbbe3fd2 +timeCreated: 1427145266 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Utilities/StringExtensions.cs b/namedropper/Assets/YamlDotNet/Serialization/Utilities/StringExtensions.cs new file mode 100644 index 0000000..7e57f1d --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Utilities/StringExtensions.cs @@ -0,0 +1,79 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Text.RegularExpressions; + +namespace YamlDotNet.Serialization.Utilities +{ + /// + /// Various string extension methods + /// + internal static class StringExtensions + { + private static string ToCamelOrPascalCase(string str, Func firstLetterTransform) + { + var text = Regex.Replace(str, "([_\\-])(?[a-z])", match => match.Groups["char"].Value.ToUpperInvariant(), RegexOptions.IgnoreCase); + return firstLetterTransform(text[0]) + text.Substring(1); + } + + + /// + /// Convert the string with underscores (this_is_a_test) or hyphens (this-is-a-test) to + /// camel case (thisIsATest). Camel case is the same as Pascal case, except the first letter + /// is lowercase. + /// + /// String to convert + /// Converted string + public static string ToCamelCase(this string str) + { + return ToCamelOrPascalCase(str, char.ToLowerInvariant); + } + + /// + /// Convert the string with underscores (this_is_a_test) or hyphens (this-is-a-test) to + /// pascal case (ThisIsATest). Pascal case is the same as camel case, except the first letter + /// is uppercase. + /// + /// String to convert + /// Converted string + public static string ToPascalCase(this string str) + { + return ToCamelOrPascalCase(str, char.ToUpperInvariant); + } + + /// + /// Convert the string from camelcase (thisIsATest) to a hyphenated (this-is-a-test) or + /// underscored (this_is_a_test) string + /// + /// String to convert + /// Separator to use between segments + /// Converted string + public static string FromCamelCase(this string str, string separator) + { + // Ensure first letter is always lowercase + str = char.ToLower(str[0]) + str.Substring(1); + + str = Regex.Replace(str.ToCamelCase(), "(?[A-Z])", match => separator + match.Groups["char"].Value.ToLowerInvariant()); + return str; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/Utilities/StringExtensions.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/Utilities/StringExtensions.cs.meta new file mode 100644 index 0000000..db9990c --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Utilities/StringExtensions.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b5dcdcf416fdbed4faabbba800ede39a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/Utilities/TypeConverter.cs b/namedropper/Assets/YamlDotNet/Serialization/Utilities/TypeConverter.cs new file mode 100644 index 0000000..ab16946 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Utilities/TypeConverter.cs @@ -0,0 +1,236 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// Remarks: This file is imported from the SixPack library. This is ok because +// the copyright holder has agreed to redistribute this file under the license +// used in YamlDotNet. + +using System; +using System.Globalization; +using System.Reflection; +using System.ComponentModel; + +namespace YamlDotNet.Serialization.Utilities +{ + /// + /// Performs type conversions using every standard provided by the .NET library. + /// + public static partial class TypeConverter + { + /// + /// Converts the specified value. + /// + /// The type to which the value is to be converted. + /// The value to convert. + /// + public static T ChangeType(object? value) + { + return (T)ChangeType(value, typeof(T))!; // This cast should always be valid + } + + /// + /// Converts the specified value. + /// + /// The type to which the value is to be converted. + /// The value to convert. + /// The provider. + /// + public static T ChangeType(object? value, IFormatProvider provider) + { + return (T)ChangeType(value, typeof(T), provider)!; // This cast should always be valid + } + + /// + /// Converts the specified value. + /// + /// The type to which the value is to be converted. + /// The value to convert. + /// The culture. + /// + public static T ChangeType(object? value, CultureInfo culture) + { + return (T)ChangeType(value, typeof(T), culture)!; // This cast should always be valid + } + + /// + /// Converts the specified value using the invariant culture. + /// + /// The value to convert. + /// The type to which the value is to be converted. + /// + public static object? ChangeType(object? value, Type destinationType) + { + return ChangeType(value, destinationType, CultureInfo.InvariantCulture); + } + + /// + /// Converts the specified value. + /// + /// The value to convert. + /// The type to which the value is to be converted. + /// The format provider. + /// + public static object? ChangeType(object? value, Type destinationType, IFormatProvider provider) + { + return ChangeType(value, destinationType, new CultureInfoAdapter(CultureInfo.CurrentCulture, provider)); + } + + /// + /// Converts the specified value. + /// + /// The value to convert. + /// The type to which the value is to be converted. + /// The culture. + /// + public static object? ChangeType(object? value, Type destinationType, CultureInfo culture) + { + // Handle null and DBNull + if (value == null || value.IsDbNull()) + { + return destinationType.IsValueType() ? Activator.CreateInstance(destinationType) : null; + } + + var sourceType = value.GetType(); + + // If the source type is compatible with the destination type, no conversion is needed + if (destinationType == sourceType || destinationType.IsAssignableFrom(sourceType)) + { + return value; + } + + // Nullable types get a special treatment + if (destinationType.IsGenericType()) + { + var genericTypeDefinition = destinationType.GetGenericTypeDefinition(); + if (genericTypeDefinition == typeof(Nullable<>)) + { + var innerType = destinationType.GetGenericArguments()[0]; + var convertedValue = ChangeType(value, innerType, culture); + return Activator.CreateInstance(destinationType, convertedValue); + } + } + + // Enums also require special handling + if (destinationType.IsEnum()) + { + return value is string valueText + ? Enum.Parse(destinationType, valueText, true) + : value; + } + + // Special case for booleans to support parsing "1" and "0". This is + // necessary for compatibility with XML Schema. + if (destinationType == typeof(bool)) + { + if ("0".Equals(value)) + { + return false; + } + + if ("1".Equals(value)) + { + return true; + } + } + + // Try with the source type's converter + var sourceConverter = TypeDescriptor.GetConverter(sourceType); + if (sourceConverter != null && sourceConverter.CanConvertTo(destinationType)) + { + return sourceConverter.ConvertTo(null, culture, value, destinationType); + } + + // Try with the destination type's converter + var destinationConverter = TypeDescriptor.GetConverter(destinationType); + if (destinationConverter != null && destinationConverter.CanConvertFrom(sourceType)) + { + return destinationConverter.ConvertFrom(null, culture, value); + } + + // Try to find a casting operator in the source or destination type + foreach (var type in new[] { sourceType, destinationType }) + { + foreach (var method in type.GetPublicStaticMethods()) + { + var isCastingOperator = + method.IsSpecialName && + (method.Name == "op_Implicit" || method.Name == "op_Explicit") && + destinationType.IsAssignableFrom(method.ReturnParameter.ParameterType); + + if (isCastingOperator) + { + var parameters = method.GetParameters(); + + var isCompatible = + parameters.Length == 1 && + parameters[0].ParameterType.IsAssignableFrom(sourceType); + + if (isCompatible) + { + try + { + return method.Invoke(null, new[] { value }); + } + catch (TargetInvocationException ex) + { + throw ex.Unwrap(); + } + } + } + } + } + + // If source type is string, try to find a Parse or TryParse method + if (sourceType == typeof(string)) + { + try + { + // Try with - public static T Parse(string, IFormatProvider) + var parseMethod = destinationType.GetPublicStaticMethod("Parse", typeof(string), typeof(IFormatProvider)); + if (parseMethod != null) + { + return parseMethod.Invoke(null, new object[] { value, culture }); + } + + // Try with - public static T Parse(string) + parseMethod = destinationType.GetPublicStaticMethod("Parse", typeof(string)); + if (parseMethod != null) + { + return parseMethod.Invoke(null, new object[] { value }); + } + } + catch (TargetInvocationException ex) + { + throw ex.Unwrap(); + } + } + + // Handle TimeSpan + if (destinationType == typeof(TimeSpan)) + { + return TimeSpan.Parse((string)ChangeType(value, typeof(string), CultureInfo.InvariantCulture)!); + } + + // Default to the Convert class + return Convert.ChangeType(value, destinationType, CultureInfo.InvariantCulture); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/Utilities/TypeConverter.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/Utilities/TypeConverter.cs.meta new file mode 100644 index 0000000..45885fb --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/Utilities/TypeConverter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6450212473c552045b5fcfa8b6b759a3 +timeCreated: 1427145264 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers.meta b/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers.meta new file mode 100644 index 0000000..5761972 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d42ae4e770457104786ea4387344db74 +folderAsset: yes +timeCreated: 1427145262 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/AliasValueDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/AliasValueDeserializer.cs new file mode 100644 index 0000000..8c82f3a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/AliasValueDeserializer.cs @@ -0,0 +1,147 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization.ValueDeserializers +{ + public sealed class AliasValueDeserializer : IValueDeserializer + { + private readonly IValueDeserializer innerDeserializer; + + public AliasValueDeserializer(IValueDeserializer innerDeserializer) + { + this.innerDeserializer = innerDeserializer ?? throw new ArgumentNullException(nameof(innerDeserializer)); + } + + private sealed class AliasState : Dictionary, IPostDeserializationCallback + { + public void OnDeserialization() + { + foreach (var promise in Values) + { + if (!promise.HasValue) + { + var alias = promise.Alias!; // When the value is not known, the alias is always known + throw new AnchorNotFoundException(alias.Start, alias.End, $"Anchor '{alias.Value}' not found"); + } + } + } + } + + private sealed class ValuePromise : IValuePromise + { + public event Action? ValueAvailable; + + public bool HasValue { get; private set; } + + private object? value; + + public readonly AnchorAlias? Alias; + + public ValuePromise(AnchorAlias alias) + { + this.Alias = alias; + } + + public ValuePromise(object? value) + { + HasValue = true; + this.value = value; + } + + public object? Value + { + get + { + if (!HasValue) + { + throw new InvalidOperationException("Value not set"); + } + return value; + } + set + { + if (HasValue) + { + throw new InvalidOperationException("Value already set"); + } + HasValue = true; + this.value = value; + + ValueAvailable?.Invoke(value); + } + } + } + + public object? DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer) + { + object? value; + if (parser.TryConsume(out var alias)) + { + var aliasState = state.Get(); + if (!aliasState.TryGetValue(alias.Value, out var valuePromise)) + { + throw new AnchorNotFoundException(alias.Start, alias.End, $"Alias ${alias.Value} cannot precede anchor declaration"); + } + + return valuePromise.HasValue ? valuePromise.Value : valuePromise; + } + + var anchor = AnchorName.Empty; + if (parser.Accept(out var nodeEvent) && !nodeEvent.Anchor.IsEmpty) + { + anchor = nodeEvent.Anchor; + var aliasState = state.Get(); + if (!aliasState.ContainsKey(anchor)) + { + aliasState[anchor] = new ValuePromise(new AnchorAlias(anchor)); + } + } + + value = innerDeserializer.DeserializeValue(parser, expectedType, state, nestedObjectDeserializer); + + if (!anchor.IsEmpty) + { + var aliasState = state.Get(); + + if (!aliasState.TryGetValue(anchor, out var valuePromise)) + { + aliasState.Add(anchor, new ValuePromise(value)); + } + else if (!valuePromise.HasValue) + { + valuePromise.Value = value; + } + else + { + aliasState[anchor] = new ValuePromise(value); + } + } + + return value; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/AliasValueDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/AliasValueDeserializer.cs.meta new file mode 100644 index 0000000..384575b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/AliasValueDeserializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2b42e3b48f16da04d81b23e165d66fc3 +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/NodeValueDeserializer.cs b/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/NodeValueDeserializer.cs new file mode 100644 index 0000000..da17e2d --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/NodeValueDeserializer.cs @@ -0,0 +1,89 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using YamlDotNet.Core; +using YamlDotNet.Core.Events; +using YamlDotNet.Serialization.Utilities; + +namespace YamlDotNet.Serialization.ValueDeserializers +{ + public sealed class NodeValueDeserializer : IValueDeserializer + { + private readonly IList deserializers; + private readonly IList typeResolvers; + + public NodeValueDeserializer(IList deserializers, IList typeResolvers) + { + this.deserializers = deserializers ?? throw new ArgumentNullException(nameof(deserializers)); + this.typeResolvers = typeResolvers ?? throw new ArgumentNullException(nameof(typeResolvers)); + } + + public object? DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer) + { + parser.Accept(out var nodeEvent); + var nodeType = GetTypeFromEvent(nodeEvent, expectedType); + + try + { + foreach (var deserializer in deserializers) + { + if (deserializer.Deserialize(parser, nodeType, (r, t) => nestedObjectDeserializer.DeserializeValue(r, t, state, nestedObjectDeserializer), out var value)) + { + return TypeConverter.ChangeType(value, expectedType); + } + } + } + catch (YamlException) + { + throw; + } + catch (Exception ex) + { + throw new YamlException( + nodeEvent?.Start ?? Mark.Empty, + nodeEvent?.End ?? Mark.Empty, + "Exception during deserialization", + ex + ); + } + + throw new YamlException( + nodeEvent?.Start ?? Mark.Empty, + nodeEvent?.End ?? Mark.Empty, + $"No node deserializer was able to deserialize the node into type {expectedType.AssemblyQualifiedName}" + ); + } + + private Type GetTypeFromEvent(NodeEvent? nodeEvent, Type currentType) + { + foreach (var typeResolver in typeResolvers) + { + if (typeResolver.Resolve(nodeEvent, ref currentType)) + { + break; + } + } + return currentType; + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/NodeValueDeserializer.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/NodeValueDeserializer.cs.meta new file mode 100644 index 0000000..faeecb8 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/ValueDeserializers/NodeValueDeserializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3782a2b6c58f1ae459162e3ce74fc25f +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverrides.cs b/namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverrides.cs new file mode 100644 index 0000000..de2b206 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverrides.cs @@ -0,0 +1,198 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using HashCode = YamlDotNet.Core.HashCode; + +namespace YamlDotNet.Serialization +{ + /// + /// Define a collection of YamlAttribute Overrides for pre-defined object types. + /// + public sealed partial class YamlAttributeOverrides + { + private struct AttributeKey + { + public readonly Type AttributeType; + public readonly string PropertyName; + + public AttributeKey(Type attributeType, string propertyName) + { + AttributeType = attributeType; + PropertyName = propertyName; + } + + public override bool Equals(object? obj) + { + return obj is AttributeKey other + && AttributeType.Equals(other.AttributeType) + && PropertyName.Equals(other.PropertyName); + } + + public override int GetHashCode() + { + return HashCode.CombineHashCodes(AttributeType.GetHashCode(), PropertyName.GetHashCode()); + } + } + + private sealed class AttributeMapping + { + public readonly Type RegisteredType; + public readonly Attribute Attribute; + + public AttributeMapping(Type registeredType, Attribute attribute) + { + this.RegisteredType = registeredType; + Attribute = attribute; + } + + public override bool Equals(object? obj) + { + return obj is AttributeMapping other + && RegisteredType.Equals(other.RegisteredType) + && Attribute.Equals(other.Attribute); + } + + public override int GetHashCode() + { + return HashCode.CombineHashCodes(RegisteredType.GetHashCode(), Attribute.GetHashCode()); + } + + /// + /// Checks whether this mapping matches the specified type, and returns a value indicating the match priority. + /// + /// The priority of the match. Higher values have more priority. Zero indicates no match. + public int Matches(Type matchType) + { + var currentPriority = 0; + Type? currentType = matchType; + do + { + ++currentPriority; + if (currentType == RegisteredType) + { + return currentPriority; + } + currentType = currentType.BaseType(); + } while (currentType != null); + + if (matchType.GetInterfaces().Contains(RegisteredType)) + { + return currentPriority; + } + + return 0; + } + } + + private readonly Dictionary> overrides = new Dictionary>(); + + [return: MaybeNull] + public T GetAttribute(Type type, string member) where T : Attribute + { + if (overrides.TryGetValue(new AttributeKey(typeof(T), member), out var mappings)) + { + var bestMatchPriority = 0; + AttributeMapping? bestMatch = null; + + foreach (var mapping in mappings) + { + var priority = mapping.Matches(type); + if (priority > bestMatchPriority) + { + bestMatchPriority = priority; + bestMatch = mapping; + } + } + + if (bestMatchPriority > 0) + { + return (T)bestMatch!.Attribute; + } + } + + return default; + } + + /// + /// Adds a Member Attribute Override + /// + /// Type + /// Class Member + /// Overriding Attribute + public void Add(Type type, string member, Attribute attribute) + { + var mapping = new AttributeMapping(type, attribute); + + var attributeKey = new AttributeKey(attribute.GetType(), member); + if (!overrides.TryGetValue(attributeKey, out var mappings)) + { + mappings = new List(); + overrides.Add(attributeKey, mappings); + } + else if (mappings.Contains(mapping)) + { + throw new InvalidOperationException($"Attribute ({attribute}) already set for Type {type.FullName}, Member {member}"); + } + + mappings.Add(mapping); + } + + /// + /// Creates a copy of this instance. + /// + public YamlAttributeOverrides Clone() + { + var clone = new YamlAttributeOverrides(); + foreach (var entry in overrides) + { + foreach (var item in entry.Value) + { + clone.Add(item.RegisteredType, entry.Key.PropertyName, item.Attribute); + } + } + return clone; + } + } +} + +#if !NET20 +namespace YamlDotNet.Serialization +{ + using System.Linq.Expressions; + using YamlDotNet.Helpers; + + partial class YamlAttributeOverrides + { + /// + /// Adds a Member Attribute Override + /// + public void Add(Expression> propertyAccessor, Attribute attribute) + { + var property = propertyAccessor.AsProperty(); + Add(typeof(TClass), property.Name, attribute); + } + } +} +#endif diff --git a/namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverrides.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverrides.cs.meta new file mode 100644 index 0000000..72e8c2e --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverrides.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f3e06bc7aba37a84aa39139991421fdb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverridesInspector.cs b/namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverridesInspector.cs new file mode 100644 index 0000000..1d88d7a --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverridesInspector.cs @@ -0,0 +1,110 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; +using YamlDotNet.Core; +using YamlDotNet.Serialization.TypeInspectors; + +namespace YamlDotNet.Serialization +{ + /// + /// Applies the Yaml attribute overrides to another . + /// + public sealed class YamlAttributeOverridesInspector : TypeInspectorSkeleton + { + private readonly ITypeInspector innerTypeDescriptor; + private readonly YamlAttributeOverrides overrides; + + public YamlAttributeOverridesInspector(ITypeInspector innerTypeDescriptor, YamlAttributeOverrides overrides) + { + this.innerTypeDescriptor = innerTypeDescriptor; + this.overrides = overrides; + } + + public override IEnumerable GetProperties(Type type, object? container) + { + var properties = innerTypeDescriptor.GetProperties(type, container); + if (overrides != null) + { + properties = properties + .Select(p => (IPropertyDescriptor)new OverridePropertyDescriptor(p, overrides, type)); + } + + return properties; + } + + public sealed class OverridePropertyDescriptor : IPropertyDescriptor + { + private readonly IPropertyDescriptor baseDescriptor; + private readonly YamlAttributeOverrides overrides; + private readonly Type classType; + + public OverridePropertyDescriptor(IPropertyDescriptor baseDescriptor, YamlAttributeOverrides overrides, Type classType) + { + this.baseDescriptor = baseDescriptor; + this.overrides = overrides; + this.classType = classType; + } + + public string Name { get { return baseDescriptor.Name; } } + + public bool CanWrite { get { return baseDescriptor.CanWrite; } } + + public Type Type { get { return baseDescriptor.Type; } } + + public Type? TypeOverride + { + get { return baseDescriptor.TypeOverride; } + set { baseDescriptor.TypeOverride = value; } + } + + public int Order + { + get { return baseDescriptor.Order; } + set { baseDescriptor.Order = value; } + } + + public ScalarStyle ScalarStyle + { + get { return baseDescriptor.ScalarStyle; } + set { baseDescriptor.ScalarStyle = value; } + } + + public void Write(object target, object? value) + { + baseDescriptor.Write(target, value); + } + + public T GetCustomAttribute() where T : Attribute + { + var attr = overrides.GetAttribute(classType, Name); + return attr ?? baseDescriptor.GetCustomAttribute(); + } + + public IObjectDescriptor Read(object target) + { + return baseDescriptor.Read(target); + } + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverridesInspector.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverridesInspector.cs.meta new file mode 100644 index 0000000..0a3aee0 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/YamlAttributeOverridesInspector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9e3ccb290369abf4e89e3f5569b1daca +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/YamlAttributesTypeInspector.cs b/namedropper/Assets/YamlDotNet/Serialization/YamlAttributesTypeInspector.cs new file mode 100644 index 0000000..e8fe65f --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/YamlAttributesTypeInspector.cs @@ -0,0 +1,70 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Collections.Generic; +using System.Linq; +using YamlDotNet.Serialization.TypeInspectors; + +namespace YamlDotNet.Serialization +{ + /// + /// Applies the Yaml* attributes to another . + /// + public sealed class YamlAttributesTypeInspector : TypeInspectorSkeleton + { + private readonly ITypeInspector innerTypeDescriptor; + + public YamlAttributesTypeInspector(ITypeInspector innerTypeDescriptor) + { + this.innerTypeDescriptor = innerTypeDescriptor; + } + + public override IEnumerable GetProperties(Type type, object? container) + { + return innerTypeDescriptor.GetProperties(type, container) + .Where(p => p.GetCustomAttribute() == null) + .Select(p => + { + var descriptor = new PropertyDescriptor(p); + var member = p.GetCustomAttribute(); + if (member != null) + { + if (member.SerializeAs != null) + { + descriptor.TypeOverride = member.SerializeAs; + } + + descriptor.Order = member.Order; + descriptor.ScalarStyle = member.ScalarStyle; + + if (member.Alias != null) + { + descriptor.Name = member.Alias; + } + } + + return (IPropertyDescriptor)descriptor; + }) + .OrderBy(p => p.Order); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/YamlAttributesTypeInspector.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/YamlAttributesTypeInspector.cs.meta new file mode 100644 index 0000000..71c912b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/YamlAttributesTypeInspector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8bbeea575ee7a0b4cb53bf99b07e9949 +timeCreated: 1427145265 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/YamlFormatter.cs b/namedropper/Assets/YamlDotNet/Serialization/YamlFormatter.cs new file mode 100644 index 0000000..efac9d1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/YamlFormatter.cs @@ -0,0 +1,75 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Globalization; + +namespace YamlDotNet.Serialization +{ + internal static class YamlFormatter + { + public static readonly NumberFormatInfo NumberFormat = new NumberFormatInfo + { + CurrencyDecimalSeparator = ".", + CurrencyGroupSeparator = "_", + CurrencyGroupSizes = new[] { 3 }, + CurrencySymbol = string.Empty, + CurrencyDecimalDigits = 99, + NumberDecimalSeparator = ".", + NumberGroupSeparator = "_", + NumberGroupSizes = new[] { 3 }, + NumberDecimalDigits = 99, + NaNSymbol = ".nan", + PositiveInfinitySymbol = ".inf", + NegativeInfinitySymbol = "-.inf" + }; + + public static string FormatNumber(object number) + { + return Convert.ToString(number, NumberFormat)!; + } + + public static string FormatNumber(double number) + { + return number.ToString("G17", NumberFormat); + } + + public static string FormatNumber(float number) + { + return number.ToString("G17", NumberFormat); + } + + public static string FormatBoolean(object boolean) + { + return boolean.Equals(true) ? "true" : "false"; + } + + public static string FormatDateTime(object dateTime) + { + return ((DateTime)dateTime).ToString("o", CultureInfo.InvariantCulture); + } + + public static string FormatTimeSpan(object timeSpan) + { + return ((TimeSpan)timeSpan).ToString(); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/YamlFormatter.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/YamlFormatter.cs.meta new file mode 100644 index 0000000..c778492 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/YamlFormatter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 197ec9064396a7c42bfa14c2edfd50ad +timeCreated: 1427145263 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/YamlIgnoreAttribute.cs b/namedropper/Assets/YamlDotNet/Serialization/YamlIgnoreAttribute.cs new file mode 100644 index 0000000..1d812c9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/YamlIgnoreAttribute.cs @@ -0,0 +1,34 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; + +namespace YamlDotNet.Serialization +{ + /// + /// Instructs the YamlSerializer not to serialize the public field or public read/write property value. + /// + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)] + public sealed class YamlIgnoreAttribute : Attribute + { + } +} + diff --git a/namedropper/Assets/YamlDotNet/Serialization/YamlIgnoreAttribute.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/YamlIgnoreAttribute.cs.meta new file mode 100644 index 0000000..7a5a15b --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/YamlIgnoreAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ecf403b8b63963644a55535cb66115a5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/Serialization/YamlMemberAttribute.cs b/namedropper/Assets/YamlDotNet/Serialization/YamlMemberAttribute.cs new file mode 100644 index 0000000..42b6db9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/YamlMemberAttribute.cs @@ -0,0 +1,95 @@ +// This file is part of YamlDotNet - A .NET library for YAML. +// Copyright (c) Antoine Aubry and contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to +// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +// of the Software, and to permit persons to whom the Software is furnished to do +// so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using YamlDotNet.Core; + +namespace YamlDotNet.Serialization +{ + /// + /// Provides special Yaml serialization instructions. + /// + [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] + public sealed class YamlMemberAttribute : Attribute + { + /// + /// Decription/Comment about this property. + /// When set, a comment will be emitted when serializing this member. + /// + public string? Description { get; set; } + + /// + /// Specifies that this property should be serialized as the given type, rather than using the actual runtime value's type. + /// + public Type? SerializeAs { get; set; } + + /// + /// Specifies the order priority of this property. + /// + public int Order { get; set; } + + /// + /// Instructs the to use a different field name for serialization. + /// + public string? Alias { get; set; } + + /// + /// When false, naming conventions will not be applied to this member. Defaults to true. + /// + public bool ApplyNamingConventions { get; set; } + + /// + /// Specifies the scalar style of the property when serialized. This will only affect the serialization of scalar properties. + /// + public ScalarStyle ScalarStyle { get; set; } + + private DefaultValuesHandling? defaultValuesHandling; + + /// + /// Overrides how null and default values should be handled for this property. + /// + public DefaultValuesHandling DefaultValuesHandling + { + get => defaultValuesHandling.GetValueOrDefault(); + set => defaultValuesHandling = value; + } + + public bool IsDefaultValuesHandlingSpecified => defaultValuesHandling.HasValue; + + /// + /// Initializes a new instance of the class. + /// + public YamlMemberAttribute() + { + ScalarStyle = ScalarStyle.Any; + ApplyNamingConventions = true; + } + + /// + /// Initializes a new instance of the class. + /// + /// Specifies that this property should be serialized as the given type, rather than using the actual runtime value's type. + public YamlMemberAttribute(Type serializeAs) : this() + { + SerializeAs = serializeAs ?? throw new ArgumentNullException(nameof(serializeAs)); + } + } +} diff --git a/namedropper/Assets/YamlDotNet/Serialization/YamlMemberAttribute.cs.meta b/namedropper/Assets/YamlDotNet/Serialization/YamlMemberAttribute.cs.meta new file mode 100644 index 0000000..8979374 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/Serialization/YamlMemberAttribute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a147c05022081f548af64bfe6d560dd0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/YamlDotNet.asmdef b/namedropper/Assets/YamlDotNet/YamlDotNet.asmdef new file mode 100644 index 0000000..6d2469f --- /dev/null +++ b/namedropper/Assets/YamlDotNet/YamlDotNet.asmdef @@ -0,0 +1,14 @@ +{ + "name": "YamlDotNet", + "rootNamespace": "", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": true +} \ No newline at end of file diff --git a/namedropper/Assets/YamlDotNet/YamlDotNet.asmdef.meta b/namedropper/Assets/YamlDotNet/YamlDotNet.asmdef.meta new file mode 100644 index 0000000..206f2c1 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/YamlDotNet.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: b3f49edfedc855a48aa1a9e5d3cba438 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/YamlDotNet.license.txt b/namedropper/Assets/YamlDotNet/YamlDotNet.license.txt new file mode 100644 index 0000000..8cae53f --- /dev/null +++ b/namedropper/Assets/YamlDotNet/YamlDotNet.license.txt @@ -0,0 +1,7 @@ +Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Antoine Aubry + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/namedropper/Assets/YamlDotNet/YamlDotNet.license.txt.meta b/namedropper/Assets/YamlDotNet/YamlDotNet.license.txt.meta new file mode 100644 index 0000000..14af1d9 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/YamlDotNet.license.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ae757a5a9013c3543882d26d55092bc9 +timeCreated: 1431027192 +licenseType: Store +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/namedropper/Assets/YamlDotNet/csc.rsp b/namedropper/Assets/YamlDotNet/csc.rsp new file mode 100644 index 0000000..2d66b02 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/csc.rsp @@ -0,0 +1 @@ +-nullable:enable diff --git a/namedropper/Assets/YamlDotNet/csc.rsp.meta b/namedropper/Assets/YamlDotNet/csc.rsp.meta new file mode 100644 index 0000000..6e48d58 --- /dev/null +++ b/namedropper/Assets/YamlDotNet/csc.rsp.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 97114576076ec87458f29ce5e29d493a +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: