I have a custom Exception:
namespace BO.Application.Shared.Errors;
using System;
using System.Globalization;
using System.Runtime.Serialization;
[Serializable]
public class NullReferenceException : System.NullReferenceException
{
private const string ErrorMessage = "VariableNotSet:{0}";
public NullReferenceException()
{
}
public NullReferenceException(string message, System.Exception innerException) : base(message, innerException)
{
}
public NullReferenceException(string name) : base(string.Format(CultureInfo.InvariantCulture, ErrorMessage, name))
{
}
protected NullReferenceException(SerializationInfo info, StreamingContext context)
#pragma warning disable SYSLIB0051 // Type or member is obsolete
Do not suppress issues.
: base(info, context)
#pragma warning restore SYSLIB0051 // Type or member is obsolete
{
}
}
I need the protected NullReferenceException(SerializationInfo info, StreamingContext context)
constructor to have all needed construuctors for sonar to be happy
But if I add that then the Roslyn analyzer is not happy since I Use .Net 8
and this is depricated
Witch in turn also shows up in sonar.
If I mark the constructor as depricated Sonar tels me to remove depricated code
IF I suppress the Roslyn message it Sonar tels me not to suppres issiues
Is there any way to make that compliant without disabling the rule in sonar?