S3925 - Can't understand how to fix the issue

Please provide

  • Operating system: Windows 10 - Visual Studio 2019
  • SonarLint plugin version: 6.7.0.52071
  • Is connected to SonarQube: 9.6.0.59041

And a thorough description of the problem / question:

I have this class:

[Serializable]
public class Options: Dictionary<CustomerOptions, string> {

        public Options(): base() {
        }

        public Options(SerializationInfo info, StreamingContext context) : base(info, context) { }
}

where CustomerOptions is an enumerator but the same warning is given with a Dictionary<string, string>

I did everything to make the class Options compliant to the documentation of S3925 warning but I wasn’t able to.

It seems all ok for me.

Can you provide some advice how to take care of this warning?

Thank you

Mirko

Finally got it

The overload with SerializationInfo must be marked as protected instead of public

Glad you sorted it out. We agree that the issue message could be clearer – you can track this issue: Improve S3925 message to be clear about expected action. · Issue #4993 · SonarSource/sonar-dotnet · GitHub