diff --git a/Src/Newtonsoft.Json/JsonConverter.cs b/Src/Newtonsoft.Json/JsonConverter.cs
index 457291d8..3735844f 100644
--- a/Src/Newtonsoft.Json/JsonConverter.cs
+++ b/Src/Newtonsoft.Json/JsonConverter.cs
@@ -24,10 +24,7 @@
#endregion
using System;
-using System.Collections.Generic;
-using System.Text;
using Newtonsoft.Json.Utilities;
-using Newtonsoft.Json.Schema;
using System.Globalization;
namespace Newtonsoft.Json
diff --git a/Src/Newtonsoft.Json/JsonSerializer.cs b/Src/Newtonsoft.Json/JsonSerializer.cs
index 45925c45..c4c506ce 100644
--- a/Src/Newtonsoft.Json/JsonSerializer.cs
+++ b/Src/Newtonsoft.Json/JsonSerializer.cs
@@ -86,7 +86,7 @@ namespace Newtonsoft.Json
///
public virtual IReferenceResolver ReferenceResolver
{
- get { return GetReferenceResolver(); }
+ get => GetReferenceResolver();
set
{
if (value == null)
@@ -116,8 +116,7 @@ namespace Newtonsoft.Json
return legacySerializationBinder;
}
- SerializationBinderAdapter adapter = _serializationBinder as SerializationBinderAdapter;
- if (adapter != null)
+ if (_serializationBinder is SerializationBinderAdapter adapter)
{
return adapter.SerializationBinder;
}
@@ -140,7 +139,7 @@ namespace Newtonsoft.Json
///
public virtual ISerializationBinder SerializationBinder
{
- get { return _serializationBinder; }
+ get => _serializationBinder;
set
{
if (value == null)
@@ -158,8 +157,8 @@ namespace Newtonsoft.Json
/// The trace writer.
public virtual ITraceWriter TraceWriter
{
- get { return _traceWriter; }
- set { _traceWriter = value; }
+ get => _traceWriter;
+ set => _traceWriter = value;
}
///
@@ -168,8 +167,8 @@ namespace Newtonsoft.Json
/// The equality comparer.
public virtual IEqualityComparer EqualityComparer
{
- get { return _equalityComparer; }
- set { _equalityComparer = value; }
+ get => _equalityComparer;
+ set => _equalityComparer = value;
}
///
@@ -183,7 +182,7 @@ namespace Newtonsoft.Json
///
public virtual TypeNameHandling TypeNameHandling
{
- get { return _typeNameHandling; }
+ get => _typeNameHandling;
set
{
if (value < TypeNameHandling.None || value > TypeNameHandling.Auto)
@@ -203,7 +202,7 @@ namespace Newtonsoft.Json
[Obsolete("TypeNameAssemblyFormat is obsolete. Use TypeNameAssemblyFormatHandling instead.")]
public virtual FormatterAssemblyStyle TypeNameAssemblyFormat
{
- get { return (FormatterAssemblyStyle)_typeNameAssemblyFormatHandling; }
+ get => (FormatterAssemblyStyle)_typeNameAssemblyFormatHandling;
set
{
if (value < FormatterAssemblyStyle.Simple || value > FormatterAssemblyStyle.Full)
@@ -222,7 +221,7 @@ namespace Newtonsoft.Json
/// The type name assembly format.
public virtual TypeNameAssemblyFormatHandling TypeNameAssemblyFormatHandling
{
- get { return _typeNameAssemblyFormatHandling; }
+ get => _typeNameAssemblyFormatHandling;
set
{
if (value < TypeNameAssemblyFormatHandling.Simple || value > TypeNameAssemblyFormatHandling.Full)
@@ -240,7 +239,7 @@ namespace Newtonsoft.Json
///
public virtual PreserveReferencesHandling PreserveReferencesHandling
{
- get { return _preserveReferencesHandling; }
+ get => _preserveReferencesHandling;
set
{
if (value < PreserveReferencesHandling.None || value > PreserveReferencesHandling.All)
@@ -258,7 +257,7 @@ namespace Newtonsoft.Json
///
public virtual ReferenceLoopHandling ReferenceLoopHandling
{
- get { return _referenceLoopHandling; }
+ get => _referenceLoopHandling;
set
{
if (value < ReferenceLoopHandling.Error || value > ReferenceLoopHandling.Serialize)
@@ -276,7 +275,7 @@ namespace Newtonsoft.Json
///
public virtual MissingMemberHandling MissingMemberHandling
{
- get { return _missingMemberHandling; }
+ get => _missingMemberHandling;
set
{
if (value < MissingMemberHandling.Ignore || value > MissingMemberHandling.Error)
@@ -294,7 +293,7 @@ namespace Newtonsoft.Json
///
public virtual NullValueHandling NullValueHandling
{
- get { return _nullValueHandling; }
+ get => _nullValueHandling;
set
{
if (value < NullValueHandling.Include || value > NullValueHandling.Ignore)
@@ -312,7 +311,7 @@ namespace Newtonsoft.Json
///
public virtual DefaultValueHandling DefaultValueHandling
{
- get { return _defaultValueHandling; }
+ get => _defaultValueHandling;
set
{
if (value < DefaultValueHandling.Include || value > DefaultValueHandling.IgnoreAndPopulate)
@@ -331,7 +330,7 @@ namespace Newtonsoft.Json
/// The object creation handling.
public virtual ObjectCreationHandling ObjectCreationHandling
{
- get { return _objectCreationHandling; }
+ get => _objectCreationHandling;
set
{
if (value < ObjectCreationHandling.Auto || value > ObjectCreationHandling.Replace)
@@ -350,7 +349,7 @@ namespace Newtonsoft.Json
/// The constructor handling.
public virtual ConstructorHandling ConstructorHandling
{
- get { return _constructorHandling; }
+ get => _constructorHandling;
set
{
if (value < ConstructorHandling.Default || value > ConstructorHandling.AllowNonPublicDefaultConstructor)
@@ -369,7 +368,7 @@ namespace Newtonsoft.Json
/// The metadata properties handling.
public virtual MetadataPropertyHandling MetadataPropertyHandling
{
- get { return _metadataPropertyHandling; }
+ get => _metadataPropertyHandling;
set
{
if (value < MetadataPropertyHandling.Default || value > MetadataPropertyHandling.Ignore)
@@ -404,8 +403,8 @@ namespace Newtonsoft.Json
///
public virtual IContractResolver ContractResolver
{
- get { return _contractResolver; }
- set { _contractResolver = value ?? DefaultContractResolver.Instance; }
+ get => _contractResolver;
+ set => _contractResolver = value ?? DefaultContractResolver.Instance;
}
///
@@ -414,8 +413,8 @@ namespace Newtonsoft.Json
/// The context.
public virtual StreamingContext Context
{
- get { return _context; }
- set { _context = value; }
+ get => _context;
+ set => _context = value;
}
///
@@ -424,8 +423,8 @@ namespace Newtonsoft.Json
///
public virtual Formatting Formatting
{
- get { return _formatting ?? JsonSerializerSettings.DefaultFormatting; }
- set { _formatting = value; }
+ get => _formatting ?? JsonSerializerSettings.DefaultFormatting;
+ set => _formatting = value;
}
///
@@ -434,8 +433,8 @@ namespace Newtonsoft.Json
///
public virtual DateFormatHandling DateFormatHandling
{
- get { return _dateFormatHandling ?? JsonSerializerSettings.DefaultDateFormatHandling; }
- set { _dateFormatHandling = value; }
+ get => _dateFormatHandling ?? JsonSerializerSettings.DefaultDateFormatHandling;
+ set => _dateFormatHandling = value;
}
///
@@ -444,8 +443,8 @@ namespace Newtonsoft.Json
///
public virtual DateTimeZoneHandling DateTimeZoneHandling
{
- get { return _dateTimeZoneHandling ?? JsonSerializerSettings.DefaultDateTimeZoneHandling; }
- set { _dateTimeZoneHandling = value; }
+ get => _dateTimeZoneHandling ?? JsonSerializerSettings.DefaultDateTimeZoneHandling;
+ set => _dateTimeZoneHandling = value;
}
///
@@ -454,8 +453,8 @@ namespace Newtonsoft.Json
///
public virtual DateParseHandling DateParseHandling
{
- get { return _dateParseHandling ?? JsonSerializerSettings.DefaultDateParseHandling; }
- set { _dateParseHandling = value; }
+ get => _dateParseHandling ?? JsonSerializerSettings.DefaultDateParseHandling;
+ set => _dateParseHandling = value;
}
///
@@ -464,8 +463,8 @@ namespace Newtonsoft.Json
///
public virtual FloatParseHandling FloatParseHandling
{
- get { return _floatParseHandling ?? JsonSerializerSettings.DefaultFloatParseHandling; }
- set { _floatParseHandling = value; }
+ get => _floatParseHandling ?? JsonSerializerSettings.DefaultFloatParseHandling;
+ set => _floatParseHandling = value;
}
///
@@ -476,8 +475,8 @@ namespace Newtonsoft.Json
///
public virtual FloatFormatHandling FloatFormatHandling
{
- get { return _floatFormatHandling ?? JsonSerializerSettings.DefaultFloatFormatHandling; }
- set { _floatFormatHandling = value; }
+ get => _floatFormatHandling ?? JsonSerializerSettings.DefaultFloatFormatHandling;
+ set => _floatFormatHandling = value;
}
///
@@ -486,8 +485,8 @@ namespace Newtonsoft.Json
///
public virtual StringEscapeHandling StringEscapeHandling
{
- get { return _stringEscapeHandling ?? JsonSerializerSettings.DefaultStringEscapeHandling; }
- set { _stringEscapeHandling = value; }
+ get => _stringEscapeHandling ?? JsonSerializerSettings.DefaultStringEscapeHandling;
+ set => _stringEscapeHandling = value;
}
///
@@ -497,7 +496,7 @@ namespace Newtonsoft.Json
///
public virtual string DateFormatString
{
- get { return _dateFormatString ?? JsonSerializerSettings.DefaultDateFormatString; }
+ get => _dateFormatString ?? JsonSerializerSettings.DefaultDateFormatString;
set
{
_dateFormatString = value;
@@ -511,8 +510,8 @@ namespace Newtonsoft.Json
///
public virtual CultureInfo Culture
{
- get { return _culture ?? JsonSerializerSettings.DefaultCulture; }
- set { _culture = value; }
+ get => _culture ?? JsonSerializerSettings.DefaultCulture;
+ set => _culture = value;
}
///
@@ -522,7 +521,7 @@ namespace Newtonsoft.Json
///
public virtual int? MaxDepth
{
- get { return _maxDepth; }
+ get => _maxDepth;
set
{
if (value <= 0)
@@ -544,8 +543,8 @@ namespace Newtonsoft.Json
///
public virtual bool CheckAdditionalContent
{
- get { return _checkAdditionalContent ?? JsonSerializerSettings.DefaultCheckAdditionalContent; }
- set { _checkAdditionalContent = value; }
+ get => _checkAdditionalContent ?? JsonSerializerSettings.DefaultCheckAdditionalContent;
+ set => _checkAdditionalContent = value;
}
internal bool IsCheckAdditionalContentSet()
@@ -1035,7 +1034,7 @@ namespace Newtonsoft.Json
/// The to serialize.
///
/// The type of the value being serialized.
- /// This parameter is used when is to write out the type name if the type of the value does not match.
+ /// This parameter is used when is to write out the type name if the type of the value does not match.
/// Specifying the type is optional.
///
public void Serialize(JsonWriter jsonWriter, object value, Type objectType)
diff --git a/Src/Newtonsoft.Json/JsonSerializerSettings.cs b/Src/Newtonsoft.Json/JsonSerializerSettings.cs
index 482cf7ce..b0c7a42f 100644
--- a/Src/Newtonsoft.Json/JsonSerializerSettings.cs
+++ b/Src/Newtonsoft.Json/JsonSerializerSettings.cs
@@ -93,8 +93,8 @@ namespace Newtonsoft.Json
/// Reference loop handling.
public ReferenceLoopHandling ReferenceLoopHandling
{
- get { return _referenceLoopHandling ?? DefaultReferenceLoopHandling; }
- set { _referenceLoopHandling = value; }
+ get => _referenceLoopHandling ?? DefaultReferenceLoopHandling;
+ set => _referenceLoopHandling = value;
}
///
@@ -104,8 +104,8 @@ namespace Newtonsoft.Json
/// Missing member handling.
public MissingMemberHandling MissingMemberHandling
{
- get { return _missingMemberHandling ?? DefaultMissingMemberHandling; }
- set { _missingMemberHandling = value; }
+ get => _missingMemberHandling ?? DefaultMissingMemberHandling;
+ set => _missingMemberHandling = value;
}
///
@@ -115,8 +115,8 @@ namespace Newtonsoft.Json
/// The object creation handling.
public ObjectCreationHandling ObjectCreationHandling
{
- get { return _objectCreationHandling ?? DefaultObjectCreationHandling; }
- set { _objectCreationHandling = value; }
+ get => _objectCreationHandling ?? DefaultObjectCreationHandling;
+ set => _objectCreationHandling = value;
}
///
@@ -126,8 +126,8 @@ namespace Newtonsoft.Json
/// Null value handling.
public NullValueHandling NullValueHandling
{
- get { return _nullValueHandling ?? DefaultNullValueHandling; }
- set { _nullValueHandling = value; }
+ get => _nullValueHandling ?? DefaultNullValueHandling;
+ set => _nullValueHandling = value;
}
///
@@ -137,8 +137,8 @@ namespace Newtonsoft.Json
/// The default value handling.
public DefaultValueHandling DefaultValueHandling
{
- get { return _defaultValueHandling ?? DefaultDefaultValueHandling; }
- set { _defaultValueHandling = value; }
+ get => _defaultValueHandling ?? DefaultDefaultValueHandling;
+ set => _defaultValueHandling = value;
}
///
@@ -154,8 +154,8 @@ namespace Newtonsoft.Json
/// The preserve references handling.
public PreserveReferencesHandling PreserveReferencesHandling
{
- get { return _preserveReferencesHandling ?? DefaultPreserveReferencesHandling; }
- set { _preserveReferencesHandling = value; }
+ get => _preserveReferencesHandling ?? DefaultPreserveReferencesHandling;
+ set => _preserveReferencesHandling = value;
}
///
@@ -170,8 +170,8 @@ namespace Newtonsoft.Json
/// The type name handling.
public TypeNameHandling TypeNameHandling
{
- get { return _typeNameHandling ?? DefaultTypeNameHandling; }
- set { _typeNameHandling = value; }
+ get => _typeNameHandling ?? DefaultTypeNameHandling;
+ set => _typeNameHandling = value;
}
///
@@ -181,8 +181,8 @@ namespace Newtonsoft.Json
/// The metadata properties handling.
public MetadataPropertyHandling MetadataPropertyHandling
{
- get { return _metadataPropertyHandling ?? DefaultMetadataPropertyHandling; }
- set { _metadataPropertyHandling = value; }
+ get => _metadataPropertyHandling ?? DefaultMetadataPropertyHandling;
+ set => _metadataPropertyHandling = value;
}
///
@@ -193,8 +193,8 @@ namespace Newtonsoft.Json
[Obsolete("TypeNameAssemblyFormat is obsolete. Use TypeNameAssemblyFormatHandling instead.")]
public FormatterAssemblyStyle TypeNameAssemblyFormat
{
- get { return (FormatterAssemblyStyle)TypeNameAssemblyFormatHandling; }
- set { TypeNameAssemblyFormatHandling = (TypeNameAssemblyFormatHandling)value; }
+ get => (FormatterAssemblyStyle)TypeNameAssemblyFormatHandling;
+ set => TypeNameAssemblyFormatHandling = (TypeNameAssemblyFormatHandling)value;
}
///
@@ -204,8 +204,8 @@ namespace Newtonsoft.Json
/// The type name assembly format.
public TypeNameAssemblyFormatHandling TypeNameAssemblyFormatHandling
{
- get { return _typeNameAssemblyFormatHandling ?? DefaultTypeNameAssemblyFormatHandling; }
- set { _typeNameAssemblyFormatHandling = value; }
+ get => _typeNameAssemblyFormatHandling ?? DefaultTypeNameAssemblyFormatHandling;
+ set => _typeNameAssemblyFormatHandling = value;
}
///
@@ -215,8 +215,8 @@ namespace Newtonsoft.Json
/// The constructor handling.
public ConstructorHandling ConstructorHandling
{
- get { return _constructorHandling ?? DefaultConstructorHandling; }
- set { _constructorHandling = value; }
+ get => _constructorHandling ?? DefaultConstructorHandling;
+ set => _constructorHandling = value;
}
///
@@ -239,10 +239,7 @@ namespace Newtonsoft.Json
[Obsolete("ReferenceResolver property is obsolete. Use the ReferenceResolverProvider property to set the IReferenceResolver: settings.ReferenceResolverProvider = () => resolver")]
public IReferenceResolver ReferenceResolver
{
- get
- {
- return ReferenceResolverProvider?.Invoke();
- }
+ get => ReferenceResolverProvider?.Invoke();
set
{
ReferenceResolverProvider = (value != null)
@@ -277,15 +274,14 @@ namespace Newtonsoft.Json
return null;
}
- SerializationBinderAdapter adapter = SerializationBinder as SerializationBinderAdapter;
- if (adapter != null)
+ if (SerializationBinder is SerializationBinderAdapter adapter)
{
return adapter.SerializationBinder;
}
throw new InvalidOperationException("Cannot get SerializationBinder because an ISerializationBinder was previously set.");
}
- set { SerializationBinder = value == null ? null : new SerializationBinderAdapter(value); }
+ set => SerializationBinder = value == null ? null : new SerializationBinderAdapter(value);
}
///
@@ -306,8 +302,8 @@ namespace Newtonsoft.Json
/// The context.
public StreamingContext Context
{
- get { return _context ?? DefaultContext; }
- set { _context = value; }
+ get => _context ?? DefaultContext;
+ set => _context = value;
}
///
@@ -317,7 +313,7 @@ namespace Newtonsoft.Json
///
public string DateFormatString
{
- get { return _dateFormatString ?? DefaultDateFormatString; }
+ get => _dateFormatString ?? DefaultDateFormatString;
set
{
_dateFormatString = value;
@@ -332,7 +328,7 @@ namespace Newtonsoft.Json
///
public int? MaxDepth
{
- get { return _maxDepth; }
+ get => _maxDepth;
set
{
if (value <= 0)
@@ -351,8 +347,8 @@ namespace Newtonsoft.Json
///
public Formatting Formatting
{
- get { return _formatting ?? DefaultFormatting; }
- set { _formatting = value; }
+ get => _formatting ?? DefaultFormatting;
+ set => _formatting = value;
}
///
@@ -361,8 +357,8 @@ namespace Newtonsoft.Json
///
public DateFormatHandling DateFormatHandling
{
- get { return _dateFormatHandling ?? DefaultDateFormatHandling; }
- set { _dateFormatHandling = value; }
+ get => _dateFormatHandling ?? DefaultDateFormatHandling;
+ set => _dateFormatHandling = value;
}
///
@@ -371,8 +367,8 @@ namespace Newtonsoft.Json
///
public DateTimeZoneHandling DateTimeZoneHandling
{
- get { return _dateTimeZoneHandling ?? DefaultDateTimeZoneHandling; }
- set { _dateTimeZoneHandling = value; }
+ get => _dateTimeZoneHandling ?? DefaultDateTimeZoneHandling;
+ set => _dateTimeZoneHandling = value;
}
///
@@ -381,8 +377,8 @@ namespace Newtonsoft.Json
///
public DateParseHandling DateParseHandling
{
- get { return _dateParseHandling ?? DefaultDateParseHandling; }
- set { _dateParseHandling = value; }
+ get => _dateParseHandling ?? DefaultDateParseHandling;
+ set => _dateParseHandling = value;
}
///
@@ -393,8 +389,8 @@ namespace Newtonsoft.Json
///
public FloatFormatHandling FloatFormatHandling
{
- get { return _floatFormatHandling ?? DefaultFloatFormatHandling; }
- set { _floatFormatHandling = value; }
+ get => _floatFormatHandling ?? DefaultFloatFormatHandling;
+ set => _floatFormatHandling = value;
}
///
@@ -403,8 +399,8 @@ namespace Newtonsoft.Json
///
public FloatParseHandling FloatParseHandling
{
- get { return _floatParseHandling ?? DefaultFloatParseHandling; }
- set { _floatParseHandling = value; }
+ get => _floatParseHandling ?? DefaultFloatParseHandling;
+ set => _floatParseHandling = value;
}
///
@@ -413,8 +409,8 @@ namespace Newtonsoft.Json
///
public StringEscapeHandling StringEscapeHandling
{
- get { return _stringEscapeHandling ?? DefaultStringEscapeHandling; }
- set { _stringEscapeHandling = value; }
+ get => _stringEscapeHandling ?? DefaultStringEscapeHandling;
+ set => _stringEscapeHandling = value;
}
///
@@ -423,8 +419,8 @@ namespace Newtonsoft.Json
///
public CultureInfo Culture
{
- get { return _culture ?? DefaultCulture; }
- set { _culture = value; }
+ get => _culture ?? DefaultCulture;
+ set => _culture = value;
}
///
@@ -436,8 +432,8 @@ namespace Newtonsoft.Json
///
public bool CheckAdditionalContent
{
- get { return _checkAdditionalContent ?? DefaultCheckAdditionalContent; }
- set { _checkAdditionalContent = value; }
+ get => _checkAdditionalContent ?? DefaultCheckAdditionalContent;
+ set => _checkAdditionalContent = value;
}
static JsonSerializerSettings()