// I can't write violation code for CA2101:Field.
// I can't write violation code for CA2101:FieldImplicitAnsi.

using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;

namespace Sasa.QualityTools.DrFx.Tests.Violation.CSharp.Microsoft.Globalization
{
    public static class Rule2101A
    {
        public static int Register(IntPtr key, string subkey, IntPtr result)
        {
            return RegCreateKey(key, subkey, out result);
        }

        public static IntPtr GetWindow(string className, string windowName)
        {
            return FindWindow(className, windowName);
        }

        // このメソッドは CA2101:Parameter に違反しています。
        [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
        [DllImport("advapi32.dll", CharSet = CharSet.Auto)]
        private static extern int RegCreateKey(IntPtr key, String subKey, out IntPtr result);

        // このメソッドは CA2101:ParameterImplicitAnsi に違反しています。
        [SuppressMessage("Microsoft.Design", "CA1060:MovePInvokesToNativeMethodsClass")]
        [DllImport("user32.dll")]
        private static extern IntPtr FindWindow(string lpClassName, [MarshalAs(UnmanagedType.LPWStr)] string lpWindowName);
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
    public class Rule2101B : MarshalByRefObject
    {
        private string value;

        public override string ToString()
        {
            return this.value;
        }
    }
}
