Skip to content

Commit

Permalink
SWEEP: Marked all serialization constructors and GetObjectData() meth…
Browse files Browse the repository at this point in the history
…ods obsolete and hidden from the IDE. Also suppressed related build warnings, since we are doing this on all target frameworks. (fixes #983)
  • Loading branch information
NightOwl888 committed Oct 23, 2024
1 parent a5310b8 commit a2a3c3e
Show file tree
Hide file tree
Showing 65 changed files with 273 additions and 30 deletions.
4 changes: 4 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

<Import Project=".build/dependencies.props" Condition="Exists('.build/dependencies.props')" />

<PropertyGroup Label="Warnings to be Disabled in Solution">
<NoWarn Label="Legacy serialization support APIs are obsolete">$(NoWarn);SYSLIB0051</NoWarn>
</PropertyGroup>

<PropertyGroup Label="Solution-level Publish to Project-specific Directory">
<PublishDir Condition="'$(AlternatePublishRootDirectory)' != ''">$(AlternatePublishRootDirectory)/$(TargetFramework)/$(MSBuildProjectName)/</PublishDir>
</PropertyGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/Lucene.Net.Benchmark/ByTask/Feeds/NoMoreDataException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;

#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif

Expand Down Expand Up @@ -43,6 +45,8 @@ public NoMoreDataException()
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected NoMoreDataException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand Down
8 changes: 8 additions & 0 deletions src/Lucene.Net.Benchmark/Support/Sax/SAXException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
// $Id: SAXException.java,v 1.7 2002/01/30 21:13:48 dbrownell Exp $

using System;

#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif
#if FEATURE_CODE_ACCESS_SECURITY
Expand Down Expand Up @@ -98,6 +100,8 @@ public SAXException(string message, Exception e)
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected SAXException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand All @@ -107,7 +111,11 @@ protected SAXException(SerializationInfo info, StreamingContext context)
#if FEATURE_CODE_ACCESS_SECURITY
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
#endif
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override void GetObjectData(SerializationInfo info, StreamingContext context)
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member
{
base.GetObjectData(info, context);
info.AddValue("Exception", exception, typeof(Exception));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

using System;
#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif

Expand Down Expand Up @@ -58,6 +59,8 @@ public SAXNotRecognizedException(string message)
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected SAXNotRecognizedException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

using System;
#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif

Expand Down Expand Up @@ -59,6 +60,8 @@ public SAXNotSupportedException(string message)
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected SAXNotSupportedException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand Down
7 changes: 7 additions & 0 deletions src/Lucene.Net.Benchmark/Support/Sax/SAXParseException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System;
#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif
#if FEATURE_CODE_ACCESS_SECURITY
Expand Down Expand Up @@ -170,6 +171,8 @@ internal SAXParseException(string message)
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected SAXParseException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand All @@ -182,7 +185,11 @@ protected SAXParseException(SerializationInfo info, StreamingContext context)
#if FEATURE_CODE_ACCESS_SECURITY
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
#endif
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override void GetObjectData(SerializationInfo info, StreamingContext context)
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member
{
base.GetObjectData(info, context);
info.AddValue("publicId", publicId, typeof(string));
Expand Down
3 changes: 0 additions & 3 deletions src/Lucene.Net.Expressions/JS/JavascriptLexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
// ANTLR GENERATED CODE: DO NOT EDIT (LUCENENET: Not really auto generated in the port)

using System;
#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.Runtime.Serialization;
#endif
using Antlr.Runtime;
using J2N.Text;
using Lucene.Net.Support;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif

Expand Down Expand Up @@ -50,10 +51,12 @@ public InvalidTokenOffsetsException(string message, Exception inner) : base(mess
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected InvalidTokenOffsetsException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Lucene.Net.Util.Mutable;
using System;
#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif

Expand Down Expand Up @@ -185,11 +186,13 @@ internal DocTermsIndexException(string message)
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
private DocTermsIndexException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
#endif
}
}
}
}
9 changes: 8 additions & 1 deletion src/Lucene.Net.QueryParser/Classic/ParseException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif
#if FEATURE_CODE_ACCESS_SECURITY
Expand Down Expand Up @@ -87,6 +88,8 @@ public ParseException(string message, Exception innerException)
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected ParseException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand All @@ -98,7 +101,11 @@ protected ParseException(SerializationInfo info, StreamingContext context)
#if FEATURE_CODE_ACCESS_SECURITY
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
#endif
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override void GetObjectData(SerializationInfo info, StreamingContext context)
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member
{
base.GetObjectData(info, context);
info.AddValue("CurrentToken", CurrentToken, typeof(Token));
Expand Down Expand Up @@ -265,4 +272,4 @@ internal static string AddEscapes(string str)
return retval.ToString();
}
}
}
}
5 changes: 4 additions & 1 deletion src/Lucene.Net.QueryParser/Classic/QueryParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.IO;
#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif
using JCG = J2N.Collections.Generic;
Expand Down Expand Up @@ -731,6 +732,8 @@ public LookaheadSuccess()
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public LookaheadSuccess(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand Down Expand Up @@ -961,4 +964,4 @@ internal sealed class JJCalls
internal JJCalls next;
}
}
}
}
3 changes: 3 additions & 0 deletions src/Lucene.Net.QueryParser/Classic/QueryParserBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Globalization;
using System.IO;
#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif
using System.Text;
Expand Down Expand Up @@ -73,6 +74,8 @@ public MethodRemovedUseAnother()
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected MethodRemovedUseAnother(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand Down
9 changes: 8 additions & 1 deletion src/Lucene.Net.QueryParser/Classic/TokenMgrError.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif
#if FEATURE_CODE_ACCESS_SECURITY
Expand Down Expand Up @@ -180,6 +181,8 @@ public TokenMgrError(bool eofSeen, int lexState, int errorLine, int errorColumn,
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected TokenMgrError(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand All @@ -189,11 +192,15 @@ protected TokenMgrError(SerializationInfo info, StreamingContext context)
#if FEATURE_CODE_ACCESS_SECURITY
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
#endif
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override void GetObjectData(SerializationInfo info, StreamingContext context)
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member
{
base.GetObjectData(info, context);
info.AddValue("errorCode", errorCode, typeof(int));
}
#endif
}
}
}
3 changes: 3 additions & 0 deletions src/Lucene.Net.QueryParser/Flexible/Core/QueryNodeError.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif
#nullable enable
Expand Down Expand Up @@ -103,6 +104,8 @@ public QueryNodeError(string? message, Exception? innerException)
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected QueryNodeError(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif
#nullable enable
Expand Down Expand Up @@ -76,6 +77,8 @@ public QueryNodeException(string? message, Exception? innerException)
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected QueryNodeException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif
#if FEATURE_CODE_ACCESS_SECURITY
Expand Down Expand Up @@ -82,6 +83,8 @@ public QueryNodeParseException(string? message, Exception? innerException)
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected QueryNodeParseException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand All @@ -94,7 +97,11 @@ protected QueryNodeParseException(SerializationInfo info, StreamingContext conte
#if FEATURE_CODE_ACCESS_SECURITY
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
#endif
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override void GetObjectData(SerializationInfo info, StreamingContext context)
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member
{
base.GetObjectData(info, context);
info.AddValue("query", query, typeof(string));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#if FEATURE_SERIALIZABLE_EXCEPTIONS
using System.ComponentModel;
using System.Runtime.Serialization;
#endif
#if FEATURE_CODE_ACCESS_SECURITY
Expand Down Expand Up @@ -102,6 +103,8 @@ public ParseException(string? message, Exception? innerException)
/// </summary>
/// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext"/> that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected ParseException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand All @@ -113,7 +116,11 @@ protected ParseException(SerializationInfo info, StreamingContext context)
#if FEATURE_CODE_ACCESS_SECURITY
[SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
#endif
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.")]
[EditorBrowsable(EditorBrowsableState.Never)]
#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member
public override void GetObjectData(SerializationInfo info, StreamingContext context)
#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member
{
base.GetObjectData(info, context);
info.AddValue("CurrentToken", CurrentToken, typeof(Token));
Expand Down
Loading

0 comments on commit a2a3c3e

Please sign in to comment.