From 1eb391c14700fa0b485818a6f26278b1041b192f Mon Sep 17 00:00:00 2001 From: stakx Date: Sat, 24 Dec 2016 01:01:15 +0100 Subject: [PATCH] Replace "stream" in reader/writer classes' comments XML documentation comments for JsonReader, JsonWriter and derived classes often mention "underlying streams". In most cases however, these types don't operate directly on Streams, but through other types such as TextReader and TextWriter. This commit changes these comments to reflect more accurately what kind of objects the various JSON reader / writer classes operate on. Additionally the effect of JsonReader.CloseInput and JsonWriter.Close- Output is made more explicit in the comments for the Close methods. --- Src/Newtonsoft.Json/Bson/BsonReader.cs | 11 ++++----- Src/Newtonsoft.Json/Bson/BsonWriter.cs | 9 ++++---- Src/Newtonsoft.Json/JsonReader.cs | 25 ++++++++++----------- Src/Newtonsoft.Json/JsonSerializer.cs | 8 +++---- Src/Newtonsoft.Json/JsonTextReader.cs | 19 ++++++++-------- Src/Newtonsoft.Json/JsonTextWriter.cs | 5 +++-- Src/Newtonsoft.Json/JsonValidatingReader.cs | 18 +++++++-------- Src/Newtonsoft.Json/JsonWriter.cs | 11 +++++---- Src/Newtonsoft.Json/Linq/JTokenReader.cs | 2 +- Src/Newtonsoft.Json/Linq/JTokenWriter.cs | 11 +++++---- 10 files changed, 62 insertions(+), 57 deletions(-) diff --git a/Src/Newtonsoft.Json/Bson/BsonReader.cs b/Src/Newtonsoft.Json/Bson/BsonReader.cs index 69281fce..bb36ff8b 100644 --- a/Src/Newtonsoft.Json/Bson/BsonReader.cs +++ b/Src/Newtonsoft.Json/Bson/BsonReader.cs @@ -122,7 +122,7 @@ namespace Newtonsoft.Json.Bson /// /// Initializes a new instance of the class. /// - /// The stream. + /// The containing the BSON data to read. public BsonReader(Stream stream) : this(stream, false, DateTimeKind.Local) { @@ -131,7 +131,7 @@ namespace Newtonsoft.Json.Bson /// /// Initializes a new instance of the class. /// - /// The reader. + /// The containing the BSON data to read. public BsonReader(BinaryReader reader) : this(reader, false, DateTimeKind.Local) { @@ -140,7 +140,7 @@ namespace Newtonsoft.Json.Bson /// /// Initializes a new instance of the class. /// - /// The stream. + /// The containing the BSON data to read. /// if set to true the root object will be read as a JSON array. /// The used when reading values from BSON. public BsonReader(Stream stream, bool readRootValueAsArray, DateTimeKind dateTimeKindHandling) @@ -155,7 +155,7 @@ namespace Newtonsoft.Json.Bson /// /// Initializes a new instance of the class. /// - /// The reader. + /// The containing the BSON data to read. /// if set to true the root object will be read as a JSON array. /// The used when reading values from BSON. public BsonReader(BinaryReader reader, bool readRootValueAsArray, DateTimeKind dateTimeKindHandling) @@ -175,7 +175,7 @@ namespace Newtonsoft.Json.Bson } /// - /// Reads the next JSON token from the stream. + /// Reads the next JSON token from the underlying . /// /// /// true if the next token was read successfully; false if there are no more tokens to read. @@ -224,6 +224,7 @@ namespace Newtonsoft.Json.Bson /// /// Changes the reader's state to . + /// If is set to true, the underlying is also closed. /// public override void Close() { diff --git a/Src/Newtonsoft.Json/Bson/BsonWriter.cs b/Src/Newtonsoft.Json/Bson/BsonWriter.cs index f46b67c3..71bd038a 100644 --- a/Src/Newtonsoft.Json/Bson/BsonWriter.cs +++ b/Src/Newtonsoft.Json/Bson/BsonWriter.cs @@ -62,7 +62,7 @@ namespace Newtonsoft.Json.Bson /// /// Initializes a new instance of the class. /// - /// The stream. + /// The to write to. public BsonWriter(Stream stream) { ValidationUtils.ArgumentNotNull(stream, nameof(stream)); @@ -72,7 +72,7 @@ namespace Newtonsoft.Json.Bson /// /// Initializes a new instance of the class. /// - /// The writer. + /// The to write to. public BsonWriter(BinaryWriter writer) { ValidationUtils.ArgumentNotNull(writer, nameof(writer)); @@ -80,7 +80,7 @@ namespace Newtonsoft.Json.Bson } /// - /// Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream. + /// Flushes whatever is in the buffer to the underlying and also flushes the underlying stream. /// public override void Flush() { @@ -170,7 +170,8 @@ namespace Newtonsoft.Json.Bson } /// - /// Closes this stream and the underlying stream. + /// Closes this writer. + /// If is set to true, the underlying is also closed. /// public override void Close() { diff --git a/Src/Newtonsoft.Json/JsonReader.cs b/Src/Newtonsoft.Json/JsonReader.cs index 1c6e6b1b..b3244b3d 100644 --- a/Src/Newtonsoft.Json/JsonReader.cs +++ b/Src/Newtonsoft.Json/JsonReader.cs @@ -141,12 +141,10 @@ namespace Newtonsoft.Json } /// - /// Gets or sets a value indicating whether the underlying stream or - /// should be closed when the reader is closed. + /// Gets or sets a value indicating whether the source should be closed when this reader is closed. /// /// - /// true to close the underlying stream or when - /// the reader is closed; otherwise false. The default is true. + /// true to close the source when this reader is closed; otherwise false. The default is true. /// public bool CloseInput { get; set; } @@ -406,13 +404,13 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream. + /// Reads the next JSON token from the source. /// /// true if the next token was read successfully; false if there are no more tokens to read. public abstract bool Read(); /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the source as a of . /// /// A of . This method will return null at the end of an array. public virtual int? ReadAsInt32() @@ -463,7 +461,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a . + /// Reads the next JSON token from the source as a . /// /// A . This method will return null at the end of an array. public virtual string ReadAsString() @@ -507,7 +505,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a []. + /// Reads the next JSON token from the source as a []. /// /// A [] or null if the next JSON token is null. This method will return null at the end of an array. public virtual byte[] ReadAsBytes() @@ -606,7 +604,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the source as a of . /// /// A of . This method will return null at the end of an array. public virtual double? ReadAsDouble() @@ -668,7 +666,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the source as a of . /// /// A of . This method will return null at the end of an array. public virtual bool? ReadAsBoolean() @@ -729,7 +727,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the source as a of . /// /// A of . This method will return null at the end of an array. public virtual decimal? ReadAsDecimal() @@ -779,7 +777,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the source as a of . /// /// A of . This method will return null at the end of an array. public virtual DateTime? ReadAsDateTime() @@ -835,7 +833,7 @@ namespace Newtonsoft.Json #if !NET20 /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the source as a of . /// /// A of . This method will return null at the end of an array. public virtual DateTimeOffset? ReadAsDateTimeOffset() @@ -1124,6 +1122,7 @@ namespace Newtonsoft.Json /// /// Changes the reader's state to . + /// If is set to true, the source is also closed. /// public virtual void Close() { diff --git a/Src/Newtonsoft.Json/JsonSerializer.cs b/Src/Newtonsoft.Json/JsonSerializer.cs index 108a9f6c..fae8697a 100644 --- a/Src/Newtonsoft.Json/JsonSerializer.cs +++ b/Src/Newtonsoft.Json/JsonSerializer.cs @@ -994,7 +994,7 @@ namespace Newtonsoft.Json /// /// Serializes the specified and writes the JSON structure - /// to a using the specified . + /// using the specified . /// /// The used to write the JSON structure. /// The to serialize. @@ -1005,7 +1005,7 @@ namespace Newtonsoft.Json /// /// Serializes the specified and writes the JSON structure - /// to a using the specified . + /// using the specified . /// /// The used to write the JSON structure. /// The to serialize. @@ -1021,7 +1021,7 @@ namespace Newtonsoft.Json /// /// Serializes the specified and writes the JSON structure - /// to a Stream using the specified . + /// using the specified . /// /// The used to write the JSON structure. /// The to serialize. @@ -1037,7 +1037,7 @@ namespace Newtonsoft.Json /// /// Serializes the specified and writes the JSON structure - /// to a Stream using the specified . + /// using the specified . /// /// The used to write the JSON structure. /// The to serialize. diff --git a/Src/Newtonsoft.Json/JsonTextReader.cs b/Src/Newtonsoft.Json/JsonTextReader.cs index a3609d0d..b2bcbdc9 100644 --- a/Src/Newtonsoft.Json/JsonTextReader.cs +++ b/Src/Newtonsoft.Json/JsonTextReader.cs @@ -359,7 +359,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream. + /// Reads the next JSON token from the underlying . /// /// /// true if the next token was read successfully; false if there are no more tokens to read. @@ -416,7 +416,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the underlying as a of . /// /// A of . This method will return null at the end of an array. public override int? ReadAsInt32() @@ -425,7 +425,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the underlying as a of . /// /// A of . This method will return null at the end of an array. public override DateTime? ReadAsDateTime() @@ -434,7 +434,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a . + /// Reads the next JSON token from the underlying as a . /// /// A . This method will return null at the end of an array. public override string ReadAsString() @@ -443,7 +443,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a []. + /// Reads the next JSON token from the underlying as a []. /// /// A [] or null if the next JSON token is null. This method will return null at the end of an array. public override byte[] ReadAsBytes() @@ -697,7 +697,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the underlying as a of . /// /// A of . This method will return null at the end of an array. public override bool? ReadAsBoolean() @@ -945,7 +945,7 @@ namespace Newtonsoft.Json #if !NET20 /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the underlying as a of . /// /// A of . This method will return null at the end of an array. public override DateTimeOffset? ReadAsDateTimeOffset() @@ -955,7 +955,7 @@ namespace Newtonsoft.Json #endif /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the underlying as a of . /// /// A of . This method will return null at the end of an array. public override decimal? ReadAsDecimal() @@ -964,7 +964,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the underlying as a of . /// /// A of . This method will return null at the end of an array. public override double? ReadAsDouble() @@ -2402,6 +2402,7 @@ namespace Newtonsoft.Json /// /// Changes the reader's state to . + /// If is set to true, the underlying is also closed. /// public override void Close() { diff --git a/Src/Newtonsoft.Json/JsonTextWriter.cs b/Src/Newtonsoft.Json/JsonTextWriter.cs index 2abd8186..304609d1 100644 --- a/Src/Newtonsoft.Json/JsonTextWriter.cs +++ b/Src/Newtonsoft.Json/JsonTextWriter.cs @@ -163,7 +163,7 @@ namespace Newtonsoft.Json } /// - /// Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream. + /// Flushes whatever is in the buffer to the underlying and also flushes the underlying . /// public override void Flush() { @@ -171,7 +171,8 @@ namespace Newtonsoft.Json } /// - /// Closes this stream and the underlying stream. + /// Closes this writer. + /// If is set to true, the underlying is also closed. /// public override void Close() { diff --git a/Src/Newtonsoft.Json/JsonValidatingReader.cs b/Src/Newtonsoft.Json/JsonValidatingReader.cs index 21d54c69..d2e5b862 100644 --- a/Src/Newtonsoft.Json/JsonValidatingReader.cs +++ b/Src/Newtonsoft.Json/JsonValidatingReader.cs @@ -392,7 +392,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the underlying as a of . /// /// A of . public override int? ReadAsInt32() @@ -404,7 +404,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a []. + /// Reads the next JSON token from the underlying as a []. /// /// /// A [] or null if the next JSON token is null. @@ -418,7 +418,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the underlying as a of . /// /// A of . public override decimal? ReadAsDecimal() @@ -430,7 +430,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the underlying as a of . /// /// A of . public override double? ReadAsDouble() @@ -442,7 +442,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the underlying as a of . /// /// A of . public override bool? ReadAsBoolean() @@ -454,7 +454,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a . + /// Reads the next JSON token from the underlying as a . /// /// A . This method will return null at the end of an array. public override string ReadAsString() @@ -466,7 +466,7 @@ namespace Newtonsoft.Json } /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the underlying as a of . /// /// A of . This method will return null at the end of an array. public override DateTime? ReadAsDateTime() @@ -479,7 +479,7 @@ namespace Newtonsoft.Json #if !NET20 /// - /// Reads the next JSON token from the stream as a of . + /// Reads the next JSON token from the underlying as a of . /// /// A of . public override DateTimeOffset? ReadAsDateTimeOffset() @@ -492,7 +492,7 @@ namespace Newtonsoft.Json #endif /// - /// Reads the next JSON token from the stream. + /// Reads the next JSON token from the underlying . /// /// /// true if the next token was read successfully; false if there are no more tokens to read. diff --git a/Src/Newtonsoft.Json/JsonWriter.cs b/Src/Newtonsoft.Json/JsonWriter.cs index c1fda614..e0c16fa9 100644 --- a/Src/Newtonsoft.Json/JsonWriter.cs +++ b/Src/Newtonsoft.Json/JsonWriter.cs @@ -119,12 +119,10 @@ namespace Newtonsoft.Json private Formatting _formatting; /// - /// Gets or sets a value indicating whether the underlying stream or - /// should be closed when the writer is closed. + /// Gets or sets a value indicating whether the destination should be closed when this writer is closed. /// /// - /// true to close the underlying stream or when - /// the writer is closed; otherwise false. The default is true. + /// true to close the destination when this writer is closed; otherwise false. The default is true. /// public bool CloseOutput { get; set; } @@ -389,12 +387,13 @@ namespace Newtonsoft.Json } /// - /// Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream. + /// Flushes whatever is in the buffer to the destination and also flushes the destination. /// public abstract void Flush(); /// - /// Closes this stream and the underlying stream. + /// Closes this writer. + /// If is set to true, the destination is also closed. /// public virtual void Close() { diff --git a/Src/Newtonsoft.Json/Linq/JTokenReader.cs b/Src/Newtonsoft.Json/Linq/JTokenReader.cs index 0f5c98dc..20ea19f8 100644 --- a/Src/Newtonsoft.Json/Linq/JTokenReader.cs +++ b/Src/Newtonsoft.Json/Linq/JTokenReader.cs @@ -65,7 +65,7 @@ namespace Newtonsoft.Json.Linq } /// - /// Reads the next JSON token from the stream. + /// Reads the next JSON token from the underlying . /// /// /// true if the next token was read successfully; false if there are no more tokens to read. diff --git a/Src/Newtonsoft.Json/Linq/JTokenWriter.cs b/Src/Newtonsoft.Json/Linq/JTokenWriter.cs index 3c76cbfc..b60305cf 100644 --- a/Src/Newtonsoft.Json/Linq/JTokenWriter.cs +++ b/Src/Newtonsoft.Json/Linq/JTokenWriter.cs @@ -52,9 +52,9 @@ namespace Newtonsoft.Json.Linq } /// - /// Gets the token being writen. + /// Gets the token being written. /// - /// The token being writen. + /// The token being written. public JToken Token { get @@ -88,15 +88,18 @@ namespace Newtonsoft.Json.Linq } /// - /// Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream. + /// Flushes whatever is in the buffer to the underlying . /// public override void Flush() { } /// - /// Closes this stream and the underlying stream. + /// Closes this writer. /// + /// + /// Setting to true has no additional effect, since the underlying is a type that cannot be closed. + /// public override void Close() { base.Close();