static string MakeDllImportArguments(string entryPoint, System.Runtime.InteropServices.CharSet charSet,
                                             bool setLastError, bool exactSpelling, bool preserveSig,
                                             System.Runtime.InteropServices.CallingConvention callingConvention,
                                             bool bestFitMapping, bool throwOnUnmappableChar)
        {
            var retval = new StringBuilder();

            if (!String.IsNullOrWhiteSpace(entryPoint))
            {
                retval.Append(", EntryPoint=\"" + entryPoint + '"');
            }
            if (charSet != DefaultDllImportAttribute.CharSet)
            {
                retval.Append(", CharSet = System.Runtime.InteropServices.CharSet." + charSet.ToString());
            }

            MakeDllImportArgument(retval, "SetLastError", setLastError, DefaultDllImportAttribute.SetLastError);
            MakeDllImportArgument(retval, "ExactSpelling", exactSpelling, DefaultDllImportAttribute.ExactSpelling);
            MakeDllImportArgument(retval, "PreserveSig", preserveSig, DefaultDllImportAttribute.PreserveSig);

            if (callingConvention != DefaultDllImportAttribute.CallingConvention)
            {
                retval.Append(", CallingConvention=" + callingConvention.ToString());
            }

            MakeDllImportArgument(retval, "BestFitMapping", bestFitMapping, DefaultDllImportAttribute.BestFitMapping);
            MakeDllImportArgument(retval, "ThrowOnUnmappableChar", throwOnUnmappableChar, DefaultDllImportAttribute.ThrowOnUnmappableChar);

            return(retval.ToString());
        }