diff --git a/Src/Newtonsoft.Json/Bson/BsonObjectId.cs b/Src/Newtonsoft.Json/Bson/BsonObjectId.cs
index 0bb603eb..3ed885b1 100644
--- a/Src/Newtonsoft.Json/Bson/BsonObjectId.cs
+++ b/Src/Newtonsoft.Json/Bson/BsonObjectId.cs
@@ -37,7 +37,7 @@ namespace Newtonsoft.Json.Bson
/// Gets or sets the value of the Oid.
///
/// The value of the Oid.
- public byte[] Value { get; private set; }
+ public byte[] Value { get; }
///
/// Initializes a new instance of the class.
diff --git a/Src/Newtonsoft.Json/Bson/BsonWriter.cs b/Src/Newtonsoft.Json/Bson/BsonWriter.cs
index a3de3a2a..78e86010 100644
--- a/Src/Newtonsoft.Json/Bson/BsonWriter.cs
+++ b/Src/Newtonsoft.Json/Bson/BsonWriter.cs
@@ -238,7 +238,7 @@ namespace Newtonsoft.Json.Bson
#if HAVE_BIG_INTEGER
if (value is BigInteger)
{
- InternalWriteValue(JsonToken.Integer);
+ SetWriteState(JsonToken.Integer, null);
AddToken(new BsonBinary(((BigInteger)value).ToByteArray(), BsonBinaryType.Binary));
}
else
@@ -516,8 +516,7 @@ namespace Newtonsoft.Json.Bson
}
// hack to update the writer state
- UpdateScopeWithFinishedValue();
- AutoComplete(JsonToken.Undefined);
+ SetWriteState(JsonToken.Undefined, null);
AddValue(value, BsonType.Oid);
}
@@ -531,8 +530,7 @@ namespace Newtonsoft.Json.Bson
ValidationUtils.ArgumentNotNull(pattern, nameof(pattern));
// hack to update the writer state
- UpdateScopeWithFinishedValue();
- AutoComplete(JsonToken.Undefined);
+ SetWriteState(JsonToken.Undefined, null);
AddToken(new BsonRegex(pattern, options));
}
}
diff --git a/Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs b/Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs
index e494ac3d..77e89f96 100644
--- a/Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs
+++ b/Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs
@@ -435,7 +435,7 @@ namespace Newtonsoft.Json.Converters
#if HAVE_XLINQ
internal class XDeclarationWrapper : XObjectWrapper, IXmlDeclaration
{
- internal XDeclaration Declaration { get; private set; }
+ internal XDeclaration Declaration { get; }
public XDeclarationWrapper(XDeclaration declaration)
: base(null)
diff --git a/Src/Newtonsoft.Json/JsonConverterAttribute.cs b/Src/Newtonsoft.Json/JsonConverterAttribute.cs
index ef9d2c11..4ccceeb9 100644
--- a/Src/Newtonsoft.Json/JsonConverterAttribute.cs
+++ b/Src/Newtonsoft.Json/JsonConverterAttribute.cs
@@ -50,7 +50,7 @@ namespace Newtonsoft.Json
/// The parameter list to use when constructing the described by .
/// If null, the default constructor is used.
///
- public object[] ConverterParameters { get; private set; }
+ public object[] ConverterParameters { get; }
///
/// Initializes a new instance of the class.
diff --git a/Src/Newtonsoft.Json/JsonReaderException.cs b/Src/Newtonsoft.Json/JsonReaderException.cs
index 940e14e8..3de4f168 100644
--- a/Src/Newtonsoft.Json/JsonReaderException.cs
+++ b/Src/Newtonsoft.Json/JsonReaderException.cs
@@ -42,19 +42,19 @@ namespace Newtonsoft.Json
/// Gets the line number indicating where the error occurred.
///
/// The line number indicating where the error occurred.
- public int LineNumber { get; private set; }
+ public int LineNumber { get; }
///
/// Gets the line position indicating where the error occurred.
///
/// The line position indicating where the error occurred.
- public int LinePosition { get; private set; }
+ public int LinePosition { get; }
///
/// Gets the path to the JSON where the error occurred.
///
/// The path to the JSON where the error occurred.
- public string Path { get; private set; }
+ public string Path { get; }
///
/// Initializes a new instance of the class.
@@ -98,7 +98,16 @@ namespace Newtonsoft.Json
}
#endif
- internal JsonReaderException(string message, Exception innerException, string path, int lineNumber, int linePosition)
+ ///
+ /// Initializes a new instance of the class
+ /// with a specified error message, JSON path, line number, line position, and a reference to the inner exception that is the cause of this exception.
+ ///
+ /// The error message that explains the reason for the exception.
+ /// The path to the JSON where the error occurred.
+ /// The line number indicating where the error occurred.
+ /// The line position indicating where the error occurred.
+ /// The exception that is the cause of the current exception, or null if no inner exception is specified.
+ public JsonReaderException(string message, string path, int lineNumber, int linePosition, Exception innerException)
: base(message, innerException)
{
Path = path;
@@ -133,7 +142,7 @@ namespace Newtonsoft.Json
linePosition = 0;
}
- return new JsonReaderException(message, ex, path, lineNumber, linePosition);
+ return new JsonReaderException(message, path, lineNumber, linePosition, ex);
}
}
}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json/JsonValidatingReader.cs b/Src/Newtonsoft.Json/JsonValidatingReader.cs
index cca64386..677a49c6 100644
--- a/Src/Newtonsoft.Json/JsonValidatingReader.cs
+++ b/Src/Newtonsoft.Json/JsonValidatingReader.cs
@@ -62,8 +62,8 @@ namespace Newtonsoft.Json
public string CurrentPropertyName { get; set; }
public int ArrayItemCount { get; set; }
- public bool IsUniqueArray { get; set; }
- public IList UniqueArrayItems { get; set; }
+ public bool IsUniqueArray { get; }
+ public IList UniqueArrayItems { get; }
public JTokenWriter CurrentItemWriter { get; set; }
public IList Schemas
diff --git a/Src/Newtonsoft.Json/JsonWriterException.cs b/Src/Newtonsoft.Json/JsonWriterException.cs
index aed9866a..cbdce1ca 100644
--- a/Src/Newtonsoft.Json/JsonWriterException.cs
+++ b/Src/Newtonsoft.Json/JsonWriterException.cs
@@ -42,7 +42,7 @@ namespace Newtonsoft.Json
/// Gets the path to the JSON where the error occurred.
///
/// The path to the JSON where the error occurred.
- public string Path { get; private set; }
+ public string Path { get; }
///
/// Initializes a new instance of the class.
@@ -86,7 +86,14 @@ namespace Newtonsoft.Json
}
#endif
- internal JsonWriterException(string message, Exception innerException, string path)
+ ///
+ /// Initializes a new instance of the class
+ /// with a specified error message, JSON path and a reference to the inner exception that is the cause of this exception.
+ ///
+ /// The error message that explains the reason for the exception.
+ /// The path to the JSON where the error occurred.
+ /// The exception that is the cause of the current exception, or null if no inner exception is specified.
+ public JsonWriterException(string message, string path, Exception innerException)
: base(message, innerException)
{
Path = path;
@@ -101,7 +108,7 @@ namespace Newtonsoft.Json
{
message = JsonPosition.FormatMessage(null, path, message);
- return new JsonWriterException(message, ex, path);
+ return new JsonWriterException(message, path, ex);
}
}
}
\ No newline at end of file
diff --git a/Src/Newtonsoft.Json/Linq/JsonPath/JPath.cs b/Src/Newtonsoft.Json/Linq/JsonPath/JPath.cs
index 4656fc48..0002e0d1 100644
--- a/Src/Newtonsoft.Json/Linq/JsonPath/JPath.cs
+++ b/Src/Newtonsoft.Json/Linq/JsonPath/JPath.cs
@@ -34,7 +34,7 @@ namespace Newtonsoft.Json.Linq.JsonPath
internal class JPath
{
private readonly string _expression;
- public List Filters { get; private set; }
+ public List Filters { get; }
private int _currentIndex;
diff --git a/Src/Newtonsoft.Json/Schema/JsonSchemaException.cs b/Src/Newtonsoft.Json/Schema/JsonSchemaException.cs
index bf523d29..aa5f2349 100644
--- a/Src/Newtonsoft.Json/Schema/JsonSchemaException.cs
+++ b/Src/Newtonsoft.Json/Schema/JsonSchemaException.cs
@@ -46,19 +46,19 @@ namespace Newtonsoft.Json.Schema
/// Gets the line number indicating where the error occurred.
///
/// The line number indicating where the error occurred.
- public int LineNumber { get; private set; }
+ public int LineNumber { get; }
///
/// Gets the line position indicating where the error occurred.
///
/// The line position indicating where the error occurred.
- public int LinePosition { get; private set; }
+ public int LinePosition { get; }
///
/// Gets the path to the JSON where the error occurred.
///
/// The path to the JSON where the error occurred.
- public string Path { get; private set; }
+ public string Path { get; }
///
/// Initializes a new instance of the class.
diff --git a/Src/Newtonsoft.Json/Schema/JsonSchemaGenerator.cs b/Src/Newtonsoft.Json/Schema/JsonSchemaGenerator.cs
index 0bbcc3b9..b19c7e07 100644
--- a/Src/Newtonsoft.Json/Schema/JsonSchemaGenerator.cs
+++ b/Src/Newtonsoft.Json/Schema/JsonSchemaGenerator.cs
@@ -77,8 +77,8 @@ namespace Newtonsoft.Json.Schema
private class TypeSchema
{
- public Type Type { get; private set; }
- public JsonSchema Schema { get; private set; }
+ public Type Type { get; }
+ public JsonSchema Schema { get; }
public TypeSchema(Type type, JsonSchema schema)
{
diff --git a/Src/Newtonsoft.Json/Schema/JsonSchemaNode.cs b/Src/Newtonsoft.Json/Schema/JsonSchemaNode.cs
index cbe9ba2f..4acad1f8 100644
--- a/Src/Newtonsoft.Json/Schema/JsonSchemaNode.cs
+++ b/Src/Newtonsoft.Json/Schema/JsonSchemaNode.cs
@@ -38,11 +38,11 @@ namespace Newtonsoft.Json.Schema
[Obsolete("JSON Schema validation has been moved to its own package. See http://www.newtonsoft.com/jsonschema for more details.")]
internal class JsonSchemaNode
{
- public string Id { get; private set; }
- public ReadOnlyCollection Schemas { get; private set; }
- public Dictionary Properties { get; private set; }
- public Dictionary PatternProperties { get; private set; }
- public List Items { get; private set; }
+ public string Id { get; }
+ public ReadOnlyCollection Schemas { get; }
+ public Dictionary Properties { get; }
+ public Dictionary PatternProperties { get; }
+ public List Items { get; }
public JsonSchemaNode AdditionalProperties { get; set; }
public JsonSchemaNode AdditionalItems { get; set; }
diff --git a/Src/Newtonsoft.Json/Serialization/ErrorContext.cs b/Src/Newtonsoft.Json/Serialization/ErrorContext.cs
index bcb2fbbe..366064a0 100644
--- a/Src/Newtonsoft.Json/Serialization/ErrorContext.cs
+++ b/Src/Newtonsoft.Json/Serialization/ErrorContext.cs
@@ -46,25 +46,25 @@ namespace Newtonsoft.Json.Serialization
/// Gets the error.
///
/// The error.
- public Exception Error { get; private set; }
+ public Exception Error { get; }
///
/// Gets the original object that caused the error.
///
/// The original object that caused the error.
- public object OriginalObject { get; private set; }
+ public object OriginalObject { get; }
///
/// Gets the member that caused the error.
///
/// The member that caused the error.
- public object Member { get; private set; }
+ public object Member { get; }
///
/// Gets the path of the JSON location where the error occurred.
///
/// The path of the JSON location where the error occurred.
- public string Path { get; private set; }
+ public string Path { get; }
///
/// Gets or sets a value indicating whether this is handled.
diff --git a/Src/Newtonsoft.Json/Serialization/ErrorEventArgs.cs b/Src/Newtonsoft.Json/Serialization/ErrorEventArgs.cs
index cae7d035..1b16c607 100644
--- a/Src/Newtonsoft.Json/Serialization/ErrorEventArgs.cs
+++ b/Src/Newtonsoft.Json/Serialization/ErrorEventArgs.cs
@@ -36,13 +36,13 @@ namespace Newtonsoft.Json.Serialization
/// Gets the current object the error event is being raised against.
///
/// The current object the error event is being raised against.
- public object CurrentObject { get; private set; }
+ public object CurrentObject { get; }
///
/// Gets the error context.
///
/// The error context.
- public ErrorContext ErrorContext { get; private set; }
+ public ErrorContext ErrorContext { get; }
///
/// Initializes a new instance of the class.
diff --git a/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs b/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs
index 96afac5b..c5ab7176 100644
--- a/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs
+++ b/Src/Newtonsoft.Json/Serialization/JsonArrayContract.cs
@@ -49,13 +49,13 @@ namespace Newtonsoft.Json.Serialization
/// Gets the of the collection items.
///
/// The of the collection items.
- public Type CollectionItemType { get; private set; }
+ public Type CollectionItemType { get; }
///
/// Gets a value indicating whether the collection type is a multidimensional array.
///
/// true if the collection type is a multidimensional array; otherwise, false.
- public bool IsMultidimensionalArray { get; private set; }
+ public bool IsMultidimensionalArray { get; }
private readonly Type _genericCollectionDefinitionType;
@@ -63,8 +63,8 @@ namespace Newtonsoft.Json.Serialization
private ObjectConstructor