From 60002d0cdeb379db2c256784425f707ed7469a47 Mon Sep 17 00:00:00 2001 From: Antoine Aubry Date: Fri, 9 Aug 2013 18:05:23 +0100 Subject: [PATCH] Extract interfaces of Emitter and Parser. --- Dumper/Program.cs | 2 +- YamlDotNet.Core/Emitter.cs | 10 ++--- YamlDotNet.Core/EventReader.cs | 6 +-- YamlDotNet.Core/IEmitter.cs | 15 +++++++ YamlDotNet.Core/IParser.cs | 21 ++++++++++ YamlDotNet.Core/Parser.cs | 4 +- YamlDotNet.Core/YamlDotNet.Core.csproj | 4 +- .../CustomSerializationObjectGraphVisitor.cs | 4 +- .../Serialization/IYamlSerializable.cs | 6 +-- .../Serialization/IYamlTypeConverter.cs | 4 +- .../Serialization/Serializer.cs | 14 +++---- .../Serialization/StreamFragment.cs | 4 +- .../Serialization/WriterEventEmitter.cs | 4 +- .../YamlAliasNode.cs | 2 +- .../YamlDocument.cs | 2 +- .../YamlMappingNode.cs | 2 +- YamlDotNet.RepresentationModel/YamlNode.cs | 4 +- .../YamlScalarNode.cs | 2 +- .../YamlSequenceNode.cs | 2 +- YamlDotNet.RepresentationModel/YamlStream.cs | 4 +- YamlDotNet.UnitTests/Core/EmitterTests.cs | 4 +- YamlDotNet.UnitTests/Core/ParserTests.cs | 42 +++++++++---------- .../RepresentationModel/SerializationTests.cs | 4 +- 23 files changed, 102 insertions(+), 64 deletions(-) create mode 100644 YamlDotNet.Core/IEmitter.cs create mode 100644 YamlDotNet.Core/IParser.cs diff --git a/Dumper/Program.cs b/Dumper/Program.cs index 3ef0ae4..cb63cbb 100644 --- a/Dumper/Program.cs +++ b/Dumper/Program.cs @@ -33,7 +33,7 @@ namespace Dumper using (TextReader input = File.OpenText(args[0])) { int indent = 0; - Parser parser = new Parser(input); + var parser = new Parser(input); while(parser.MoveNext()) { if (parser.Current is StreamEnd || parser.Current is DocumentEnd || parser.Current is SequenceEnd || parser.Current is SequenceEnd || parser.Current is MappingEnd) diff --git a/YamlDotNet.Core/Emitter.cs b/YamlDotNet.Core/Emitter.cs index bdb6b07..32df5e1 100644 --- a/YamlDotNet.Core/Emitter.cs +++ b/YamlDotNet.Core/Emitter.cs @@ -36,7 +36,7 @@ namespace YamlDotNet.Core /// /// Emits YAML streams. /// - public class Emitter + public class Emitter : IEmitter { private readonly TextWriter output; @@ -108,7 +108,7 @@ namespace YamlDotNet.Core private const int MaxBestIndent = 9; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The where the emitter will write. public Emitter(TextWriter output) @@ -117,7 +117,7 @@ namespace YamlDotNet.Core } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The where the emitter will write. /// The preferred indentation. @@ -127,7 +127,7 @@ namespace YamlDotNet.Core } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The where the emitter will write. /// The preferred indentation. @@ -139,7 +139,7 @@ namespace YamlDotNet.Core /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The where the emitter will write. /// The preferred indentation. diff --git a/YamlDotNet.Core/EventReader.cs b/YamlDotNet.Core/EventReader.cs index f1918c3..32f8fd0 100644 --- a/YamlDotNet.Core/EventReader.cs +++ b/YamlDotNet.Core/EventReader.cs @@ -33,14 +33,14 @@ namespace YamlDotNet.Core /// public class EventReader { - private readonly Parser parser; + private readonly IParser parser; private bool endOfStream; /// /// Initializes a new instance of the class. /// /// The parser that provides the events. - public EventReader(Parser parser) + public EventReader(IParser parser) { this.parser = parser; MoveNext(); @@ -50,7 +50,7 @@ namespace YamlDotNet.Core /// Gets the underlying parser. /// /// The parser. - public Parser Parser + public IParser Parser { get { diff --git a/YamlDotNet.Core/IEmitter.cs b/YamlDotNet.Core/IEmitter.cs new file mode 100644 index 0000000..4a87fce --- /dev/null +++ b/YamlDotNet.Core/IEmitter.cs @@ -0,0 +1,15 @@ +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Core +{ + /// + /// Represents a YAML stream emitter. + /// + public interface IEmitter + { + /// + /// Emits an event. + /// + void Emit(IParsingEvent @event); + } +} diff --git a/YamlDotNet.Core/IParser.cs b/YamlDotNet.Core/IParser.cs new file mode 100644 index 0000000..60f0140 --- /dev/null +++ b/YamlDotNet.Core/IParser.cs @@ -0,0 +1,21 @@ +using YamlDotNet.Core.Events; + +namespace YamlDotNet.Core +{ + /// + /// Represents a YAML stream paser. + /// + public interface IParser + { + /// + /// Gets the current event. + /// + ParsingEvent Current { get; } + + /// + /// Moves to the next event. + /// + /// Returns true if there are more events available, otherwise returns false. + bool MoveNext(); + } +} \ No newline at end of file diff --git a/YamlDotNet.Core/Parser.cs b/YamlDotNet.Core/Parser.cs index ccbcc8c..302d4b0 100644 --- a/YamlDotNet.Core/Parser.cs +++ b/YamlDotNet.Core/Parser.cs @@ -33,7 +33,7 @@ namespace YamlDotNet.Core /// /// Parses YAML streams. /// - public class Parser + public class Parser : IParser { private readonly Stack states = new Stack(); private readonly TagDirectiveCollection tagDirectives = new TagDirectiveCollection(); @@ -57,7 +57,7 @@ namespace YamlDotNet.Core } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The input where the YAML stream is to be read. public Parser(TextReader input) diff --git a/YamlDotNet.Core/YamlDotNet.Core.csproj b/YamlDotNet.Core/YamlDotNet.Core.csproj index 3d883ae..9fd99e7 100644 --- a/YamlDotNet.Core/YamlDotNet.Core.csproj +++ b/YamlDotNet.Core/YamlDotNet.Core.csproj @@ -1,4 +1,4 @@ - + Debug @@ -101,8 +101,10 @@ + + diff --git a/YamlDotNet.RepresentationModel/Serialization/CustomSerializationObjectGraphVisitor.cs b/YamlDotNet.RepresentationModel/Serialization/CustomSerializationObjectGraphVisitor.cs index 8123b1e..0d289f4 100644 --- a/YamlDotNet.RepresentationModel/Serialization/CustomSerializationObjectGraphVisitor.cs +++ b/YamlDotNet.RepresentationModel/Serialization/CustomSerializationObjectGraphVisitor.cs @@ -7,10 +7,10 @@ namespace YamlDotNet.RepresentationModel.Serialization { public sealed class CustomSerializationObjectGraphVisitor : ChainedObjectGraphVisitor { - private readonly Emitter emitter; + private readonly IEmitter emitter; private readonly IEnumerable typeConverters; - public CustomSerializationObjectGraphVisitor(Emitter emitter, IObjectGraphVisitor nextVisitor, IEnumerable typeConverters) + public CustomSerializationObjectGraphVisitor(IEmitter emitter, IObjectGraphVisitor nextVisitor, IEnumerable typeConverters) : base(nextVisitor) { this.emitter = emitter; diff --git a/YamlDotNet.RepresentationModel/Serialization/IYamlSerializable.cs b/YamlDotNet.RepresentationModel/Serialization/IYamlSerializable.cs index d12afd6..3594193 100644 --- a/YamlDotNet.RepresentationModel/Serialization/IYamlSerializable.cs +++ b/YamlDotNet.RepresentationModel/Serialization/IYamlSerializable.cs @@ -31,12 +31,12 @@ namespace YamlDotNet.RepresentationModel { /// /// Reads this object's state from a YAML parser. - /// - void ReadYaml(Parser parser); + /// + void ReadYaml(IParser parser); /// /// Writes this object's state to a YAML emitter. /// - void WriteYaml(Emitter emitter); + void WriteYaml(IEmitter emitter); } } \ No newline at end of file diff --git a/YamlDotNet.RepresentationModel/Serialization/IYamlTypeConverter.cs b/YamlDotNet.RepresentationModel/Serialization/IYamlTypeConverter.cs index 94f384a..45454ba 100644 --- a/YamlDotNet.RepresentationModel/Serialization/IYamlTypeConverter.cs +++ b/YamlDotNet.RepresentationModel/Serialization/IYamlTypeConverter.cs @@ -37,11 +37,11 @@ namespace YamlDotNet.RepresentationModel.Serialization /// /// Reads an object's state from a YAML parser. /// - object ReadYaml(Parser parser, Type type); + object ReadYaml(IParser parser, Type type); /// /// Writes the specified object's state to a YAML emitter. /// - void WriteYaml(Emitter emitter, object value, Type type); + void WriteYaml(IEmitter emitter, object value, Type type); } } \ No newline at end of file diff --git a/YamlDotNet.RepresentationModel/Serialization/Serializer.cs b/YamlDotNet.RepresentationModel/Serialization/Serializer.cs index 94d3400..6158a8b 100644 --- a/YamlDotNet.RepresentationModel/Serialization/Serializer.cs +++ b/YamlDotNet.RepresentationModel/Serialization/Serializer.cs @@ -122,9 +122,9 @@ namespace YamlDotNet.RepresentationModel.Serialization /// /// Serializes the specified object. /// - /// The where to serialize the object. + /// The where to serialize the object. /// The object to serialize. - public void Serialize(Emitter emitter, object graph) + public void Serialize(IEmitter emitter, object graph) { Serialize(emitter, graph, graph != null ? graph.GetType() : typeof(object)); } @@ -132,10 +132,10 @@ namespace YamlDotNet.RepresentationModel.Serialization /// /// Serializes the specified object. /// - /// The where to serialize the object. + /// The where to serialize the object. /// The object to serialize. /// The static type of the object to serialize. - public void Serialize(Emitter emitter, object graph, Type type) + public void Serialize(IEmitter emitter, object graph, Type type) { if (emitter == null) { @@ -153,7 +153,7 @@ namespace YamlDotNet.RepresentationModel.Serialization EmitDocument(emitter, traversalStrategy, emittingVisitor, graph, type); } - private void EmitDocument(Emitter emitter, IObjectGraphTraversalStrategy traversalStrategy, IObjectGraphVisitor emittingVisitor, object graph, Type type) + private void EmitDocument(IEmitter emitter, IObjectGraphTraversalStrategy traversalStrategy, IObjectGraphVisitor emittingVisitor, object graph, Type type) { emitter.Emit(new StreamStart()); emitter.Emit(new DocumentStart()); @@ -164,7 +164,7 @@ namespace YamlDotNet.RepresentationModel.Serialization emitter.Emit(new StreamEnd()); } - private IObjectGraphVisitor CreateEmittingVisitor(Emitter emitter, IObjectGraphTraversalStrategy traversalStrategy, IEventEmitter eventEmitter, object graph, Type type) + private IObjectGraphVisitor CreateEmittingVisitor(IEmitter emitter, IObjectGraphTraversalStrategy traversalStrategy, IEventEmitter eventEmitter, object graph, Type type) { IObjectGraphVisitor emittingVisitor = new EmittingObjectGraphVisitor(eventEmitter); @@ -186,7 +186,7 @@ namespace YamlDotNet.RepresentationModel.Serialization return emittingVisitor; } - private IEventEmitter CreateEventEmitter(Emitter emitter) + private IEventEmitter CreateEventEmitter(IEmitter emitter) { var writer = new WriterEventEmitter(emitter); diff --git a/YamlDotNet.RepresentationModel/Serialization/StreamFragment.cs b/YamlDotNet.RepresentationModel/Serialization/StreamFragment.cs index 7ce5b3a..b81fd09 100644 --- a/YamlDotNet.RepresentationModel/Serialization/StreamFragment.cs +++ b/YamlDotNet.RepresentationModel/Serialization/StreamFragment.cs @@ -51,7 +51,7 @@ namespace YamlDotNet.RepresentationModel.Serialization /// Reads this object's state from a YAML parser. /// /// - void IYamlSerializable.ReadYaml(Parser parser) + void IYamlSerializable.ReadYaml(IParser parser) { events.Clear(); @@ -74,7 +74,7 @@ namespace YamlDotNet.RepresentationModel.Serialization /// Writes this object's state to a YAML emitter. /// /// - void IYamlSerializable.WriteYaml(Emitter emitter) + void IYamlSerializable.WriteYaml(IEmitter emitter) { foreach (var item in events) { diff --git a/YamlDotNet.RepresentationModel/Serialization/WriterEventEmitter.cs b/YamlDotNet.RepresentationModel/Serialization/WriterEventEmitter.cs index 8e9beb6..203cc37 100644 --- a/YamlDotNet.RepresentationModel/Serialization/WriterEventEmitter.cs +++ b/YamlDotNet.RepresentationModel/Serialization/WriterEventEmitter.cs @@ -5,9 +5,9 @@ namespace YamlDotNet.RepresentationModel.Serialization { public sealed class WriterEventEmitter : IEventEmitter { - private readonly Emitter emitter; + private readonly IEmitter emitter; - public WriterEventEmitter(Emitter emitter) + public WriterEventEmitter(IEmitter emitter) { this.emitter = emitter; } diff --git a/YamlDotNet.RepresentationModel/YamlAliasNode.cs b/YamlDotNet.RepresentationModel/YamlAliasNode.cs index e648dec..2d0374c 100644 --- a/YamlDotNet.RepresentationModel/YamlAliasNode.cs +++ b/YamlDotNet.RepresentationModel/YamlAliasNode.cs @@ -53,7 +53,7 @@ namespace YamlDotNet.RepresentationModel /// /// The emitter where the node is to be saved. /// The state. - internal override void Emit(Emitter emitter, EmitterState state) + internal override void Emit(IEmitter emitter, EmitterState state) { throw new NotSupportedException("A YamlAliasNode is an implementation detail and should never be saved."); } diff --git a/YamlDotNet.RepresentationModel/YamlDocument.cs b/YamlDotNet.RepresentationModel/YamlDocument.cs index 42185ee..174516b 100644 --- a/YamlDotNet.RepresentationModel/YamlDocument.cs +++ b/YamlDotNet.RepresentationModel/YamlDocument.cs @@ -168,7 +168,7 @@ namespace YamlDotNet.RepresentationModel visitor.AssignAnchors(this); } - internal void Save(Emitter emitter) + internal void Save(IEmitter emitter) { AssignAnchors(); diff --git a/YamlDotNet.RepresentationModel/YamlMappingNode.cs b/YamlDotNet.RepresentationModel/YamlMappingNode.cs index 18735f9..88e7403 100644 --- a/YamlDotNet.RepresentationModel/YamlMappingNode.cs +++ b/YamlDotNet.RepresentationModel/YamlMappingNode.cs @@ -251,7 +251,7 @@ namespace YamlDotNet.RepresentationModel /// /// The emitter where the node is to be saved. /// The state. - internal override void Emit(Emitter emitter, EmitterState state) + internal override void Emit(IEmitter emitter, EmitterState state) { emitter.Emit(new MappingStart(Anchor, Tag, true, Style)); foreach (var entry in children) diff --git a/YamlDotNet.RepresentationModel/YamlNode.cs b/YamlDotNet.RepresentationModel/YamlNode.cs index 3652a40..78f073b 100644 --- a/YamlDotNet.RepresentationModel/YamlNode.cs +++ b/YamlDotNet.RepresentationModel/YamlNode.cs @@ -113,7 +113,7 @@ namespace YamlDotNet.RepresentationModel /// /// The emitter where the node is to be saved. /// The state. - internal void Save(Emitter emitter, EmitterState state) + internal void Save(IEmitter emitter, EmitterState state) { if (!string.IsNullOrEmpty(Anchor) && !state.EmittedAnchors.Add(Anchor)) { @@ -130,7 +130,7 @@ namespace YamlDotNet.RepresentationModel /// /// The emitter where the node is to be saved. /// The state. - internal abstract void Emit(Emitter emitter, EmitterState state); + internal abstract void Emit(IEmitter emitter, EmitterState state); /// /// Accepts the specified visitor by calling the appropriate Visit method on it. diff --git a/YamlDotNet.RepresentationModel/YamlScalarNode.cs b/YamlDotNet.RepresentationModel/YamlScalarNode.cs index d87a934..56f7676 100644 --- a/YamlDotNet.RepresentationModel/YamlScalarNode.cs +++ b/YamlDotNet.RepresentationModel/YamlScalarNode.cs @@ -89,7 +89,7 @@ namespace YamlDotNet.RepresentationModel /// /// The emitter where the node is to be saved. /// The state. - internal override void Emit(Emitter emitter, EmitterState state) + internal override void Emit(IEmitter emitter, EmitterState state) { emitter.Emit(new Scalar(Anchor, Tag, Value, Style, true, false)); } diff --git a/YamlDotNet.RepresentationModel/YamlSequenceNode.cs b/YamlDotNet.RepresentationModel/YamlSequenceNode.cs index 8b1d3d3..1653de0 100644 --- a/YamlDotNet.RepresentationModel/YamlSequenceNode.cs +++ b/YamlDotNet.RepresentationModel/YamlSequenceNode.cs @@ -158,7 +158,7 @@ namespace YamlDotNet.RepresentationModel /// /// The emitter where the node is to be saved. /// The state. - internal override void Emit(Emitter emitter, EmitterState state) + internal override void Emit(IEmitter emitter, EmitterState state) { emitter.Emit(new SequenceStart(Anchor, Tag, true, Style)); foreach (var node in children) diff --git a/YamlDotNet.RepresentationModel/YamlStream.cs b/YamlDotNet.RepresentationModel/YamlStream.cs index 356c50a..6b6fc5f 100644 --- a/YamlDotNet.RepresentationModel/YamlStream.cs +++ b/YamlDotNet.RepresentationModel/YamlStream.cs @@ -88,7 +88,7 @@ namespace YamlDotNet.RepresentationModel { documents.Clear(); - Parser parser = new Parser(input); + var parser = new Parser(input); EventReader events = new EventReader(parser); events.Expect(); @@ -106,7 +106,7 @@ namespace YamlDotNet.RepresentationModel /// The output. public void Save(TextWriter output) { - Emitter emitter = new Emitter(output); + IEmitter emitter = new Emitter(output); emitter.Emit(new StreamStart()); foreach (var document in documents) diff --git a/YamlDotNet.UnitTests/Core/EmitterTests.cs b/YamlDotNet.UnitTests/Core/EmitterTests.cs index 36051ac..f49e11f 100644 --- a/YamlDotNet.UnitTests/Core/EmitterTests.cs +++ b/YamlDotNet.UnitTests/Core/EmitterTests.cs @@ -36,9 +36,9 @@ namespace YamlDotNet.UnitTests private void ParseAndEmit(string name) { string testText = YamlFile(name).ReadToEnd(); - Parser parser = new Parser(new StringReader(testText)); + IParser parser = new Parser(new StringReader(testText)); using(StringWriter output = new StringWriter()) { - Emitter emitter = new Emitter(output, 2, int.MaxValue, false); + IEmitter emitter = new Emitter(output, 2, int.MaxValue, false); while(parser.MoveNext()) { //Console.WriteLine(parser.Current.GetType().Name); Console.Error.WriteLine(parser.Current); diff --git a/YamlDotNet.UnitTests/Core/ParserTests.cs b/YamlDotNet.UnitTests/Core/ParserTests.cs index ab0c12f..b7aae76 100644 --- a/YamlDotNet.UnitTests/Core/ParserTests.cs +++ b/YamlDotNet.UnitTests/Core/ParserTests.cs @@ -33,19 +33,19 @@ namespace YamlDotNet.UnitTests { public class ParserTests : YamlTest { - private static Parser CreateParser(string name) { + private static IParser CreateParser(string name) { return new Parser(YamlFile(name)); } - private void AssertHasNext(Parser parser) { + private void AssertHasNext(IParser parser) { Assert.True(parser.MoveNext()); } - private void AssertDoesNotHaveNext(Parser parser) { + private void AssertDoesNotHaveNext(IParser parser) { Assert.False(parser.MoveNext()); } - private void AssertCurrent(Parser parser, ParsingEvent expected) { + private void AssertCurrent(IParser parser, ParsingEvent expected) { Console.WriteLine(expected.GetType().Name); Assert.True(expected.GetType().IsAssignableFrom(parser.Current.GetType()), string.Format("The event is not of the expected type. Exprected: {0}, Actual: {1}", expected.GetType().Name, parser.Current.GetType().Name)); @@ -86,7 +86,7 @@ namespace YamlDotNet.UnitTests } } - private void AssertNext(Parser parser, ParsingEvent expected) { + private void AssertNext(IParser parser, ParsingEvent expected) { AssertHasNext(parser); AssertCurrent(parser, expected); } @@ -94,7 +94,7 @@ namespace YamlDotNet.UnitTests [Fact] public void EmptyDocument() { - Parser parser = CreateParser("empty.yaml"); + IParser parser = CreateParser("empty.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new StreamEnd()); @@ -109,7 +109,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyEventsOnExample1() { - Parser parser = CreateParser("test1.yaml"); + IParser parser = CreateParser("test1.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(new VersionDirective(new Core.Version(1, 1)), new TagDirectiveCollection(new TagDirective[] { @@ -126,7 +126,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyTokensOnExample2() { - Parser parser = CreateParser("test2.yaml"); + IParser parser = CreateParser("test2.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(null, defaultDirectives, true)); @@ -139,7 +139,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyTokensOnExample3() { - Parser parser = CreateParser("test3.yaml"); + IParser parser = CreateParser("test3.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(null, defaultDirectives, false)); @@ -152,7 +152,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyTokensOnExample4() { - Parser parser = CreateParser("test4.yaml"); + IParser parser = CreateParser("test4.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(null, defaultDirectives, true)); @@ -171,7 +171,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyTokensOnExample5() { - Parser parser = CreateParser("test5.yaml"); + IParser parser = CreateParser("test5.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(null, defaultDirectives, true)); @@ -186,7 +186,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyTokensOnExample6() { - Parser parser = CreateParser("test6.yaml"); + IParser parser = CreateParser("test6.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(null, defaultDirectives, true)); @@ -199,7 +199,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyTokensOnExample7() { - Parser parser = CreateParser("test7.yaml"); + IParser parser = CreateParser("test7.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(null, defaultDirectives, false)); @@ -227,7 +227,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyTokensOnExample8() { - Parser parser = CreateParser("test8.yaml"); + IParser parser = CreateParser("test8.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(null, defaultDirectives, true)); @@ -244,7 +244,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyTokensOnExample9() { - Parser parser = CreateParser("test9.yaml"); + IParser parser = CreateParser("test9.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(null, defaultDirectives, true)); @@ -262,7 +262,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyTokensOnExample10() { - Parser parser = CreateParser("test10.yaml"); + IParser parser = CreateParser("test10.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(null, defaultDirectives, true)); @@ -288,7 +288,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyTokensOnExample11() { - Parser parser = CreateParser("test11.yaml"); + IParser parser = CreateParser("test11.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(null, defaultDirectives, true)); @@ -318,7 +318,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyTokensOnExample12() { - Parser parser = CreateParser("test12.yaml"); + IParser parser = CreateParser("test12.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(null, defaultDirectives, true)); @@ -346,7 +346,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyTokensOnExample13() { - Parser parser = CreateParser("test13.yaml"); + IParser parser = CreateParser("test13.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(null, defaultDirectives, true)); @@ -372,7 +372,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyTokensOnExample14() { - Parser parser = CreateParser("test14.yaml"); + IParser parser = CreateParser("test14.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(null, defaultDirectives, true)); @@ -391,7 +391,7 @@ namespace YamlDotNet.UnitTests [Fact] public void VerifyTokenWithLocalTags() { - Parser parser = CreateParser("local-tags.yaml"); + IParser parser = CreateParser("local-tags.yaml"); AssertNext(parser, new StreamStart()); AssertNext(parser, new DocumentStart(null, defaultDirectives, false)); diff --git a/YamlDotNet.UnitTests/RepresentationModel/SerializationTests.cs b/YamlDotNet.UnitTests/RepresentationModel/SerializationTests.cs index a36b64d..385f6e8 100644 --- a/YamlDotNet.UnitTests/RepresentationModel/SerializationTests.cs +++ b/YamlDotNet.UnitTests/RepresentationModel/SerializationTests.cs @@ -614,14 +614,14 @@ namespace YamlDotNet.UnitTests.RepresentationModel { public bool Accepts(Type type) { return type == typeof(SomeCustomeType); } - public object ReadYaml(Parser parser, Type type) + public object ReadYaml(IParser parser, Type type) { var value = ((Scalar)parser.Current).Value; parser.MoveNext(); return new SomeCustomeType(value); } - public void WriteYaml(Emitter emitter, object value, Type type) + public void WriteYaml(IEmitter emitter, object value, Type type) { emitter.Emit(new Scalar(((SomeCustomeType)value).Value)); }