using System;
using System.Runtime.Serialization;
using System.Security.Permissions;

namespace Sasa.QualityTools.DrFx.Tests.Violation.CSharp.Microsoft.Usage
{
    [Serializable]
    public class Rule2236 : Rule2236A, ISerializable
    {
        public Rule2236()
        {
        }

        // このコンストラクタは CA2236 に違反しています。
        protected Rule2236(SerializationInfo info, StreamingContext context)
            : base()
        {
        }

        // このメソッドは CA2236 に違反しています。
        [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
        protected override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
        }

        [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
        void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
        {
            GetObjectData(info, context);
        }
    }

    [Serializable]
    public class Rule2236A : ISerializable
    {
        public Rule2236A()
        {
        }

        protected Rule2236A(SerializationInfo info, StreamingContext context)
        {
        }

        [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
        protected virtual void GetObjectData(SerializationInfo info, StreamingContext context)
        {
        }

        [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
        void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
        {
            GetObjectData(info, context);
        }
    }
}
