Fix warnings (#3031)

This commit is contained in:
James Newton-King
2025-03-07 16:37:00 +08:00
committed by GitHub
parent c603502b95
commit bd0773b8f3
7 changed files with 13 additions and 2 deletions
@@ -192,5 +192,6 @@
<AssemblyTitle>Json.NET Tests .NET Standard 1.0</AssemblyTitle> <AssemblyTitle>Json.NET Tests .NET Standard 1.0</AssemblyTitle>
<ReferringTargetFrameworkForProjectReferences>.NETStandard,Version=v1.0</ReferringTargetFrameworkForProjectReferences> <ReferringTargetFrameworkForProjectReferences>.NETStandard,Version=v1.0</ReferringTargetFrameworkForProjectReferences>
<DefineConstants>NETSTANDARD1_0;DNXCORE50;PORTABLE;HAVE_REGEX_TIMEOUTS;$(AdditionalConstants)</DefineConstants> <DefineConstants>NETSTANDARD1_0;DNXCORE50;PORTABLE;HAVE_REGEX_TIMEOUTS;$(AdditionalConstants)</DefineConstants>
<NoWarn>$(NoWarn);NETSDK1023</NoWarn>
</PropertyGroup> </PropertyGroup>
</Project> </Project>
+2
View File
@@ -76,10 +76,12 @@ namespace Newtonsoft.Json
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param> /// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
/// <exception cref="ArgumentNullException">The <paramref name="info"/> parameter is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="info"/> parameter is <c>null</c>.</exception>
/// <exception cref="SerializationException">The class name is <c>null</c> or <see cref="Exception.HResult"/> is zero (0).</exception> /// <exception cref="SerializationException">The class name is <c>null</c> or <see cref="Exception.HResult"/> is zero (0).</exception>
#pragma warning disable SYSLIB0051
public JsonException(SerializationInfo info, StreamingContext context) public JsonException(SerializationInfo info, StreamingContext context)
: base(info, context) : base(info, context)
{ {
} }
#pragma warning restore SYSLIB0051
#endif #endif
internal static JsonException Create(IJsonLineInfo lineInfo, string path, string message) internal static JsonException Create(IJsonLineInfo lineInfo, string path, string message)
+2 -2
View File
@@ -952,12 +952,12 @@ namespace Newtonsoft.Json.Linq
} }
#if HAVE_COMPONENT_MODEL #if HAVE_COMPONENT_MODEL
string ITypedList.GetListName(PropertyDescriptor[] listAccessors) string ITypedList.GetListName(PropertyDescriptor[]? listAccessors)
{ {
return string.Empty; return string.Empty;
} }
PropertyDescriptorCollection ITypedList.GetItemProperties(PropertyDescriptor[] listAccessors) PropertyDescriptorCollection ITypedList.GetItemProperties(PropertyDescriptor[]? listAccessors)
{ {
#if HAVE_APPCONTEXT #if HAVE_APPCONTEXT
if (!ComponentModelIsSupported) if (!ComponentModelIsSupported)
@@ -33,6 +33,7 @@ using Newtonsoft.Json.Linq;
namespace Newtonsoft.Json.Serialization namespace Newtonsoft.Json.Serialization
{ {
#pragma warning disable SYSLIB0050
[RequiresUnreferencedCode(MiscellaneousUtils.TrimWarning)] [RequiresUnreferencedCode(MiscellaneousUtils.TrimWarning)]
[RequiresDynamicCode(MiscellaneousUtils.AotWarning)] [RequiresDynamicCode(MiscellaneousUtils.AotWarning)]
internal class JsonFormatterConverter : IFormatterConverter internal class JsonFormatterConverter : IFormatterConverter
@@ -155,6 +156,7 @@ namespace Newtonsoft.Json.Serialization
return GetTokenValue<ulong>(value); return GetTokenValue<ulong>(value);
} }
} }
#pragma warning restore SYSLIB0050
} }
#endif #endif
@@ -189,6 +189,7 @@ namespace Newtonsoft.Json.Serialization
#endif #endif
internal object GetUninitializedObject() internal object GetUninitializedObject()
{ {
#pragma warning disable SYSLIB0050
// we should never get here if the environment is not fully trusted, check just in case // we should never get here if the environment is not fully trusted, check just in case
if (!JsonTypeReflector.FullyTrusted) if (!JsonTypeReflector.FullyTrusted)
{ {
@@ -196,6 +197,7 @@ namespace Newtonsoft.Json.Serialization
} }
return FormatterServices.GetUninitializedObject(NonNullableUnderlyingType); return FormatterServices.GetUninitializedObject(NonNullableUnderlyingType);
#pragma warning restore SYSLIB0050
} }
#endif #endif
} }
@@ -1758,6 +1758,7 @@ namespace Newtonsoft.Json.Serialization
[RequiresDynamicCode(MiscellaneousUtils.AotWarning)] [RequiresDynamicCode(MiscellaneousUtils.AotWarning)]
private object CreateISerializable(JsonReader reader, JsonISerializableContract contract, JsonProperty? member, string? id) private object CreateISerializable(JsonReader reader, JsonISerializableContract contract, JsonProperty? member, string? id)
{ {
#pragma warning disable SYSLIB0050
Type objectType = contract.UnderlyingType; Type objectType = contract.UnderlyingType;
if (!JsonTypeReflector.FullyTrusted) if (!JsonTypeReflector.FullyTrusted)
@@ -1826,6 +1827,7 @@ namespace Newtonsoft.Json.Serialization
OnDeserialized(reader, contract, createdObject); OnDeserialized(reader, contract, createdObject);
return createdObject; return createdObject;
#pragma warning restore SYSLIB0050
} }
[RequiresUnreferencedCode(MiscellaneousUtils.TrimWarning)] [RequiresUnreferencedCode(MiscellaneousUtils.TrimWarning)]
@@ -888,6 +888,7 @@ namespace Newtonsoft.Json.Serialization
[RequiresDynamicCode(MiscellaneousUtils.AotWarning)] [RequiresDynamicCode(MiscellaneousUtils.AotWarning)]
private void SerializeISerializable(JsonWriter writer, ISerializable value, JsonISerializableContract contract, JsonProperty? member, JsonContainerContract? collectionContract, JsonProperty? containerProperty) private void SerializeISerializable(JsonWriter writer, ISerializable value, JsonISerializableContract contract, JsonProperty? member, JsonContainerContract? collectionContract, JsonProperty? containerProperty)
{ {
#pragma warning disable SYSLIB0050
if (!JsonTypeReflector.FullyTrusted) if (!JsonTypeReflector.FullyTrusted)
{ {
string message = @"Type '{0}' implements ISerializable but cannot be serialized using the ISerializable interface because the current application is not fully trusted and ISerializable can expose secure data." + Environment.NewLine + string message = @"Type '{0}' implements ISerializable but cannot be serialized using the ISerializable interface because the current application is not fully trusted and ISerializable can expose secure data." + Environment.NewLine +
@@ -925,6 +926,7 @@ namespace Newtonsoft.Json.Serialization
_serializeStack.RemoveAt(_serializeStack.Count - 1); _serializeStack.RemoveAt(_serializeStack.Count - 1);
OnSerialized(writer, contract, value); OnSerialized(writer, contract, value);
#pragma warning restore SYSLIB0050
} }
#endif #endif