1
0

Adding support for .NET 8.0 LTS, renaming private fields to start with underscore

This commit is contained in:
2023-12-29 01:58:40 +01:00
parent 8bd511a936
commit 99d3f7758a
59 changed files with 922 additions and 871 deletions

View File

@@ -17,7 +17,7 @@ namespace Newtonsoft.Json
/// <summary>
/// Common JSON serializer settings.
/// </summary>
private static readonly JsonSerializerSettings jsonSerializerSettings = new()
private static readonly JsonSerializerSettings _jsonSerializerSettings = new()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
Culture = CultureInfo.InvariantCulture
@@ -32,7 +32,7 @@ namespace Newtonsoft.Json
public static void DeserializeJson<T>(this T target, string json)
{
if (!string.IsNullOrWhiteSpace(json))
JsonConvert.PopulateObject(json, target, jsonSerializerSettings);
JsonConvert.PopulateObject(json, target, _jsonSerializerSettings);
}
/// <summary>
@@ -42,7 +42,7 @@ namespace Newtonsoft.Json
/// <param name="json">The JSON string to read the values from.</param>
/// <returns>A new instance of <typeparamref name="T"/> with the deserialized values.</returns>
public static T DeserializeJson<T>(this string json)
=> JsonConvert.DeserializeObject<T>(json, jsonSerializerSettings);
=> JsonConvert.DeserializeObject<T>(json, _jsonSerializerSettings);
/// <summary>
/// Deserializes a JSON string into a new instance or using the fallback value.
@@ -55,7 +55,7 @@ namespace Newtonsoft.Json
{
try
{
return JsonConvert.DeserializeObject<T>(json, jsonSerializerSettings);
return JsonConvert.DeserializeObject<T>(json, _jsonSerializerSettings);
}
catch
{
@@ -83,7 +83,7 @@ namespace Newtonsoft.Json
jw.QuoteChar = '\'';
jw.Formatting = indented ? Formatting.Indented : Formatting.None;
var serializer = useCamelCase ? JsonSerializer.Create(jsonSerializerSettings) : JsonSerializer.CreateDefault();
var serializer = useCamelCase ? JsonSerializer.Create(_jsonSerializerSettings) : JsonSerializer.CreateDefault();
serializer.Error += (s, a) =>
{
@@ -107,7 +107,7 @@ namespace Newtonsoft.Json
if (obj == null)
return null;
var serializer = JsonSerializer.Create(jsonSerializerSettings);
var serializer = JsonSerializer.Create(_jsonSerializerSettings);
return JObject.FromObject(obj, serializer);
}
@@ -121,7 +121,7 @@ namespace Newtonsoft.Json
if (array == null)
return null;
var serializer = JsonSerializer.Create(jsonSerializerSettings);
var serializer = JsonSerializer.Create(_jsonSerializerSettings);
return JArray.FromObject(array, serializer);
}

View File

@@ -58,30 +58,30 @@
private struct DisposableReadWriteLock : IDisposable
{
private readonly ReaderWriterLockSlim rwLock;
private LockMode lockMode;
private readonly ReaderWriterLockSlim _rwLock;
private LockMode _lockMode;
public DisposableReadWriteLock(ReaderWriterLockSlim rwLock, LockMode lockMode)
{
this.rwLock = rwLock;
this.lockMode = lockMode;
_rwLock = rwLock;
_lockMode = lockMode;
}
public void Dispose()
{
if (lockMode == LockMode.Read)
rwLock.ExitReadLock();
if (_lockMode == LockMode.Read)
_rwLock.ExitReadLock();
if (lockMode == LockMode.Upgradable && rwLock.IsWriteLockHeld) // Upgraded with EnterWriteLock alone
rwLock.ExitWriteLock();
if (_lockMode == LockMode.Upgradable && _rwLock.IsWriteLockHeld) // Upgraded with EnterWriteLock alone
_rwLock.ExitWriteLock();
if (lockMode == LockMode.Upgradable)
rwLock.ExitUpgradeableReadLock();
if (_lockMode == LockMode.Upgradable)
_rwLock.ExitUpgradeableReadLock();
if (lockMode == LockMode.Write)
rwLock.ExitWriteLock();
if (_lockMode == LockMode.Write)
_rwLock.ExitWriteLock();
lockMode = LockMode.None;
_lockMode = LockMode.None;
}
}

View File

@@ -177,10 +177,7 @@ namespace System
if (isValid && nameservers?.Any() == true)
{
var dnsClientType = Type.GetType("DNS.Client.DnsClient, DNS");
if (dnsClientType == null)
throw new DllNotFoundException("The DNS NuGet package is required: https://www.nuget.org/packages/DNS/7.0.0");
var dnsClientType = Type.GetType("DNS.Client.DnsClient, DNS") ?? throw new DllNotFoundException("The DNS NuGet package is required: https://www.nuget.org/packages/DNS/7.0.0");
var recordTypeType = Type.GetType("DNS.Protocol.RecordType, DNS");
var resolveMethodInfo = dnsClientType.GetMethod("Resolve", new[] { typeof(string), recordTypeType, typeof(CancellationToken) });