Improve allocations in WinForms startup (dotnet/corefx#39275)
authorJeremy Kuhne <jkuhne@microsoft.com>
Mon, 15 Jul 2019 22:19:17 +0000 (15:19 -0700)
committerGitHub <noreply@github.com>
Mon, 15 Jul 2019 22:19:17 +0000 (15:19 -0700)
* Strip out delegate API calls and use the SetDllImportResolver functionality instead.

* Fix the Unix buidl

* Fix NetFX build, create class for custom resolving

* Fix namespace, tweak comments in project file

* Tweak LibraryResolver per feedback

* Fix  breaks

* Adjust tests for NetFX behavior

* Harvest downlevel packages

* Put back UAP build, respond to feedback on projects and LOGFONT marking

* Remove local

* Tweak FileNotFoundException, guard in PageSettings

* Address feedback

Change LOGFONT round tripping to allow structs

* Fix hintpath. Finish fixing LOGFONT references.

* Address feedback

Commit migrated from https://github.com/dotnet/corefx/commit/b75421a0035bf3a44e1f68447255470d57074dbb

50 files changed:
src/libraries/System.Drawing.Common/System.Drawing.Common.sln
src/libraries/System.Drawing.Common/pkg/System.Drawing.Common.pkgproj
src/libraries/System.Drawing.Common/ref/Configurations.props
src/libraries/System.Drawing.Common/ref/System.Drawing.Common.csproj
src/libraries/System.Drawing.Common/ref/System.Drawing.Common.netstandard.cs [deleted file]
src/libraries/System.Drawing.Common/src/Configurations.props
src/libraries/System.Drawing.Common/src/System.Drawing.Common.csproj
src/libraries/System.Drawing.Common/src/System/Drawing/Brush.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPath.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPath.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPathIterator.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/Matrix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/SafeCustomLineCapHandle.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Font.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Font.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Font.cs
src/libraries/System.Drawing.Common/src/System/Drawing/FontFamily.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Gdiplus.cs
src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Icon.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Image.Unix.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Image.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageAttributes.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Internal/GPStream.cs
src/libraries/System.Drawing.Common/src/System/Drawing/LibraryResolver.cs [new file with mode: 0644]
src/libraries/System.Drawing.Common/src/System/Drawing/NativeMethods.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Pen.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Printing/LibcupsNative.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Region.cs
src/libraries/System.Drawing.Common/src/System/Drawing/ScreenDC.cs [new file with mode: 0644]
src/libraries/System.Drawing.Common/src/System/Drawing/StringFormat.cs
src/libraries/System.Drawing.Common/src/System/Drawing/SystemFonts.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/SystemIcons.Windows.cs
src/libraries/System.Drawing.Common/src/System/Drawing/Text/PrivateFontCollection.cs
src/libraries/System.Drawing.Common/src/System/Drawing/UnsafeNativeMethods.cs
src/libraries/System.Drawing.Common/src/misc/DebugHandleTracker.cs [deleted file]
src/libraries/System.Drawing.Common/src/misc/GDI/DeviceContext.cs
src/libraries/System.Drawing.Common/src/misc/GDI/SafeNativeMethods.cs
src/libraries/System.Drawing.Common/src/misc/GDI/UnsafeNativeMethods.cs
src/libraries/System.Drawing.Common/src/misc/GDI/WindowsRegion.cs
src/libraries/System.Drawing.Common/src/misc/HandleCollector.cs [deleted file]
src/libraries/System.Drawing.Common/src/misc/InvalidEnumArgumentException.cs [deleted file]
src/libraries/System.Drawing.Common/tests/FontTests.cs
src/libraries/System.Drawing.Common/tests/IconTests.cs
src/libraries/System.Drawing.Common/tests/Printing/PrintDocumentTests.cs

index cbbbebd..a3d9e63 100644 (file)
@@ -1,6 +1,6 @@
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27213.1
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29102.190
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common.Tests", "tests\System.Drawing.Common.Tests.csproj", "{4B93E684-0630-45F4-8F63-6C7788C9892F}"
        ProjectSection(ProjectDependencies) = postProject
index d240caf..2b47015 100644 (file)
@@ -2,11 +2,13 @@
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.props))\Directory.Build.props" />
   <ItemGroup>
     <ProjectReference Include="..\ref\System.Drawing.Common.csproj">
-      <SupportedFramework>uap10.0.16299;net461;netcoreapp2.0;$(AllXamarinFrameworks)</SupportedFramework>
+      <SupportedFramework>netcoreapp3.0</SupportedFramework>
     </ProjectReference>
     <ProjectReference Include="..\src\System.Drawing.Common.csproj" />
-
+    <HarvestIncludePaths Include="runtimes/win/lib/netcoreapp2.0;runtimes/unix/lib/netcoreapp2.0" />
+    <HarvestIncludePaths Include="ref/netstandard2.0;lib/netstandard2.0" />
+    <HarvestIncludePaths Include="ref/net461;lib/net461" />
     <InboxOnTargetFramework Include="$(AllXamarinFrameworks)" />
   </ItemGroup>
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" />
-</Project>
\ No newline at end of file
+</Project>
index 09e9a4a..2b2323d 100644 (file)
@@ -1,14 +1,8 @@
 <Project>
   <PropertyGroup>
-    <PackageConfigurations>
+    <BuildConfigurations>
       netcoreapp;
-      netstandard;
-      net461;
       uap;
-    </PackageConfigurations>
-    <BuildConfigurations>
-      $(PackageConfigurations);
-      netfx;
     </BuildConfigurations>
   </PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
index 8f2831d..ea8dc24 100644 (file)
@@ -1,19 +1,13 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <ProjectGuid>{D7AEA698-275D-441F-B7A7-8491D1F0EFF0}</ProjectGuid>
-    <IsPartialFacadeAssembly Condition="'$(TargetsNetFx)' == 'true'">true</IsPartialFacadeAssembly>
-    <Configurations>net461-Debug;net461-Release;netcoreapp-Debug;netcoreapp-Release;netfx-Debug;netfx-Release;netstandard-Debug;netstandard-Release;uap-Debug;uap-Release</Configurations>
+    <Configurations>netcoreapp-Debug;netcoreapp-Release;uap-Debug;uap-Release</Configurations>
   </PropertyGroup>
   <ItemGroup>
     <Compile Include="System.Drawing.Common.cs" />
-  </ItemGroup>
-  <ItemGroup Condition="'$(TargetsNetFx)' == 'true' OR '$(TargetsNETStandard)' == 'true'">
-    <Compile Include="System.Drawing.Common.netstandard.cs" />
-  </ItemGroup>
-  <ItemGroup Condition="'$(TargetsNetCoreApp)' == 'true' OR '$(TargetsUap)' == 'true'">  
     <Compile Include="System.Drawing.Common.Forwards.cs" />
   </ItemGroup>
-  <ItemGroup Condition="'$(TargetsNetCoreApp)' == 'true' OR '$(TargetsUap)' == 'true'">
+  <ItemGroup>
     <ProjectReference Include="..\..\System.Collections.NonGeneric\ref\System.Collections.NonGeneric.csproj" />
     <ProjectReference Include="..\..\System.ComponentModel\ref\System.ComponentModel.csproj" />
     <ProjectReference Include="..\..\System.ComponentModel.Primitives\ref\System.ComponentModel.Primitives.csproj" />
@@ -24,9 +18,4 @@
     <ProjectReference Include="..\..\System.Runtime.Extensions\ref\System.Runtime.Extensions.csproj" />
     <ProjectReference Include="..\..\System.Runtime.InteropServices\ref\System.Runtime.InteropServices.csproj" />
   </ItemGroup>
-  <ItemGroup Condition="'$(TargetsNetFx)' == 'true'">
-    <Reference Include="mscorlib" />
-    <Reference Include="System" />
-    <Reference Include="System.Drawing" />
-  </ItemGroup>
 </Project>
\ No newline at end of file
diff --git a/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.netstandard.cs b/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.netstandard.cs
deleted file mode 100644 (file)
index 26781d2..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace System.Drawing
-{
-    public static partial class ColorTranslator
-    {
-        public static System.Drawing.Color FromHtml(string htmlColor) { throw null; }
-        public static System.Drawing.Color FromOle(int oleColor) { throw null; }
-        public static System.Drawing.Color FromWin32(int win32Color) { throw null; }
-        public static string ToHtml(System.Drawing.Color c) { throw null; }
-        public static int ToOle(System.Drawing.Color c) { throw null; }
-        public static int ToWin32(System.Drawing.Color c) { throw null; }
-    }
-    public static partial class SystemColors
-    {
-        public static System.Drawing.Color ActiveBorder { get { throw null; } }
-        public static System.Drawing.Color ActiveCaption { get { throw null; } }
-        public static System.Drawing.Color ActiveCaptionText { get { throw null; } }
-        public static System.Drawing.Color AppWorkspace { get { throw null; } }
-        public static System.Drawing.Color ButtonFace { get { throw null; } }
-        public static System.Drawing.Color ButtonHighlight { get { throw null; } }
-        public static System.Drawing.Color ButtonShadow { get { throw null; } }
-        public static System.Drawing.Color Control { get { throw null; } }
-        public static System.Drawing.Color ControlDark { get { throw null; } }
-        public static System.Drawing.Color ControlDarkDark { get { throw null; } }
-        public static System.Drawing.Color ControlLight { get { throw null; } }
-        public static System.Drawing.Color ControlLightLight { get { throw null; } }
-        public static System.Drawing.Color ControlText { get { throw null; } }
-        public static System.Drawing.Color Desktop { get { throw null; } }
-        public static System.Drawing.Color GradientActiveCaption { get { throw null; } }
-        public static System.Drawing.Color GradientInactiveCaption { get { throw null; } }
-        public static System.Drawing.Color GrayText { get { throw null; } }
-        public static System.Drawing.Color Highlight { get { throw null; } }
-        public static System.Drawing.Color HighlightText { get { throw null; } }
-        public static System.Drawing.Color HotTrack { get { throw null; } }
-        public static System.Drawing.Color InactiveBorder { get { throw null; } }
-        public static System.Drawing.Color InactiveCaption { get { throw null; } }
-        public static System.Drawing.Color InactiveCaptionText { get { throw null; } }
-        public static System.Drawing.Color Info { get { throw null; } }
-        public static System.Drawing.Color InfoText { get { throw null; } }
-        public static System.Drawing.Color Menu { get { throw null; } }
-        public static System.Drawing.Color MenuBar { get { throw null; } }
-        public static System.Drawing.Color MenuHighlight { get { throw null; } }
-        public static System.Drawing.Color MenuText { get { throw null; } }
-        public static System.Drawing.Color ScrollBar { get { throw null; } }
-        public static System.Drawing.Color Window { get { throw null; } }
-        public static System.Drawing.Color WindowFrame { get { throw null; } }
-        public static System.Drawing.Color WindowText { get { throw null; } }
-    }
-}
\ No newline at end of file
index 42c8516..e2ac689 100644 (file)
@@ -1,17 +1,9 @@
 <Project>
   <PropertyGroup>
-    <PackageConfigurations>
-      netcoreapp2.0-Windows_NT;
-      netcoreapp2.0-Unix;
+    <BuildConfigurations>
       netcoreapp-Windows_NT;
       netcoreapp-Unix;
-      net461;
-      netstandard;
       uap;
-    </PackageConfigurations>
-    <BuildConfigurations>
-      $(PackageConfigurations);
-      netfx;
     </BuildConfigurations>
   </PropertyGroup>
 </Project>
index ed383d8..ca1a267 100644 (file)
@@ -7,12 +7,12 @@
     <WarningsNotAsErrors>CS0618</WarningsNotAsErrors>
     <DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
     <DefineConstants Condition="'$(TargetsWindows)' == 'true'">$(DefineConstants);FEATURE_WINDOWS_SYSTEM_COLORS;FEATURE_SYSTEM_EVENTS</DefineConstants>
-    <IsPartialFacadeAssembly Condition="'$(TargetsNetFx)' == 'true' OR '$(TargetGroup)' == 'netcoreapp' OR '$(TargetsUap)' == 'true'">true</IsPartialFacadeAssembly>
-    <GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetGroup)' == 'netstandard' OR '$(TargetsUap)' == 'true'">SR.PlatformNotSupported_Drawing</GeneratePlatformNotSupportedAssemblyMessage>
-    <Configurations>net461-Debug;net461-Release;netcoreapp-Unix-Debug;netcoreapp-Unix-Release;netcoreapp-Windows_NT-Debug;netcoreapp-Windows_NT-Release;netcoreapp2.0-Unix-Debug;netcoreapp2.0-Unix-Release;netcoreapp2.0-Windows_NT-Debug;netcoreapp2.0-Windows_NT-Release;netfx-Debug;netfx-Release;netstandard-Debug;netstandard-Release;uap-Debug;uap-Release</Configurations>
+    <IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
+    <GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetsUap)' == 'true'">SR.PlatformNotSupported_Drawing</GeneratePlatformNotSupportedAssemblyMessage>
+    <Configurations>netcoreapp-Unix-Debug;netcoreapp-Unix-Release;netcoreapp-Windows_NT-Debug;netcoreapp-Windows_NT-Release;uap-Debug;uap-Release</Configurations>
   </PropertyGroup>
+  <!-- Shared source code, all configurations -->
   <ItemGroup Condition="$(TargetGroup.StartsWith('netcoreapp'))">
-    <!-- Shared source code, all configurations -->
     <Compile Include="System\Drawing\Bitmap.cs" />
     <Compile Include="System\Drawing\BitmapSuffixInSameAssemblyAttribute.cs" />
     <Compile Include="System\Drawing\BitmapSuffixInSatelliteAssemblyAttribute.cs" />
     <Compile Include="System\Drawing\Text\PrivateFontCollection.cs" />
     <Compile Include="System\Drawing\ClientUtils.cs" />
     <Compile Include="misc\CompModSwitches.cs" />
-    <Compile Include="misc\DebugHandleTracker.cs" />
-    <Compile Include="misc\HandleCollector.cs" />
     <Compile Include="System\Drawing\Gdiplus.cs" />
     <Compile Include="System\Drawing\NativeMethods.cs" />
     <Compile Include="System\Drawing\UnsafeNativeMethods.cs" />
     <Compile Include="System\Drawing\Brush.cs" />
     <Compile Include="System\Drawing\Font.cs" />
     <Compile Include="System\Drawing\FontFamily.cs" />
+    <Compile Include="System\Drawing\ScreenDC.cs" />
     <Compile Include="System\Drawing\SolidBrush.cs" />
     <Compile Include="System\Drawing\SystemBrushes.cs" />
     <Compile Include="System\Drawing\TextureBrush.cs" />
     <Compile Condition="'$(TargetGroup)' == 'netcoreapp2.0'" Include="$(CommonPath)\System\Drawing\KnownColorTable.cs">
       <Link>System\Drawing\KnownColorTable.cs</Link>
     </Compile>
-    <Compile Include="$(CommonPath)\System\Runtime\InteropServices\FunctionWrapper.cs">
-      <Link>Common\System\Runtime\InteropServices\FunctionWrapper.cs</Link>
-    </Compile>
     <EmbeddedResource Include="Resources\System\Drawing\DefaultComponent.bmp">
       <LogicalName>System.Drawing.DefaultComponent.bmp</LogicalName>
     </EmbeddedResource>
       <LogicalName>System.Drawing.ShieldIcon.ico</LogicalName>
     </EmbeddedResource>
   </ItemGroup>
-  <ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp2.0'">
-    <Compile Include="misc\InvalidEnumArgumentException.cs" />
-    <Compile Include="$(CommonPath)\System\Drawing\KnownColor.cs">
-      <Link>System\Drawing\KnownColor.cs</Link>
-    </Compile>
-    <Compile Include="$(CommonPath)\System\Drawing\SystemColors.cs">
-      <Link>System\Drawing\SystemColors.cs</Link>
-    </Compile>
-  </ItemGroup>
+  <!-- Windows-specific -->
   <ItemGroup Condition="$(TargetGroup.StartsWith('netcoreapp')) AND '$(TargetsWindows)' == 'true'">
-    <!-- Windows-specific -->
     <Compile Include="SRDescriptionAttribute.cs" />
     <Compile Include="System\Drawing\Bitmap.Windows.cs" />
     <Compile Include="System\Drawing\BitmapSelector.cs" />
     <Compile Include="$(CommonPath)\CoreLib\Microsoft\Win32\SafeHandles\SafeLibraryHandle.cs">
       <Link>Common\CoreLib\Microsoft\Win32\SafeHandles\SafeLibraryHandle.cs</Link>
     </Compile>
-    <Compile Include="$(CommonPath)\System\Runtime\InteropServices\FunctionWrapper.Windows.cs">
-      <Link>Common\System\Runtime\InteropServices\FunctionWrapper.Windows.cs</Link>
-    </Compile>
     <Compile Include="$(CommonPath)\Interop\Windows\Ole32\Interop.IStream.cs">
       <Link>Common\Interop\Windows\Ole32\Interop.IStream.cs</Link>
     </Compile>
       <Link>Common\Interop\Windows\Interop.HRESULT.cs</Link>
     </Compile>
   </ItemGroup>
+  <!-- Unix specific -->
   <ItemGroup Condition="$(TargetGroup.StartsWith('netcoreapp')) AND '$(TargetsUnix)' == 'true'">
-    <!-- Unix-specific -->
     <Compile Include="System\Drawing\Graphics.Unix.cs" />
     <Compile Include="System\Drawing\Icon.Unix.cs" />
     <Compile Include="System\Drawing\SystemFonts.Unix.cs" />
     <Compile Include="System\Drawing\Drawing2D\CustomLineCap.Unix.cs" />
     <Compile Include="System\Drawing\Drawing2D\GraphicsPath.Unix.cs" />
     <Compile Include="System\Drawing\Text\PrivateFontCollection.Unix.cs" />
+    <Compile Include="System\Drawing\LibraryResolver.cs" />
     <Compile Include="misc\ExternDll.Unix.cs" />
     <Compile Include="$(CommonPath)\Interop\Unix\Interop.Libraries.cs">
       <Link>Common\Interop\Unix\Interop.Libraries.cs</Link>
       <LogicalName>placeholder.ico</LogicalName>
     </EmbeddedResource>
   </ItemGroup>
-  <ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp2.0' AND '$(TargetsUnix)' == 'true'">
-    <Compile Include="$(CommonPath)\Interop\Unix\libdl\Interop.dlopen.cs">
-      <Link>Common\Interop\Unix\libdl\Interop.dlopen.cs</Link>
-    </Compile>
-    <Compile Include="$(CommonPath)\Interop\Unix\libdl\Interop.dlsym.cs">
-      <Link>Common\Interop\Unix\libdl\Interop.dlsym.cs</Link>
-    </Compile>
-    <Compile Include="$(CommonPath)\System\Runtime\InteropServices\FunctionWrapper.Unix.cs">
-      <Link>Common\System\Runtime\InteropServices\FunctionWrapper.Unix.cs</Link>
-    </Compile>
-  </ItemGroup>
-  <ItemGroup Condition="'$(TargetsNetFx)' != 'true'">
+  <!-- References -->
+  <ItemGroup>
     <Reference Include="Microsoft.Win32.Primitives" />
     <Reference Condition="'$(TargetsWindows)' == 'true'" Include="Microsoft.Win32.SystemEvents" />
     <Reference Include="System.Buffers" />
     <Reference Include="System.Threading.Thread" />
     <Reference Include="System.Text.Encoding.Extensions" />
   </ItemGroup>
-  <ItemGroup Condition="'$(TargetsNetFx)' == 'true'">
-    <Reference Include="mscorlib" />
-    <Reference Include="System" />
-    <Reference Include="System.Drawing" />
-  </ItemGroup>
 </Project>
\ No newline at end of file
index b36b42a..8c05dc0 100644 (file)
@@ -44,7 +44,7 @@ namespace System.Drawing
                 try
                 {
 #if DEBUG
-                    int status =
+                    int status = !Gdip.Initialized ? Gdip.Ok :
 #endif
                     Gdip.GdipDeleteBrush(new HandleRef(this, _nativeBrush));
 #if DEBUG
index 75780ef..dc36d0f 100644 (file)
@@ -121,7 +121,7 @@ namespace System.Drawing.Drawing2D
             int status;
             if (_nativePath != IntPtr.Zero)
             {
-                status = Gdip.GdipDeletePath(_nativePath);
+                status = Gdip.GdipDeletePath(new HandleRef(this, _nativePath));
                 Gdip.CheckStatus(status);
 
                 _nativePath = IntPtr.Zero;
index 8623d4f..3b6e095 100644 (file)
@@ -91,7 +91,7 @@ namespace System.Drawing.Drawing2D
                 try
                 {
 #if DEBUG
-                    int status =
+                    int status = !Gdip.Initialized ? Gdip.Ok :
 #endif
                     Gdip.GdipDeletePath(new HandleRef(this, _nativePath));
 #if DEBUG
index b9325a6..52d792c 100644 (file)
@@ -35,7 +35,7 @@ namespace System.Drawing.Drawing2D
                 try
                 {
 #if DEBUG
-                    int status =
+                    int status = !Gdip.Initialized ? Gdip.Ok :
 #endif
                     Gdip.GdipDeletePathIter(new HandleRef(this, nativeIter));
 #if DEBUG
index a7582f8..0fe9a42 100644 (file)
@@ -66,7 +66,10 @@ namespace System.Drawing.Drawing2D
         {
             if (NativeMatrix != IntPtr.Zero)
             {
-                Gdip.GdipDeleteMatrix(new HandleRef(this, NativeMatrix));
+                if (Gdip.Initialized)
+                {
+                    Gdip.GdipDeleteMatrix(new HandleRef(this, NativeMatrix));
+                }
                 NativeMatrix = IntPtr.Zero;
             }
         }
index 70ff11f..4f3db2b 100644 (file)
@@ -29,7 +29,8 @@ namespace System.Drawing.Drawing2D
             {
                 try
                 {
-                    status = Gdip.GdipDeleteCustomLineCap(new HandleRef(this, handle));
+                    status = !Gdip.Initialized ? Gdip.Ok :
+                        Gdip.GdipDeleteCustomLineCap(new HandleRef(this, handle));
                 }
                 catch (Exception ex)
                 {
index be89000..7f5700d 100644 (file)
@@ -48,7 +48,6 @@ namespace System.Drawing
     public sealed partial class Font
     {
         private const byte DefaultCharSet = 1;
-        private static int CharSetOffset = -1;
 
         private void CreateFont(string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical)
         {
@@ -210,7 +209,7 @@ namespace System.Drawing
                 newSize = lf.lfHeight;
             }
 
-            return (new Font(newObject, lf.lfFaceName, newStyle, newSize));
+            return (new Font(newObject, lf.lfFaceName.ToString(), newStyle, newSize));
         }
 
         public IntPtr ToHfont()
@@ -355,71 +354,5 @@ namespace System.Drawing
                 }
             }
         }
-
-        public void ToLogFont(object logFont, Graphics graphics)
-        {
-            if (graphics == null)
-                throw new ArgumentNullException(nameof(graphics));
-
-            if (logFont == null)
-            {
-                throw new AccessViolationException(nameof(logFont));
-            }
-
-            Type st = logFont.GetType();
-            if (!st.GetTypeInfo().IsLayoutSequential)
-                throw new ArgumentException(nameof(logFont), "Layout must be sequential.");
-
-            // note: there is no exception if 'logFont' isn't big enough
-            Type lf = typeof(LOGFONT);
-            int size = Marshal.SizeOf(logFont);
-            if (size >= Marshal.SizeOf(lf))
-            {
-                int status;
-                IntPtr copy = Marshal.AllocHGlobal(size);
-                try
-                {
-                    Marshal.StructureToPtr(logFont, copy, false);
-
-                    status = Gdip.GdipGetLogFontW(new HandleRef(this, NativeFont), new HandleRef(graphics, graphics.NativeGraphics), logFont);
-                    if (status != Gdip.Ok)
-                    {
-                        // reset to original values
-                        Marshal.PtrToStructure(copy, logFont);
-                    }
-                }
-                finally
-                {
-                    Marshal.FreeHGlobal(copy);
-                }
-
-                if (CharSetOffset == -1)
-                {
-                    // not sure why this methods returns an IntPtr since it's an offset
-                    // anyway there's no issue in downcasting the result into an int32
-                    CharSetOffset = (int)Marshal.OffsetOf(lf, "lfCharSet");
-                }
-
-                // note: Marshal.WriteByte(object,*) methods are unimplemented on Mono
-                GCHandle gch = GCHandle.Alloc(logFont, GCHandleType.Pinned);
-                try
-                {
-                    IntPtr ptr = gch.AddrOfPinnedObject();
-                    // if GDI+ lfCharSet is 0, then we return (S.D.) 1, otherwise the value is unchanged
-                    if (Marshal.ReadByte(ptr, CharSetOffset) == 0)
-                    {
-                        // set lfCharSet to 1 
-                        Marshal.WriteByte(ptr, CharSetOffset, 1);
-                    }
-                }
-                finally
-                {
-                    gch.Free();
-                }
-
-                // now we can throw, if required
-                Gdip.CheckStatus(status);
-            }
-        }
     }
 }
index c60cdb4..42a1a32 100644 (file)
@@ -12,9 +12,6 @@ namespace System.Drawing
 {
     public sealed partial class Font
     {
-        private const int LogFontCharSetOffset = 23;
-        private const int LogFontNameOffset = 28;
-
         ///<summary>
         /// Creates the GDI+ native font object.
         ///</summary>
@@ -163,25 +160,12 @@ namespace System.Drawing
             Debug.Assert(_nativeFont == IntPtr.Zero, "GDI+ native font already initialized, this will generate a handle leak");
             Debug.Assert(nativeFont != IntPtr.Zero, "nativeFont is null");
 
-            int status = 0;
-            float size = 0;
-            GraphicsUnit unit = GraphicsUnit.Point;
-            FontStyle style = FontStyle.Regular;
-            IntPtr nativeFamily = IntPtr.Zero;
-
             _nativeFont = nativeFont;
 
-            status = Gdip.GdipGetFontUnit(new HandleRef(this, nativeFont), out unit);
-            Gdip.CheckStatus(status);
-
-            status = Gdip.GdipGetFontSize(new HandleRef(this, nativeFont), out size);
-            Gdip.CheckStatus(status);
-
-            status = Gdip.GdipGetFontStyle(new HandleRef(this, nativeFont), out style);
-            Gdip.CheckStatus(status);
-
-            status = Gdip.GdipGetFamily(new HandleRef(this, nativeFont), out nativeFamily);
-            Gdip.CheckStatus(status);
+            Gdip.CheckStatus(Gdip.GdipGetFontUnit(new HandleRef(this, nativeFont), out GraphicsUnit unit));
+            Gdip.CheckStatus(Gdip.GdipGetFontSize(new HandleRef(this, nativeFont), out float size));
+            Gdip.CheckStatus(Gdip.GdipGetFontStyle(new HandleRef(this, nativeFont), out FontStyle style));
+            Gdip.CheckStatus(Gdip.GdipGetFamily(new HandleRef(this, nativeFont), out IntPtr nativeFamily));
 
             SetFontFamily(new FontFamily(nativeFamily));
             Initialize(_fontFamily, size, style, unit, gdiCharSet, gdiVerticalFont);
@@ -238,41 +222,43 @@ namespace System.Drawing
         }
 
         /// <summary>
-        /// Creates a <see cref='System.Drawing.Font'/> from the specified Windows handle.
+        /// Creates a <see cref='Font'/> from the specified Windows handle.
         /// </summary>
         public static Font FromHfont(IntPtr hfont)
         {
-            var lf = new SafeNativeMethods.LOGFONT();
-            SafeNativeMethods.GetObject(new HandleRef(null, hfont), lf);
-            
-            IntPtr screenDC = UnsafeNativeMethods.GetDC(NativeMethods.NullHandleRef);
-            try
-            {
-                return FromLogFont(lf, screenDC);
-            }
-            finally
+            var logFont = new SafeNativeMethods.LOGFONT();
+            SafeNativeMethods.GetObject(new HandleRef(null, hfont), ref logFont);
+
+            using (ScreenDC dc = ScreenDC.Create())
             {
-                UnsafeNativeMethods.ReleaseDC(NativeMethods.NullHandleRef, new HandleRef(null, screenDC));
+                return FromLogFontInternal(ref logFont, dc);
             }
         }
 
+        /// <summary>
+        /// Creates a <see cref="Font"/> from the given LOGFONT using the screen device context.
+        /// </summary>
+        /// <param name="lf">A boxed LOGFONT.</param>
+        /// <returns>The newly created <see cref="Font"/>.</returns>
         public static Font FromLogFont(object lf)
         {
-            IntPtr screenDC = UnsafeNativeMethods.GetDC(NativeMethods.NullHandleRef);
-            try
+            using (ScreenDC dc = ScreenDC.Create())
             {
-                return FromLogFont(lf, screenDC);
+                return FromLogFont(lf, dc);
             }
-            finally
+        }
+
+        internal static Font FromLogFont(ref SafeNativeMethods.LOGFONT logFont)
+        {
+            using (ScreenDC dc = ScreenDC.Create())
             {
-                UnsafeNativeMethods.ReleaseDC(NativeMethods.NullHandleRef, new HandleRef(null, screenDC));
+                return FromLogFont(logFont, dc);
             }
         }
 
-        public static Font FromLogFont(object lf, IntPtr hdc)
+        internal static Font FromLogFontInternal(ref SafeNativeMethods.LOGFONT logFont, IntPtr hdc)
         {
-            IntPtr font = IntPtr.Zero;
-            int status = Gdip.GdipCreateFontFromLogfontW(new HandleRef(null, hdc), lf, out font);
+            int status = Gdip.GdipCreateFontFromLogfontW(new HandleRef(null, hdc), ref logFont, out IntPtr font);
 
             // Special case this incredibly common error message to give more information
             if (status == Gdip.NotTrueTypeFont)
@@ -287,18 +273,63 @@ namespace System.Drawing
             // GDI+ returns font = 0 even though the status is Ok.
             if (font == IntPtr.Zero)
             {
-                throw new ArgumentException(SR.Format(SR.GdiplusNotTrueTypeFont, lf.ToString()));
+                throw new ArgumentException(SR.Format(SR.GdiplusNotTrueTypeFont, logFont.ToString()));
+            }
+
+            bool gdiVerticalFont = logFont.lfFaceName[0] == '@';
+            return new Font(font, logFont.lfCharSet, gdiVerticalFont);
+        }
+
+        /// <summary>
+        /// Creates a <see cref="Font"/> from the given LOGFONT using the given device context.
+        /// </summary>
+        /// <param name="lf">A boxed LOGFONT.</param>
+        /// <param name="hdc">Handle to a device context (HDC).</param>
+        /// <returns>The newly created <see cref="Font"/>.</returns>
+        public unsafe static Font FromLogFont(object lf, IntPtr hdc)
+        {
+            if (lf == null)
+            {
+                throw new ArgumentNullException(nameof(lf));
+            }
+
+            if (lf is SafeNativeMethods.LOGFONT logFont)
+            {
+                // A boxed LOGFONT, just use it to create the font
+                return FromLogFontInternal(ref logFont, hdc);
+            }
+
+            Type type = lf.GetType();
+            int nativeSize = sizeof(SafeNativeMethods.LOGFONT);
+            if (Marshal.SizeOf(type) != nativeSize)
+            {
+                // If we don't actually have an object that is LOGFONT in size, trying to pass
+                // it to GDI+ is likely to cause an AV.
+                throw new ArgumentException();
+            }
+
+            // Now that we know the marshalled size is the same as LOGFONT, copy in the data
+            logFont = new SafeNativeMethods.LOGFONT();
+
+            if (!type.IsValueType)
+            {
+                // Only works with non value types
+                Marshal.StructureToPtr(lf, new IntPtr(&logFont), fDeleteOld: false);
+            }
+            else
+            {
+                GCHandle handle = GCHandle.Alloc(lf, GCHandleType.Pinned);
+                Buffer.MemoryCopy((byte*)handle.AddrOfPinnedObject(), &logFont, nativeSize, nativeSize);
+                handle.Free();
             }
 
-#pragma warning disable 0618
-            bool gdiVerticalFont = (Marshal.ReadInt16(lf, LogFontNameOffset) == (short)'@');
-            return new Font(font, Marshal.ReadByte(lf, LogFontCharSetOffset), gdiVerticalFont);
-#pragma warning restore 0618
+            return FromLogFontInternal(ref logFont, hdc);
         }
 
         /// <summary>
-        /// Creates a Font from the specified Windows handle to a device context.
+        /// Creates a <see cref="Font"/> from the specified handle to a device context (HDC).
         /// </summary>
+        /// <returns>The newly created <see cref="Font"/>.</returns>
         public static Font FromHdc(IntPtr hdc)
         {
             IntPtr font = IntPtr.Zero;
@@ -322,8 +353,7 @@ namespace System.Drawing
         /// </summary>
         public object Clone()
         {
-            IntPtr clonedFont = IntPtr.Zero;
-            int status = Gdip.GdipCloneFont(new HandleRef(this, _nativeFont), out clonedFont);
+            int status = Gdip.GdipCloneFont(new HandleRef(this, _nativeFont), out IntPtr clonedFont);
             Gdip.CheckStatus(status);
 
             return new Font(clonedFont, _gdiCharSet, _gdiVerticalFont);
@@ -333,10 +363,11 @@ namespace System.Drawing
         {
             _fontFamily = family;
 
-            // GDI+ creates ref-counted singleton FontFamily objects based on the family name so all managed 
+            // GDI+ creates ref-counted singleton FontFamily objects based on the family name so all managed
             // objects with same family name share the underlying GDI+ native pointer. The unmanged object is
             // destroyed when its ref-count gets to zero.
-            // Make sure this.fontFamily is not finalized so the underlying singleton object is kept alive.
+            //
+            // Make sure _fontFamily is not finalized so the underlying singleton object is kept alive.
             GC.SuppressFinalize(_fontFamily);
         }
 
@@ -352,56 +383,11 @@ namespace System.Drawing
 
         public void ToLogFont(object logFont)
         {
-            IntPtr screenDC = UnsafeNativeMethods.GetDC(NativeMethods.NullHandleRef);
-            try
-            {
-                Graphics graphics = Graphics.FromHdcInternal(screenDC);
-                try
-                {
-                    ToLogFont(logFont, graphics);
-                }
-                finally
-                {
-                    graphics.Dispose();
-                }
-            }
-            finally
-            {
-                UnsafeNativeMethods.ReleaseDC(NativeMethods.NullHandleRef, new HandleRef(null, screenDC));
-            }
-        }
-
-        public unsafe void ToLogFont(object logFont, Graphics graphics)
-        {
-            if (graphics == null)
-            {
-                throw new ArgumentNullException(nameof(graphics));
-            }
-
-            int status = Gdip.GdipGetLogFontW(new HandleRef(this, NativeFont), new HandleRef(graphics, graphics.NativeGraphics), logFont);
-
-            // Prefix the string with '@' this is a gdiVerticalFont.
-#pragma warning disable 0618
-            if (_gdiVerticalFont)
-            {
-                // Copy the Unicode contents of the name.
-                for (int i = 60; i >= 0; i -= 2)
-                {
-                    Marshal.WriteInt16(logFont,
-                                        LogFontNameOffset + i + 2,
-                                        Marshal.ReadInt16(logFont, LogFontNameOffset + i));
-                }
-
-                // Prefix the name with an '@' sign.
-                Marshal.WriteInt16(logFont, LogFontNameOffset, (short)'@');
-            }
-            if (Marshal.ReadByte(logFont, LogFontCharSetOffset) == 0)
+            using (ScreenDC dc = ScreenDC.Create())
+            using (Graphics graphics = Graphics.FromHdcInternal(dc))
             {
-                Marshal.WriteByte(logFont, LogFontCharSetOffset, _gdiCharSet);
+                ToLogFont(logFont, graphics);
             }
-#pragma warning restore 0618
-
-            Gdip.CheckStatus(status);
         }
 
         /// <summary>
@@ -409,31 +395,26 @@ namespace System.Drawing
         /// </summary>
         public IntPtr ToHfont()
         {
-            var lf = new SafeNativeMethods.LOGFONT();
-            ToLogFont(lf);
-
-            IntPtr handle = IntUnsafeNativeMethods.IntCreateFontIndirect(lf);
-            if (handle == IntPtr.Zero)
+            using (ScreenDC dc = ScreenDC.Create())
+            using (Graphics graphics = Graphics.FromHdcInternal(dc))
             {
-                throw new Win32Exception();
-            }
+                SafeNativeMethods.LOGFONT lf = ToLogFontInternal(graphics);
+                IntPtr handle = IntUnsafeNativeMethods.CreateFontIndirect(ref lf);
+                if (handle == IntPtr.Zero)
+                {
+                    throw new Win32Exception();
+                }
 
-            return handle;
+                return handle;
+            }
         }
 
         public float GetHeight()
         {
-            IntPtr screenDC = UnsafeNativeMethods.GetDC(NativeMethods.NullHandleRef);
-            try
+            using (ScreenDC dc = ScreenDC.Create())
+            using (Graphics graphics = Graphics.FromHdcInternal(dc))
             {
-                using (Graphics graphics = Graphics.FromHdcInternal(screenDC))
-                {
-                    return GetHeight(graphics);
-                }
-            }
-            finally
-            {
-                UnsafeNativeMethods.ReleaseDC(NativeMethods.NullHandleRef, new HandleRef(null, screenDC));
+                return GetHeight(graphics);
             }
         }
 
@@ -450,21 +431,14 @@ namespace System.Drawing
                     return Size;
                 }
 
-                IntPtr screenDC = UnsafeNativeMethods.GetDC(NativeMethods.NullHandleRef);
-                try
-                {
-                    using (Graphics graphics = Graphics.FromHdcInternal(screenDC))
-                    {
-                        float pixelsPerPoint = (float)(graphics.DpiY / 72.0);
-                        float lineSpacingInPixels = GetHeight(graphics);
-                        float emHeightInPixels = lineSpacingInPixels * FontFamily.GetEmHeight(Style) / FontFamily.GetLineSpacing(Style);
-
-                        return emHeightInPixels / pixelsPerPoint;
-                    }
-                }
-                finally
+                using (ScreenDC dc = ScreenDC.Create())
+                using (Graphics graphics = Graphics.FromHdcInternal(dc))
                 {
-                    UnsafeNativeMethods.ReleaseDC(NativeMethods.NullHandleRef, new HandleRef(null, screenDC));
+                    float pixelsPerPoint = (float)(graphics.DpiY / 72.0);
+                    float lineSpacingInPixels = GetHeight(graphics);
+                    float emHeightInPixels = lineSpacingInPixels * FontFamily.GetEmHeight(Style) / FontFamily.GetLineSpacing(Style);
+
+                    return emHeightInPixels / pixelsPerPoint;
                 }
             }
         }
index 41f0c36..3eec362 100644 (file)
@@ -182,7 +182,7 @@ namespace System.Drawing
                 try
                 {
 #if DEBUG
-                    int status =
+                    int status = !Gdip.Initialized ? Gdip.Ok :
 #endif
                     Gdip.GdipDeleteFont(new HandleRef(this, _nativeFont));
 #if DEBUG
@@ -275,8 +275,69 @@ namespace System.Drawing
                                     _gdiCharSet,
                                     _gdiVerticalFont);
         }
-        
+
         // This is used by SystemFonts when constructing a system Font objects.
         internal void SetSystemFontName(string systemFontName) => _systemFontName = systemFontName;
+
+        public unsafe void ToLogFont(object logFont, Graphics graphics)
+        {
+            if (logFont == null)
+            {
+                throw new ArgumentNullException(nameof(logFont));
+            }
+
+            Type type = logFont.GetType();
+            int nativeSize = sizeof(SafeNativeMethods.LOGFONT);
+            if (Marshal.SizeOf(type) != nativeSize)
+            {
+                // If we don't actually have an object that is LOGFONT in size, trying to pass
+                // it to GDI+ is likely to cause an AV.
+                throw new ArgumentException();
+            }
+
+            SafeNativeMethods.LOGFONT nativeLogFont = ToLogFontInternal(graphics);
+
+            // PtrToStructure requires that the passed in object not be a value type.
+            if (!type.IsValueType)
+            {
+                Marshal.PtrToStructure(new IntPtr(&nativeLogFont), logFont);
+            }
+            else
+            {
+                GCHandle handle = GCHandle.Alloc(logFont, GCHandleType.Pinned);
+                Buffer.MemoryCopy(&nativeLogFont, (byte*)handle.AddrOfPinnedObject(), nativeSize, nativeSize);
+                handle.Free();
+            }
+        }
+
+        private unsafe SafeNativeMethods.LOGFONT ToLogFontInternal(Graphics graphics)
+        {
+            if (graphics == null)
+            {
+                throw new ArgumentNullException(nameof(graphics));
+            }
+
+            SafeNativeMethods.LOGFONT logFont = new SafeNativeMethods.LOGFONT();
+            Gdip.CheckStatus(Gdip.GdipGetLogFontW(
+                new HandleRef(this, NativeFont), new HandleRef(graphics, graphics.NativeGraphics), ref logFont));
+
+            // Prefix the string with '@' if this is a gdiVerticalFont.
+            if (_gdiVerticalFont)
+            {
+                Span<char> faceName = logFont.lfFaceName;
+                faceName.Slice(0, faceName.Length - 1).CopyTo(faceName.Slice(1));
+                faceName[0] = '@';
+
+                // Docs require this to be null terminated
+                faceName[faceName.Length - 1] = '\0';
+            }
+
+            if (logFont.lfCharSet == 0)
+            {
+                logFont.lfCharSet = _gdiCharSet;
+            }
+
+            return logFont;
+        }
     }
 }
index 5788d16..3c7fed8 100644 (file)
@@ -160,7 +160,7 @@ namespace System.Drawing
                 try
                 {
 #if DEBUG
-                    int status =
+                    int status = !Gdip.Initialized ? Gdip.Ok :
 #endif
                     Gdip.GdipDeleteFontFamily(new HandleRef(this, _nativeFamily));
 #if DEBUG
index c2b4286..33ebd18 100644 (file)
@@ -5,63 +5,18 @@
 using System.Collections;
 using System.Diagnostics;
 using System.Diagnostics.CodeAnalysis;
-using System.Internal;
 using System.IO;
 using System.Runtime.CompilerServices;
 using System.Runtime.ConstrainedExecution;
 using System.Runtime.InteropServices;
-using System.Text;
 using System.Threading;
 
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+BITMAP.bmBits")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+DIBSECTION.dshSection")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+Gdip.initToken")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+Gdip+StartupInput.DebugEventCallback")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+Gdip+StartupOutput.hook")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+Gdip+StartupOutput.unhook")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+ICONINFO.hbmColor")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+ICONINFO.hbmMask")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+MSG.hwnd")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+MSG.lParam")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+MSG.wParam")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+OBJECTHEADER.pInfo")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PICTDESC.union1")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLG.hDC")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLG.hDevMode")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLG.hDevNames")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLG.hInstance")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLG.hPrintTemplate")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLG.hSetupTemplate")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLG.hwndOwner")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLG.lCustData")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLGX86.hDC")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLGX86.hDevMode")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLGX86.hDevNames")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLGX86.hInstance")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLGX86.hPrintTemplate")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLGX86.hSetupTemplate")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLGX86.hwndOwner")]
-[assembly: SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources", Scope = "member", Target = "System.Drawing.SafeNativeMethods+PRINTDLGX86.lCustData")]
-[assembly: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Drawing.SafeNativeMethods+StreamConsts..ctor()")]
-[assembly: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Drawing.SafeNativeMethods+POINT..ctor()")]
-[assembly: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Drawing.SafeNativeMethods+LOGPEN..ctor()")]
-[assembly: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Drawing.SafeNativeMethods+DIBSECTION..ctor()")]
-[assembly: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Drawing.SafeNativeMethods..ctor()")]
-[assembly: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Drawing.SafeNativeMethods+Ole..ctor()")]
-[assembly: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Drawing.SafeNativeMethods+CommonHandles..ctor()")]
-[assembly: SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Scope = "type", Target = "System.Drawing.SafeNativeMethods+CommonHandles")]
-[assembly: SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Scope = "type", Target = "System.Drawing.SafeNativeMethods+ENHMETAHEADER")]
-[assembly: SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Scope = "type", Target = "System.Drawing.SafeNativeMethods+StreamConsts")]
-[assembly: SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Scope = "type", Target = "System.Drawing.SafeNativeMethods+Ole")]
-[assembly: SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Scope = "type", Target = "System.Drawing.SafeNativeMethods+Gdip")]
-[assembly: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "System.Drawing.SafeNativeMethods+ENHMETAHEADER..ctor()")]
-
 namespace System.Drawing
 {
-    internal partial class SafeNativeMethods
+    internal static partial class SafeNativeMethods
     {
         // We make this a nested class so that we don't have to initialize GDI+ to access SafeNativeMethods (mostly gdi/user32).
-        internal partial class Gdip
+        internal static partial class Gdip
         {
             private static readonly TraceSwitch s_gdiPlusInitialization = new TraceSwitch("GdiPlusInitialization", "Tracks GDI+ initialization and teardown");
 
@@ -74,8 +29,6 @@ namespace System.Drawing
                 Debug.WriteLineIf(s_gdiPlusInitialization.TraceVerbose, "Initialize GDI+ [" + AppDomain.CurrentDomain.FriendlyName + "]");
                 Debug.Indent();
 
-                s_gdipModule = LoadNativeLibrary();
-                LoadSharedFunctionPointers();
                 PlatformInitialize();
 
                 StartupInput input = StartupInput.GetDefault();
@@ -90,20 +43,12 @@ namespace System.Drawing
                 // Sync to event for handling shutdown
                 AppDomain currentDomain = AppDomain.CurrentDomain;
                 currentDomain.ProcessExit += new EventHandler(OnProcessExit);
-
-                // Also sync to DomainUnload for non-default domains since they will not get a ProcessExit if
-                // they are unloaded prior to ProcessExit (and this object's static fields are scoped to AppDomains, 
-                // so we must cleanup on AppDomain shutdown)
-                if (!currentDomain.IsDefaultAppDomain())
-                {
-                    currentDomain.DomainUnload += new EventHandler(OnProcessExit);
-                }
             }
 
             /// <summary>
             /// Returns true if GDI+ has been started, but not shut down
             /// </summary>
-            private static bool Initialized => s_initToken != IntPtr.Zero;
+            internal static bool Initialized => s_initToken != IntPtr.Zero;
 
             /// <summary>
             /// This property will give us back a hashtable we can use to store all of our static brushes and pens on
@@ -199,35 +144,6 @@ namespace System.Drawing
             }
 
             //----------------------------------------------------------------------------------------
-            // Initialization methods (GdiplusInit.h)
-            //----------------------------------------------------------------------------------------
-
-            internal static int GdipDeletePath(HandleRef path) => Initialized ? IntGdipDeletePath(path) : Ok;
-            internal static int GdipDeletePathIter(HandleRef pathIter) => Initialized ? IntGdipDeletePathIter(pathIter) : Ok;
-            internal static int GdipDeleteMatrix(HandleRef matrix) => Initialized ? IntGdipDeleteMatrix(matrix) : Ok;
-            internal static int GdipDeleteRegion(HandleRef region) => Initialized ? IntGdipDeleteRegion(region) : Ok;
-            internal static int GdipDeleteBrush(HandleRef brush) => Initialized ? IntGdipDeleteBrush(brush) : Ok;
-            internal static int GdipDeletePen(HandleRef pen) => Initialized ? IntGdipDeletePen(pen) : Ok;
-            internal static int GdipDeleteCustomLineCap(HandleRef customCap) => Initialized ? IntGdipDeleteCustomLineCap(customCap) : Ok;
-            internal static int GdipDisposeImage(HandleRef image) => Initialized ? IntGdipDisposeImage(image) : Ok;
-            internal static int GdipDisposeImageAttributes(HandleRef imageattr) => Initialized ? IntGdipDisposeImageAttributes(imageattr) : Ok;
-            internal static int GdipDeleteGraphics(HandleRef graphics) => Initialized ? IntGdipDeleteGraphics(graphics) : Ok;
-            internal static int GdipReleaseDC(HandleRef graphics, HandleRef hdc) => Initialized ? IntGdipReleaseDC(graphics, hdc) : Ok;
-            internal static int GdipDeletePrivateFontCollection(ref IntPtr fontCollection)
-            {
-                if (!Initialized)
-                {
-                    fontCollection = IntPtr.Zero;
-                    return Ok;
-                }
-
-                return IntGdipDeletePrivateFontCollection(ref fontCollection);
-            }
-            internal static int GdipDeleteFontFamily(HandleRef fontFamily) => Initialized ? IntGdipDeleteFontFamily(fontFamily) : Ok;
-            internal static int GdipDeleteFont(HandleRef font) => Initialized ? IntGdipDeleteFont(font) : Ok;
-            internal static int GdipDeleteStringFormat(HandleRef format) => Initialized ? IntGdipDeleteStringFormat(format) : Ok;
-
-            //----------------------------------------------------------------------------------------
             // Status codes
             //----------------------------------------------------------------------------------------
             internal const int Ok = 0;
@@ -555,13 +471,8 @@ namespace System.Drawing
 
         public const int NOMIRRORBITMAP = unchecked((int)0x80000000); /* Do not Mirror the bitmap in this call */
 
-        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "CreateCompatibleBitmap", CharSet = CharSet.Auto)]
-        public static extern IntPtr IntCreateCompatibleBitmap(HandleRef hDC, int width, int height);
-
-        public static IntPtr CreateCompatibleBitmap(HandleRef hDC, int width, int height)
-        {
-            return System.Internal.HandleCollector.Add(IntCreateCompatibleBitmap(hDC, width, height), CommonHandles.GDI);
-        }
+        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true)]
+        public static extern IntPtr CreateCompatibleBitmap(HandleRef hDC, int width, int height);
 
         [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
         public static extern int BitBlt(HandleRef hDC, int x, int y, int nWidth, int nHeight,
@@ -573,13 +484,8 @@ namespace System.Drawing
         [DllImport(ExternDll.Gdi32)]
         public static extern uint GetPaletteEntries(HandleRef hpal, int iStartIndex, int nEntries, byte[] lppe);
 
-        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "CreateDIBSection", CharSet = CharSet.Auto)]
-        public static extern IntPtr IntCreateDIBSection(HandleRef hdc, ref NativeMethods.BITMAPINFO_FLAT bmi, int iUsage, ref IntPtr ppvBits, IntPtr hSection, int dwOffset);
-
-        public static IntPtr CreateDIBSection(HandleRef hdc, ref NativeMethods.BITMAPINFO_FLAT bmi, int iUsage, ref IntPtr ppvBits, IntPtr hSection, int dwOffset)
-        {
-            return System.Internal.HandleCollector.Add(IntCreateDIBSection(hdc, ref bmi, iUsage, ref ppvBits, hSection, dwOffset), SafeNativeMethods.CommonHandles.GDI);
-        }
+        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true)]
+        public static extern IntPtr CreateDIBSection(HandleRef hdc, ref NativeMethods.BITMAPINFO_FLAT bmi, int iUsage, ref IntPtr ppvBits, IntPtr hSection, int dwOffset);
 
         [DllImport(ExternDll.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
         public static extern IntPtr GlobalFree(HandleRef handle);
@@ -627,13 +533,8 @@ namespace System.Drawing
         [DllImport(ExternDll.Kernel32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
         public static extern bool GlobalUnlock(HandleRef handle);
 
-        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "CreateRectRgn", CharSet = CharSet.Auto)]
-        private static extern IntPtr IntCreateRectRgn(int x1, int y1, int x2, int y2);
-
-        public static IntPtr CreateRectRgn(int x1, int y1, int x2, int y2)
-        {
-            return System.Internal.HandleCollector.Add(IntCreateRectRgn(x1, y1, x2, y2), SafeNativeMethods.CommonHandles.GDI);
-        }
+        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true)]
+        public static extern IntPtr CreateRectRgn(int x1, int y1, int x2, int y2);
 
         [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
         public static extern int GetClipRgn(HandleRef hDC, HandleRef hRgn);
@@ -708,18 +609,10 @@ namespace System.Drawing
             return IntGlobalAlloc(uFlags, new UIntPtr(dwBytes));
         }
 
-        static internal unsafe void ZeroMemory(byte* ptr, ulong length)
-        {
-            byte* end = ptr + length;
-            while (ptr != end)
-                *ptr++ = 0;
-        }
-
         public const int ERROR_ACCESS_DENIED = 5;
         public const int ERROR_INVALID_PARAMETER = 87;
         public const int ERROR_PROC_NOT_FOUND = 127;
 
-
         [StructLayout(LayoutKind.Sequential)]
         public class ENHMETAHEADER
         {
@@ -818,25 +711,25 @@ namespace System.Drawing
         }
 
         [StructLayout(LayoutKind.Sequential)]
-        public class ICONINFO
+        public struct ICONINFO
         {
-            public int fIcon;
-            public int xHotspot;
-            public int yHotspot;
-            public IntPtr hbmMask = IntPtr.Zero;
-            public IntPtr hbmColor = IntPtr.Zero;
+            public uint fIcon;
+            public uint xHotspot;
+            public uint yHotspot;
+            public IntPtr hbmMask;
+            public IntPtr hbmColor;
         }
 
         [StructLayout(LayoutKind.Sequential)]
-        public class BITMAP
+        public struct BITMAP
         {
-            public int bmType;
-            public int bmWidth;
-            public int bmHeight;
-            public int bmWidthBytes;
-            public short bmPlanes;
-            public short bmBitsPixel;
-            public IntPtr bmBits = IntPtr.Zero;
+            public uint bmType;
+            public uint bmWidth;
+            public uint bmHeight;
+            public uint bmWidthBytes;
+            public ushort bmPlanes;
+            public ushort bmBitsPixel;
+            public IntPtr bmBits;
         }
 
         [StructLayout(LayoutKind.Sequential)]
@@ -855,9 +748,11 @@ namespace System.Drawing
             public int biClrImportant;
         }
 
-        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
-        public class LOGFONT
+        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+        public unsafe struct LOGFONT
         {
+            private const int LF_FACESIZE = 32;
+
             public int lfHeight;
             public int lfWidth;
             public int lfEscapement;
@@ -871,8 +766,11 @@ namespace System.Drawing
             public byte lfClipPrecision;
             public byte lfQuality;
             public byte lfPitchAndFamily;
-            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
-            public string lfFaceName;
+            private fixed char _lfFaceName[LF_FACESIZE];
+            public Span<char> lfFaceName
+            {
+                get { fixed (char* c = _lfFaceName) { return new Span<char>(c, LF_FACESIZE); } }
+            }
 
             public override string ToString()
             {
@@ -890,30 +788,39 @@ namespace System.Drawing
                     "lfClipPrecision=" + lfClipPrecision + ", " +
                     "lfQuality=" + lfQuality + ", " +
                     "lfPitchAndFamily=" + lfPitchAndFamily + ", " +
-                    "lfFaceName=" + lfFaceName;
+                    "lfFaceName=" + lfFaceName.ToString();
             }
         }
 
+        // https://devblogs.microsoft.com/oldnewthing/20101018-00/?p=12513
+        // https://devblogs.microsoft.com/oldnewthing/20120720-00/?p=7083
+
+        // Needs to be packed to 2 to get ICONDIRENTRY to follow immediately after idCount.
         [StructLayout(LayoutKind.Sequential, Pack = 2)]
         public struct ICONDIR
         {
-            public short idReserved;
-            public short idType;
-            public short idCount;
+            // Must be 0
+            public ushort idReserved;
+            // Must be 1
+            public ushort idType;
+            // Count of entries
+            public ushort idCount;
+            // First entry (anysize array)
             public ICONDIRENTRY idEntries;
         }
 
         [StructLayout(LayoutKind.Sequential)]
         public struct ICONDIRENTRY
         {
+            // Width and height are 1 - 255 or 0 for 256
             public byte bWidth;
             public byte bHeight;
             public byte bColorCount;
             public byte bReserved;
-            public short wPlanes;
-            public short wBitCount;
-            public int dwBytesInRes;
-            public int dwImageOffset;
+            public ushort wPlanes;
+            public ushort wBitCount;
+            public uint dwBytesInRes;
+            public uint dwImageOffset;
         }
 
         [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
@@ -998,141 +905,53 @@ namespace System.Drawing
             }
         }
 
-        public sealed class CommonHandles
-        {
-            static CommonHandles()
-            {
-#if DEBUG
-                // Setup the DebugHandleTracker
-                DebugHandleTracker.Initialize();
-                AppDomain.CurrentDomain.DomainUnload += new EventHandler(CurrentDomain_DomainUnload);
-                AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
-#endif
-            }
-
-            /// <summary>
-            /// Handle type for GDI objects.
-            /// </summary>
-            public static readonly int GDI = System.Internal.HandleCollector.RegisterType("GDI", 50, 500);
-
-            /// <summary>
-            /// Handle type for HDC's that count against the Win98 limit of five DC's. 
-            /// HDC's which are not scarce, such as HDC's for bitmaps, are counted as GDIHANDLE's.
-            /// </summary>
-            public static readonly int HDC = System.Internal.HandleCollector.RegisterType("HDC", 100, 2); // wait for 2 dc's before collecting
-
-            /// <summary>
-            /// Handle type for icons.
-            /// </summary>
-            public static readonly int Icon = System.Internal.HandleCollector.RegisterType("Icon", 20, 500);
-
-            /// <summary>
-            /// Handle type for kernel objects.
-            /// </summary>
-            public static readonly int Kernel = System.Internal.HandleCollector.RegisterType("Kernel", 0, 1000);
-
-#if DEBUG
-            private static void CurrentDomain_DomainUnload(object sender, EventArgs e)
-            {
-                DebugHandleTracker.CheckLeaks();
-            }
-
-            private static void CurrentDomain_ProcessExit(object sender, EventArgs e)
-            {
-                DebugHandleTracker.CheckLeaks();
-            }
-#endif
-        }
-
         [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "DeleteObject", CharSet = CharSet.Auto)]
         internal static extern int IntDeleteObject(HandleRef hObject);
 
         public static int DeleteObject(HandleRef hObject)
         {
-            System.Internal.HandleCollector.Remove((IntPtr)hObject, CommonHandles.GDI);
             return IntDeleteObject(hObject);
         }
 
         [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
         public static extern IntPtr SelectObject(HandleRef hdc, HandleRef obj);
 
-        [DllImport(ExternDll.User32, SetLastError = true, EntryPoint = "CreateIconFromResourceEx")]
-        private unsafe static extern IntPtr IntCreateIconFromResourceEx(byte* pbIconBits, int cbIconBits, bool fIcon, int dwVersion, int csDesired, int cyDesired, int flags);
-
-        public unsafe static IntPtr CreateIconFromResourceEx(byte* pbIconBits, int cbIconBits, bool fIcon, int dwVersion, int csDesired, int cyDesired, int flags)
-        {
-            return System.Internal.HandleCollector.Add(IntCreateIconFromResourceEx(pbIconBits, cbIconBits, fIcon, dwVersion, csDesired, cyDesired, flags), SafeNativeMethods.CommonHandles.Icon);
-        }
-
-        [DllImport(ExternDll.Shell32, CharSet = CharSet.Auto, BestFitMapping = false, EntryPoint = "ExtractAssociatedIcon")]
-        public unsafe static extern IntPtr IntExtractAssociatedIcon(HandleRef hInst, StringBuilder iconPath, ref int index);
+        [DllImport(ExternDll.User32, ExactSpelling = true, SetLastError = true)]
+        public unsafe static extern IntPtr CreateIconFromResourceEx(
+            byte* pbIconBits,
+            uint cbIconBits,
+            bool fIcon,
+            int dwVersion,
+            int csDesired,
+            int cyDesired,
+            int flags);
 
-        public unsafe static IntPtr ExtractAssociatedIcon(HandleRef hInst, StringBuilder iconPath, ref int index)
-        {
-            return System.Internal.HandleCollector.Add(IntExtractAssociatedIcon(hInst, iconPath, ref index), CommonHandles.Icon);
-        }
-
-        [DllImport(ExternDll.User32, SetLastError = true, EntryPoint = "LoadIcon", CharSet = CharSet.Auto)]
-        private static extern IntPtr IntLoadIcon(HandleRef hInst, IntPtr iconId);
-
-        public static IntPtr LoadIcon(HandleRef hInst, int iconId)
-        {
-            // We only use the case were the low word of the IntPtr is used a resource id but it still has to be an intptr.
-            return IntLoadIcon(hInst, new IntPtr(iconId));
-        }
+        [DllImport(ExternDll.Shell32, CharSet = CharSet.Unicode)]
+        public unsafe static extern IntPtr ExtractAssociatedIcon(HandleRef hInst, char* iconPath, ref int index);
 
-        [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true, EntryPoint = "DestroyIcon", CharSet = CharSet.Auto)]
-        private static extern bool IntDestroyIcon(HandleRef hIcon);
+        [DllImport(ExternDll.User32, SetLastError = true, CharSet = CharSet.Unicode)]
+        public static extern IntPtr LoadIcon(HandleRef hInst, IntPtr iconId);
 
-        public static bool DestroyIcon(HandleRef hIcon)
-        {
-            System.Internal.HandleCollector.Remove((IntPtr)hIcon, SafeNativeMethods.CommonHandles.Icon);
-            return IntDestroyIcon(hIcon);
-        }
+        [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true)]
+        public static extern bool DestroyIcon(HandleRef hIcon);
 
-        [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true, EntryPoint = "CopyImage", CharSet = CharSet.Auto)]
-        private static extern IntPtr IntCopyImage(HandleRef hImage, int uType, int cxDesired, int cyDesired, int fuFlags);
-
-        public static IntPtr CopyImage(HandleRef hImage, int uType, int cxDesired, int cyDesired, int fuFlags)
-        {
-            int handleType;
-            switch (uType)
-            {
-                case IMAGE_ICON:
-                    handleType = CommonHandles.Icon;
-                    break;
-                default:
-                    handleType = CommonHandles.GDI;
-                    break;
-            }
-            return System.Internal.HandleCollector.Add(IntCopyImage(hImage, uType, cxDesired, cyDesired, fuFlags), handleType);
-        }
+        [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true)]
+        public static extern IntPtr CopyImage(HandleRef hImage, int uType, int cxDesired, int cyDesired, int fuFlags);
 
         // GetObject stuff
-        [DllImport(ExternDll.Gdi32, SetLastError = true, CharSet = CharSet.Auto)]
-        public static extern int GetObject(HandleRef hObject, int nSize, [In, Out] BITMAP bm);
+        [DllImport(ExternDll.Gdi32, SetLastError = true)]
+        public static extern int GetObject(HandleRef hObject, int nSize, ref BITMAP bm);
 
-        [DllImport(ExternDll.Gdi32, SetLastError = true, CharSet = CharSet.Auto)]
-        public static extern int GetObject(HandleRef hObject, int nSize, [In, Out] LOGFONT lf);
+        [DllImport(ExternDll.Gdi32, SetLastError = true, CharSet = CharSet.Unicode)]
+        public static extern int GetObject(HandleRef hObject, int nSize, ref LOGFONT lf);
 
-        public static int GetObject(HandleRef hObject, LOGFONT lp)
-        {
-            return GetObject(hObject, Marshal.SizeOf(typeof(LOGFONT)), lp);
-        }
+        public unsafe static int GetObject(HandleRef hObject, ref LOGFONT lp)
+            => GetObject(hObject, sizeof(LOGFONT), ref lp);
 
-        [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
-        public static extern bool GetIconInfo(HandleRef hIcon, [In, Out] ICONINFO info);
+        [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true)]
+        public static extern bool GetIconInfo(HandleRef hIcon, ref ICONINFO info);
 
         [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
         public static extern bool DrawIconEx(HandleRef hDC, int x, int y, HandleRef hIcon, int width, int height, int iStepIfAniCursor, HandleRef hBrushFlickerFree, int diFlags);
-
-#if CUSTOM_MARSHALING_ISTREAM
-        [DllImport(ExternDll.Oleaut32, PreserveSig=false)]
-        public static extern IPicture OleLoadPictureEx(
-                                                        [return: MarshalAs(UnmanagedType.CustomMarshaler,MarshalType="StreamToIStreamMarshaler")] Stream pStream, 
-                                                        int lSize, bool fRunmode, ref Guid refiid, int width, int height, int dwFlags);
-                                                        
-                                                        
-#endif
     }
 }
index 5c956fc..8fc6dc0 100644 (file)
@@ -2,10 +2,13 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+using System.Collections.Generic;
 using System.Drawing.Drawing2D;
 using System.Drawing.Imaging;
+using System.Drawing.Printing;
 using System.Drawing.Text;
 using System.IO;
+using System.Reflection;
 using System.Runtime.InteropServices;
 
 namespace System.Drawing
@@ -14,7 +17,7 @@ namespace System.Drawing
     {
         internal unsafe partial class Gdip
         {
-            private const string LibraryName = "libgdiplus";
+            internal const string LibraryName = "libgdiplus";
             public static IntPtr Display = IntPtr.Zero;
 
             // Indicates whether X11 is available. It's available on Linux but not on recent macOS versions
@@ -24,7 +27,7 @@ namespace System.Drawing
                 !RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ||
                 Environment.GetEnvironmentVariable("SYSTEM_DRAWING_COMMON_FORCE_X11") != null;
 
-            private static IntPtr LoadNativeLibrary()
+            internal static IntPtr LoadNativeLibrary()
             {
                 string libraryName;
 
@@ -90,1016 +93,600 @@ namespace System.Drawing
 
             private static void PlatformInitialize()
             {
-                LoadFunctionPointers();
-            }
-
-            private static void LoadFunctionPointers()
-            {
-                GdiplusStartup_ptr = FunctionWrapper.Load<GdiplusStartup_delegate>(s_gdipModule, "GdiplusStartup", LibraryName);
-                GdiplusShutdown_ptr = FunctionWrapper.Load<GdiplusShutdown_delegate>(s_gdipModule, "GdiplusShutdown", LibraryName);
-                GdipAlloc_ptr = FunctionWrapper.Load<GdipAlloc_delegate>(s_gdipModule, "GdipAlloc", LibraryName);
-                GdipFree_ptr = FunctionWrapper.Load<GdipFree_delegate>(s_gdipModule, "GdipFree", LibraryName);
-                GdipDeleteBrush_ptr = FunctionWrapper.Load<GdipDeleteBrush_delegate>(s_gdipModule, "GdipDeleteBrush", LibraryName);
-                GdipGetBrushType_ptr = FunctionWrapper.Load<GdipGetBrushType_delegate>(s_gdipModule, "GdipGetBrushType", LibraryName);
-                GdipCreateFromHDC_ptr = FunctionWrapper.Load<GdipCreateFromHDC_delegate>(s_gdipModule, "GdipCreateFromHDC", LibraryName);
-                GdipDeleteGraphics_ptr = FunctionWrapper.Load<GdipDeleteGraphics_delegate>(s_gdipModule, "GdipDeleteGraphics", LibraryName);
-                GdipRestoreGraphics_ptr = FunctionWrapper.Load<GdipRestoreGraphics_delegate>(s_gdipModule, "GdipRestoreGraphics", LibraryName);
-                GdipSaveGraphics_ptr = FunctionWrapper.Load<GdipSaveGraphics_delegate>(s_gdipModule, "GdipSaveGraphics", LibraryName);
-                GdipDrawArc_ptr = FunctionWrapper.Load<GdipDrawArc_delegate>(s_gdipModule, "GdipDrawArc", LibraryName);
-                GdipDrawArcI_ptr = FunctionWrapper.Load<GdipDrawArcI_delegate>(s_gdipModule, "GdipDrawArcI", LibraryName);
-                GdipDrawBezier_ptr = FunctionWrapper.Load<GdipDrawBezier_delegate>(s_gdipModule, "GdipDrawBezier", LibraryName);
-                GdipDrawBezierI_ptr = FunctionWrapper.Load<GdipDrawBezierI_delegate>(s_gdipModule, "GdipDrawBezierI", LibraryName);
-                GdipDrawEllipseI_ptr = FunctionWrapper.Load<GdipDrawEllipseI_delegate>(s_gdipModule, "GdipDrawEllipseI", LibraryName);
-                GdipDrawEllipse_ptr = FunctionWrapper.Load<GdipDrawEllipse_delegate>(s_gdipModule, "GdipDrawEllipse", LibraryName);
-                GdipDrawLine_ptr = FunctionWrapper.Load<GdipDrawLine_delegate>(s_gdipModule, "GdipDrawLine", LibraryName);
-                GdipDrawLineI_ptr = FunctionWrapper.Load<GdipDrawLineI_delegate>(s_gdipModule, "GdipDrawLineI", LibraryName);
-                GdipDrawLines_ptr = FunctionWrapper.Load<GdipDrawLines_delegate>(s_gdipModule, "GdipDrawLines", LibraryName);
-                GdipDrawLinesI_ptr = FunctionWrapper.Load<GdipDrawLinesI_delegate>(s_gdipModule, "GdipDrawLinesI", LibraryName);
-                GdipDrawPath_ptr = FunctionWrapper.Load<GdipDrawPath_delegate>(s_gdipModule, "GdipDrawPath", LibraryName);
-                GdipDrawPie_ptr = FunctionWrapper.Load<GdipDrawPie_delegate>(s_gdipModule, "GdipDrawPie", LibraryName);
-                GdipDrawPieI_ptr = FunctionWrapper.Load<GdipDrawPieI_delegate>(s_gdipModule, "GdipDrawPieI", LibraryName);
-                GdipDrawPolygon_ptr = FunctionWrapper.Load<GdipDrawPolygon_delegate>(s_gdipModule, "GdipDrawPolygon", LibraryName);
-                GdipDrawPolygonI_ptr = FunctionWrapper.Load<GdipDrawPolygonI_delegate>(s_gdipModule, "GdipDrawPolygonI", LibraryName);
-                GdipDrawRectangle_ptr = FunctionWrapper.Load<GdipDrawRectangle_delegate>(s_gdipModule, "GdipDrawRectangle", LibraryName);
-                GdipDrawRectangleI_ptr = FunctionWrapper.Load<GdipDrawRectangleI_delegate>(s_gdipModule, "GdipDrawRectangleI", LibraryName);
-                GdipDrawRectangles_ptr = FunctionWrapper.Load<GdipDrawRectangles_delegate>(s_gdipModule, "GdipDrawRectangles", LibraryName);
-                GdipDrawRectanglesI_ptr = FunctionWrapper.Load<GdipDrawRectanglesI_delegate>(s_gdipModule, "GdipDrawRectanglesI", LibraryName);
-                GdipFillEllipseI_ptr = FunctionWrapper.Load<GdipFillEllipseI_delegate>(s_gdipModule, "GdipFillEllipseI", LibraryName);
-                GdipFillEllipse_ptr = FunctionWrapper.Load<GdipFillEllipse_delegate>(s_gdipModule, "GdipFillEllipse", LibraryName);
-                GdipFillPolygon_ptr = FunctionWrapper.Load<GdipFillPolygon_delegate>(s_gdipModule, "GdipFillPolygon", LibraryName);
-                GdipFillPolygonI_ptr = FunctionWrapper.Load<GdipFillPolygonI_delegate>(s_gdipModule, "GdipFillPolygonI", LibraryName);
-                GdipFillPolygon2_ptr = FunctionWrapper.Load<GdipFillPolygon2_delegate>(s_gdipModule, "GdipFillPolygon2", LibraryName);
-                GdipFillPolygon2I_ptr = FunctionWrapper.Load<GdipFillPolygon2I_delegate>(s_gdipModule, "GdipFillPolygon2I", LibraryName);
-                GdipFillRectangle_ptr = FunctionWrapper.Load<GdipFillRectangle_delegate>(s_gdipModule, "GdipFillRectangle", LibraryName);
-                GdipFillRectangleI_ptr = FunctionWrapper.Load<GdipFillRectangleI_delegate>(s_gdipModule, "GdipFillRectangleI", LibraryName);
-                GdipFillRectangles_ptr = FunctionWrapper.Load<GdipFillRectangles_delegate>(s_gdipModule, "GdipFillRectangles", LibraryName);
-                GdipFillRectanglesI_ptr = FunctionWrapper.Load<GdipFillRectanglesI_delegate>(s_gdipModule, "GdipFillRectanglesI", LibraryName);
-                GdipDrawString_ptr = FunctionWrapper.Load<GdipDrawString_delegate>(s_gdipModule, "GdipDrawString", LibraryName);
-                GdipReleaseDC_ptr = FunctionWrapper.Load<GdipReleaseDC_delegate>(s_gdipModule, "GdipReleaseDC", LibraryName);
-                GdipDrawImageRectI_ptr = FunctionWrapper.Load<GdipDrawImageRectI_delegate>(s_gdipModule, "GdipDrawImageRectI", LibraryName);
-                GdipGraphicsClear_ptr = FunctionWrapper.Load<GdipGraphicsClear_delegate>(s_gdipModule, "GdipGraphicsClear", LibraryName);
-                GdipDrawClosedCurve_ptr = FunctionWrapper.Load<GdipDrawClosedCurve_delegate>(s_gdipModule, "GdipDrawClosedCurve", LibraryName);
-                GdipDrawClosedCurveI_ptr = FunctionWrapper.Load<GdipDrawClosedCurveI_delegate>(s_gdipModule, "GdipDrawClosedCurveI", LibraryName);
-                GdipDrawClosedCurve2_ptr = FunctionWrapper.Load<GdipDrawClosedCurve2_delegate>(s_gdipModule, "GdipDrawClosedCurve2", LibraryName);
-                GdipDrawClosedCurve2I_ptr = FunctionWrapper.Load<GdipDrawClosedCurve2I_delegate>(s_gdipModule, "GdipDrawClosedCurve2I", LibraryName);
-                GdipDrawCurve_ptr = FunctionWrapper.Load<GdipDrawCurve_delegate>(s_gdipModule, "GdipDrawCurve", LibraryName);
-                GdipDrawCurveI_ptr = FunctionWrapper.Load<GdipDrawCurveI_delegate>(s_gdipModule, "GdipDrawCurveI", LibraryName);
-                GdipDrawCurve2_ptr = FunctionWrapper.Load<GdipDrawCurve2_delegate>(s_gdipModule, "GdipDrawCurve2", LibraryName);
-                GdipDrawCurve2I_ptr = FunctionWrapper.Load<GdipDrawCurve2I_delegate>(s_gdipModule, "GdipDrawCurve2I", LibraryName);
-                GdipDrawCurve3_ptr = FunctionWrapper.Load<GdipDrawCurve3_delegate>(s_gdipModule, "GdipDrawCurve3", LibraryName);
-                GdipDrawCurve3I_ptr = FunctionWrapper.Load<GdipDrawCurve3I_delegate>(s_gdipModule, "GdipDrawCurve3I", LibraryName);
-                GdipFillClosedCurve_ptr = FunctionWrapper.Load<GdipFillClosedCurve_delegate>(s_gdipModule, "GdipFillClosedCurve", LibraryName);
-                GdipFillClosedCurveI_ptr = FunctionWrapper.Load<GdipFillClosedCurveI_delegate>(s_gdipModule, "GdipFillClosedCurveI", LibraryName);
-                GdipFillClosedCurve2_ptr = FunctionWrapper.Load<GdipFillClosedCurve2_delegate>(s_gdipModule, "GdipFillClosedCurve2", LibraryName);
-                GdipFillClosedCurve2I_ptr = FunctionWrapper.Load<GdipFillClosedCurve2I_delegate>(s_gdipModule, "GdipFillClosedCurve2I", LibraryName);
-                GdipFillPie_ptr = FunctionWrapper.Load<GdipFillPie_delegate>(s_gdipModule, "GdipFillPie", LibraryName);
-                GdipFillPieI_ptr = FunctionWrapper.Load<GdipFillPieI_delegate>(s_gdipModule, "GdipFillPieI", LibraryName);
-                GdipFillPath_ptr = FunctionWrapper.Load<GdipFillPath_delegate>(s_gdipModule, "GdipFillPath", LibraryName);
-                GdipGetNearestColor_ptr = FunctionWrapper.Load<GdipGetNearestColor_delegate>(s_gdipModule, "GdipGetNearestColor", LibraryName);
-                GdipTransformPoints_ptr = FunctionWrapper.Load<GdipTransformPoints_delegate>(s_gdipModule, "GdipTransformPoints", LibraryName);
-                GdipTransformPointsI_ptr = FunctionWrapper.Load<GdipTransformPointsI_delegate>(s_gdipModule, "GdipTransformPointsI", LibraryName);
-                GdipAddPathString_ptr = FunctionWrapper.Load<GdipAddPathString_delegate>(s_gdipModule, "GdipAddPathString", LibraryName);
-                GdipAddPathStringI_ptr = FunctionWrapper.Load<GdipAddPathStringI_delegate>(s_gdipModule, "GdipAddPathStringI", LibraryName);
-                GdipCreateFromHWND_ptr = FunctionWrapper.Load<GdipCreateFromHWND_delegate>(s_gdipModule, "GdipCreateFromHWND", LibraryName);
-                GdipMeasureString_ptr = FunctionWrapper.Load<GdipMeasureString_delegate>(s_gdipModule, "GdipMeasureString", LibraryName);
-                GdipMeasureCharacterRanges_ptr = FunctionWrapper.Load<GdipMeasureCharacterRanges_delegate>(s_gdipModule, "GdipMeasureCharacterRanges", LibraryName);
-                GdipLoadImageFromFile_ptr = FunctionWrapper.Load<GdipLoadImageFromFile_delegate>(s_gdipModule, "GdipLoadImageFromFile", LibraryName);
-                GdipCloneImage_ptr = FunctionWrapper.Load<GdipCloneImage_delegate>(s_gdipModule, "GdipCloneImage", LibraryName);
-                GdipLoadImageFromFileICM_ptr = FunctionWrapper.Load<GdipLoadImageFromFileICM_delegate>(s_gdipModule, "GdipLoadImageFromFileICM", LibraryName);
-                GdipCreateBitmapFromHBITMAP_ptr = FunctionWrapper.Load<GdipCreateBitmapFromHBITMAP_delegate>(s_gdipModule, "GdipCreateBitmapFromHBITMAP", LibraryName);
-                GdipDisposeImage_ptr = FunctionWrapper.Load<GdipDisposeImage_delegate>(s_gdipModule, "GdipDisposeImage", LibraryName);
-                GdipGetImageType_ptr = FunctionWrapper.Load<GdipGetImageType_delegate>(s_gdipModule, "GdipGetImageType", LibraryName);
-                GdipImageGetFrameDimensionsCount_ptr = FunctionWrapper.Load<GdipImageGetFrameDimensionsCount_delegate>(s_gdipModule, "GdipImageGetFrameDimensionsCount", LibraryName);
-                GdipImageGetFrameDimensionsList_ptr = FunctionWrapper.Load<GdipImageGetFrameDimensionsList_delegate>(s_gdipModule, "GdipImageGetFrameDimensionsList", LibraryName);
-                GdipGetImagePaletteSize_ptr = FunctionWrapper.Load<GdipGetImagePaletteSize_delegate>(s_gdipModule, "GdipGetImagePaletteSize", LibraryName);
-                GdipGetImagePalette_ptr = FunctionWrapper.Load<GdipGetImagePalette_delegate>(s_gdipModule, "GdipGetImagePalette", LibraryName);
-                GdipSetImagePalette_ptr = FunctionWrapper.Load<GdipSetImagePalette_delegate>(s_gdipModule, "GdipSetImagePalette", LibraryName);
-                GdipGetPropertyCount_ptr = FunctionWrapper.Load<GdipGetPropertyCount_delegate>(s_gdipModule, "GdipGetPropertyCount", LibraryName);
-                GdipGetPropertyIdList_ptr = FunctionWrapper.Load<GdipGetPropertyIdList_delegate>(s_gdipModule, "GdipGetPropertyIdList", LibraryName);
-                GdipGetPropertySize_ptr = FunctionWrapper.Load<GdipGetPropertySize_delegate>(s_gdipModule, "GdipGetPropertySize", LibraryName);
-                GdipGetAllPropertyItems_ptr = FunctionWrapper.Load<GdipGetAllPropertyItems_delegate>(s_gdipModule, "GdipGetAllPropertyItems", LibraryName);
-                GdipGetImageBounds_ptr = FunctionWrapper.Load<GdipGetImageBounds_delegate>(s_gdipModule, "GdipGetImageBounds", LibraryName);
-                GdipGetEncoderParameterListSize_ptr = FunctionWrapper.Load<GdipGetEncoderParameterListSize_delegate>(s_gdipModule, "GdipGetEncoderParameterListSize", LibraryName);
-                GdipGetEncoderParameterList_ptr = FunctionWrapper.Load<GdipGetEncoderParameterList_delegate>(s_gdipModule, "GdipGetEncoderParameterList", LibraryName);
-                GdipImageGetFrameCount_ptr = FunctionWrapper.Load<GdipImageGetFrameCount_delegate>(s_gdipModule, "GdipImageGetFrameCount", LibraryName);
-                GdipImageSelectActiveFrame_ptr = FunctionWrapper.Load<GdipImageSelectActiveFrame_delegate>(s_gdipModule, "GdipImageSelectActiveFrame", LibraryName);
-                GdipGetPropertyItemSize_ptr = FunctionWrapper.Load<GdipGetPropertyItemSize_delegate>(s_gdipModule, "GdipGetPropertyItemSize", LibraryName);
-                GdipGetPropertyItem_ptr = FunctionWrapper.Load<GdipGetPropertyItem_delegate>(s_gdipModule, "GdipGetPropertyItem", LibraryName);
-                GdipSetPropertyItem_ptr = FunctionWrapper.Load<GdipSetPropertyItem_delegate>(s_gdipModule, "GdipSetPropertyItem", LibraryName);
-                GdipGetImageThumbnail_ptr = FunctionWrapper.Load<GdipGetImageThumbnail_delegate>(s_gdipModule, "GdipGetImageThumbnail", LibraryName);
-                GdipImageRotateFlip_ptr = FunctionWrapper.Load<GdipImageRotateFlip_delegate>(s_gdipModule, "GdipImageRotateFlip", LibraryName);
-                GdipSaveImageToFile_ptr = FunctionWrapper.Load<GdipSaveImageToFile_delegate>(s_gdipModule, "GdipSaveImageToFile", LibraryName);
-                GdipSaveAdd_ptr = FunctionWrapper.Load<GdipSaveAdd_delegate>(s_gdipModule, "GdipSaveAdd", LibraryName);
-                GdipSaveAddImage_ptr = FunctionWrapper.Load<GdipSaveAddImage_delegate>(s_gdipModule, "GdipSaveAddImage", LibraryName);
-                GdipDrawImageI_ptr = FunctionWrapper.Load<GdipDrawImageI_delegate>(s_gdipModule, "GdipDrawImageI", LibraryName);
-                GdipGetImageGraphicsContext_ptr = FunctionWrapper.Load<GdipGetImageGraphicsContext_delegate>(s_gdipModule, "GdipGetImageGraphicsContext", LibraryName);
-                GdipDrawImage_ptr = FunctionWrapper.Load<GdipDrawImage_delegate>(s_gdipModule, "GdipDrawImage", LibraryName);
-                GdipDrawImagePoints_ptr = FunctionWrapper.Load<GdipDrawImagePoints_delegate>(s_gdipModule, "GdipDrawImagePoints", LibraryName);
-                GdipDrawImagePointsI_ptr = FunctionWrapper.Load<GdipDrawImagePointsI_delegate>(s_gdipModule, "GdipDrawImagePointsI", LibraryName);
-                GdipDrawImageRectRectI_ptr = FunctionWrapper.Load<GdipDrawImageRectRectI_delegate>(s_gdipModule, "GdipDrawImageRectRectI", LibraryName);
-                GdipDrawImageRectRect_ptr = FunctionWrapper.Load<GdipDrawImageRectRect_delegate>(s_gdipModule, "GdipDrawImageRectRect", LibraryName);
-                GdipDrawImagePointsRectI_ptr = FunctionWrapper.Load<GdipDrawImagePointsRectI_delegate>(s_gdipModule, "GdipDrawImagePointsRectI", LibraryName);
-                GdipDrawImagePointsRect_ptr = FunctionWrapper.Load<GdipDrawImagePointsRect_delegate>(s_gdipModule, "GdipDrawImagePointsRect", LibraryName);
-                GdipDrawImageRect_ptr = FunctionWrapper.Load<GdipDrawImageRect_delegate>(s_gdipModule, "GdipDrawImageRect", LibraryName);
-                GdipDrawImagePointRect_ptr = FunctionWrapper.Load<GdipDrawImagePointRect_delegate>(s_gdipModule, "GdipDrawImagePointRect", LibraryName);
-                GdipDrawImagePointRectI_ptr = FunctionWrapper.Load<GdipDrawImagePointRectI_delegate>(s_gdipModule, "GdipDrawImagePointRectI", LibraryName);
-                GdipCreatePath_ptr = FunctionWrapper.Load<GdipCreatePath_delegate>(s_gdipModule, "GdipCreatePath", LibraryName);
-                GdipCreatePath2_ptr = FunctionWrapper.Load<GdipCreatePath2_delegate>(s_gdipModule, "GdipCreatePath2", LibraryName);
-                GdipCreatePath2I_ptr = FunctionWrapper.Load<GdipCreatePath2I_delegate>(s_gdipModule, "GdipCreatePath2I", LibraryName);
-                GdipClonePath_ptr = FunctionWrapper.Load<GdipClonePath_delegate>(s_gdipModule, "GdipClonePath", LibraryName);
-                GdipDeletePath_ptr = FunctionWrapper.Load<GdipDeletePath_delegate>(s_gdipModule, "GdipDeletePath", LibraryName);
-                GdipResetPath_ptr = FunctionWrapper.Load<GdipResetPath_delegate>(s_gdipModule, "GdipResetPath", LibraryName);
-                GdipGetPointCount_ptr = FunctionWrapper.Load<GdipGetPointCount_delegate>(s_gdipModule, "GdipGetPointCount", LibraryName);
-                GdipGetPathTypes_ptr = FunctionWrapper.Load<GdipGetPathTypes_delegate>(s_gdipModule, "GdipGetPathTypes", LibraryName);
-                GdipGetPathPoints_ptr = FunctionWrapper.Load<GdipGetPathPoints_delegate>(s_gdipModule, "GdipGetPathPoints", LibraryName);
-                GdipGetPathPointsI_ptr = FunctionWrapper.Load<GdipGetPathPointsI_delegate>(s_gdipModule, "GdipGetPathPointsI", LibraryName);
-                GdipGetPathFillMode_ptr = FunctionWrapper.Load<GdipGetPathFillMode_delegate>(s_gdipModule, "GdipGetPathFillMode", LibraryName);
-                GdipSetPathFillMode_ptr = FunctionWrapper.Load<GdipSetPathFillMode_delegate>(s_gdipModule, "GdipSetPathFillMode", LibraryName);
-                GdipStartPathFigure_ptr = FunctionWrapper.Load<GdipStartPathFigure_delegate>(s_gdipModule, "GdipStartPathFigure", LibraryName);
-                GdipClosePathFigure_ptr = FunctionWrapper.Load<GdipClosePathFigure_delegate>(s_gdipModule, "GdipClosePathFigure", LibraryName);
-                GdipClosePathFigures_ptr = FunctionWrapper.Load<GdipClosePathFigures_delegate>(s_gdipModule, "GdipClosePathFigures", LibraryName);
-                GdipSetPathMarker_ptr = FunctionWrapper.Load<GdipSetPathMarker_delegate>(s_gdipModule, "GdipSetPathMarker", LibraryName);
-                GdipClearPathMarkers_ptr = FunctionWrapper.Load<GdipClearPathMarkers_delegate>(s_gdipModule, "GdipClearPathMarkers", LibraryName);
-                GdipReversePath_ptr = FunctionWrapper.Load<GdipReversePath_delegate>(s_gdipModule, "GdipReversePath", LibraryName);
-                GdipGetPathLastPoint_ptr = FunctionWrapper.Load<GdipGetPathLastPoint_delegate>(s_gdipModule, "GdipGetPathLastPoint", LibraryName);
-                GdipAddPathLine_ptr = FunctionWrapper.Load<GdipAddPathLine_delegate>(s_gdipModule, "GdipAddPathLine", LibraryName);
-                GdipAddPathLine2_ptr = FunctionWrapper.Load<GdipAddPathLine2_delegate>(s_gdipModule, "GdipAddPathLine2", LibraryName);
-                GdipAddPathLine2I_ptr = FunctionWrapper.Load<GdipAddPathLine2I_delegate>(s_gdipModule, "GdipAddPathLine2I", LibraryName);
-                GdipAddPathArc_ptr = FunctionWrapper.Load<GdipAddPathArc_delegate>(s_gdipModule, "GdipAddPathArc", LibraryName);
-                GdipAddPathBezier_ptr = FunctionWrapper.Load<GdipAddPathBezier_delegate>(s_gdipModule, "GdipAddPathBezier", LibraryName);
-                GdipAddPathBeziers_ptr = FunctionWrapper.Load<GdipAddPathBeziers_delegate>(s_gdipModule, "GdipAddPathBeziers", LibraryName);
-                GdipAddPathCurve_ptr = FunctionWrapper.Load<GdipAddPathCurve_delegate>(s_gdipModule, "GdipAddPathCurve", LibraryName);
-                GdipAddPathCurveI_ptr = FunctionWrapper.Load<GdipAddPathCurveI_delegate>(s_gdipModule, "GdipAddPathCurveI", LibraryName);
-                GdipAddPathCurve2_ptr = FunctionWrapper.Load<GdipAddPathCurve2_delegate>(s_gdipModule, "GdipAddPathCurve2", LibraryName);
-                GdipAddPathCurve2I_ptr = FunctionWrapper.Load<GdipAddPathCurve2I_delegate>(s_gdipModule, "GdipAddPathCurve2I", LibraryName);
-                GdipAddPathCurve3_ptr = FunctionWrapper.Load<GdipAddPathCurve3_delegate>(s_gdipModule, "GdipAddPathCurve3", LibraryName);
-                GdipAddPathCurve3I_ptr = FunctionWrapper.Load<GdipAddPathCurve3I_delegate>(s_gdipModule, "GdipAddPathCurve3I", LibraryName);
-                GdipAddPathClosedCurve_ptr = FunctionWrapper.Load<GdipAddPathClosedCurve_delegate>(s_gdipModule, "GdipAddPathClosedCurve", LibraryName);
-                GdipAddPathClosedCurveI_ptr = FunctionWrapper.Load<GdipAddPathClosedCurveI_delegate>(s_gdipModule, "GdipAddPathClosedCurveI", LibraryName);
-                GdipAddPathClosedCurve2_ptr = FunctionWrapper.Load<GdipAddPathClosedCurve2_delegate>(s_gdipModule, "GdipAddPathClosedCurve2", LibraryName);
-                GdipAddPathClosedCurve2I_ptr = FunctionWrapper.Load<GdipAddPathClosedCurve2I_delegate>(s_gdipModule, "GdipAddPathClosedCurve2I", LibraryName);
-                GdipAddPathRectangle_ptr = FunctionWrapper.Load<GdipAddPathRectangle_delegate>(s_gdipModule, "GdipAddPathRectangle", LibraryName);
-                GdipAddPathRectangles_ptr = FunctionWrapper.Load<GdipAddPathRectangles_delegate>(s_gdipModule, "GdipAddPathRectangles", LibraryName);
-                GdipAddPathEllipse_ptr = FunctionWrapper.Load<GdipAddPathEllipse_delegate>(s_gdipModule, "GdipAddPathEllipse", LibraryName);
-                GdipAddPathEllipseI_ptr = FunctionWrapper.Load<GdipAddPathEllipseI_delegate>(s_gdipModule, "GdipAddPathEllipseI", LibraryName);
-                GdipAddPathPie_ptr = FunctionWrapper.Load<GdipAddPathPie_delegate>(s_gdipModule, "GdipAddPathPie", LibraryName);
-                GdipAddPathPieI_ptr = FunctionWrapper.Load<GdipAddPathPieI_delegate>(s_gdipModule, "GdipAddPathPieI", LibraryName);
-                GdipAddPathPolygon_ptr = FunctionWrapper.Load<GdipAddPathPolygon_delegate>(s_gdipModule, "GdipAddPathPolygon", LibraryName);
-                GdipAddPathPath_ptr = FunctionWrapper.Load<GdipAddPathPath_delegate>(s_gdipModule, "GdipAddPathPath", LibraryName);
-                GdipAddPathLineI_ptr = FunctionWrapper.Load<GdipAddPathLineI_delegate>(s_gdipModule, "GdipAddPathLineI", LibraryName);
-                GdipAddPathArcI_ptr = FunctionWrapper.Load<GdipAddPathArcI_delegate>(s_gdipModule, "GdipAddPathArcI", LibraryName);
-                GdipAddPathBezierI_ptr = FunctionWrapper.Load<GdipAddPathBezierI_delegate>(s_gdipModule, "GdipAddPathBezierI", LibraryName);
-                GdipAddPathBeziersI_ptr = FunctionWrapper.Load<GdipAddPathBeziersI_delegate>(s_gdipModule, "GdipAddPathBeziersI", LibraryName);
-                GdipAddPathPolygonI_ptr = FunctionWrapper.Load<GdipAddPathPolygonI_delegate>(s_gdipModule, "GdipAddPathPolygonI", LibraryName);
-                GdipAddPathRectangleI_ptr = FunctionWrapper.Load<GdipAddPathRectangleI_delegate>(s_gdipModule, "GdipAddPathRectangleI", LibraryName);
-                GdipAddPathRectanglesI_ptr = FunctionWrapper.Load<GdipAddPathRectanglesI_delegate>(s_gdipModule, "GdipAddPathRectanglesI", LibraryName);
-                GdipFlattenPath_ptr = FunctionWrapper.Load<GdipFlattenPath_delegate>(s_gdipModule, "GdipFlattenPath", LibraryName);
-                GdipTransformPath_ptr = FunctionWrapper.Load<GdipTransformPath_delegate>(s_gdipModule, "GdipTransformPath", LibraryName);
-                GdipWarpPath_ptr = FunctionWrapper.Load<GdipWarpPath_delegate>(s_gdipModule, "GdipWarpPath", LibraryName);
-                GdipWidenPath_ptr = FunctionWrapper.Load<GdipWidenPath_delegate>(s_gdipModule, "GdipWidenPath", LibraryName);
-                GdipGetPathWorldBounds_ptr = FunctionWrapper.Load<GdipGetPathWorldBounds_delegate>(s_gdipModule, "GdipGetPathWorldBounds", LibraryName);
-                GdipGetPathWorldBoundsI_ptr = FunctionWrapper.Load<GdipGetPathWorldBoundsI_delegate>(s_gdipModule, "GdipGetPathWorldBoundsI", LibraryName);
-                GdipIsVisiblePathPoint_ptr = FunctionWrapper.Load<GdipIsVisiblePathPoint_delegate>(s_gdipModule, "GdipIsVisiblePathPoint", LibraryName);
-                GdipIsVisiblePathPointI_ptr = FunctionWrapper.Load<GdipIsVisiblePathPointI_delegate>(s_gdipModule, "GdipIsVisiblePathPointI", LibraryName);
-                GdipIsOutlineVisiblePathPoint_ptr = FunctionWrapper.Load<GdipIsOutlineVisiblePathPoint_delegate>(s_gdipModule, "GdipIsOutlineVisiblePathPoint", LibraryName);
-                GdipIsOutlineVisiblePathPointI_ptr = FunctionWrapper.Load<GdipIsOutlineVisiblePathPointI_delegate>(s_gdipModule, "GdipIsOutlineVisiblePathPointI", LibraryName);
-                GdipCreateFontFromDC_ptr = FunctionWrapper.Load<GdipCreateFontFromDC_delegate>(s_gdipModule, "GdipCreateFontFromDC", LibraryName);
-                GdipCreateFontFromLogfont_ptr = FunctionWrapper.Load<GdipCreateFontFromLogfont_delegate>(s_gdipModule, "GdipCreateFontFromLogfontW", LibraryName);
-                GdipCreateFontFromHfont_ptr = FunctionWrapper.Load<GdipCreateFontFromHfont_delegate>(s_gdipModule, "GdipCreateFontFromHfontA", LibraryName);
-                GdipCreateMetafileFromFile_ptr = FunctionWrapper.Load<GdipCreateMetafileFromFile_delegate>(s_gdipModule, "GdipCreateMetafileFromFile", LibraryName);
-                GdipCreateMetafileFromEmf_ptr = FunctionWrapper.Load<GdipCreateMetafileFromEmf_delegate>(s_gdipModule, "GdipCreateMetafileFromEmf", LibraryName);
-                GdipCreateMetafileFromWmf_ptr = FunctionWrapper.Load<GdipCreateMetafileFromWmf_delegate>(s_gdipModule, "GdipCreateMetafileFromWmf", LibraryName);
-                GdipGetMetafileHeaderFromFile_ptr = FunctionWrapper.Load<GdipGetMetafileHeaderFromFile_delegate>(s_gdipModule, "GdipGetMetafileHeaderFromFile", LibraryName);
-                GdipGetMetafileHeaderFromMetafile_ptr = FunctionWrapper.Load<GdipGetMetafileHeaderFromMetafile_delegate>(s_gdipModule, "GdipGetMetafileHeaderFromMetafile", LibraryName);
-                GdipGetMetafileHeaderFromEmf_ptr = FunctionWrapper.Load<GdipGetMetafileHeaderFromEmf_delegate>(s_gdipModule, "GdipGetMetafileHeaderFromEmf", LibraryName);
-                GdipGetMetafileHeaderFromWmf_ptr = FunctionWrapper.Load<GdipGetMetafileHeaderFromWmf_delegate>(s_gdipModule, "GdipGetMetafileHeaderFromWmf", LibraryName);
-                GdipGetHemfFromMetafile_ptr = FunctionWrapper.Load<GdipGetHemfFromMetafile_delegate>(s_gdipModule, "GdipGetHemfFromMetafile", LibraryName);
-                GdipGetMetafileDownLevelRasterizationLimit_ptr = FunctionWrapper.Load<GdipGetMetafileDownLevelRasterizationLimit_delegate>(s_gdipModule, "GdipGetMetafileDownLevelRasterizationLimit", LibraryName);
-                GdipSetMetafileDownLevelRasterizationLimit_ptr = FunctionWrapper.Load<GdipSetMetafileDownLevelRasterizationLimit_delegate>(s_gdipModule, "GdipSetMetafileDownLevelRasterizationLimit", LibraryName);
-                GdipPlayMetafileRecord_ptr = FunctionWrapper.Load<GdipPlayMetafileRecord_delegate>(s_gdipModule, "GdipPlayMetafileRecord", LibraryName);
-                GdipRecordMetafile_ptr = FunctionWrapper.Load<GdipRecordMetafile_delegate>(s_gdipModule, "GdipRecordMetafile", LibraryName);
-                GdipRecordMetafileI_ptr = FunctionWrapper.Load<GdipRecordMetafileI_delegate>(s_gdipModule, "GdipRecordMetafileI", LibraryName);
-                GdipRecordMetafileFileName_ptr = FunctionWrapper.Load<GdipRecordMetafileFileName_delegate>(s_gdipModule, "GdipRecordMetafileFileName", LibraryName);
-                GdipRecordMetafileFileNameI_ptr = FunctionWrapper.Load<GdipRecordMetafileFileNameI_delegate>(s_gdipModule, "GdipRecordMetafileFileNameI", LibraryName);
-                GdipCreateFromContext_macosx_ptr = FunctionWrapper.Load<GdipCreateFromContext_macosx_delegate>(s_gdipModule, "GdipCreateFromContext_macosx", LibraryName);
-                GdipSetVisibleClip_linux_ptr = FunctionWrapper.Load<GdipSetVisibleClip_linux_delegate>(s_gdipModule, "GdipSetVisibleClip_linux", LibraryName);
-                GdipCreateFromXDrawable_linux_ptr = FunctionWrapper.Load<GdipCreateFromXDrawable_linux_delegate>(s_gdipModule, "GdipCreateFromXDrawable_linux", LibraryName);
-                GdipLoadImageFromDelegate_linux_ptr = FunctionWrapper.Load<GdipLoadImageFromDelegate_linux_delegate>(s_gdipModule, "GdipLoadImageFromDelegate_linux", LibraryName);
-                GdipSaveImageToDelegate_linux_ptr = FunctionWrapper.Load<GdipSaveImageToDelegate_linux_delegate>(s_gdipModule, "GdipSaveImageToDelegate_linux", LibraryName);
-                GdipCreateMetafileFromDelegate_linux_ptr = FunctionWrapper.Load<GdipCreateMetafileFromDelegate_linux_delegate>(s_gdipModule, "GdipCreateMetafileFromDelegate_linux", LibraryName);
-                GdipGetMetafileHeaderFromDelegate_linux_ptr = FunctionWrapper.Load<GdipGetMetafileHeaderFromDelegate_linux_delegate>(s_gdipModule, "GdipGetMetafileHeaderFromDelegate_linux", LibraryName);
-                GdipRecordMetafileFromDelegate_linux_ptr = FunctionWrapper.Load<GdipRecordMetafileFromDelegate_linux_delegate>(s_gdipModule, "GdipRecordMetafileFromDelegate_linux", LibraryName);
-                GdipRecordMetafileFromDelegateI_linux_ptr = FunctionWrapper.Load<GdipRecordMetafileFromDelegateI_linux_delegate>(s_gdipModule, "GdipRecordMetafileFromDelegateI_linux", LibraryName);
-                GdipGetPostScriptSavePage_ptr = FunctionWrapper.Load<GdipGetPostScriptSavePage_delegate>(s_gdipModule, "GdipGetPostScriptSavePage", LibraryName);
-                GdipGetPostScriptGraphicsContext_ptr = FunctionWrapper.Load<GdipGetPostScriptGraphicsContext_delegate>(s_gdipModule, "GdipGetPostScriptGraphicsContext", LibraryName);
+                LibraryResolver.EnsureRegistered();
             }
 
             // Imported functions
 
-            private delegate int GdiplusStartup_delegate(out IntPtr token, ref StartupInput input, out StartupOutput output);
-            private static FunctionWrapper<GdiplusStartup_delegate> GdiplusStartup_ptr;
-            internal static int GdiplusStartup(out IntPtr token, ref StartupInput input, out StartupOutput output) => (int)GdiplusStartup_ptr.Delegate(out token, ref input, out output);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdiplusStartup(out IntPtr token, ref StartupInput input, out StartupOutput output);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern void GdiplusShutdown(ref ulong token);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern IntPtr GdipAlloc(int size);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern void GdipFree(IntPtr ptr);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeleteBrush(HandleRef brush);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetBrushType(IntPtr brush, out BrushType type);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateFromHDC(IntPtr hDC, out IntPtr graphics);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeleteGraphics(HandleRef graphics);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipRestoreGraphics(IntPtr graphics, uint graphicsState);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSaveGraphics(IntPtr graphics, out uint state);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawArc(IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawArcI(IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawBezier(IntPtr graphics, IntPtr pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawBezierI(IntPtr graphics, IntPtr pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawEllipseI(IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawEllipse(IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawLine(IntPtr graphics, IntPtr pen, float x1, float y1, float x2, float y2);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawLineI(IntPtr graphics, IntPtr pen, int x1, int y1, int x2, int y2);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawLines(IntPtr graphics, IntPtr pen, PointF[] points, int count);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawLinesI(IntPtr graphics, IntPtr pen, Point[] points, int count);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawPath(IntPtr graphics, IntPtr pen, IntPtr path);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawPie(IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawPieI(IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawPolygon(IntPtr graphics, IntPtr pen, PointF[] points, int count);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawPolygonI(IntPtr graphics, IntPtr pen, Point[] points, int count);
 
-            private delegate void GdiplusShutdown_delegate(ref ulong token);
-            private static FunctionWrapper<GdiplusShutdown_delegate> GdiplusShutdown_ptr;
-            internal static void GdiplusShutdown(ref ulong token) => GdiplusShutdown_ptr.Delegate(ref token);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawRectangle(IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
 
-            private delegate IntPtr GdipAlloc_delegate(int size);
-            private static FunctionWrapper<GdipAlloc_delegate> GdipAlloc_ptr;
-            internal static IntPtr GdipAlloc(int size) => GdipAlloc_ptr.Delegate(size);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawRectangleI(IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
 
-            private delegate void GdipFree_delegate(IntPtr ptr);
-            private static FunctionWrapper<GdipFree_delegate> GdipFree_ptr;
-            internal static void GdipFree(IntPtr ptr) => GdipFree_ptr.Delegate(ptr);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawRectangles(IntPtr graphics, IntPtr pen, RectangleF[] rects, int count);
 
-            private delegate int GdipDeleteBrush_delegate(IntPtr brush);
-            private static FunctionWrapper<GdipDeleteBrush_delegate> GdipDeleteBrush_ptr;
-            internal static int GdipDeleteBrush(IntPtr brush) => GdipDeleteBrush_ptr.Delegate(brush);
-            internal static int IntGdipDeleteBrush(HandleRef brush) => (int)GdipDeleteBrush_ptr.Delegate(brush.Handle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawRectanglesI(IntPtr graphics, IntPtr pen, Rectangle[] rects, int count);
 
-            private delegate int GdipGetBrushType_delegate(IntPtr brush, out BrushType type);
-            private static FunctionWrapper<GdipGetBrushType_delegate> GdipGetBrushType_ptr;
-            internal static int GdipGetBrushType(IntPtr brush, out BrushType type) => GdipGetBrushType_ptr.Delegate(brush, out type);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillEllipseI(IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
 
-            private delegate int GdipCreateFromHDC_delegate(IntPtr hDC, out IntPtr graphics);
-            private static FunctionWrapper<GdipCreateFromHDC_delegate> GdipCreateFromHDC_ptr;
-            internal static int GdipCreateFromHDC(IntPtr hDC, out IntPtr graphics) => GdipCreateFromHDC_ptr.Delegate(hDC, out graphics);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillEllipse(IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
 
-            private delegate int GdipDeleteGraphics_delegate(IntPtr graphics);
-            private static FunctionWrapper<GdipDeleteGraphics_delegate> GdipDeleteGraphics_ptr;
-            internal static int GdipDeleteGraphics(IntPtr graphics) => GdipDeleteGraphics_ptr.Delegate(graphics);
-            internal static int IntGdipDeleteGraphics(HandleRef graphics) => (int)GdipDeleteGraphics_ptr.Delegate(graphics.Handle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillPolygon(IntPtr graphics, IntPtr brush, PointF[] points, int count, FillMode fillMode);
 
-            private delegate int GdipRestoreGraphics_delegate(IntPtr graphics, uint graphicsState);
-            private static FunctionWrapper<GdipRestoreGraphics_delegate> GdipRestoreGraphics_ptr;
-            internal static int GdipRestoreGraphics(IntPtr graphics, uint graphicsState) => GdipRestoreGraphics_ptr.Delegate(graphics, graphicsState);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillPolygonI(IntPtr graphics, IntPtr brush, Point[] points, int count, FillMode fillMode);
 
-            private delegate int GdipSaveGraphics_delegate(IntPtr graphics, out uint state);
-            private static FunctionWrapper<GdipSaveGraphics_delegate> GdipSaveGraphics_ptr;
-            internal static int GdipSaveGraphics(IntPtr graphics, out uint state) => GdipSaveGraphics_ptr.Delegate(graphics, out state);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillPolygon2(IntPtr graphics, IntPtr brush, PointF[] points, int count);
 
-            private delegate int GdipDrawArc_delegate(IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipDrawArc_delegate> GdipDrawArc_ptr;
-            internal static int GdipDrawArc(IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle) => GdipDrawArc_ptr.Delegate(graphics, pen, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillPolygon2I(IntPtr graphics, IntPtr brush, Point[] points, int count);
 
-            private delegate int GdipDrawArcI_delegate(IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipDrawArcI_delegate> GdipDrawArcI_ptr;
-            internal static int GdipDrawArcI(IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle) => GdipDrawArcI_ptr.Delegate(graphics, pen, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillRectangle(IntPtr graphics, IntPtr brush, float x1, float y1, float x2, float y2);
 
-            private delegate int GdipDrawBezier_delegate(IntPtr graphics, IntPtr pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
-            private static FunctionWrapper<GdipDrawBezier_delegate> GdipDrawBezier_ptr;
-            internal static int GdipDrawBezier(IntPtr graphics, IntPtr pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) => GdipDrawBezier_ptr.Delegate(graphics, pen, x1, y1, x2, y2, x3, y3, x4, y4);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillRectangleI(IntPtr graphics, IntPtr brush, int x1, int y1, int x2, int y2);
 
-            private delegate int GdipDrawBezierI_delegate(IntPtr graphics, IntPtr pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
-            private static FunctionWrapper<GdipDrawBezierI_delegate> GdipDrawBezierI_ptr;
-            internal static int GdipDrawBezierI(IntPtr graphics, IntPtr pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) => GdipDrawBezierI_ptr.Delegate(graphics, pen, x1, y1, x2, y2, x3, y3, x4, y4);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillRectangles(IntPtr graphics, IntPtr brush, RectangleF[] rects, int count);
 
-            private delegate int GdipDrawEllipseI_delegate(IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
-            private static FunctionWrapper<GdipDrawEllipseI_delegate> GdipDrawEllipseI_ptr;
-            internal static int GdipDrawEllipseI(IntPtr graphics, IntPtr pen, int x, int y, int width, int height) => GdipDrawEllipseI_ptr.Delegate(graphics, pen, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillRectanglesI(IntPtr graphics, IntPtr brush, Rectangle[] rects, int count);
 
-            private delegate int GdipDrawEllipse_delegate(IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
-            private static FunctionWrapper<GdipDrawEllipse_delegate> GdipDrawEllipse_ptr;
-            internal static int GdipDrawEllipse(IntPtr graphics, IntPtr pen, float x, float y, float width, float height) => GdipDrawEllipse_ptr.Delegate(graphics, pen, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawString(IntPtr graphics, string text, int len, IntPtr font, ref RectangleF rc, IntPtr format, IntPtr brush);
 
-            private delegate int GdipDrawLine_delegate(IntPtr graphics, IntPtr pen, float x1, float y1, float x2, float y2);
-            private static FunctionWrapper<GdipDrawLine_delegate> GdipDrawLine_ptr;
-            internal static int GdipDrawLine(IntPtr graphics, IntPtr pen, float x1, float y1, float x2, float y2) => GdipDrawLine_ptr.Delegate(graphics, pen, x1, y1, x2, y2);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipReleaseDC(HandleRef graphics, HandleRef hdc);
 
-            private delegate int GdipDrawLineI_delegate(IntPtr graphics, IntPtr pen, int x1, int y1, int x2, int y2);
-            private static FunctionWrapper<GdipDrawLineI_delegate> GdipDrawLineI_ptr;
-            internal static int GdipDrawLineI(IntPtr graphics, IntPtr pen, int x1, int y1, int x2, int y2) => GdipDrawLineI_ptr.Delegate(graphics, pen, x1, y1, x2, y2);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImageRectI(IntPtr graphics, IntPtr image, int x, int y, int width, int height);
 
-            private delegate int GdipDrawLines_delegate(IntPtr graphics, IntPtr pen, PointF[] points, int count);
-            private static FunctionWrapper<GdipDrawLines_delegate> GdipDrawLines_ptr;
-            internal static int GdipDrawLines(IntPtr graphics, IntPtr pen, PointF[] points, int count) => GdipDrawLines_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGraphicsClear(IntPtr graphics, int argb);
 
-            private delegate int GdipDrawLinesI_delegate(IntPtr graphics, IntPtr pen, Point[] points, int count);
-            private static FunctionWrapper<GdipDrawLinesI_delegate> GdipDrawLinesI_ptr;
-            internal static int GdipDrawLinesI(IntPtr graphics, IntPtr pen, Point[] points, int count) => GdipDrawLinesI_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawClosedCurve(IntPtr graphics, IntPtr pen, PointF[] points, int count);
 
-            private delegate int GdipDrawPath_delegate(IntPtr graphics, IntPtr pen, IntPtr path);
-            private static FunctionWrapper<GdipDrawPath_delegate> GdipDrawPath_ptr;
-            internal static int GdipDrawPath(IntPtr graphics, IntPtr pen, IntPtr path) => GdipDrawPath_ptr.Delegate(graphics, pen, path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawClosedCurveI(IntPtr graphics, IntPtr pen, Point[] points, int count);
 
-            private delegate int GdipDrawPie_delegate(IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipDrawPie_delegate> GdipDrawPie_ptr;
-            internal static int GdipDrawPie(IntPtr graphics, IntPtr pen, float x, float y, float width, float height, float startAngle, float sweepAngle) => GdipDrawPie_ptr.Delegate(graphics, pen, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawClosedCurve2(IntPtr graphics, IntPtr pen, PointF[] points, int count, float tension);
 
-            private delegate int GdipDrawPieI_delegate(IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipDrawPieI_delegate> GdipDrawPieI_ptr;
-            internal static int GdipDrawPieI(IntPtr graphics, IntPtr pen, int x, int y, int width, int height, float startAngle, float sweepAngle) => GdipDrawPieI_ptr.Delegate(graphics, pen, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawClosedCurve2I(IntPtr graphics, IntPtr pen, Point[] points, int count, float tension);
 
-            private delegate int GdipDrawPolygon_delegate(IntPtr graphics, IntPtr pen, PointF[] points, int count);
-            private static FunctionWrapper<GdipDrawPolygon_delegate> GdipDrawPolygon_ptr;
-            internal static int GdipDrawPolygon(IntPtr graphics, IntPtr pen, PointF[] points, int count) => GdipDrawPolygon_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawCurve(IntPtr graphics, IntPtr pen, PointF[] points, int count);
 
-            private delegate int GdipDrawPolygonI_delegate(IntPtr graphics, IntPtr pen, Point[] points, int count);
-            private static FunctionWrapper<GdipDrawPolygonI_delegate> GdipDrawPolygonI_ptr;
-            internal static int GdipDrawPolygonI(IntPtr graphics, IntPtr pen, Point[] points, int count) => GdipDrawPolygonI_ptr.Delegate(graphics, pen, points, count);
-
-            private delegate int GdipDrawRectangle_delegate(IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
-            private static FunctionWrapper<GdipDrawRectangle_delegate> GdipDrawRectangle_ptr;
-            internal static int GdipDrawRectangle(IntPtr graphics, IntPtr pen, float x, float y, float width, float height) => GdipDrawRectangle_ptr.Delegate(graphics, pen, x, y, width, height);
-
-            private delegate int GdipDrawRectangleI_delegate(IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
-            private static FunctionWrapper<GdipDrawRectangleI_delegate> GdipDrawRectangleI_ptr;
-            internal static int GdipDrawRectangleI(IntPtr graphics, IntPtr pen, int x, int y, int width, int height) => GdipDrawRectangleI_ptr.Delegate(graphics, pen, x, y, width, height);
-
-            private delegate int GdipDrawRectangles_delegate(IntPtr graphics, IntPtr pen, RectangleF[] rects, int count);
-            private static FunctionWrapper<GdipDrawRectangles_delegate> GdipDrawRectangles_ptr;
-            internal static int GdipDrawRectangles(IntPtr graphics, IntPtr pen, RectangleF[] rects, int count) => GdipDrawRectangles_ptr.Delegate(graphics, pen, rects, count);
-
-            private delegate int GdipDrawRectanglesI_delegate(IntPtr graphics, IntPtr pen, Rectangle[] rects, int count);
-            private static FunctionWrapper<GdipDrawRectanglesI_delegate> GdipDrawRectanglesI_ptr;
-            internal static int GdipDrawRectanglesI(IntPtr graphics, IntPtr pen, Rectangle[] rects, int count) => GdipDrawRectanglesI_ptr.Delegate(graphics, pen, rects, count);
-
-            private delegate int GdipFillEllipseI_delegate(IntPtr graphics, IntPtr pen, int x, int y, int width, int height);
-            private static FunctionWrapper<GdipFillEllipseI_delegate> GdipFillEllipseI_ptr;
-            internal static int GdipFillEllipseI(IntPtr graphics, IntPtr pen, int x, int y, int width, int height) => GdipFillEllipseI_ptr.Delegate(graphics, pen, x, y, width, height);
-
-            private delegate int GdipFillEllipse_delegate(IntPtr graphics, IntPtr pen, float x, float y, float width, float height);
-            private static FunctionWrapper<GdipFillEllipse_delegate> GdipFillEllipse_ptr;
-            internal static int GdipFillEllipse(IntPtr graphics, IntPtr pen, float x, float y, float width, float height) => GdipFillEllipse_ptr.Delegate(graphics, pen, x, y, width, height);
-
-            private delegate int GdipFillPolygon_delegate(IntPtr graphics, IntPtr brush, PointF[] points, int count, FillMode fillMode);
-            private static FunctionWrapper<GdipFillPolygon_delegate> GdipFillPolygon_ptr;
-            internal static int GdipFillPolygon(IntPtr graphics, IntPtr brush, PointF[] points, int count, FillMode fillMode) => GdipFillPolygon_ptr.Delegate(graphics, brush, points, count, fillMode);
-
-            private delegate int GdipFillPolygonI_delegate(IntPtr graphics, IntPtr brush, Point[] points, int count, FillMode fillMode);
-            private static FunctionWrapper<GdipFillPolygonI_delegate> GdipFillPolygonI_ptr;
-            internal static int GdipFillPolygonI(IntPtr graphics, IntPtr brush, Point[] points, int count, FillMode fillMode) => GdipFillPolygonI_ptr.Delegate(graphics, brush, points, count, fillMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawCurveI(IntPtr graphics, IntPtr pen, Point[] points, int count);
 
-            private delegate int GdipFillPolygon2_delegate(IntPtr graphics, IntPtr brush, PointF[] points, int count);
-            private static FunctionWrapper<GdipFillPolygon2_delegate> GdipFillPolygon2_ptr;
-            internal static int GdipFillPolygon2(IntPtr graphics, IntPtr brush, PointF[] points, int count) => GdipFillPolygon2_ptr.Delegate(graphics, brush, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawCurve2(IntPtr graphics, IntPtr pen, PointF[] points, int count, float tension);
 
-            private delegate int GdipFillPolygon2I_delegate(IntPtr graphics, IntPtr brush, Point[] points, int count);
-            private static FunctionWrapper<GdipFillPolygon2I_delegate> GdipFillPolygon2I_ptr;
-            internal static int GdipFillPolygon2I(IntPtr graphics, IntPtr brush, Point[] points, int count) => GdipFillPolygon2I_ptr.Delegate(graphics, brush, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawCurve2I(IntPtr graphics, IntPtr pen, Point[] points, int count, float tension);
 
-            private delegate int GdipFillRectangle_delegate(IntPtr graphics, IntPtr brush, float x1, float y1, float x2, float y2);
-            private static FunctionWrapper<GdipFillRectangle_delegate> GdipFillRectangle_ptr;
-            internal static int GdipFillRectangle(IntPtr graphics, IntPtr brush, float x1, float y1, float x2, float y2) => GdipFillRectangle_ptr.Delegate(graphics, brush, x1, y1, x2, y2);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawCurve3(IntPtr graphics, IntPtr pen, PointF[] points, int count, int offset, int numberOfSegments, float tension);
 
-            private delegate int GdipFillRectangleI_delegate(IntPtr graphics, IntPtr brush, int x1, int y1, int x2, int y2);
-            private static FunctionWrapper<GdipFillRectangleI_delegate> GdipFillRectangleI_ptr;
-            internal static int GdipFillRectangleI(IntPtr graphics, IntPtr brush, int x1, int y1, int x2, int y2) => GdipFillRectangleI_ptr.Delegate(graphics, brush, x1, y1, x2, y2);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawCurve3I(IntPtr graphics, IntPtr pen, Point[] points, int count, int offset, int numberOfSegments, float tension);
 
-            private delegate int GdipFillRectangles_delegate(IntPtr graphics, IntPtr brush, RectangleF[] rects, int count);
-            private static FunctionWrapper<GdipFillRectangles_delegate> GdipFillRectangles_ptr;
-            internal static int GdipFillRectangles(IntPtr graphics, IntPtr brush, RectangleF[] rects, int count) => GdipFillRectangles_ptr.Delegate(graphics, brush, rects, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillClosedCurve(IntPtr graphics, IntPtr brush, PointF[] points, int count);
 
-            private delegate int GdipFillRectanglesI_delegate(IntPtr graphics, IntPtr brush, Rectangle[] rects, int count);
-            private static FunctionWrapper<GdipFillRectanglesI_delegate> GdipFillRectanglesI_ptr;
-            internal static int GdipFillRectanglesI(IntPtr graphics, IntPtr brush, Rectangle[] rects, int count) => GdipFillRectanglesI_ptr.Delegate(graphics, brush, rects, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillClosedCurveI(IntPtr graphics, IntPtr brush, Point[] points, int count);
 
-            private delegate int GdipDrawString_delegate(IntPtr graphics, [MarshalAs(UnmanagedType.LPWStr)]string text, int len, IntPtr font, ref RectangleF rc, IntPtr format, IntPtr brush);
-            private static FunctionWrapper<GdipDrawString_delegate> GdipDrawString_ptr;
-            internal static int GdipDrawString(IntPtr graphics, string text, int len, IntPtr font, ref RectangleF rc, IntPtr format, IntPtr brush) => GdipDrawString_ptr.Delegate(graphics, text, len, font, ref rc, format, brush);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillClosedCurve2(IntPtr graphics, IntPtr brush, PointF[] points, int count, float tension, FillMode fillMode);
 
-            private delegate int GdipReleaseDC_delegate(IntPtr graphics, IntPtr hdc);
-            private static FunctionWrapper<GdipReleaseDC_delegate> GdipReleaseDC_ptr;
-            internal static int GdipReleaseDC(IntPtr graphics, IntPtr hdc) => GdipReleaseDC_ptr.Delegate(graphics, hdc);
-            internal static int IntGdipReleaseDC(HandleRef graphics, HandleRef hdc) => (int)GdipReleaseDC_ptr.Delegate(graphics.Handle, hdc.Handle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillClosedCurve2I(IntPtr graphics, IntPtr brush, Point[] points, int count, float tension, FillMode fillMode);
 
-            private delegate int GdipDrawImageRectI_delegate(IntPtr graphics, IntPtr image, int x, int y, int width, int height);
-            private static FunctionWrapper<GdipDrawImageRectI_delegate> GdipDrawImageRectI_ptr;
-            internal static int GdipDrawImageRectI(IntPtr graphics, IntPtr image, int x, int y, int width, int height) => GdipDrawImageRectI_ptr.Delegate(graphics, image, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillPie(IntPtr graphics, IntPtr brush, float x, float y, float width, float height, float startAngle, float sweepAngle);
 
-            private delegate int GdipGraphicsClear_delegate(IntPtr graphics, int argb);
-            private static FunctionWrapper<GdipGraphicsClear_delegate> GdipGraphicsClear_ptr;
-            internal static int GdipGraphicsClear(IntPtr graphics, int argb) => GdipGraphicsClear_ptr.Delegate(graphics, argb);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillPieI(IntPtr graphics, IntPtr brush, int x, int y, int width, int height, float startAngle, float sweepAngle);
 
-            private delegate int GdipDrawClosedCurve_delegate(IntPtr graphics, IntPtr pen, PointF[] points, int count);
-            private static FunctionWrapper<GdipDrawClosedCurve_delegate> GdipDrawClosedCurve_ptr;
-            internal static int GdipDrawClosedCurve(IntPtr graphics, IntPtr pen, PointF[] points, int count) => GdipDrawClosedCurve_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillPath(IntPtr graphics, IntPtr brush, IntPtr path);
 
-            private delegate int GdipDrawClosedCurveI_delegate(IntPtr graphics, IntPtr pen, Point[] points, int count);
-            private static FunctionWrapper<GdipDrawClosedCurveI_delegate> GdipDrawClosedCurveI_ptr;
-            internal static int GdipDrawClosedCurveI(IntPtr graphics, IntPtr pen, Point[] points, int count) => GdipDrawClosedCurveI_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetNearestColor(IntPtr graphics, out int argb);
 
-            private delegate int GdipDrawClosedCurve2_delegate(IntPtr graphics, IntPtr pen, PointF[] points, int count, float tension);
-            private static FunctionWrapper<GdipDrawClosedCurve2_delegate> GdipDrawClosedCurve2_ptr;
-            internal static int GdipDrawClosedCurve2(IntPtr graphics, IntPtr pen, PointF[] points, int count, float tension) => GdipDrawClosedCurve2_ptr.Delegate(graphics, pen, points, count, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTransformPoints(IntPtr graphics, CoordinateSpace destSpace, CoordinateSpace srcSpace, IntPtr points, int count);
 
-            private delegate int GdipDrawClosedCurve2I_delegate(IntPtr graphics, IntPtr pen, Point[] points, int count, float tension);
-            private static FunctionWrapper<GdipDrawClosedCurve2I_delegate> GdipDrawClosedCurve2I_ptr;
-            internal static int GdipDrawClosedCurve2I(IntPtr graphics, IntPtr pen, Point[] points, int count, float tension) => GdipDrawClosedCurve2I_ptr.Delegate(graphics, pen, points, count, tension);
-
-            private delegate int GdipDrawCurve_delegate(IntPtr graphics, IntPtr pen, PointF[] points, int count);
-            private static FunctionWrapper<GdipDrawCurve_delegate> GdipDrawCurve_ptr;
-            internal static int GdipDrawCurve(IntPtr graphics, IntPtr pen, PointF[] points, int count) => GdipDrawCurve_ptr.Delegate(graphics, pen, points, count);
-
-            private delegate int GdipDrawCurveI_delegate(IntPtr graphics, IntPtr pen, Point[] points, int count);
-            private static FunctionWrapper<GdipDrawCurveI_delegate> GdipDrawCurveI_ptr;
-            internal static int GdipDrawCurveI(IntPtr graphics, IntPtr pen, Point[] points, int count) => GdipDrawCurveI_ptr.Delegate(graphics, pen, points, count);
-
-            private delegate int GdipDrawCurve2_delegate(IntPtr graphics, IntPtr pen, PointF[] points, int count, float tension);
-            private static FunctionWrapper<GdipDrawCurve2_delegate> GdipDrawCurve2_ptr;
-            internal static int GdipDrawCurve2(IntPtr graphics, IntPtr pen, PointF[] points, int count, float tension) => GdipDrawCurve2_ptr.Delegate(graphics, pen, points, count, tension);
-
-            private delegate int GdipDrawCurve2I_delegate(IntPtr graphics, IntPtr pen, Point[] points, int count, float tension);
-            private static FunctionWrapper<GdipDrawCurve2I_delegate> GdipDrawCurve2I_ptr;
-            internal static int GdipDrawCurve2I(IntPtr graphics, IntPtr pen, Point[] points, int count, float tension) => GdipDrawCurve2I_ptr.Delegate(graphics, pen, points, count, tension);
-
-            private delegate int GdipDrawCurve3_delegate(IntPtr graphics, IntPtr pen, PointF[] points, int count, int offset, int numberOfSegments, float tension);
-            private static FunctionWrapper<GdipDrawCurve3_delegate> GdipDrawCurve3_ptr;
-            internal static int GdipDrawCurve3(IntPtr graphics, IntPtr pen, PointF[] points, int count, int offset, int numberOfSegments, float tension) => GdipDrawCurve3_ptr.Delegate(graphics, pen, points, count, offset, numberOfSegments, tension);
-
-            private delegate int GdipDrawCurve3I_delegate(IntPtr graphics, IntPtr pen, Point[] points, int count, int offset, int numberOfSegments, float tension);
-            private static FunctionWrapper<GdipDrawCurve3I_delegate> GdipDrawCurve3I_ptr;
-            internal static int GdipDrawCurve3I(IntPtr graphics, IntPtr pen, Point[] points, int count, int offset, int numberOfSegments, float tension) => GdipDrawCurve3I_ptr.Delegate(graphics, pen, points, count, offset, numberOfSegments, tension);
-
-            private delegate int GdipFillClosedCurve_delegate(IntPtr graphics, IntPtr brush, PointF[] points, int count);
-            private static FunctionWrapper<GdipFillClosedCurve_delegate> GdipFillClosedCurve_ptr;
-            internal static int GdipFillClosedCurve(IntPtr graphics, IntPtr brush, PointF[] points, int count) => GdipFillClosedCurve_ptr.Delegate(graphics, brush, points, count);
-
-            private delegate int GdipFillClosedCurveI_delegate(IntPtr graphics, IntPtr brush, Point[] points, int count);
-            private static FunctionWrapper<GdipFillClosedCurveI_delegate> GdipFillClosedCurveI_ptr;
-            internal static int GdipFillClosedCurveI(IntPtr graphics, IntPtr brush, Point[] points, int count) => GdipFillClosedCurveI_ptr.Delegate(graphics, brush, points, count);
-
-            private delegate int GdipFillClosedCurve2_delegate(IntPtr graphics, IntPtr brush, PointF[] points, int count, float tension, FillMode fillMode);
-            private static FunctionWrapper<GdipFillClosedCurve2_delegate> GdipFillClosedCurve2_ptr;
-            internal static int GdipFillClosedCurve2(IntPtr graphics, IntPtr brush, PointF[] points, int count, float tension, FillMode fillMode) => GdipFillClosedCurve2_ptr.Delegate(graphics, brush, points, count, tension, fillMode);
-
-            private delegate int GdipFillClosedCurve2I_delegate(IntPtr graphics, IntPtr brush, Point[] points, int count, float tension, FillMode fillMode);
-            private static FunctionWrapper<GdipFillClosedCurve2I_delegate> GdipFillClosedCurve2I_ptr;
-            internal static int GdipFillClosedCurve2I(IntPtr graphics, IntPtr brush, Point[] points, int count, float tension, FillMode fillMode) => GdipFillClosedCurve2I_ptr.Delegate(graphics, brush, points, count, tension, fillMode);
-
-            private delegate int GdipFillPie_delegate(IntPtr graphics, IntPtr brush, float x, float y, float width, float height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipFillPie_delegate> GdipFillPie_ptr;
-            internal static int GdipFillPie(IntPtr graphics, IntPtr brush, float x, float y, float width, float height, float startAngle, float sweepAngle) => GdipFillPie_ptr.Delegate(graphics, brush, x, y, width, height, startAngle, sweepAngle);
-
-            private delegate int GdipFillPieI_delegate(IntPtr graphics, IntPtr brush, int x, int y, int width, int height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipFillPieI_delegate> GdipFillPieI_ptr;
-            internal static int GdipFillPieI(IntPtr graphics, IntPtr brush, int x, int y, int width, int height, float startAngle, float sweepAngle) => GdipFillPieI_ptr.Delegate(graphics, brush, x, y, width, height, startAngle, sweepAngle);
-
-            private delegate int GdipFillPath_delegate(IntPtr graphics, IntPtr brush, IntPtr path);
-            private static FunctionWrapper<GdipFillPath_delegate> GdipFillPath_ptr;
-            internal static int GdipFillPath(IntPtr graphics, IntPtr brush, IntPtr path) => GdipFillPath_ptr.Delegate(graphics, brush, path);
-
-            private delegate int GdipGetNearestColor_delegate(IntPtr graphics, out int argb);
-            private static FunctionWrapper<GdipGetNearestColor_delegate> GdipGetNearestColor_ptr;
-            internal static int GdipGetNearestColor(IntPtr graphics, out int argb) => GdipGetNearestColor_ptr.Delegate(graphics, out argb);
-
-            private delegate int GdipTransformPoints_delegate(IntPtr graphics, CoordinateSpace destSpace, CoordinateSpace srcSpace, IntPtr points, int count);
-            private static FunctionWrapper<GdipTransformPoints_delegate> GdipTransformPoints_ptr;
-            internal static int GdipTransformPoints(IntPtr graphics, CoordinateSpace destSpace, CoordinateSpace srcSpace, IntPtr points, int count) => GdipTransformPoints_ptr.Delegate(graphics, destSpace, srcSpace, points, count);
-
-            private delegate int GdipTransformPointsI_delegate(IntPtr graphics, CoordinateSpace destSpace, CoordinateSpace srcSpace, IntPtr points, int count);
-            private static FunctionWrapper<GdipTransformPointsI_delegate> GdipTransformPointsI_ptr;
-            internal static int GdipTransformPointsI(IntPtr graphics, CoordinateSpace destSpace, CoordinateSpace srcSpace, IntPtr points, int count) => GdipTransformPointsI_ptr.Delegate(graphics, destSpace, srcSpace, points, count);
-
-            private delegate int GdipAddPathString_delegate(IntPtr path, [MarshalAs(UnmanagedType.LPWStr)]string s, int lenght, IntPtr family, int style, float emSize, ref RectangleF layoutRect, IntPtr format);
-            private static FunctionWrapper<GdipAddPathString_delegate> GdipAddPathString_ptr;
-            internal static int GdipAddPathString(IntPtr path, string s, int lenght, IntPtr family, int style, float emSize, ref RectangleF layoutRect, IntPtr format) => GdipAddPathString_ptr.Delegate(path, s, lenght, family, style, emSize, ref layoutRect, format);
-
-            private delegate int GdipAddPathStringI_delegate(IntPtr path, [MarshalAs(UnmanagedType.LPWStr)]string s, int lenght, IntPtr family, int style, float emSize, ref Rectangle layoutRect, IntPtr format);
-            private static FunctionWrapper<GdipAddPathStringI_delegate> GdipAddPathStringI_ptr;
-            internal static int GdipAddPathStringI(IntPtr path, string s, int lenght, IntPtr family, int style, float emSize, ref Rectangle layoutRect, IntPtr format) => GdipAddPathStringI_ptr.Delegate(path, s, lenght, family, style, emSize, ref layoutRect, format);
-
-            private delegate int GdipCreateFromHWND_delegate(IntPtr hwnd, out IntPtr graphics);
-            private static FunctionWrapper<GdipCreateFromHWND_delegate> GdipCreateFromHWND_ptr;
-            internal static int GdipCreateFromHWND(IntPtr hwnd, out IntPtr graphics) => GdipCreateFromHWND_ptr.Delegate(hwnd, out graphics);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTransformPointsI(IntPtr graphics, CoordinateSpace destSpace, CoordinateSpace srcSpace, IntPtr points, int count);
 
-            private delegate int GdipMeasureString_delegate(IntPtr graphics, [MarshalAs(UnmanagedType.LPWStr)]string str, int length, IntPtr font, ref RectangleF layoutRect, IntPtr stringFormat, out RectangleF boundingBox, int* codepointsFitted, int* linesFilled);
-            private static FunctionWrapper<GdipMeasureString_delegate> GdipMeasureString_ptr;
-            internal static int GdipMeasureString(IntPtr graphics, string str, int length, IntPtr font, ref RectangleF layoutRect, IntPtr stringFormat, out RectangleF boundingBox, int* codepointsFitted, int* linesFilled) => GdipMeasureString_ptr.Delegate(graphics, str, length, font, ref layoutRect, stringFormat, out boundingBox, codepointsFitted, linesFilled);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipAddPathString(IntPtr path, string s, int lenght, IntPtr family, int style, float emSize, ref RectangleF layoutRect, IntPtr format);
 
-            private delegate int GdipMeasureCharacterRanges_delegate(IntPtr graphics, [MarshalAs(UnmanagedType.LPWStr)]string str, int length, IntPtr font, ref RectangleF layoutRect, IntPtr stringFormat, int regcount, out IntPtr regions);
-            private static FunctionWrapper<GdipMeasureCharacterRanges_delegate> GdipMeasureCharacterRanges_ptr;
-            internal static int GdipMeasureCharacterRanges(IntPtr graphics, string str, int length, IntPtr font, ref RectangleF layoutRect, IntPtr stringFormat, int regcount, out IntPtr regions) => GdipMeasureCharacterRanges_ptr.Delegate(graphics, str, length, font, ref layoutRect, stringFormat, regcount, out regions);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipAddPathStringI(IntPtr path, string s, int lenght, IntPtr family, int style, float emSize, ref Rectangle layoutRect, IntPtr format);
 
-            private delegate int GdipLoadImageFromFile_delegate([MarshalAs(UnmanagedType.LPWStr)]string filename, out IntPtr image);
-            private static FunctionWrapper<GdipLoadImageFromFile_delegate> GdipLoadImageFromFile_ptr;
-            internal static int GdipLoadImageFromFile(string filename, out IntPtr image) => GdipLoadImageFromFile_ptr.Delegate(filename, out image);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateFromHWND(IntPtr hwnd, out IntPtr graphics);
 
-            private delegate int GdipCloneImage_delegate(IntPtr image, out IntPtr imageclone);
-            private static FunctionWrapper<GdipCloneImage_delegate> GdipCloneImage_ptr;
-            internal static int GdipCloneImage(IntPtr image, out IntPtr imageclone) => GdipCloneImage_ptr.Delegate(image, out imageclone);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipMeasureString(IntPtr graphics, string str, int length, IntPtr font, ref RectangleF layoutRect, IntPtr stringFormat, out RectangleF boundingBox, int* codepointsFitted, int* linesFilled);
 
-            private delegate int GdipLoadImageFromFileICM_delegate([MarshalAs(UnmanagedType.LPWStr)]string filename, out IntPtr image);
-            private static FunctionWrapper<GdipLoadImageFromFileICM_delegate> GdipLoadImageFromFileICM_ptr;
-            internal static int GdipLoadImageFromFileICM(string filename, out IntPtr image) => GdipLoadImageFromFileICM_ptr.Delegate(filename, out image);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipMeasureCharacterRanges(IntPtr graphics, string str, int length, IntPtr font, ref RectangleF layoutRect, IntPtr stringFormat, int regcount, out IntPtr regions);
 
-            private delegate int GdipDisposeImage_delegate(IntPtr image);
-            private static FunctionWrapper<GdipDisposeImage_delegate> GdipDisposeImage_ptr;
-            internal static int GdipDisposeImage(IntPtr image) => GdipDisposeImage_ptr.Delegate(image);
-            internal static int IntGdipDisposeImage(HandleRef image) => (int)GdipDisposeImage_ptr.Delegate(image.Handle);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipLoadImageFromFile(string filename, out IntPtr image);
 
-            private delegate int GdipGetImageType_delegate(IntPtr image, out ImageType type);
-            private static FunctionWrapper<GdipGetImageType_delegate> GdipGetImageType_ptr;
-            internal static int GdipGetImageType(IntPtr image, out ImageType type) => GdipGetImageType_ptr.Delegate(image, out type);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCloneImage(IntPtr image, out IntPtr imageclone);
 
-            private delegate int GdipGetImagePaletteSize_delegate(IntPtr image, out int size);
-            private static FunctionWrapper<GdipGetImagePaletteSize_delegate> GdipGetImagePaletteSize_ptr;
-            internal static int GdipGetImagePaletteSize(IntPtr image, out int size) => GdipGetImagePaletteSize_ptr.Delegate(image, out size);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipLoadImageFromFileICM(string filename, out IntPtr image);
 
-            private delegate int GdipGetImagePalette_delegate(IntPtr image, IntPtr palette, int size);
-            private static FunctionWrapper<GdipGetImagePalette_delegate> GdipGetImagePalette_ptr;
-            internal static int GdipGetImagePalette(IntPtr image, IntPtr palette, int size) => GdipGetImagePalette_ptr.Delegate(image, palette, size);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDisposeImage(HandleRef image);
 
-            private delegate int GdipSetImagePalette_delegate(IntPtr image, IntPtr palette);
-            private static FunctionWrapper<GdipSetImagePalette_delegate> GdipSetImagePalette_ptr;
-            internal static int GdipSetImagePalette(IntPtr image, IntPtr palette) => GdipSetImagePalette_ptr.Delegate(image, palette);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageType(IntPtr image, out ImageType type);
 
-            private delegate int GdipGetPropertyCount_delegate(IntPtr image, out uint propNumbers);
-            private static FunctionWrapper<GdipGetPropertyCount_delegate> GdipGetPropertyCount_ptr;
-            internal static int GdipGetPropertyCount(IntPtr image, out uint propNumbers) => GdipGetPropertyCount_ptr.Delegate(image, out propNumbers);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImagePaletteSize(IntPtr image, out int size);
 
-            private delegate int GdipGetPropertyIdList_delegate(IntPtr image, uint propNumbers, [Out] int[] list);
-            private static FunctionWrapper<GdipGetPropertyIdList_delegate> GdipGetPropertyIdList_ptr;
-            internal static int GdipGetPropertyIdList(IntPtr image, uint propNumbers, [Out] int[] list) => GdipGetPropertyIdList_ptr.Delegate(image, propNumbers, list);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImagePalette(IntPtr image, IntPtr palette, int size);
 
-            private delegate int GdipGetPropertySize_delegate(IntPtr image, out int bufferSize, out int propNumbers);
-            private static FunctionWrapper<GdipGetPropertySize_delegate> GdipGetPropertySize_ptr;
-            internal static int GdipGetPropertySize(IntPtr image, out int bufferSize, out int propNumbers) => GdipGetPropertySize_ptr.Delegate(image, out bufferSize, out propNumbers);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetImagePalette(IntPtr image, IntPtr palette);
 
-            private delegate int GdipGetAllPropertyItems_delegate(IntPtr image, int bufferSize, int propNumbers, IntPtr items);
-            private static FunctionWrapper<GdipGetAllPropertyItems_delegate> GdipGetAllPropertyItems_ptr;
-            internal static int GdipGetAllPropertyItems(IntPtr image, int bufferSize, int propNumbers, IntPtr items) => GdipGetAllPropertyItems_ptr.Delegate(image, bufferSize, propNumbers, items);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPropertyCount(IntPtr image, out uint propNumbers);
 
-            private delegate int GdipGetImageBounds_delegate(IntPtr image, out RectangleF source, ref GraphicsUnit unit);
-            private static FunctionWrapper<GdipGetImageBounds_delegate> GdipGetImageBounds_ptr;
-            internal static int GdipGetImageBounds(IntPtr image, out RectangleF source, ref GraphicsUnit unit) => GdipGetImageBounds_ptr.Delegate(image, out source, ref unit);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPropertyIdList(IntPtr image, uint propNumbers, [Out] int[] list);
 
-            private delegate int GdipGetEncoderParameterListSize_delegate(IntPtr image, ref Guid encoder, out uint size);
-            private static FunctionWrapper<GdipGetEncoderParameterListSize_delegate> GdipGetEncoderParameterListSize_ptr;
-            internal static int GdipGetEncoderParameterListSize(IntPtr image, ref Guid encoder, out uint size) => GdipGetEncoderParameterListSize_ptr.Delegate(image, ref encoder, out size);
-
-            private delegate int GdipGetEncoderParameterList_delegate(IntPtr image, ref Guid encoder, uint size, IntPtr buffer);
-            private static FunctionWrapper<GdipGetEncoderParameterList_delegate> GdipGetEncoderParameterList_ptr;
-            internal static int GdipGetEncoderParameterList(IntPtr image, ref Guid encoder, uint size, IntPtr buffer) => GdipGetEncoderParameterList_ptr.Delegate(image, ref encoder, size, buffer);
-
-            private delegate int GdipGetPropertyItemSize_delegate(IntPtr image, int propertyID, out int propertySize);
-            private static FunctionWrapper<GdipGetPropertyItemSize_delegate> GdipGetPropertyItemSize_ptr;
-            internal static int GdipGetPropertyItemSize(IntPtr image, int propertyID, out int propertySize) => GdipGetPropertyItemSize_ptr.Delegate(image, propertyID, out propertySize);
-
-            private delegate int GdipGetPropertyItem_delegate(IntPtr image, int propertyID, int propertySize, IntPtr buffer);
-            private static FunctionWrapper<GdipGetPropertyItem_delegate> GdipGetPropertyItem_ptr;
-            internal static int GdipGetPropertyItem(IntPtr image, int propertyID, int propertySize, IntPtr buffer) => GdipGetPropertyItem_ptr.Delegate(image, propertyID, propertySize, buffer);
-
-            private delegate int GdipSetPropertyItem_delegate(IntPtr image, GdipPropertyItem* propertyItem);
-            private static FunctionWrapper<GdipSetPropertyItem_delegate> GdipSetPropertyItem_ptr;
-            internal static int GdipSetPropertyItem(IntPtr image, GdipPropertyItem* propertyItem) => GdipSetPropertyItem_ptr.Delegate(image, propertyItem);
-
-            private delegate int GdipGetImageThumbnail_delegate(IntPtr image, uint width, uint height, out IntPtr thumbImage, IntPtr callback, IntPtr callBackData);
-            private static FunctionWrapper<GdipGetImageThumbnail_delegate> GdipGetImageThumbnail_ptr;
-            internal static int GdipGetImageThumbnail(IntPtr image, uint width, uint height, out IntPtr thumbImage, IntPtr callback, IntPtr callBackData) => GdipGetImageThumbnail_ptr.Delegate(image, width, height, out thumbImage, callback, callBackData);
-
-            private delegate int GdipSaveImageToFile_delegate(IntPtr image, [MarshalAs(UnmanagedType.LPWStr)]string filename, ref Guid encoderClsID, IntPtr encoderParameters);
-            private static FunctionWrapper<GdipSaveImageToFile_delegate> GdipSaveImageToFile_ptr;
-            internal static int GdipSaveImageToFile(IntPtr image, string filename, ref Guid encoderClsID, IntPtr encoderParameters) => GdipSaveImageToFile_ptr.Delegate(image, filename, ref encoderClsID, encoderParameters);
-
-            private delegate int GdipSaveAdd_delegate(IntPtr image, IntPtr encoderParameters);
-            private static FunctionWrapper<GdipSaveAdd_delegate> GdipSaveAdd_ptr;
-            internal static int GdipSaveAdd(IntPtr image, IntPtr encoderParameters) => GdipSaveAdd_ptr.Delegate(image, encoderParameters);
-
-            private delegate int GdipSaveAddImage_delegate(IntPtr image, IntPtr imagenew, IntPtr encoderParameters);
-            private static FunctionWrapper<GdipSaveAddImage_delegate> GdipSaveAddImage_ptr;
-            internal static int GdipSaveAddImage(IntPtr image, IntPtr imagenew, IntPtr encoderParameters) => GdipSaveAddImage_ptr.Delegate(image, imagenew, encoderParameters);
-
-            private delegate int GdipDrawImageI_delegate(IntPtr graphics, IntPtr image, int x, int y);
-            private static FunctionWrapper<GdipDrawImageI_delegate> GdipDrawImageI_ptr;
-            internal static int GdipDrawImageI(IntPtr graphics, IntPtr image, int x, int y) => GdipDrawImageI_ptr.Delegate(graphics, image, x, y);
-
-            private delegate int GdipGetImageGraphicsContext_delegate(IntPtr image, out IntPtr graphics);
-            private static FunctionWrapper<GdipGetImageGraphicsContext_delegate> GdipGetImageGraphicsContext_ptr;
-            internal static int GdipGetImageGraphicsContext(IntPtr image, out IntPtr graphics) => GdipGetImageGraphicsContext_ptr.Delegate(image, out graphics);
-
-            private delegate int GdipDrawImage_delegate(IntPtr graphics, IntPtr image, float x, float y);
-            private static FunctionWrapper<GdipDrawImage_delegate> GdipDrawImage_ptr;
-            internal static int GdipDrawImage(IntPtr graphics, IntPtr image, float x, float y) => GdipDrawImage_ptr.Delegate(graphics, image, x, y);
-
-            private delegate int GdipDrawImagePoints_delegate(IntPtr graphics, IntPtr image, PointF[] destPoints, int count);
-            private static FunctionWrapper<GdipDrawImagePoints_delegate> GdipDrawImagePoints_ptr;
-            internal static int GdipDrawImagePoints(IntPtr graphics, IntPtr image, PointF[] destPoints, int count) => GdipDrawImagePoints_ptr.Delegate(graphics, image, destPoints, count);
-
-            private delegate int GdipDrawImagePointsI_delegate(IntPtr graphics, IntPtr image, Point[] destPoints, int count);
-            private static FunctionWrapper<GdipDrawImagePointsI_delegate> GdipDrawImagePointsI_ptr;
-            internal static int GdipDrawImagePointsI(IntPtr graphics, IntPtr image, Point[] destPoints, int count) => GdipDrawImagePointsI_ptr.Delegate(graphics, image, destPoints, count);
-
-            private delegate int GdipDrawImageRectRectI_delegate(IntPtr graphics, IntPtr image, int dstx, int dsty, int dstwidth, int dstheight, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
-            private static FunctionWrapper<GdipDrawImageRectRectI_delegate> GdipDrawImageRectRectI_ptr;
-            internal static int GdipDrawImageRectRectI(IntPtr graphics, IntPtr image, int dstx, int dsty, int dstwidth, int dstheight, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData) => GdipDrawImageRectRectI_ptr.Delegate(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageattr, callback, callbackData);
-
-            private delegate int GdipDrawImageRectRect_delegate(IntPtr graphics, IntPtr image, float dstx, float dsty, float dstwidth, float dstheight, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
-            private static FunctionWrapper<GdipDrawImageRectRect_delegate> GdipDrawImageRectRect_ptr;
-            internal static int GdipDrawImageRectRect(IntPtr graphics, IntPtr image, float dstx, float dsty, float dstwidth, float dstheight, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData) => GdipDrawImageRectRect_ptr.Delegate(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageattr, callback, callbackData);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPropertySize(IntPtr image, out int bufferSize, out int propNumbers);
 
-            private delegate int GdipDrawImagePointsRectI_delegate(IntPtr graphics, IntPtr image, Point[] destPoints, int count, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
-            private static FunctionWrapper<GdipDrawImagePointsRectI_delegate> GdipDrawImagePointsRectI_ptr;
-            internal static int GdipDrawImagePointsRectI(IntPtr graphics, IntPtr image, Point[] destPoints, int count, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData) => GdipDrawImagePointsRectI_ptr.Delegate(graphics, image, destPoints, count, srcx, srcy, srcwidth, srcheight, srcUnit, imageattr, callback, callbackData);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetAllPropertyItems(IntPtr image, int bufferSize, int propNumbers, IntPtr items);
 
-            private delegate int GdipDrawImagePointsRect_delegate(IntPtr graphics, IntPtr image, PointF[] destPoints, int count, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
-            private static FunctionWrapper<GdipDrawImagePointsRect_delegate> GdipDrawImagePointsRect_ptr;
-            internal static int GdipDrawImagePointsRect(IntPtr graphics, IntPtr image, PointF[] destPoints, int count, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData) => GdipDrawImagePointsRect_ptr.Delegate(graphics, image, destPoints, count, srcx, srcy, srcwidth, srcheight, srcUnit, imageattr, callback, callbackData);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageBounds(IntPtr image, out RectangleF source, ref GraphicsUnit unit);
 
-            private delegate int GdipDrawImageRect_delegate(IntPtr graphics, IntPtr image, float x, float y, float width, float height);
-            private static FunctionWrapper<GdipDrawImageRect_delegate> GdipDrawImageRect_ptr;
-            internal static int GdipDrawImageRect(IntPtr graphics, IntPtr image, float x, float y, float width, float height) => GdipDrawImageRect_ptr.Delegate(graphics, image, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetEncoderParameterListSize(IntPtr image, ref Guid encoder, out uint size);
 
-            private delegate int GdipDrawImagePointRect_delegate(IntPtr graphics, IntPtr image, float x, float y, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit);
-            private static FunctionWrapper<GdipDrawImagePointRect_delegate> GdipDrawImagePointRect_ptr;
-            internal static int GdipDrawImagePointRect(IntPtr graphics, IntPtr image, float x, float y, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit) => GdipDrawImagePointRect_ptr.Delegate(graphics, image, x, y, srcx, srcy, srcwidth, srcheight, srcUnit);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetEncoderParameterList(IntPtr image, ref Guid encoder, uint size, IntPtr buffer);
 
-            private delegate int GdipDrawImagePointRectI_delegate(IntPtr graphics, IntPtr image, int x, int y, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit);
-            private static FunctionWrapper<GdipDrawImagePointRectI_delegate> GdipDrawImagePointRectI_ptr;
-            internal static int GdipDrawImagePointRectI(IntPtr graphics, IntPtr image, int x, int y, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit) => GdipDrawImagePointRectI_ptr.Delegate(graphics, image, x, y, srcx, srcy, srcwidth, srcheight, srcUnit);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPropertyItemSize(IntPtr image, int propertyID, out int propertySize);
 
-            private delegate int GdipCreatePath_delegate(FillMode brushMode, out IntPtr path);
-            private static FunctionWrapper<GdipCreatePath_delegate> GdipCreatePath_ptr;
-            internal static int GdipCreatePath(FillMode brushMode, out IntPtr path) => GdipCreatePath_ptr.Delegate(brushMode, out path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPropertyItem(IntPtr image, int propertyID, int propertySize, IntPtr buffer);
 
-            private delegate int GdipCreatePath2_delegate(PointF[] points, byte[] types, int count, FillMode brushMode, out IntPtr path);
-            private static FunctionWrapper<GdipCreatePath2_delegate> GdipCreatePath2_ptr;
-            internal static int GdipCreatePath2(PointF[] points, byte[] types, int count, FillMode brushMode, out IntPtr path) => GdipCreatePath2_ptr.Delegate(points, types, count, brushMode, out path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPropertyItem(IntPtr image, GdipPropertyItem* propertyItem);
 
-            private delegate int GdipCreatePath2I_delegate(Point[] points, byte[] types, int count, FillMode brushMode, out IntPtr path);
-            private static FunctionWrapper<GdipCreatePath2I_delegate> GdipCreatePath2I_ptr;
-            internal static int GdipCreatePath2I(Point[] points, byte[] types, int count, FillMode brushMode, out IntPtr path) => GdipCreatePath2I_ptr.Delegate(points, types, count, brushMode, out path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageThumbnail(IntPtr image, uint width, uint height, out IntPtr thumbImage, IntPtr callback, IntPtr callBackData);
 
-            private delegate int GdipClonePath_delegate(IntPtr path, out IntPtr clonePath);
-            private static FunctionWrapper<GdipClonePath_delegate> GdipClonePath_ptr;
-            internal static int GdipClonePath(IntPtr path, out IntPtr clonePath) => GdipClonePath_ptr.Delegate(path, out clonePath);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipSaveImageToFile(IntPtr image, string filename, ref Guid encoderClsID, IntPtr encoderParameters);
 
-            private delegate int GdipDeletePath_delegate(IntPtr path);
-            private static FunctionWrapper<GdipDeletePath_delegate> GdipDeletePath_ptr;
-            internal static int GdipDeletePath(IntPtr path) => GdipDeletePath_ptr.Delegate(path);
-            internal static int IntGdipDeletePath(HandleRef path) => (int)GdipDeletePath_ptr.Delegate(path.Handle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSaveAdd(IntPtr image, IntPtr encoderParameters);
 
-            private delegate int GdipResetPath_delegate(IntPtr path);
-            private static FunctionWrapper<GdipResetPath_delegate> GdipResetPath_ptr;
-            internal static int GdipResetPath(IntPtr path) => GdipResetPath_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSaveAddImage(IntPtr image, IntPtr imagenew, IntPtr encoderParameters);
 
-            private delegate int GdipGetPointCount_delegate(IntPtr path, out int count);
-            private static FunctionWrapper<GdipGetPointCount_delegate> GdipGetPointCount_ptr;
-            internal static int GdipGetPointCount(IntPtr path, out int count) => GdipGetPointCount_ptr.Delegate(path, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImageI(IntPtr graphics, IntPtr image, int x, int y);
 
-            private delegate int GdipGetPathTypes_delegate(IntPtr path, [Out] byte[] types, int count);
-            private static FunctionWrapper<GdipGetPathTypes_delegate> GdipGetPathTypes_ptr;
-            internal static int GdipGetPathTypes(IntPtr path, [Out] byte[] types, int count) => GdipGetPathTypes_ptr.Delegate(path, types, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageGraphicsContext(IntPtr image, out IntPtr graphics);
 
-            private delegate int GdipGetPathPoints_delegate(IntPtr path, [Out] PointF[] points, int count);
-            private static FunctionWrapper<GdipGetPathPoints_delegate> GdipGetPathPoints_ptr;
-            internal static int GdipGetPathPoints(IntPtr path, [Out] PointF[] points, int count) => GdipGetPathPoints_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImage(IntPtr graphics, IntPtr image, float x, float y);
 
-            private delegate int GdipGetPathPointsI_delegate(IntPtr path, [Out] Point[] points, int count);
-            private static FunctionWrapper<GdipGetPathPointsI_delegate> GdipGetPathPointsI_ptr;
-            internal static int GdipGetPathPointsI(IntPtr path, [Out] Point[] points, int count) => GdipGetPathPointsI_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImagePoints(IntPtr graphics, IntPtr image, PointF[] destPoints, int count);
 
-            private delegate int GdipGetPathFillMode_delegate(IntPtr path, out FillMode fillMode);
-            private static FunctionWrapper<GdipGetPathFillMode_delegate> GdipGetPathFillMode_ptr;
-            internal static int GdipGetPathFillMode(IntPtr path, out FillMode fillMode) => GdipGetPathFillMode_ptr.Delegate(path, out fillMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImagePointsI(IntPtr graphics, IntPtr image, Point[] destPoints, int count);
 
-            private delegate int GdipSetPathFillMode_delegate(IntPtr path, FillMode fillMode);
-            private static FunctionWrapper<GdipSetPathFillMode_delegate> GdipSetPathFillMode_ptr;
-            internal static int GdipSetPathFillMode(IntPtr path, FillMode fillMode) => GdipSetPathFillMode_ptr.Delegate(path, fillMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImageRectRectI(IntPtr graphics, IntPtr image, int dstx, int dsty, int dstwidth, int dstheight, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
 
-            private delegate int GdipStartPathFigure_delegate(IntPtr path);
-            private static FunctionWrapper<GdipStartPathFigure_delegate> GdipStartPathFigure_ptr;
-            internal static int GdipStartPathFigure(IntPtr path) => GdipStartPathFigure_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImageRectRect(IntPtr graphics, IntPtr image, float dstx, float dsty, float dstwidth, float dstheight, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
 
-            private delegate int GdipClosePathFigure_delegate(IntPtr path);
-            private static FunctionWrapper<GdipClosePathFigure_delegate> GdipClosePathFigure_ptr;
-            internal static int GdipClosePathFigure(IntPtr path) => GdipClosePathFigure_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImagePointsRectI(IntPtr graphics, IntPtr image, Point[] destPoints, int count, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
 
-            private delegate int GdipClosePathFigures_delegate(IntPtr path);
-            private static FunctionWrapper<GdipClosePathFigures_delegate> GdipClosePathFigures_ptr;
-            internal static int GdipClosePathFigures(IntPtr path) => GdipClosePathFigures_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImagePointsRect(IntPtr graphics, IntPtr image, PointF[] destPoints, int count, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit, IntPtr imageattr, Graphics.DrawImageAbort callback, IntPtr callbackData);
 
-            private delegate int GdipSetPathMarker_delegate(IntPtr path);
-            private static FunctionWrapper<GdipSetPathMarker_delegate> GdipSetPathMarker_ptr;
-            internal static int GdipSetPathMarker(IntPtr path) => GdipSetPathMarker_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImageRect(IntPtr graphics, IntPtr image, float x, float y, float width, float height);
 
-            private delegate int GdipClearPathMarkers_delegate(IntPtr path);
-            private static FunctionWrapper<GdipClearPathMarkers_delegate> GdipClearPathMarkers_ptr;
-            internal static int GdipClearPathMarkers(IntPtr path) => GdipClearPathMarkers_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImagePointRect(IntPtr graphics, IntPtr image, float x, float y, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit);
 
-            private delegate int GdipReversePath_delegate(IntPtr path);
-            private static FunctionWrapper<GdipReversePath_delegate> GdipReversePath_ptr;
-            internal static int GdipReversePath(IntPtr path) => GdipReversePath_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImagePointRectI(IntPtr graphics, IntPtr image, int x, int y, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit);
 
-            private delegate int GdipGetPathLastPoint_delegate(IntPtr path, out PointF lastPoint);
-            private static FunctionWrapper<GdipGetPathLastPoint_delegate> GdipGetPathLastPoint_ptr;
-            internal static int GdipGetPathLastPoint(IntPtr path, out PointF lastPoint) => GdipGetPathLastPoint_ptr.Delegate(path, out lastPoint);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreatePath(FillMode brushMode, out IntPtr path);
 
-            private delegate int GdipAddPathLine_delegate(IntPtr path, float x1, float y1, float x2, float y2);
-            private static FunctionWrapper<GdipAddPathLine_delegate> GdipAddPathLine_ptr;
-            internal static int GdipAddPathLine(IntPtr path, float x1, float y1, float x2, float y2) => GdipAddPathLine_ptr.Delegate(path, x1, y1, x2, y2);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreatePath2(PointF[] points, byte[] types, int count, FillMode brushMode, out IntPtr path);
 
-            private delegate int GdipAddPathLine2_delegate(IntPtr path, PointF[] points, int count);
-            private static FunctionWrapper<GdipAddPathLine2_delegate> GdipAddPathLine2_ptr;
-            internal static int GdipAddPathLine2(IntPtr path, PointF[] points, int count) => GdipAddPathLine2_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreatePath2I(Point[] points, byte[] types, int count, FillMode brushMode, out IntPtr path);
 
-            private delegate int GdipAddPathLine2I_delegate(IntPtr path, Point[] points, int count);
-            private static FunctionWrapper<GdipAddPathLine2I_delegate> GdipAddPathLine2I_ptr;
-            internal static int GdipAddPathLine2I(IntPtr path, Point[] points, int count) => GdipAddPathLine2I_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipClonePath(IntPtr path, out IntPtr clonePath);
 
-            private delegate int GdipAddPathArc_delegate(IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipAddPathArc_delegate> GdipAddPathArc_ptr;
-            internal static int GdipAddPathArc(IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle) => GdipAddPathArc_ptr.Delegate(path, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeletePath(HandleRef path);
 
-            private delegate int GdipAddPathBezier_delegate(IntPtr path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
-            private static FunctionWrapper<GdipAddPathBezier_delegate> GdipAddPathBezier_ptr;
-            internal static int GdipAddPathBezier(IntPtr path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) => GdipAddPathBezier_ptr.Delegate(path, x1, y1, x2, y2, x3, y3, x4, y4);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipResetPath(IntPtr path);
 
-            private delegate int GdipAddPathBeziers_delegate(IntPtr path, PointF[] points, int count);
-            private static FunctionWrapper<GdipAddPathBeziers_delegate> GdipAddPathBeziers_ptr;
-            internal static int GdipAddPathBeziers(IntPtr path, PointF[] points, int count) => GdipAddPathBeziers_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPointCount(IntPtr path, out int count);
 
-            private delegate int GdipAddPathCurve_delegate(IntPtr path, PointF[] points, int count);
-            private static FunctionWrapper<GdipAddPathCurve_delegate> GdipAddPathCurve_ptr;
-            internal static int GdipAddPathCurve(IntPtr path, PointF[] points, int count) => GdipAddPathCurve_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathTypes(IntPtr path, [Out] byte[] types, int count);
 
-            private delegate int GdipAddPathCurveI_delegate(IntPtr path, Point[] points, int count);
-            private static FunctionWrapper<GdipAddPathCurveI_delegate> GdipAddPathCurveI_ptr;
-            internal static int GdipAddPathCurveI(IntPtr path, Point[] points, int count) => GdipAddPathCurveI_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathPoints(IntPtr path, [Out] PointF[] points, int count);
 
-            private delegate int GdipAddPathCurve2_delegate(IntPtr path, PointF[] points, int count, float tension);
-            private static FunctionWrapper<GdipAddPathCurve2_delegate> GdipAddPathCurve2_ptr;
-            internal static int GdipAddPathCurve2(IntPtr path, PointF[] points, int count, float tension) => GdipAddPathCurve2_ptr.Delegate(path, points, count, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathPointsI(IntPtr path, [Out] Point[] points, int count);
 
-            private delegate int GdipAddPathCurve2I_delegate(IntPtr path, Point[] points, int count, float tension);
-            private static FunctionWrapper<GdipAddPathCurve2I_delegate> GdipAddPathCurve2I_ptr;
-            internal static int GdipAddPathCurve2I(IntPtr path, Point[] points, int count, float tension) => GdipAddPathCurve2I_ptr.Delegate(path, points, count, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathFillMode(IntPtr path, out FillMode fillMode);
 
-            private delegate int GdipAddPathCurve3_delegate(IntPtr path, PointF[] points, int count, int offset, int numberOfSegments, float tension);
-            private static FunctionWrapper<GdipAddPathCurve3_delegate> GdipAddPathCurve3_ptr;
-            internal static int GdipAddPathCurve3(IntPtr path, PointF[] points, int count, int offset, int numberOfSegments, float tension) => GdipAddPathCurve3_ptr.Delegate(path, points, count, offset, numberOfSegments, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPathFillMode(IntPtr path, FillMode fillMode);
 
-            private delegate int GdipAddPathCurve3I_delegate(IntPtr path, Point[] points, int count, int offset, int numberOfSegments, float tension);
-            private static FunctionWrapper<GdipAddPathCurve3I_delegate> GdipAddPathCurve3I_ptr;
-            internal static int GdipAddPathCurve3I(IntPtr path, Point[] points, int count, int offset, int numberOfSegments, float tension) => GdipAddPathCurve3I_ptr.Delegate(path, points, count, offset, numberOfSegments, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipStartPathFigure(IntPtr path);
 
-            private delegate int GdipAddPathClosedCurve_delegate(IntPtr path, PointF[] points, int count);
-            private static FunctionWrapper<GdipAddPathClosedCurve_delegate> GdipAddPathClosedCurve_ptr;
-            internal static int GdipAddPathClosedCurve(IntPtr path, PointF[] points, int count) => GdipAddPathClosedCurve_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipClosePathFigure(IntPtr path);
 
-            private delegate int GdipAddPathClosedCurveI_delegate(IntPtr path, Point[] points, int count);
-            private static FunctionWrapper<GdipAddPathClosedCurveI_delegate> GdipAddPathClosedCurveI_ptr;
-            internal static int GdipAddPathClosedCurveI(IntPtr path, Point[] points, int count) => GdipAddPathClosedCurveI_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipClosePathFigures(IntPtr path);
 
-            private delegate int GdipAddPathClosedCurve2_delegate(IntPtr path, PointF[] points, int count, float tension);
-            private static FunctionWrapper<GdipAddPathClosedCurve2_delegate> GdipAddPathClosedCurve2_ptr;
-            internal static int GdipAddPathClosedCurve2(IntPtr path, PointF[] points, int count, float tension) => GdipAddPathClosedCurve2_ptr.Delegate(path, points, count, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPathMarker(IntPtr path);
 
-            private delegate int GdipAddPathClosedCurve2I_delegate(IntPtr path, Point[] points, int count, float tension);
-            private static FunctionWrapper<GdipAddPathClosedCurve2I_delegate> GdipAddPathClosedCurve2I_ptr;
-            internal static int GdipAddPathClosedCurve2I(IntPtr path, Point[] points, int count, float tension) => GdipAddPathClosedCurve2I_ptr.Delegate(path, points, count, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipClearPathMarkers(IntPtr path);
 
-            private delegate int GdipAddPathRectangle_delegate(IntPtr path, float x, float y, float width, float height);
-            private static FunctionWrapper<GdipAddPathRectangle_delegate> GdipAddPathRectangle_ptr;
-            internal static int GdipAddPathRectangle(IntPtr path, float x, float y, float width, float height) => GdipAddPathRectangle_ptr.Delegate(path, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipReversePath(IntPtr path);
 
-            private delegate int GdipAddPathRectangles_delegate(IntPtr path, RectangleF[] rects, int count);
-            private static FunctionWrapper<GdipAddPathRectangles_delegate> GdipAddPathRectangles_ptr;
-            internal static int GdipAddPathRectangles(IntPtr path, RectangleF[] rects, int count) => GdipAddPathRectangles_ptr.Delegate(path, rects, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathLastPoint(IntPtr path, out PointF lastPoint);
 
-            private delegate int GdipAddPathEllipse_delegate(IntPtr path, float x, float y, float width, float height);
-            private static FunctionWrapper<GdipAddPathEllipse_delegate> GdipAddPathEllipse_ptr;
-            internal static int GdipAddPathEllipse(IntPtr path, float x, float y, float width, float height) => GdipAddPathEllipse_ptr.Delegate(path, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathLine(IntPtr path, float x1, float y1, float x2, float y2);
 
-            private delegate int GdipAddPathEllipseI_delegate(IntPtr path, int x, int y, int width, int height);
-            private static FunctionWrapper<GdipAddPathEllipseI_delegate> GdipAddPathEllipseI_ptr;
-            internal static int GdipAddPathEllipseI(IntPtr path, int x, int y, int width, int height) => GdipAddPathEllipseI_ptr.Delegate(path, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathLine2(IntPtr path, PointF[] points, int count);
 
-            private delegate int GdipAddPathPie_delegate(IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipAddPathPie_delegate> GdipAddPathPie_ptr;
-            internal static int GdipAddPathPie(IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle) => GdipAddPathPie_ptr.Delegate(path, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathLine2I(IntPtr path, Point[] points, int count);
 
-            private delegate int GdipAddPathPieI_delegate(IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipAddPathPieI_delegate> GdipAddPathPieI_ptr;
-            internal static int GdipAddPathPieI(IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle) => GdipAddPathPieI_ptr.Delegate(path, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathArc(IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle);
 
-            private delegate int GdipAddPathPolygon_delegate(IntPtr path, PointF[] points, int count);
-            private static FunctionWrapper<GdipAddPathPolygon_delegate> GdipAddPathPolygon_ptr;
-            internal static int GdipAddPathPolygon(IntPtr path, PointF[] points, int count) => GdipAddPathPolygon_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathBezier(IntPtr path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
 
-            private delegate int GdipAddPathPath_delegate(IntPtr path, IntPtr addingPath, bool connect);
-            private static FunctionWrapper<GdipAddPathPath_delegate> GdipAddPathPath_ptr;
-            internal static int GdipAddPathPath(IntPtr path, IntPtr addingPath, bool connect) => GdipAddPathPath_ptr.Delegate(path, addingPath, connect);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathBeziers(IntPtr path, PointF[] points, int count);
 
-            private delegate int GdipAddPathLineI_delegate(IntPtr path, int x1, int y1, int x2, int y2);
-            private static FunctionWrapper<GdipAddPathLineI_delegate> GdipAddPathLineI_ptr;
-            internal static int GdipAddPathLineI(IntPtr path, int x1, int y1, int x2, int y2) => GdipAddPathLineI_ptr.Delegate(path, x1, y1, x2, y2);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathCurve(IntPtr path, PointF[] points, int count);
 
-            private delegate int GdipAddPathArcI_delegate(IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipAddPathArcI_delegate> GdipAddPathArcI_ptr;
-            internal static int GdipAddPathArcI(IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle) => GdipAddPathArcI_ptr.Delegate(path, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathCurveI(IntPtr path, Point[] points, int count);
 
-            private delegate int GdipAddPathBezierI_delegate(IntPtr path, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
-            private static FunctionWrapper<GdipAddPathBezierI_delegate> GdipAddPathBezierI_ptr;
-            internal static int GdipAddPathBezierI(IntPtr path, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) => GdipAddPathBezierI_ptr.Delegate(path, x1, y1, x2, y2, x3, y3, x4, y4);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathCurve2(IntPtr path, PointF[] points, int count, float tension);
 
-            private delegate int GdipAddPathBeziersI_delegate(IntPtr path, Point[] points, int count);
-            private static FunctionWrapper<GdipAddPathBeziersI_delegate> GdipAddPathBeziersI_ptr;
-            internal static int GdipAddPathBeziersI(IntPtr path, Point[] points, int count) => GdipAddPathBeziersI_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathCurve2I(IntPtr path, Point[] points, int count, float tension);
 
-            private delegate int GdipAddPathPolygonI_delegate(IntPtr path, Point[] points, int count);
-            private static FunctionWrapper<GdipAddPathPolygonI_delegate> GdipAddPathPolygonI_ptr;
-            internal static int GdipAddPathPolygonI(IntPtr path, Point[] points, int count) => GdipAddPathPolygonI_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathCurve3(IntPtr path, PointF[] points, int count, int offset, int numberOfSegments, float tension);
 
-            private delegate int GdipAddPathRectangleI_delegate(IntPtr path, int x, int y, int width, int height);
-            private static FunctionWrapper<GdipAddPathRectangleI_delegate> GdipAddPathRectangleI_ptr;
-            internal static int GdipAddPathRectangleI(IntPtr path, int x, int y, int width, int height) => GdipAddPathRectangleI_ptr.Delegate(path, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathCurve3I(IntPtr path, Point[] points, int count, int offset, int numberOfSegments, float tension);
 
-            private delegate int GdipAddPathRectanglesI_delegate(IntPtr path, Rectangle[] rects, int count);
-            private static FunctionWrapper<GdipAddPathRectanglesI_delegate> GdipAddPathRectanglesI_ptr;
-            internal static int GdipAddPathRectanglesI(IntPtr path, Rectangle[] rects, int count) => GdipAddPathRectanglesI_ptr.Delegate(path, rects, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathClosedCurve(IntPtr path, PointF[] points, int count);
 
-            private delegate int GdipFlattenPath_delegate(IntPtr path, IntPtr matrix, float floatness);
-            private static FunctionWrapper<GdipFlattenPath_delegate> GdipFlattenPath_ptr;
-            internal static int GdipFlattenPath(IntPtr path, IntPtr matrix, float floatness) => GdipFlattenPath_ptr.Delegate(path, matrix, floatness);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathClosedCurveI(IntPtr path, Point[] points, int count);
 
-            private delegate int GdipTransformPath_delegate(IntPtr path, IntPtr matrix);
-            private static FunctionWrapper<GdipTransformPath_delegate> GdipTransformPath_ptr;
-            internal static int GdipTransformPath(IntPtr path, IntPtr matrix) => GdipTransformPath_ptr.Delegate(path, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathClosedCurve2(IntPtr path, PointF[] points, int count, float tension);
 
-            private delegate int GdipWarpPath_delegate(IntPtr path, IntPtr matrix, PointF[] points, int count, float srcx, float srcy, float srcwidth, float srcheight, WarpMode mode, float flatness);
-            private static FunctionWrapper<GdipWarpPath_delegate> GdipWarpPath_ptr;
-            internal static int GdipWarpPath(IntPtr path, IntPtr matrix, PointF[] points, int count, float srcx, float srcy, float srcwidth, float srcheight, WarpMode mode, float flatness) => GdipWarpPath_ptr.Delegate(path, matrix, points, count, srcx, srcy, srcwidth, srcheight, mode, flatness);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathClosedCurve2I(IntPtr path, Point[] points, int count, float tension);
 
-            private delegate int GdipWidenPath_delegate(IntPtr path, IntPtr pen, IntPtr matrix, float flatness);
-            private static FunctionWrapper<GdipWidenPath_delegate> GdipWidenPath_ptr;
-            internal static int GdipWidenPath(IntPtr path, IntPtr pen, IntPtr matrix, float flatness) => GdipWidenPath_ptr.Delegate(path, pen, matrix, flatness);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathRectangle(IntPtr path, float x, float y, float width, float height);
 
-            private delegate int GdipGetPathWorldBounds_delegate(IntPtr path, out RectangleF bounds, IntPtr matrix, IntPtr pen);
-            private static FunctionWrapper<GdipGetPathWorldBounds_delegate> GdipGetPathWorldBounds_ptr;
-            internal static int GdipGetPathWorldBounds(IntPtr path, out RectangleF bounds, IntPtr matrix, IntPtr pen) => GdipGetPathWorldBounds_ptr.Delegate(path, out bounds, matrix, pen);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathRectangles(IntPtr path, RectangleF[] rects, int count);
 
-            private delegate int GdipGetPathWorldBoundsI_delegate(IntPtr path, out Rectangle bounds, IntPtr matrix, IntPtr pen);
-            private static FunctionWrapper<GdipGetPathWorldBoundsI_delegate> GdipGetPathWorldBoundsI_ptr;
-            internal static int GdipGetPathWorldBoundsI(IntPtr path, out Rectangle bounds, IntPtr matrix, IntPtr pen) => GdipGetPathWorldBoundsI_ptr.Delegate(path, out bounds, matrix, pen);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathEllipse(IntPtr path, float x, float y, float width, float height);
 
-            private delegate int GdipIsVisiblePathPoint_delegate(IntPtr path, float x, float y, IntPtr graphics, out bool result);
-            private static FunctionWrapper<GdipIsVisiblePathPoint_delegate> GdipIsVisiblePathPoint_ptr;
-            internal static int GdipIsVisiblePathPoint(IntPtr path, float x, float y, IntPtr graphics, out bool result) => GdipIsVisiblePathPoint_ptr.Delegate(path, x, y, graphics, out result);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathEllipseI(IntPtr path, int x, int y, int width, int height);
 
-            private delegate int GdipIsVisiblePathPointI_delegate(IntPtr path, int x, int y, IntPtr graphics, out bool result);
-            private static FunctionWrapper<GdipIsVisiblePathPointI_delegate> GdipIsVisiblePathPointI_ptr;
-            internal static int GdipIsVisiblePathPointI(IntPtr path, int x, int y, IntPtr graphics, out bool result) => GdipIsVisiblePathPointI_ptr.Delegate(path, x, y, graphics, out result);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathPie(IntPtr path, float x, float y, float width, float height, float startAngle, float sweepAngle);
 
-            private delegate int GdipIsOutlineVisiblePathPoint_delegate(IntPtr path, float x, float y, IntPtr pen, IntPtr graphics, out bool result);
-            private static FunctionWrapper<GdipIsOutlineVisiblePathPoint_delegate> GdipIsOutlineVisiblePathPoint_ptr;
-            internal static int GdipIsOutlineVisiblePathPoint(IntPtr path, float x, float y, IntPtr pen, IntPtr graphics, out bool result) => GdipIsOutlineVisiblePathPoint_ptr.Delegate(path, x, y, pen, graphics, out result);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathPieI(IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle);
 
-            private delegate int GdipIsOutlineVisiblePathPointI_delegate(IntPtr path, int x, int y, IntPtr pen, IntPtr graphics, out bool result);
-            private static FunctionWrapper<GdipIsOutlineVisiblePathPointI_delegate> GdipIsOutlineVisiblePathPointI_ptr;
-            internal static int GdipIsOutlineVisiblePathPointI(IntPtr path, int x, int y, IntPtr pen, IntPtr graphics, out bool result) => GdipIsOutlineVisiblePathPointI_ptr.Delegate(path, x, y, pen, graphics, out result);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathPolygon(IntPtr path, PointF[] points, int count);
 
-            private delegate int GdipCreateFontFromDC_delegate(IntPtr hdc, out IntPtr font);
-            private static FunctionWrapper<GdipCreateFontFromDC_delegate> GdipCreateFontFromDC_ptr;
-            internal static int GdipCreateFontFromDC(IntPtr hdc, out IntPtr font) => GdipCreateFontFromDC_ptr.Delegate(hdc, out font);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathPath(IntPtr path, IntPtr addingPath, bool connect);
 
-            private delegate int GdipCreateFontFromLogfont_delegate(IntPtr hdc, ref LOGFONT lf, out IntPtr ptr);
-            private static FunctionWrapper<GdipCreateFontFromLogfont_delegate> GdipCreateFontFromLogfont_ptr;
-            internal static int GdipCreateFontFromLogfont(IntPtr hdc, ref LOGFONT lf, out IntPtr ptr) => GdipCreateFontFromLogfont_ptr.Delegate(hdc, ref lf, out ptr);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathLineI(IntPtr path, int x1, int y1, int x2, int y2);
 
-            private delegate int GdipCreateFontFromHfont_delegate(IntPtr hdc, out IntPtr font, ref LOGFONT lf);
-            private static FunctionWrapper<GdipCreateFontFromHfont_delegate> GdipCreateFontFromHfont_ptr;
-            internal static int GdipCreateFontFromHfont(IntPtr hdc, out IntPtr font, ref LOGFONT lf) => GdipCreateFontFromHfont_ptr.Delegate(hdc, out font, ref lf);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathArcI(IntPtr path, int x, int y, int width, int height, float startAngle, float sweepAngle);
 
-            private delegate int GdipCreateMetafileFromFile_delegate([MarshalAs(UnmanagedType.LPWStr)]string filename, out IntPtr metafile);
-            private static FunctionWrapper<GdipCreateMetafileFromFile_delegate> GdipCreateMetafileFromFile_ptr;
-            internal static int GdipCreateMetafileFromFile(string filename, out IntPtr metafile) => GdipCreateMetafileFromFile_ptr.Delegate(filename, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathBezierI(IntPtr path, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
 
-            private delegate int GdipCreateMetafileFromEmf_delegate(IntPtr hEmf, bool deleteEmf, out IntPtr metafile);
-            private static FunctionWrapper<GdipCreateMetafileFromEmf_delegate> GdipCreateMetafileFromEmf_ptr;
-            internal static int GdipCreateMetafileFromEmf(IntPtr hEmf, bool deleteEmf, out IntPtr metafile) => GdipCreateMetafileFromEmf_ptr.Delegate(hEmf, deleteEmf, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathBeziersI(IntPtr path, Point[] points, int count);
 
-            private delegate int GdipCreateMetafileFromWmf_delegate(IntPtr hWmf, bool deleteWmf, WmfPlaceableFileHeader wmfPlaceableFileHeader, out IntPtr metafile);
-            private static FunctionWrapper<GdipCreateMetafileFromWmf_delegate> GdipCreateMetafileFromWmf_ptr;
-            internal static int GdipCreateMetafileFromWmf(IntPtr hWmf, bool deleteWmf, WmfPlaceableFileHeader wmfPlaceableFileHeader, out IntPtr metafile) => GdipCreateMetafileFromWmf_ptr.Delegate(hWmf, deleteWmf, wmfPlaceableFileHeader, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathPolygonI(IntPtr path, Point[] points, int count);
 
-            private delegate int GdipGetMetafileHeaderFromFile_delegate([MarshalAs(UnmanagedType.LPWStr)]string filename, IntPtr header);
-            private static FunctionWrapper<GdipGetMetafileHeaderFromFile_delegate> GdipGetMetafileHeaderFromFile_ptr;
-            internal static int GdipGetMetafileHeaderFromFile(string filename, IntPtr header) => GdipGetMetafileHeaderFromFile_ptr.Delegate(filename, header);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathRectangleI(IntPtr path, int x, int y, int width, int height);
 
-            private delegate int GdipGetMetafileHeaderFromMetafile_delegate(IntPtr metafile, IntPtr header);
-            private static FunctionWrapper<GdipGetMetafileHeaderFromMetafile_delegate> GdipGetMetafileHeaderFromMetafile_ptr;
-            internal static int GdipGetMetafileHeaderFromMetafile(IntPtr metafile, IntPtr header) => GdipGetMetafileHeaderFromMetafile_ptr.Delegate(metafile, header);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathRectanglesI(IntPtr path, Rectangle[] rects, int count);
 
-            private delegate int GdipGetMetafileHeaderFromEmf_delegate(IntPtr hEmf, IntPtr header);
-            private static FunctionWrapper<GdipGetMetafileHeaderFromEmf_delegate> GdipGetMetafileHeaderFromEmf_ptr;
-            internal static int GdipGetMetafileHeaderFromEmf(IntPtr hEmf, IntPtr header) => GdipGetMetafileHeaderFromEmf_ptr.Delegate(hEmf, header);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFlattenPath(IntPtr path, IntPtr matrix, float floatness);
 
-            private delegate int GdipGetMetafileHeaderFromWmf_delegate(IntPtr hWmf, IntPtr wmfPlaceableFileHeader, IntPtr header);
-            private static FunctionWrapper<GdipGetMetafileHeaderFromWmf_delegate> GdipGetMetafileHeaderFromWmf_ptr;
-            internal static int GdipGetMetafileHeaderFromWmf(IntPtr hWmf, IntPtr wmfPlaceableFileHeader, IntPtr header) => GdipGetMetafileHeaderFromWmf_ptr.Delegate(hWmf, wmfPlaceableFileHeader, header);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTransformPath(IntPtr path, IntPtr matrix);
 
-            private delegate int GdipGetHemfFromMetafile_delegate(IntPtr metafile, out IntPtr hEmf);
-            private static FunctionWrapper<GdipGetHemfFromMetafile_delegate> GdipGetHemfFromMetafile_ptr;
-            internal static int GdipGetHemfFromMetafile(IntPtr metafile, out IntPtr hEmf) => GdipGetHemfFromMetafile_ptr.Delegate(metafile, out hEmf);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipWarpPath(IntPtr path, IntPtr matrix, PointF[] points, int count, float srcx, float srcy, float srcwidth, float srcheight, WarpMode mode, float flatness);
 
-            private delegate int GdipGetMetafileDownLevelRasterizationLimit_delegate(IntPtr metafile, ref uint metafileRasterizationLimitDpi);
-            private static FunctionWrapper<GdipGetMetafileDownLevelRasterizationLimit_delegate> GdipGetMetafileDownLevelRasterizationLimit_ptr;
-            internal static int GdipGetMetafileDownLevelRasterizationLimit(IntPtr metafile, ref uint metafileRasterizationLimitDpi) => GdipGetMetafileDownLevelRasterizationLimit_ptr.Delegate(metafile, ref metafileRasterizationLimitDpi);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipWidenPath(IntPtr path, IntPtr pen, IntPtr matrix, float flatness);
 
-            private delegate int GdipSetMetafileDownLevelRasterizationLimit_delegate(IntPtr metafile, uint metafileRasterizationLimitDpi);
-            private static FunctionWrapper<GdipSetMetafileDownLevelRasterizationLimit_delegate> GdipSetMetafileDownLevelRasterizationLimit_ptr;
-            internal static int GdipSetMetafileDownLevelRasterizationLimit(IntPtr metafile, uint metafileRasterizationLimitDpi) => GdipSetMetafileDownLevelRasterizationLimit_ptr.Delegate(metafile, metafileRasterizationLimitDpi);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathWorldBounds(IntPtr path, out RectangleF bounds, IntPtr matrix, IntPtr pen);
 
-            private delegate int GdipPlayMetafileRecord_delegate(IntPtr metafile, EmfPlusRecordType recordType, int flags, int dataSize, byte[] data);
-            private static FunctionWrapper<GdipPlayMetafileRecord_delegate> GdipPlayMetafileRecord_ptr;
-            internal static int GdipPlayMetafileRecord(IntPtr metafile, EmfPlusRecordType recordType, int flags, int dataSize, byte[] data) => GdipPlayMetafileRecord_ptr.Delegate(metafile, recordType, flags, dataSize, data);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathWorldBoundsI(IntPtr path, out Rectangle bounds, IntPtr matrix, IntPtr pen);
 
-            private delegate int GdipRecordMetafile_delegate(IntPtr hdc, EmfType type, ref RectangleF frameRect, MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)]string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafile_delegate> GdipRecordMetafile_ptr;
-            internal static int GdipRecordMetafile(IntPtr hdc, EmfType type, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile) => GdipRecordMetafile_ptr.Delegate(hdc, type, ref frameRect, frameUnit, description, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsVisiblePathPoint(IntPtr path, float x, float y, IntPtr graphics, out bool result);
 
-            private delegate int GdipRecordMetafileI_delegate(IntPtr hdc, EmfType type, ref Rectangle frameRect, MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)]string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafileI_delegate> GdipRecordMetafileI_ptr;
-            internal static int GdipRecordMetafileI(IntPtr hdc, EmfType type, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile) => GdipRecordMetafileI_ptr.Delegate(hdc, type, ref frameRect, frameUnit, description, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsVisiblePathPointI(IntPtr path, int x, int y, IntPtr graphics, out bool result);
 
-            private delegate int GdipRecordMetafileFileName_delegate([MarshalAs(UnmanagedType.LPWStr)]string filename, IntPtr hdc, EmfType type, ref RectangleF frameRect, MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)]string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafileFileName_delegate> GdipRecordMetafileFileName_ptr;
-            internal static int GdipRecordMetafileFileName(string filename, IntPtr hdc, EmfType type, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile) => GdipRecordMetafileFileName_ptr.Delegate(filename, hdc, type, ref frameRect, frameUnit, description, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsOutlineVisiblePathPoint(IntPtr path, float x, float y, IntPtr pen, IntPtr graphics, out bool result);
 
-            private delegate int GdipRecordMetafileFileNameI_delegate([MarshalAs(UnmanagedType.LPWStr)]string filename, IntPtr hdc, EmfType type, ref Rectangle frameRect, MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)]string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafileFileNameI_delegate> GdipRecordMetafileFileNameI_ptr;
-            internal static int GdipRecordMetafileFileNameI(string filename, IntPtr hdc, EmfType type, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile) => GdipRecordMetafileFileNameI_ptr.Delegate(filename, hdc, type, ref frameRect, frameUnit, description, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsOutlineVisiblePathPointI(IntPtr path, int x, int y, IntPtr pen, IntPtr graphics, out bool result);
 
-            private delegate int GdipCreateFromContext_macosx_delegate(IntPtr cgref, int width, int height, out IntPtr graphics);
-            private static FunctionWrapper<GdipCreateFromContext_macosx_delegate> GdipCreateFromContext_macosx_ptr;
-            internal static int GdipCreateFromContext_macosx(IntPtr cgref, int width, int height, out IntPtr graphics) => GdipCreateFromContext_macosx_ptr.Delegate(cgref, width, height, out graphics);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateFontFromDC(IntPtr hdc, out IntPtr font);
 
-            private delegate int GdipSetVisibleClip_linux_delegate(IntPtr graphics, ref Rectangle rect);
-            private static FunctionWrapper<GdipSetVisibleClip_linux_delegate> GdipSetVisibleClip_linux_ptr;
-            internal static int GdipSetVisibleClip_linux(IntPtr graphics, ref Rectangle rect) => GdipSetVisibleClip_linux_ptr.Delegate(graphics, ref rect);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateFontFromLogfont(IntPtr hdc, ref LOGFONT lf, out IntPtr ptr);
 
-            private delegate int GdipCreateFromXDrawable_linux_delegate(IntPtr drawable, IntPtr display, out IntPtr graphics);
-            private static FunctionWrapper<GdipCreateFromXDrawable_linux_delegate> GdipCreateFromXDrawable_linux_ptr;
-            internal static int GdipCreateFromXDrawable_linux(IntPtr drawable, IntPtr display, out IntPtr graphics) => GdipCreateFromXDrawable_linux_ptr.Delegate(drawable, display, out graphics);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateFontFromHfont(IntPtr hdc, out IntPtr font, ref LOGFONT lf);
+
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipCreateMetafileFromFile(string filename, out IntPtr metafile);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateMetafileFromEmf(IntPtr hEmf, bool deleteEmf, out IntPtr metafile);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateMetafileFromWmf(IntPtr hWmf, bool deleteWmf, WmfPlaceableFileHeader wmfPlaceableFileHeader, out IntPtr metafile);
+
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipGetMetafileHeaderFromFile(string filename, IntPtr header);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetMetafileHeaderFromMetafile(IntPtr metafile, IntPtr header);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetMetafileHeaderFromEmf(IntPtr hEmf, IntPtr header);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetMetafileHeaderFromWmf(IntPtr hWmf, IntPtr wmfPlaceableFileHeader, IntPtr header);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetHemfFromMetafile(IntPtr metafile, out IntPtr hEmf);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetMetafileDownLevelRasterizationLimit(IntPtr metafile, ref uint metafileRasterizationLimitDpi);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetMetafileDownLevelRasterizationLimit(IntPtr metafile, uint metafileRasterizationLimitDpi);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipPlayMetafileRecord(IntPtr metafile, EmfPlusRecordType recordType, int flags, int dataSize, byte[] data);
+
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipRecordMetafile(IntPtr hdc, EmfType type, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipRecordMetafileI(IntPtr hdc, EmfType type, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipRecordMetafileFileName(string filename, IntPtr hdc, EmfType type, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipRecordMetafileFileNameI(string filename, IntPtr hdc, EmfType type, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateFromContext_macosx(IntPtr cgref, int width, int height, out IntPtr graphics);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetVisibleClip_linux(IntPtr graphics, ref Rectangle rect);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateFromXDrawable_linux(IntPtr drawable, IntPtr display, out IntPtr graphics);
 
             // Stream functions for non-Win32 (libgdiplus specific)
-            private delegate int GdipLoadImageFromDelegate_linux_delegate(StreamGetHeaderDelegate getHeader,
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipLoadImageFromDelegate_linux(StreamGetHeaderDelegate getHeader,
                 StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
                 StreamCloseDelegate close, StreamSizeDelegate size, out IntPtr image);
-            private static FunctionWrapper<GdipLoadImageFromDelegate_linux_delegate> GdipLoadImageFromDelegate_linux_ptr;
-            internal static int GdipLoadImageFromDelegate_linux(StreamGetHeaderDelegate getHeader,
-                StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
-                StreamCloseDelegate close, StreamSizeDelegate size, out IntPtr image)
-                => GdipLoadImageFromDelegate_linux_ptr.Delegate(getHeader, getBytes, putBytes, doSeek, close, size, out image);
 
-            private delegate int GdipSaveImageToDelegate_linux_delegate(IntPtr image, StreamGetBytesDelegate getBytes,
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSaveImageToDelegate_linux(IntPtr image, StreamGetBytesDelegate getBytes,
                 StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, StreamCloseDelegate close,
                 StreamSizeDelegate size, ref Guid encoderClsID, IntPtr encoderParameters);
-            private static FunctionWrapper<GdipSaveImageToDelegate_linux_delegate> GdipSaveImageToDelegate_linux_ptr;
-            internal static int GdipSaveImageToDelegate_linux(IntPtr image, StreamGetBytesDelegate getBytes,
-                StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek, StreamCloseDelegate close,
-                StreamSizeDelegate size, ref Guid encoderClsID, IntPtr encoderParameters)
-                => GdipSaveImageToDelegate_linux_ptr.Delegate(image, getBytes, putBytes, doSeek, close, size, ref encoderClsID, encoderParameters);
 
-            private delegate int GdipCreateMetafileFromDelegate_linux_delegate(StreamGetHeaderDelegate getHeader,
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateMetafileFromDelegate_linux(StreamGetHeaderDelegate getHeader,
                 StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
                 StreamCloseDelegate close, StreamSizeDelegate size, out IntPtr metafile);
-            private static FunctionWrapper<GdipCreateMetafileFromDelegate_linux_delegate> GdipCreateMetafileFromDelegate_linux_ptr;
-            internal static int GdipCreateMetafileFromDelegate_linux(StreamGetHeaderDelegate getHeader,
-                StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
-                StreamCloseDelegate close, StreamSizeDelegate size, out IntPtr metafile)
-                => GdipCreateMetafileFromDelegate_linux_ptr.Delegate(getHeader, getBytes, putBytes, doSeek, close, size, out metafile);
 
-            private delegate int GdipGetMetafileHeaderFromDelegate_linux_delegate(StreamGetHeaderDelegate getHeader,
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetMetafileHeaderFromDelegate_linux(StreamGetHeaderDelegate getHeader,
                 StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
                 StreamCloseDelegate close, StreamSizeDelegate size, IntPtr header);
-            private static FunctionWrapper<GdipGetMetafileHeaderFromDelegate_linux_delegate> GdipGetMetafileHeaderFromDelegate_linux_ptr;
-            internal static int GdipGetMetafileHeaderFromDelegate_linux(StreamGetHeaderDelegate getHeader,
-                StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
-                StreamCloseDelegate close, StreamSizeDelegate size, IntPtr header)
-                => GdipGetMetafileHeaderFromDelegate_linux_ptr.Delegate(getHeader, getBytes, putBytes, doSeek, close, size, header);
 
-            private delegate int GdipRecordMetafileFromDelegate_linux_delegate(StreamGetHeaderDelegate getHeader,
-                StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
-                StreamCloseDelegate close, StreamSizeDelegate size, IntPtr hdc, EmfType type, ref RectangleF frameRect,
-                MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)] string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafileFromDelegate_linux_delegate> GdipRecordMetafileFromDelegate_linux_ptr;
-            internal static int GdipRecordMetafileFromDelegate_linux(StreamGetHeaderDelegate getHeader,
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipRecordMetafileFromDelegate_linux(StreamGetHeaderDelegate getHeader,
                 StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
                 StreamCloseDelegate close, StreamSizeDelegate size, IntPtr hdc, EmfType type, ref RectangleF frameRect,
-                MetafileFrameUnit frameUnit, string description, out IntPtr metafile)
-                => GdipRecordMetafileFromDelegate_linux_ptr.Delegate(getHeader, getBytes, putBytes, doSeek, close, size, hdc, type, ref frameRect, frameUnit, description, out metafile);
+                MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
 
-            private delegate int GdipRecordMetafileFromDelegateI_linux_delegate(StreamGetHeaderDelegate getHeader,
-                StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
-                StreamCloseDelegate close, StreamSizeDelegate size, IntPtr hdc, EmfType type, ref Rectangle frameRect,
-                MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)] string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafileFromDelegateI_linux_delegate> GdipRecordMetafileFromDelegateI_linux_ptr;
-            internal static int GdipRecordMetafileFromDelegateI_linux(StreamGetHeaderDelegate getHeader,
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipRecordMetafileFromDelegateI_linux(StreamGetHeaderDelegate getHeader,
                 StreamGetBytesDelegate getBytes, StreamPutBytesDelegate putBytes, StreamSeekDelegate doSeek,
                 StreamCloseDelegate close, StreamSizeDelegate size, IntPtr hdc, EmfType type, ref Rectangle frameRect,
-                MetafileFrameUnit frameUnit, string description, out IntPtr metafile)
-                => GdipRecordMetafileFromDelegateI_linux_ptr.Delegate(getHeader, getBytes, putBytes, doSeek, close, size, hdc, type, ref frameRect, frameUnit, description, out metafile);
+                MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
 
-            private delegate int GdipGetPostScriptGraphicsContext_delegate(string filename, int width, int height, double dpix, double dpiy, ref IntPtr graphics);
-            private static FunctionWrapper<GdipGetPostScriptGraphicsContext_delegate> GdipGetPostScriptGraphicsContext_ptr;
-            internal static int GdipGetPostScriptGraphicsContext([MarshalAs(UnmanagedType.LPStr)]string filename, int width, int height, double dpix, double dpiy, ref IntPtr graphics)
-                => GdipGetPostScriptGraphicsContext_ptr.Delegate(filename, width, height, dpix, dpiy, ref graphics);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPostScriptGraphicsContext(
+                [MarshalAs(UnmanagedType.LPStr)]string filename,
+                int width, int height, double dpix, double dpiy, ref IntPtr graphics);
 
-            private delegate int GdipGetPostScriptSavePage_delegate(IntPtr graphics);
-            private static FunctionWrapper<GdipGetPostScriptSavePage_delegate> GdipGetPostScriptSavePage_ptr;
-            internal static int GdipGetPostScriptSavePage(IntPtr graphics) => GdipGetPostScriptSavePage_ptr.Delegate(graphics);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPostScriptSavePage(IntPtr graphics);
         }
     }
 
index 94068e4..7214ca6 100644 (file)
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#pragma warning disable BCL0015 // We know these APIs are only on Windows
+
 using System.Drawing.Drawing2D;
 using System.Drawing.Imaging;
 using System.Drawing.Internal;
-using System.Drawing.Text;
 using System.Runtime.InteropServices;
-using Microsoft.Win32.SafeHandles;
 
 namespace System.Drawing
 {
-    internal unsafe partial class SafeNativeMethods
+    internal unsafe static partial class SafeNativeMethods
     {
-        internal partial class Gdip
+        internal static partial class Gdip
         {
             private const string LibraryName = "gdiplus.dll";
 
-            private static SafeLibraryHandle s_gdipHandle;
-
-            private static IntPtr LoadNativeLibrary()
-            {
-                s_gdipHandle = Interop.Kernel32.LoadLibraryExW(LibraryName, IntPtr.Zero, 0);
-                return s_gdipHandle.DangerousGetHandle();
-            }
-
             private static void PlatformInitialize()
             {
-                LoadFunctionPointers();
-            }
-
-            private static void LoadFunctionPointers()
-            {
-                GdiplusStartup_ptr = FunctionWrapper.Load<GdiplusStartup_delegate>(s_gdipModule, "GdiplusStartup", LibraryName);
-                GdipCreatePath_ptr = FunctionWrapper.Load<GdipCreatePath_delegate>(s_gdipModule, "GdipCreatePath", LibraryName);
-                GdipCreatePath2_ptr = FunctionWrapper.Load<GdipCreatePath2_delegate>(s_gdipModule, "GdipCreatePath2", LibraryName);
-                GdipCreatePath2I_ptr = FunctionWrapper.Load<GdipCreatePath2I_delegate>(s_gdipModule, "GdipCreatePath2I", LibraryName);
-                GdipClonePath_ptr = FunctionWrapper.Load<GdipClonePath_delegate>(s_gdipModule, "GdipClonePath", LibraryName);
-                GdipDeletePath_ptr = FunctionWrapper.Load<GdipDeletePath_delegate>(s_gdipModule, "GdipDeletePath", LibraryName);
-                GdipResetPath_ptr = FunctionWrapper.Load<GdipResetPath_delegate>(s_gdipModule, "GdipResetPath", LibraryName);
-                GdipGetPointCount_ptr = FunctionWrapper.Load<GdipGetPointCount_delegate>(s_gdipModule, "GdipGetPointCount", LibraryName);
-                GdipGetPathTypes_ptr = FunctionWrapper.Load<GdipGetPathTypes_delegate>(s_gdipModule, "GdipGetPathTypes", LibraryName);
-                GdipGetPathPoints_ptr = FunctionWrapper.Load<GdipGetPathPoints_delegate>(s_gdipModule, "GdipGetPathPoints", LibraryName);
-                GdipGetPathFillMode_ptr = FunctionWrapper.Load<GdipGetPathFillMode_delegate>(s_gdipModule, "GdipGetPathFillMode", LibraryName);
-                GdipSetPathFillMode_ptr = FunctionWrapper.Load<GdipSetPathFillMode_delegate>(s_gdipModule, "GdipSetPathFillMode", LibraryName);
-                GdipGetPathData_ptr = FunctionWrapper.Load<GdipGetPathData_delegate>(s_gdipModule, "GdipGetPathData", LibraryName);
-                GdipStartPathFigure_ptr = FunctionWrapper.Load<GdipStartPathFigure_delegate>(s_gdipModule, "GdipStartPathFigure", LibraryName);
-                GdipClosePathFigure_ptr = FunctionWrapper.Load<GdipClosePathFigure_delegate>(s_gdipModule, "GdipClosePathFigure", LibraryName);
-                GdipClosePathFigures_ptr = FunctionWrapper.Load<GdipClosePathFigures_delegate>(s_gdipModule, "GdipClosePathFigures", LibraryName);
-                GdipSetPathMarker_ptr = FunctionWrapper.Load<GdipSetPathMarker_delegate>(s_gdipModule, "GdipSetPathMarker", LibraryName);
-                GdipClearPathMarkers_ptr = FunctionWrapper.Load<GdipClearPathMarkers_delegate>(s_gdipModule, "GdipClearPathMarkers", LibraryName);
-                GdipReversePath_ptr = FunctionWrapper.Load<GdipReversePath_delegate>(s_gdipModule, "GdipReversePath", LibraryName);
-                GdipGetPathLastPoint_ptr = FunctionWrapper.Load<GdipGetPathLastPoint_delegate>(s_gdipModule, "GdipGetPathLastPoint", LibraryName);
-                GdipAddPathLine_ptr = FunctionWrapper.Load<GdipAddPathLine_delegate>(s_gdipModule, "GdipAddPathLine", LibraryName);
-                GdipAddPathLine2_ptr = FunctionWrapper.Load<GdipAddPathLine2_delegate>(s_gdipModule, "GdipAddPathLine2", LibraryName);
-                GdipAddPathArc_ptr = FunctionWrapper.Load<GdipAddPathArc_delegate>(s_gdipModule, "GdipAddPathArc", LibraryName);
-                GdipAddPathBezier_ptr = FunctionWrapper.Load<GdipAddPathBezier_delegate>(s_gdipModule, "GdipAddPathBezier", LibraryName);
-                GdipAddPathBeziers_ptr = FunctionWrapper.Load<GdipAddPathBeziers_delegate>(s_gdipModule, "GdipAddPathBeziers", LibraryName);
-                GdipAddPathCurve_ptr = FunctionWrapper.Load<GdipAddPathCurve_delegate>(s_gdipModule, "GdipAddPathCurve", LibraryName);
-                GdipAddPathCurve2_ptr = FunctionWrapper.Load<GdipAddPathCurve2_delegate>(s_gdipModule, "GdipAddPathCurve2", LibraryName);
-                GdipAddPathCurve3_ptr = FunctionWrapper.Load<GdipAddPathCurve3_delegate>(s_gdipModule, "GdipAddPathCurve3", LibraryName);
-                GdipAddPathClosedCurve_ptr = FunctionWrapper.Load<GdipAddPathClosedCurve_delegate>(s_gdipModule, "GdipAddPathClosedCurve", LibraryName);
-                GdipAddPathClosedCurve2_ptr = FunctionWrapper.Load<GdipAddPathClosedCurve2_delegate>(s_gdipModule, "GdipAddPathClosedCurve2", LibraryName);
-                GdipAddPathRectangle_ptr = FunctionWrapper.Load<GdipAddPathRectangle_delegate>(s_gdipModule, "GdipAddPathRectangle", LibraryName);
-                GdipAddPathRectangles_ptr = FunctionWrapper.Load<GdipAddPathRectangles_delegate>(s_gdipModule, "GdipAddPathRectangles", LibraryName);
-                GdipAddPathEllipse_ptr = FunctionWrapper.Load<GdipAddPathEllipse_delegate>(s_gdipModule, "GdipAddPathEllipse", LibraryName);
-                GdipAddPathPie_ptr = FunctionWrapper.Load<GdipAddPathPie_delegate>(s_gdipModule, "GdipAddPathPie", LibraryName);
-                GdipAddPathPolygon_ptr = FunctionWrapper.Load<GdipAddPathPolygon_delegate>(s_gdipModule, "GdipAddPathPolygon", LibraryName);
-                GdipAddPathPath_ptr = FunctionWrapper.Load<GdipAddPathPath_delegate>(s_gdipModule, "GdipAddPathPath", LibraryName);
-                GdipAddPathString_ptr = FunctionWrapper.Load<GdipAddPathString_delegate>(s_gdipModule, "GdipAddPathString", LibraryName);
-                GdipAddPathStringI_ptr = FunctionWrapper.Load<GdipAddPathStringI_delegate>(s_gdipModule, "GdipAddPathStringI", LibraryName);
-                GdipAddPathLineI_ptr = FunctionWrapper.Load<GdipAddPathLineI_delegate>(s_gdipModule, "GdipAddPathLineI", LibraryName);
-                GdipAddPathLine2I_ptr = FunctionWrapper.Load<GdipAddPathLine2I_delegate>(s_gdipModule, "GdipAddPathLine2I", LibraryName);
-                GdipAddPathArcI_ptr = FunctionWrapper.Load<GdipAddPathArcI_delegate>(s_gdipModule, "GdipAddPathArcI", LibraryName);
-                GdipAddPathBezierI_ptr = FunctionWrapper.Load<GdipAddPathBezierI_delegate>(s_gdipModule, "GdipAddPathBezierI", LibraryName);
-                GdipAddPathBeziersI_ptr = FunctionWrapper.Load<GdipAddPathBeziersI_delegate>(s_gdipModule, "GdipAddPathBeziersI", LibraryName);
-                GdipAddPathCurveI_ptr = FunctionWrapper.Load<GdipAddPathCurveI_delegate>(s_gdipModule, "GdipAddPathCurveI", LibraryName);
-                GdipAddPathCurve2I_ptr = FunctionWrapper.Load<GdipAddPathCurve2I_delegate>(s_gdipModule, "GdipAddPathCurve2I", LibraryName);
-                GdipAddPathCurve3I_ptr = FunctionWrapper.Load<GdipAddPathCurve3I_delegate>(s_gdipModule, "GdipAddPathCurve3I", LibraryName);
-                GdipAddPathClosedCurveI_ptr = FunctionWrapper.Load<GdipAddPathClosedCurveI_delegate>(s_gdipModule, "GdipAddPathClosedCurveI", LibraryName);
-                GdipAddPathClosedCurve2I_ptr = FunctionWrapper.Load<GdipAddPathClosedCurve2I_delegate>(s_gdipModule, "GdipAddPathClosedCurve2I", LibraryName);
-                GdipAddPathRectangleI_ptr = FunctionWrapper.Load<GdipAddPathRectangleI_delegate>(s_gdipModule, "GdipAddPathRectangleI", LibraryName);
-                GdipAddPathRectanglesI_ptr = FunctionWrapper.Load<GdipAddPathRectanglesI_delegate>(s_gdipModule, "GdipAddPathRectanglesI", LibraryName);
-                GdipAddPathEllipseI_ptr = FunctionWrapper.Load<GdipAddPathEllipseI_delegate>(s_gdipModule, "GdipAddPathEllipseI", LibraryName);
-                GdipAddPathPieI_ptr = FunctionWrapper.Load<GdipAddPathPieI_delegate>(s_gdipModule, "GdipAddPathPieI", LibraryName);
-                GdipAddPathPolygonI_ptr = FunctionWrapper.Load<GdipAddPathPolygonI_delegate>(s_gdipModule, "GdipAddPathPolygonI", LibraryName);
-                GdipFlattenPath_ptr = FunctionWrapper.Load<GdipFlattenPath_delegate>(s_gdipModule, "GdipFlattenPath", LibraryName);
-                GdipWidenPath_ptr = FunctionWrapper.Load<GdipWidenPath_delegate>(s_gdipModule, "GdipWidenPath", LibraryName);
-                GdipWarpPath_ptr = FunctionWrapper.Load<GdipWarpPath_delegate>(s_gdipModule, "GdipWarpPath", LibraryName);
-                GdipTransformPath_ptr = FunctionWrapper.Load<GdipTransformPath_delegate>(s_gdipModule, "GdipTransformPath", LibraryName);
-                GdipGetPathWorldBounds_ptr = FunctionWrapper.Load<GdipGetPathWorldBounds_delegate>(s_gdipModule, "GdipGetPathWorldBounds", LibraryName);
-                GdipIsVisiblePathPoint_ptr = FunctionWrapper.Load<GdipIsVisiblePathPoint_delegate>(s_gdipModule, "GdipIsVisiblePathPoint", LibraryName);
-                GdipIsVisiblePathPointI_ptr = FunctionWrapper.Load<GdipIsVisiblePathPointI_delegate>(s_gdipModule, "GdipIsVisiblePathPointI", LibraryName);
-                GdipIsOutlineVisiblePathPoint_ptr = FunctionWrapper.Load<GdipIsOutlineVisiblePathPoint_delegate>(s_gdipModule, "GdipIsOutlineVisiblePathPoint", LibraryName);
-                GdipIsOutlineVisiblePathPointI_ptr = FunctionWrapper.Load<GdipIsOutlineVisiblePathPointI_delegate>(s_gdipModule, "GdipIsOutlineVisiblePathPointI", LibraryName);
-                GdipDeleteBrush_ptr = FunctionWrapper.Load<GdipDeleteBrush_delegate>(s_gdipModule, "GdipDeleteBrush", LibraryName);
-                GdipLoadImageFromStream_ptr = FunctionWrapper.Load<GdipLoadImageFromStream_delegate>(s_gdipModule, "GdipLoadImageFromStream", LibraryName);
-                GdipLoadImageFromFile_ptr = FunctionWrapper.Load<GdipLoadImageFromFile_delegate>(s_gdipModule, "GdipLoadImageFromFile", LibraryName);
-                GdipLoadImageFromStreamICM_ptr = FunctionWrapper.Load<GdipLoadImageFromStreamICM_delegate>(s_gdipModule, "GdipLoadImageFromStreamICM", LibraryName);
-                GdipLoadImageFromFileICM_ptr = FunctionWrapper.Load<GdipLoadImageFromFileICM_delegate>(s_gdipModule, "GdipLoadImageFromFileICM", LibraryName);
-                GdipCloneImage_ptr = FunctionWrapper.Load<GdipCloneImage_delegate>(s_gdipModule, "GdipCloneImage", LibraryName);
-                GdipDisposeImage_ptr = FunctionWrapper.Load<GdipDisposeImage_delegate>(s_gdipModule, "GdipDisposeImage", LibraryName);
-                GdipSaveImageToFile_ptr = FunctionWrapper.Load<GdipSaveImageToFile_delegate>(s_gdipModule, "GdipSaveImageToFile", LibraryName);
-                GdipSaveImageToStream_ptr = FunctionWrapper.Load<GdipSaveImageToStream_delegate>(s_gdipModule, "GdipSaveImageToStream", LibraryName);
-                GdipSaveAdd_ptr = FunctionWrapper.Load<GdipSaveAdd_delegate>(s_gdipModule, "GdipSaveAdd", LibraryName);
-                GdipSaveAddImage_ptr = FunctionWrapper.Load<GdipSaveAddImage_delegate>(s_gdipModule, "GdipSaveAddImage", LibraryName);
-                GdipGetImageGraphicsContext_ptr = FunctionWrapper.Load<GdipGetImageGraphicsContext_delegate>(s_gdipModule, "GdipGetImageGraphicsContext", LibraryName);
-                GdipGetImageBounds_ptr = FunctionWrapper.Load<GdipGetImageBounds_delegate>(s_gdipModule, "GdipGetImageBounds", LibraryName);
-                GdipGetImageType_ptr = FunctionWrapper.Load<GdipGetImageType_delegate>(s_gdipModule, "GdipGetImageType", LibraryName);
-                GdipGetImageThumbnail_ptr = FunctionWrapper.Load<GdipGetImageThumbnail_delegate>(s_gdipModule, "GdipGetImageThumbnail", LibraryName);
-                GdipGetEncoderParameterListSize_ptr = FunctionWrapper.Load<GdipGetEncoderParameterListSize_delegate>(s_gdipModule, "GdipGetEncoderParameterListSize", LibraryName);
-                GdipGetEncoderParameterList_ptr = FunctionWrapper.Load<GdipGetEncoderParameterList_delegate>(s_gdipModule, "GdipGetEncoderParameterList", LibraryName);
-                GdipGetImagePalette_ptr = FunctionWrapper.Load<GdipGetImagePalette_delegate>(s_gdipModule, "GdipGetImagePalette", LibraryName);
-                GdipSetImagePalette_ptr = FunctionWrapper.Load<GdipSetImagePalette_delegate>(s_gdipModule, "GdipSetImagePalette", LibraryName);
-                GdipGetImagePaletteSize_ptr = FunctionWrapper.Load<GdipGetImagePaletteSize_delegate>(s_gdipModule, "GdipGetImagePaletteSize", LibraryName);
-                GdipGetPropertyCount_ptr = FunctionWrapper.Load<GdipGetPropertyCount_delegate>(s_gdipModule, "GdipGetPropertyCount", LibraryName);
-                GdipGetPropertyIdList_ptr = FunctionWrapper.Load<GdipGetPropertyIdList_delegate>(s_gdipModule, "GdipGetPropertyIdList", LibraryName);
-                GdipGetPropertyItemSize_ptr = FunctionWrapper.Load<GdipGetPropertyItemSize_delegate>(s_gdipModule, "GdipGetPropertyItemSize", LibraryName);
-                GdipGetPropertyItem_ptr = FunctionWrapper.Load<GdipGetPropertyItem_delegate>(s_gdipModule, "GdipGetPropertyItem", LibraryName);
-                GdipGetPropertySize_ptr = FunctionWrapper.Load<GdipGetPropertySize_delegate>(s_gdipModule, "GdipGetPropertySize", LibraryName);
-                GdipGetAllPropertyItems_ptr = FunctionWrapper.Load<GdipGetAllPropertyItems_delegate>(s_gdipModule, "GdipGetAllPropertyItems", LibraryName);
-                GdipSetPropertyItem_ptr = FunctionWrapper.Load<GdipSetPropertyItem_delegate>(s_gdipModule, "GdipSetPropertyItem", LibraryName);
-                GdipImageForceValidation_ptr = FunctionWrapper.Load<GdipImageForceValidation_delegate>(s_gdipModule, "GdipImageForceValidation", LibraryName);
-                GdipCreateFromHDC_ptr = FunctionWrapper.Load<GdipCreateFromHDC_delegate>(s_gdipModule, "GdipCreateFromHDC", LibraryName);
-                GdipCreateFromHDC2_ptr = FunctionWrapper.Load<GdipCreateFromHDC2_delegate>(s_gdipModule, "GdipCreateFromHDC2", LibraryName);
-                GdipCreateFromHWND_ptr = FunctionWrapper.Load<GdipCreateFromHWND_delegate>(s_gdipModule, "GdipCreateFromHWND", LibraryName);
-                GdipDeleteGraphics_ptr = FunctionWrapper.Load<GdipDeleteGraphics_delegate>(s_gdipModule, "GdipDeleteGraphics", LibraryName);
-                GdipReleaseDC_ptr = FunctionWrapper.Load<GdipReleaseDC_delegate>(s_gdipModule, "GdipReleaseDC", LibraryName);
-                GdipTransformPoints_ptr = FunctionWrapper.Load<GdipTransformPoints_delegate>(s_gdipModule, "GdipTransformPoints", LibraryName);
-                GdipTransformPointsI_ptr = FunctionWrapper.Load<GdipTransformPointsI_delegate>(s_gdipModule, "GdipTransformPointsI", LibraryName);
-                GdipGetNearestColor_ptr = FunctionWrapper.Load<GdipGetNearestColor_delegate>(s_gdipModule, "GdipGetNearestColor", LibraryName);
-                GdipCreateHalftonePalette_ptr = FunctionWrapper.Load<GdipCreateHalftonePalette_delegate>(s_gdipModule, "GdipCreateHalftonePalette", LibraryName);
-                GdipDrawLine_ptr = FunctionWrapper.Load<GdipDrawLine_delegate>(s_gdipModule, "GdipDrawLine", LibraryName);
-                GdipDrawLineI_ptr = FunctionWrapper.Load<GdipDrawLineI_delegate>(s_gdipModule, "GdipDrawLineI", LibraryName);
-                GdipDrawLines_ptr = FunctionWrapper.Load<GdipDrawLines_delegate>(s_gdipModule, "GdipDrawLines", LibraryName);
-                GdipDrawLinesI_ptr = FunctionWrapper.Load<GdipDrawLinesI_delegate>(s_gdipModule, "GdipDrawLinesI", LibraryName);
-                GdipDrawArc_ptr = FunctionWrapper.Load<GdipDrawArc_delegate>(s_gdipModule, "GdipDrawArc", LibraryName);
-                GdipDrawArcI_ptr = FunctionWrapper.Load<GdipDrawArcI_delegate>(s_gdipModule, "GdipDrawArcI", LibraryName);
-                GdipDrawBezier_ptr = FunctionWrapper.Load<GdipDrawBezier_delegate>(s_gdipModule, "GdipDrawBezier", LibraryName);
-                GdipDrawBeziers_ptr = FunctionWrapper.Load<GdipDrawBeziers_delegate>(s_gdipModule, "GdipDrawBeziers", LibraryName);
-                GdipDrawBeziersI_ptr = FunctionWrapper.Load<GdipDrawBeziersI_delegate>(s_gdipModule, "GdipDrawBeziersI", LibraryName);
-                GdipDrawRectangle_ptr = FunctionWrapper.Load<GdipDrawRectangle_delegate>(s_gdipModule, "GdipDrawRectangle", LibraryName);
-                GdipDrawRectangleI_ptr = FunctionWrapper.Load<GdipDrawRectangleI_delegate>(s_gdipModule, "GdipDrawRectangleI", LibraryName);
-                GdipDrawRectangles_ptr = FunctionWrapper.Load<GdipDrawRectangles_delegate>(s_gdipModule, "GdipDrawRectangles", LibraryName);
-                GdipDrawRectanglesI_ptr = FunctionWrapper.Load<GdipDrawRectanglesI_delegate>(s_gdipModule, "GdipDrawRectanglesI", LibraryName);
-                GdipDrawEllipse_ptr = FunctionWrapper.Load<GdipDrawEllipse_delegate>(s_gdipModule, "GdipDrawEllipse", LibraryName);
-                GdipDrawEllipseI_ptr = FunctionWrapper.Load<GdipDrawEllipseI_delegate>(s_gdipModule, "GdipDrawEllipseI", LibraryName);
-                GdipDrawPie_ptr = FunctionWrapper.Load<GdipDrawPie_delegate>(s_gdipModule, "GdipDrawPie", LibraryName);
-                GdipDrawPieI_ptr = FunctionWrapper.Load<GdipDrawPieI_delegate>(s_gdipModule, "GdipDrawPieI", LibraryName);
-                GdipDrawPolygon_ptr = FunctionWrapper.Load<GdipDrawPolygon_delegate>(s_gdipModule, "GdipDrawPolygon", LibraryName);
-                GdipDrawPolygonI_ptr = FunctionWrapper.Load<GdipDrawPolygonI_delegate>(s_gdipModule, "GdipDrawPolygonI", LibraryName);
-                GdipDrawPath_ptr = FunctionWrapper.Load<GdipDrawPath_delegate>(s_gdipModule, "GdipDrawPath", LibraryName);
-                GdipDrawCurve_ptr = FunctionWrapper.Load<GdipDrawCurve_delegate>(s_gdipModule, "GdipDrawCurve", LibraryName);
-                GdipDrawCurveI_ptr = FunctionWrapper.Load<GdipDrawCurveI_delegate>(s_gdipModule, "GdipDrawCurveI", LibraryName);
-                GdipDrawCurve2_ptr = FunctionWrapper.Load<GdipDrawCurve2_delegate>(s_gdipModule, "GdipDrawCurve2", LibraryName);
-                GdipDrawCurve2I_ptr = FunctionWrapper.Load<GdipDrawCurve2I_delegate>(s_gdipModule, "GdipDrawCurve2I", LibraryName);
-                GdipDrawCurve3_ptr = FunctionWrapper.Load<GdipDrawCurve3_delegate>(s_gdipModule, "GdipDrawCurve3", LibraryName);
-                GdipDrawCurve3I_ptr = FunctionWrapper.Load<GdipDrawCurve3I_delegate>(s_gdipModule, "GdipDrawCurve3I", LibraryName);
-                GdipDrawClosedCurve_ptr = FunctionWrapper.Load<GdipDrawClosedCurve_delegate>(s_gdipModule, "GdipDrawClosedCurve", LibraryName);
-                GdipDrawClosedCurveI_ptr = FunctionWrapper.Load<GdipDrawClosedCurveI_delegate>(s_gdipModule, "GdipDrawClosedCurveI", LibraryName);
-                GdipDrawClosedCurve2_ptr = FunctionWrapper.Load<GdipDrawClosedCurve2_delegate>(s_gdipModule, "GdipDrawClosedCurve2", LibraryName);
-                GdipDrawClosedCurve2I_ptr = FunctionWrapper.Load<GdipDrawClosedCurve2I_delegate>(s_gdipModule, "GdipDrawClosedCurve2I", LibraryName);
-                GdipGraphicsClear_ptr = FunctionWrapper.Load<GdipGraphicsClear_delegate>(s_gdipModule, "GdipGraphicsClear", LibraryName);
-                GdipFillRectangle_ptr = FunctionWrapper.Load<GdipFillRectangle_delegate>(s_gdipModule, "GdipFillRectangle", LibraryName);
-                GdipFillRectangleI_ptr = FunctionWrapper.Load<GdipFillRectangleI_delegate>(s_gdipModule, "GdipFillRectangleI", LibraryName);
-                GdipFillRectangles_ptr = FunctionWrapper.Load<GdipFillRectangles_delegate>(s_gdipModule, "GdipFillRectangles", LibraryName);
-                GdipFillRectanglesI_ptr = FunctionWrapper.Load<GdipFillRectanglesI_delegate>(s_gdipModule, "GdipFillRectanglesI", LibraryName);
-                GdipFillPolygon_ptr = FunctionWrapper.Load<GdipFillPolygon_delegate>(s_gdipModule, "GdipFillPolygon", LibraryName);
-                GdipFillPolygonI_ptr = FunctionWrapper.Load<GdipFillPolygonI_delegate>(s_gdipModule, "GdipFillPolygonI", LibraryName);
-                GdipFillEllipse_ptr = FunctionWrapper.Load<GdipFillEllipse_delegate>(s_gdipModule, "GdipFillEllipse", LibraryName);
-                GdipFillEllipseI_ptr = FunctionWrapper.Load<GdipFillEllipseI_delegate>(s_gdipModule, "GdipFillEllipseI", LibraryName);
-                GdipFillPie_ptr = FunctionWrapper.Load<GdipFillPie_delegate>(s_gdipModule, "GdipFillPie", LibraryName);
-                GdipFillPieI_ptr = FunctionWrapper.Load<GdipFillPieI_delegate>(s_gdipModule, "GdipFillPieI", LibraryName);
-                GdipFillPath_ptr = FunctionWrapper.Load<GdipFillPath_delegate>(s_gdipModule, "GdipFillPath", LibraryName);
-                GdipFillClosedCurve_ptr = FunctionWrapper.Load<GdipFillClosedCurve_delegate>(s_gdipModule, "GdipFillClosedCurve", LibraryName);
-                GdipFillClosedCurveI_ptr = FunctionWrapper.Load<GdipFillClosedCurveI_delegate>(s_gdipModule, "GdipFillClosedCurveI", LibraryName);
-                GdipFillClosedCurve2_ptr = FunctionWrapper.Load<GdipFillClosedCurve2_delegate>(s_gdipModule, "GdipFillClosedCurve2", LibraryName);
-                GdipFillClosedCurve2I_ptr = FunctionWrapper.Load<GdipFillClosedCurve2I_delegate>(s_gdipModule, "GdipFillClosedCurve2I", LibraryName);
-                GdipDrawImage_ptr = FunctionWrapper.Load<GdipDrawImage_delegate>(s_gdipModule, "GdipDrawImage", LibraryName);
-                GdipDrawImageI_ptr = FunctionWrapper.Load<GdipDrawImageI_delegate>(s_gdipModule, "GdipDrawImageI", LibraryName);
-                GdipDrawImageRect_ptr = FunctionWrapper.Load<GdipDrawImageRect_delegate>(s_gdipModule, "GdipDrawImageRect", LibraryName);
-                GdipDrawImageRectI_ptr = FunctionWrapper.Load<GdipDrawImageRectI_delegate>(s_gdipModule, "GdipDrawImageRectI", LibraryName);
-                GdipDrawImagePoints_ptr = FunctionWrapper.Load<GdipDrawImagePoints_delegate>(s_gdipModule, "GdipDrawImagePoints", LibraryName);
-                GdipDrawImagePointsI_ptr = FunctionWrapper.Load<GdipDrawImagePointsI_delegate>(s_gdipModule, "GdipDrawImagePointsI", LibraryName);
-                GdipDrawImagePointRect_ptr = FunctionWrapper.Load<GdipDrawImagePointRect_delegate>(s_gdipModule, "GdipDrawImagePointRect", LibraryName);
-                GdipDrawImagePointRectI_ptr = FunctionWrapper.Load<GdipDrawImagePointRectI_delegate>(s_gdipModule, "GdipDrawImagePointRectI", LibraryName);
-                GdipDrawImageRectRect_ptr = FunctionWrapper.Load<GdipDrawImageRectRect_delegate>(s_gdipModule, "GdipDrawImageRectRect", LibraryName);
-                GdipDrawImageRectRectI_ptr = FunctionWrapper.Load<GdipDrawImageRectRectI_delegate>(s_gdipModule, "GdipDrawImageRectRectI", LibraryName);
-                GdipDrawImagePointsRect_ptr = FunctionWrapper.Load<GdipDrawImagePointsRect_delegate>(s_gdipModule, "GdipDrawImagePointsRect", LibraryName);
-                GdipDrawImagePointsRectI_ptr = FunctionWrapper.Load<GdipDrawImagePointsRectI_delegate>(s_gdipModule, "GdipDrawImagePointsRectI", LibraryName);
-                GdipEnumerateMetafileDestPoint_ptr = FunctionWrapper.Load<GdipEnumerateMetafileDestPoint_delegate>(s_gdipModule, "GdipEnumerateMetafileDestPoint", LibraryName);
-                GdipEnumerateMetafileDestPointI_ptr = FunctionWrapper.Load<GdipEnumerateMetafileDestPointI_delegate>(s_gdipModule, "GdipEnumerateMetafileDestPointI", LibraryName);
-                GdipEnumerateMetafileDestRect_ptr = FunctionWrapper.Load<GdipEnumerateMetafileDestRect_delegate>(s_gdipModule, "GdipEnumerateMetafileDestRect", LibraryName);
-                GdipEnumerateMetafileDestRectI_ptr = FunctionWrapper.Load<GdipEnumerateMetafileDestRectI_delegate>(s_gdipModule, "GdipEnumerateMetafileDestRectI", LibraryName);
-                GdipEnumerateMetafileDestPoints_ptr = FunctionWrapper.Load<GdipEnumerateMetafileDestPoints_delegate>(s_gdipModule, "GdipEnumerateMetafileDestPoints", LibraryName);
-                GdipEnumerateMetafileDestPointsI_ptr = FunctionWrapper.Load<GdipEnumerateMetafileDestPointsI_delegate>(s_gdipModule, "GdipEnumerateMetafileDestPointsI", LibraryName);
-                GdipEnumerateMetafileSrcRectDestPoint_ptr = FunctionWrapper.Load<GdipEnumerateMetafileSrcRectDestPoint_delegate>(s_gdipModule, "GdipEnumerateMetafileSrcRectDestPoint", LibraryName);
-                GdipEnumerateMetafileSrcRectDestPointI_ptr = FunctionWrapper.Load<GdipEnumerateMetafileSrcRectDestPointI_delegate>(s_gdipModule, "GdipEnumerateMetafileSrcRectDestPointI", LibraryName);
-                GdipEnumerateMetafileSrcRectDestRect_ptr = FunctionWrapper.Load<GdipEnumerateMetafileSrcRectDestRect_delegate>(s_gdipModule, "GdipEnumerateMetafileSrcRectDestRect", LibraryName);
-                GdipEnumerateMetafileSrcRectDestRectI_ptr = FunctionWrapper.Load<GdipEnumerateMetafileSrcRectDestRectI_delegate>(s_gdipModule, "GdipEnumerateMetafileSrcRectDestRectI", LibraryName);
-                GdipEnumerateMetafileSrcRectDestPoints_ptr = FunctionWrapper.Load<GdipEnumerateMetafileSrcRectDestPoints_delegate>(s_gdipModule, "GdipEnumerateMetafileSrcRectDestPoints", LibraryName);
-                GdipEnumerateMetafileSrcRectDestPointsI_ptr = FunctionWrapper.Load<GdipEnumerateMetafileSrcRectDestPointsI_delegate>(s_gdipModule, "GdipEnumerateMetafileSrcRectDestPointsI", LibraryName);
-                GdipPlayMetafileRecord_ptr = FunctionWrapper.Load<GdipPlayMetafileRecord_delegate>(s_gdipModule, "GdipPlayMetafileRecord", LibraryName);
-                GdipSaveGraphics_ptr = FunctionWrapper.Load<GdipSaveGraphics_delegate>(s_gdipModule, "GdipSaveGraphics", LibraryName);
-                GdipRestoreGraphics_ptr = FunctionWrapper.Load<GdipRestoreGraphics_delegate>(s_gdipModule, "GdipRestoreGraphics", LibraryName);
-                GdipEndContainer_ptr = FunctionWrapper.Load<GdipEndContainer_delegate>(s_gdipModule, "GdipEndContainer", LibraryName);
-                GdipGetMetafileHeaderFromWmf_ptr = FunctionWrapper.Load<GdipGetMetafileHeaderFromWmf_delegate>(s_gdipModule, "GdipGetMetafileHeaderFromWmf", LibraryName);
-                GdipGetMetafileHeaderFromEmf_ptr = FunctionWrapper.Load<GdipGetMetafileHeaderFromEmf_delegate>(s_gdipModule, "GdipGetMetafileHeaderFromEmf", LibraryName);
-                GdipGetMetafileHeaderFromFile_ptr = FunctionWrapper.Load<GdipGetMetafileHeaderFromFile_delegate>(s_gdipModule, "GdipGetMetafileHeaderFromFile", LibraryName);
-                GdipGetMetafileHeaderFromStream_ptr = FunctionWrapper.Load<GdipGetMetafileHeaderFromStream_delegate>(s_gdipModule, "GdipGetMetafileHeaderFromStream", LibraryName);
-                GdipGetMetafileHeaderFromMetafile_ptr = FunctionWrapper.Load<GdipGetMetafileHeaderFromMetafile_delegate>(s_gdipModule, "GdipGetMetafileHeaderFromMetafile", LibraryName);
-                GdipGetHemfFromMetafile_ptr = FunctionWrapper.Load<GdipGetHemfFromMetafile_delegate>(s_gdipModule, "GdipGetHemfFromMetafile", LibraryName);
-                GdipCreateMetafileFromWmf_ptr = FunctionWrapper.Load<GdipCreateMetafileFromWmf_delegate>(s_gdipModule, "GdipCreateMetafileFromWmf", LibraryName);
-                GdipCreateMetafileFromEmf_ptr = FunctionWrapper.Load<GdipCreateMetafileFromEmf_delegate>(s_gdipModule, "GdipCreateMetafileFromEmf", LibraryName);
-                GdipCreateMetafileFromFile_ptr = FunctionWrapper.Load<GdipCreateMetafileFromFile_delegate>(s_gdipModule, "GdipCreateMetafileFromFile", LibraryName);
-                GdipCreateMetafileFromStream_ptr = FunctionWrapper.Load<GdipCreateMetafileFromStream_delegate>(s_gdipModule, "GdipCreateMetafileFromStream", LibraryName);
-                GdipRecordMetafile_ptr = FunctionWrapper.Load<GdipRecordMetafile_delegate>(s_gdipModule, "GdipRecordMetafile", LibraryName);
-                GdipRecordMetafile2_ptr = FunctionWrapper.Load<GdipRecordMetafile2_delegate>(s_gdipModule, "GdipRecordMetafile", LibraryName);
-                GdipRecordMetafileI_ptr = FunctionWrapper.Load<GdipRecordMetafileI_delegate>(s_gdipModule, "GdipRecordMetafileI", LibraryName);
-                GdipRecordMetafileFileName_ptr = FunctionWrapper.Load<GdipRecordMetafileFileName_delegate>(s_gdipModule, "GdipRecordMetafileFileName", LibraryName);
-                GdipRecordMetafileFileName2_ptr = FunctionWrapper.Load<GdipRecordMetafileFileName2_delegate>(s_gdipModule, "GdipRecordMetafileFileName", LibraryName);
-                GdipRecordMetafileFileNameI_ptr = FunctionWrapper.Load<GdipRecordMetafileFileNameI_delegate>(s_gdipModule, "GdipRecordMetafileFileNameI", LibraryName);
-                GdipRecordMetafileStream_ptr = FunctionWrapper.Load<GdipRecordMetafileStream_delegate>(s_gdipModule, "GdipRecordMetafileStream", LibraryName);
-                GdipRecordMetafileStream2_ptr = FunctionWrapper.Load<GdipRecordMetafileStream2_delegate>(s_gdipModule, "GdipRecordMetafileStream", LibraryName);
-                GdipRecordMetafileStreamI_ptr = FunctionWrapper.Load<GdipRecordMetafileStreamI_delegate>(s_gdipModule, "GdipRecordMetafileStreamI", LibraryName);
-                GdipComment_ptr = FunctionWrapper.Load<GdipComment_delegate>(s_gdipModule, "GdipComment", LibraryName);
-                GdipCreateFontFromDC_ptr = FunctionWrapper.Load<GdipCreateFontFromDC_delegate>(s_gdipModule, "GdipCreateFontFromDC", LibraryName);
-                GdipCreateFontFromLogfontW_ptr = FunctionWrapper.Load<GdipCreateFontFromLogfontW_delegate>(s_gdipModule, "GdipCreateFontFromLogfontW", LibraryName);
-                GdipDrawString_ptr = FunctionWrapper.Load<GdipDrawString_delegate>(s_gdipModule, "GdipDrawString", LibraryName);
-                GdipMeasureString_ptr = FunctionWrapper.Load<GdipMeasureString_delegate>(s_gdipModule, "GdipMeasureString", LibraryName);
-                GdipMeasureCharacterRanges_ptr = FunctionWrapper.Load<GdipMeasureCharacterRanges_delegate>(s_gdipModule, "GdipMeasureCharacterRanges", LibraryName);
-                GdipCreateBitmapFromStream_ptr = FunctionWrapper.Load<GdipCreateBitmapFromStream_delegate>(s_gdipModule, "GdipCreateBitmapFromStream", LibraryName);
-                GdipCreateBitmapFromStreamICM_ptr = FunctionWrapper.Load<GdipCreateBitmapFromStreamICM_delegate>(s_gdipModule, "GdipCreateBitmapFromStreamICM", LibraryName);
             }
 
             // Imported functions
 
-            private delegate int GdiplusStartup_delegate(out IntPtr token, ref StartupInput input, out StartupOutput output);
-            private static FunctionWrapper<GdiplusStartup_delegate> GdiplusStartup_ptr;
-            private static int GdiplusStartup(out IntPtr token, ref StartupInput input, out StartupOutput output) => GdiplusStartup_ptr.Delegate(out token, ref input, out output);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            private static extern int GdiplusStartup(out IntPtr token, ref StartupInput input, out StartupOutput output);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreatePath(int brushMode, out IntPtr path);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreatePath2(PointF* points, byte* types, int count, int brushMode, out IntPtr path);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreatePath2I(Point* points, byte* types, int count, int brushMode, out IntPtr path);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipClonePath(HandleRef path, out IntPtr clonepath);
+
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeletePath(HandleRef path);
 
-            private delegate int GdipCreatePath_delegate(int brushMode, out IntPtr path);
-            private static FunctionWrapper<GdipCreatePath_delegate> GdipCreatePath_ptr;
-            internal static int GdipCreatePath(int brushMode, out IntPtr path) => GdipCreatePath_ptr.Delegate(brushMode, out path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipResetPath(HandleRef path);
 
-            private delegate int GdipCreatePath2_delegate(PointF* points, byte* types, int count, int brushMode, out IntPtr path);
-            private static FunctionWrapper<GdipCreatePath2_delegate> GdipCreatePath2_ptr;
-            internal static int GdipCreatePath2(PointF* points, byte* types, int count, int brushMode, out IntPtr path) => GdipCreatePath2_ptr.Delegate(points, types, count, brushMode, out path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPointCount(HandleRef path, out int count);
 
-            private delegate int GdipCreatePath2I_delegate(Point* points, byte* types, int count, int brushMode, out IntPtr path);
-            private static FunctionWrapper<GdipCreatePath2I_delegate> GdipCreatePath2I_ptr;
-            internal static int GdipCreatePath2I(Point* points, byte* types, int count, int brushMode, out IntPtr path) => GdipCreatePath2I_ptr.Delegate(points, types, count, brushMode, out path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathTypes(HandleRef path, byte[] types, int count);
 
-            private delegate int GdipClonePath_delegate(HandleRef path, out IntPtr clonepath);
-            private static FunctionWrapper<GdipClonePath_delegate> GdipClonePath_ptr;
-            internal static int GdipClonePath(HandleRef path, out IntPtr clonepath) => GdipClonePath_ptr.Delegate(path, out clonepath);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathPoints(HandleRef path, PointF* points, int count);
 
-            private delegate int GdipDeletePath_delegate(HandleRef path);
-            private static FunctionWrapper<GdipDeletePath_delegate> GdipDeletePath_ptr;
-            internal static int IntGdipDeletePath(HandleRef path) => GdipDeletePath_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathFillMode(HandleRef path, out FillMode fillmode);
 
-            private delegate int GdipResetPath_delegate(HandleRef path);
-            private static FunctionWrapper<GdipResetPath_delegate> GdipResetPath_ptr;
-            internal static int GdipResetPath(HandleRef path) => GdipResetPath_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPathFillMode(HandleRef path, FillMode fillmode);
 
-            private delegate int GdipGetPointCount_delegate(HandleRef path, out int count);
-            private static FunctionWrapper<GdipGetPointCount_delegate> GdipGetPointCount_ptr;
-            internal static int GdipGetPointCount(HandleRef path, out int count) => GdipGetPointCount_ptr.Delegate(path, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathData(HandleRef path, GpPathData* pathData);
 
-            private delegate int GdipGetPathTypes_delegate(HandleRef path, byte[] types, int count);
-            private static FunctionWrapper<GdipGetPathTypes_delegate> GdipGetPathTypes_ptr;
-            internal static int GdipGetPathTypes(HandleRef path, byte[] types, int count) => GdipGetPathTypes_ptr.Delegate(path, types, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipStartPathFigure(HandleRef path);
 
-            private delegate int GdipGetPathPoints_delegate(HandleRef path, PointF* points, int count);
-            private static FunctionWrapper<GdipGetPathPoints_delegate> GdipGetPathPoints_ptr;
-            internal static int GdipGetPathPoints(HandleRef path, PointF* points, int count) => GdipGetPathPoints_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipClosePathFigure(HandleRef path);
 
-            private delegate int GdipGetPathFillMode_delegate(HandleRef path, out FillMode fillmode);
-            private static FunctionWrapper<GdipGetPathFillMode_delegate> GdipGetPathFillMode_ptr;
-            internal static int GdipGetPathFillMode(HandleRef path, out FillMode fillmode) => GdipGetPathFillMode_ptr.Delegate(path, out fillmode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipClosePathFigures(HandleRef path);
 
-            private delegate int GdipSetPathFillMode_delegate(HandleRef path, FillMode fillmode);
-            private static FunctionWrapper<GdipSetPathFillMode_delegate> GdipSetPathFillMode_ptr;
-            internal static int GdipSetPathFillMode(HandleRef path, FillMode fillmode) => GdipSetPathFillMode_ptr.Delegate(path, fillmode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPathMarker(HandleRef path);
 
-            private delegate int GdipGetPathData_delegate(HandleRef path, GpPathData* pathData);
-            private static FunctionWrapper<GdipGetPathData_delegate> GdipGetPathData_ptr;
-            internal static int GdipGetPathData(HandleRef path, GpPathData* pathData) => GdipGetPathData_ptr.Delegate(path, pathData);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipClearPathMarkers(HandleRef path);
 
-            private delegate int GdipStartPathFigure_delegate(HandleRef path);
-            private static FunctionWrapper<GdipStartPathFigure_delegate> GdipStartPathFigure_ptr;
-            internal static int GdipStartPathFigure(HandleRef path) => GdipStartPathFigure_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipReversePath(HandleRef path);
 
-            private delegate int GdipClosePathFigure_delegate(HandleRef path);
-            private static FunctionWrapper<GdipClosePathFigure_delegate> GdipClosePathFigure_ptr;
-            internal static int GdipClosePathFigure(HandleRef path) => GdipClosePathFigure_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathLastPoint(HandleRef path, out PointF lastPoint);
 
-            private delegate int GdipClosePathFigures_delegate(HandleRef path);
-            private static FunctionWrapper<GdipClosePathFigures_delegate> GdipClosePathFigures_ptr;
-            internal static int GdipClosePathFigures(HandleRef path) => GdipClosePathFigures_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathLine(HandleRef path, float x1, float y1, float x2, float y2);
 
-            private delegate int GdipSetPathMarker_delegate(HandleRef path);
-            private static FunctionWrapper<GdipSetPathMarker_delegate> GdipSetPathMarker_ptr;
-            internal static int GdipSetPathMarker(HandleRef path) => GdipSetPathMarker_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathLine2(HandleRef path, PointF* points, int count);
 
-            private delegate int GdipClearPathMarkers_delegate(HandleRef path);
-            private static FunctionWrapper<GdipClearPathMarkers_delegate> GdipClearPathMarkers_ptr;
-            internal static int GdipClearPathMarkers(HandleRef path) => GdipClearPathMarkers_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathArc(HandleRef path, float x, float y, float width, float height, float startAngle, float sweepAngle);
 
-            private delegate int GdipReversePath_delegate(HandleRef path);
-            private static FunctionWrapper<GdipReversePath_delegate> GdipReversePath_ptr;
-            internal static int GdipReversePath(HandleRef path) => GdipReversePath_ptr.Delegate(path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathBezier(HandleRef path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
 
-            private delegate int GdipGetPathLastPoint_delegate(HandleRef path, out PointF lastPoint);
-            private static FunctionWrapper<GdipGetPathLastPoint_delegate> GdipGetPathLastPoint_ptr;
-            internal static int GdipGetPathLastPoint(HandleRef path, out PointF lastPoint) => GdipGetPathLastPoint_ptr.Delegate(path, out lastPoint);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathBeziers(HandleRef path, PointF* points, int count);
 
-            private delegate int GdipAddPathLine_delegate(HandleRef path, float x1, float y1, float x2, float y2);
-            private static FunctionWrapper<GdipAddPathLine_delegate> GdipAddPathLine_ptr;
-            internal static int GdipAddPathLine(HandleRef path, float x1, float y1, float x2, float y2) => GdipAddPathLine_ptr.Delegate(path, x1, y1, x2, y2);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathCurve(HandleRef path, PointF* points, int count);
 
-            private delegate int GdipAddPathLine2_delegate(HandleRef path, PointF* points, int count);
-            private static FunctionWrapper<GdipAddPathLine2_delegate> GdipAddPathLine2_ptr;
-            internal static int GdipAddPathLine2(HandleRef path, PointF* points, int count) => GdipAddPathLine2_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathCurve2(HandleRef path, PointF* points, int count, float tension);
 
-            private delegate int GdipAddPathArc_delegate(HandleRef path, float x, float y, float width, float height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipAddPathArc_delegate> GdipAddPathArc_ptr;
-            internal static int GdipAddPathArc(HandleRef path, float x, float y, float width, float height, float startAngle, float sweepAngle) => GdipAddPathArc_ptr.Delegate(path, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathCurve3(HandleRef path, PointF* points, int count, int offset, int numberOfSegments, float tension);
 
-            private delegate int GdipAddPathBezier_delegate(HandleRef path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
-            private static FunctionWrapper<GdipAddPathBezier_delegate> GdipAddPathBezier_ptr;
-            internal static int GdipAddPathBezier(HandleRef path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) => GdipAddPathBezier_ptr.Delegate(path, x1, y1, x2, y2, x3, y3, x4, y4);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathClosedCurve(HandleRef path, PointF* points, int count);
 
-            private delegate int GdipAddPathBeziers_delegate(HandleRef path, PointF* points, int count);
-            private static FunctionWrapper<GdipAddPathBeziers_delegate> GdipAddPathBeziers_ptr;
-            internal static int GdipAddPathBeziers(HandleRef path, PointF* points, int count) => GdipAddPathBeziers_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathClosedCurve2(HandleRef path, PointF* points, int count, float tension);
 
-            private delegate int GdipAddPathCurve_delegate(HandleRef path, PointF* points, int count);
-            private static FunctionWrapper<GdipAddPathCurve_delegate> GdipAddPathCurve_ptr;
-            internal static int GdipAddPathCurve(HandleRef path, PointF* points, int count) => GdipAddPathCurve_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathRectangle(HandleRef path, float x, float y, float width, float height);
 
-            private delegate int GdipAddPathCurve2_delegate(HandleRef path, PointF* points, int count, float tension);
-            private static FunctionWrapper<GdipAddPathCurve2_delegate> GdipAddPathCurve2_ptr;
-            internal static int GdipAddPathCurve2(HandleRef path, PointF* points, int count, float tension) => GdipAddPathCurve2_ptr.Delegate(path, points, count, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathRectangles(HandleRef path, RectangleF* rects, int count);
 
-            private delegate int GdipAddPathCurve3_delegate(HandleRef path, PointF* points, int count, int offset, int numberOfSegments, float tension);
-            private static FunctionWrapper<GdipAddPathCurve3_delegate> GdipAddPathCurve3_ptr;
-            internal static int GdipAddPathCurve3(HandleRef path, PointF* points, int count, int offset, int numberOfSegments, float tension) => GdipAddPathCurve3_ptr.Delegate(path, points, count, offset, numberOfSegments, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathEllipse(HandleRef path, float x, float y, float width, float height);
 
-            private delegate int GdipAddPathClosedCurve_delegate(HandleRef path, PointF* points, int count);
-            private static FunctionWrapper<GdipAddPathClosedCurve_delegate> GdipAddPathClosedCurve_ptr;
-            internal static int GdipAddPathClosedCurve(HandleRef path, PointF* points, int count) => GdipAddPathClosedCurve_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathPie(HandleRef path, float x, float y, float width, float height, float startAngle, float sweepAngle);
 
-            private delegate int GdipAddPathClosedCurve2_delegate(HandleRef path, PointF* points, int count, float tension);
-            private static FunctionWrapper<GdipAddPathClosedCurve2_delegate> GdipAddPathClosedCurve2_ptr;
-            internal static int GdipAddPathClosedCurve2(HandleRef path, PointF* points, int count, float tension) => GdipAddPathClosedCurve2_ptr.Delegate(path, points, count, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathPolygon(HandleRef path, PointF* points, int count);
 
-            private delegate int GdipAddPathRectangle_delegate(HandleRef path, float x, float y, float width, float height);
-            private static FunctionWrapper<GdipAddPathRectangle_delegate> GdipAddPathRectangle_ptr;
-            internal static int GdipAddPathRectangle(HandleRef path, float x, float y, float width, float height) => GdipAddPathRectangle_ptr.Delegate(path, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathPath(HandleRef path, HandleRef addingPath, bool connect);
 
-            private delegate int GdipAddPathRectangles_delegate(HandleRef path, RectangleF* rects, int count);
-            private static FunctionWrapper<GdipAddPathRectangles_delegate> GdipAddPathRectangles_ptr;
-            internal static int GdipAddPathRectangles(HandleRef path, RectangleF* rects, int count) => GdipAddPathRectangles_ptr.Delegate(path, rects, count);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipAddPathString(HandleRef path, string s, int length, HandleRef fontFamily, int style, float emSize, ref RectangleF layoutRect, HandleRef format);
 
-            private delegate int GdipAddPathEllipse_delegate(HandleRef path, float x, float y, float width, float height);
-            private static FunctionWrapper<GdipAddPathEllipse_delegate> GdipAddPathEllipse_ptr;
-            internal static int GdipAddPathEllipse(HandleRef path, float x, float y, float width, float height) => GdipAddPathEllipse_ptr.Delegate(path, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipAddPathStringI(HandleRef path, string s, int length, HandleRef fontFamily, int style, float emSize, ref Rectangle layoutRect, HandleRef format);
 
-            private delegate int GdipAddPathPie_delegate(HandleRef path, float x, float y, float width, float height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipAddPathPie_delegate> GdipAddPathPie_ptr;
-            internal static int GdipAddPathPie(HandleRef path, float x, float y, float width, float height, float startAngle, float sweepAngle) => GdipAddPathPie_ptr.Delegate(path, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathLineI(HandleRef path, int x1, int y1, int x2, int y2);
 
-            private delegate int GdipAddPathPolygon_delegate(HandleRef path, PointF* points, int count);
-            private static FunctionWrapper<GdipAddPathPolygon_delegate> GdipAddPathPolygon_ptr;
-            internal static int GdipAddPathPolygon(HandleRef path, PointF* points, int count) => GdipAddPathPolygon_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathLine2I(HandleRef path, Point* points, int count);
 
-            private delegate int GdipAddPathPath_delegate(HandleRef path, HandleRef addingPath, bool connect);
-            private static FunctionWrapper<GdipAddPathPath_delegate> GdipAddPathPath_ptr;
-            internal static int GdipAddPathPath(HandleRef path, HandleRef addingPath, bool connect) => GdipAddPathPath_ptr.Delegate(path, addingPath, connect);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathArcI(HandleRef path, int x, int y, int width, int height, float startAngle, float sweepAngle);
 
-            private delegate int GdipAddPathString_delegate(HandleRef path, [MarshalAs(UnmanagedType.LPWStr)]string s, int length, HandleRef fontFamily, int style, float emSize, ref RectangleF layoutRect, HandleRef format);
-            private static FunctionWrapper<GdipAddPathString_delegate> GdipAddPathString_ptr;
-            internal static int GdipAddPathString(HandleRef path, string s, int length, HandleRef fontFamily, int style, float emSize, ref RectangleF layoutRect, HandleRef format) => GdipAddPathString_ptr.Delegate(path, s, length, fontFamily, style, emSize, ref layoutRect, format);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathBezierI(HandleRef path, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
 
-            private delegate int GdipAddPathStringI_delegate(HandleRef path, [MarshalAs(UnmanagedType.LPWStr)]string s, int length, HandleRef fontFamily, int style, float emSize, ref Rectangle layoutRect, HandleRef format);
-            private static FunctionWrapper<GdipAddPathStringI_delegate> GdipAddPathStringI_ptr;
-            internal static int GdipAddPathStringI(HandleRef path, string s, int length, HandleRef fontFamily, int style, float emSize, ref Rectangle layoutRect, HandleRef format) => GdipAddPathStringI_ptr.Delegate(path, s, length, fontFamily, style, emSize, ref layoutRect, format);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathBeziersI(HandleRef path, Point* points, int count);
 
-            private delegate int GdipAddPathLineI_delegate(HandleRef path, int x1, int y1, int x2, int y2);
-            private static FunctionWrapper<GdipAddPathLineI_delegate> GdipAddPathLineI_ptr;
-            internal static int GdipAddPathLineI(HandleRef path, int x1, int y1, int x2, int y2) => GdipAddPathLineI_ptr.Delegate(path, x1, y1, x2, y2);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathCurveI(HandleRef path, Point* points, int count);
 
-            private delegate int GdipAddPathLine2I_delegate(HandleRef path, Point* points, int count);
-            private static FunctionWrapper<GdipAddPathLine2I_delegate> GdipAddPathLine2I_ptr;
-            internal static int GdipAddPathLine2I(HandleRef path, Point* points, int count) => GdipAddPathLine2I_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathCurve2I(HandleRef path, Point* points, int count, float tension);
 
-            private delegate int GdipAddPathArcI_delegate(HandleRef path, int x, int y, int width, int height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipAddPathArcI_delegate> GdipAddPathArcI_ptr;
-            internal static int GdipAddPathArcI(HandleRef path, int x, int y, int width, int height, float startAngle, float sweepAngle) => GdipAddPathArcI_ptr.Delegate(path, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathCurve3I(HandleRef path, Point* points, int count, int offset, int numberOfSegments, float tension);
 
-            private delegate int GdipAddPathBezierI_delegate(HandleRef path, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
-            private static FunctionWrapper<GdipAddPathBezierI_delegate> GdipAddPathBezierI_ptr;
-            internal static int GdipAddPathBezierI(HandleRef path, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) => GdipAddPathBezierI_ptr.Delegate(path, x1, y1, x2, y2, x3, y3, x4, y4);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathClosedCurveI(HandleRef path, Point* points, int count);
 
-            private delegate int GdipAddPathBeziersI_delegate(HandleRef path, Point* points, int count);
-            private static FunctionWrapper<GdipAddPathBeziersI_delegate> GdipAddPathBeziersI_ptr;
-            internal static int GdipAddPathBeziersI(HandleRef path, Point* points, int count) => GdipAddPathBeziersI_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathClosedCurve2I(HandleRef path, Point* points, int count, float tension);
 
-            private delegate int GdipAddPathCurveI_delegate(HandleRef path, Point* points, int count);
-            private static FunctionWrapper<GdipAddPathCurveI_delegate> GdipAddPathCurveI_ptr;
-            internal static int GdipAddPathCurveI(HandleRef path, Point* points, int count) => GdipAddPathCurveI_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathRectangleI(HandleRef path, int x, int y, int width, int height);
 
-            private delegate int GdipAddPathCurve2I_delegate(HandleRef path, Point* points, int count, float tension);
-            private static FunctionWrapper<GdipAddPathCurve2I_delegate> GdipAddPathCurve2I_ptr;
-            internal static int GdipAddPathCurve2I(HandleRef path, Point* points, int count, float tension) => GdipAddPathCurve2I_ptr.Delegate(path, points, count, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathRectanglesI(HandleRef path, Rectangle* rects, int count);
 
-            private delegate int GdipAddPathCurve3I_delegate(HandleRef path, Point* points, int count, int offset, int numberOfSegments, float tension);
-            private static FunctionWrapper<GdipAddPathCurve3I_delegate> GdipAddPathCurve3I_ptr;
-            internal static int GdipAddPathCurve3I(HandleRef path, Point* points, int count, int offset, int numberOfSegments, float tension) => GdipAddPathCurve3I_ptr.Delegate(path, points, count, offset, numberOfSegments, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathEllipseI(HandleRef path, int x, int y, int width, int height);
 
-            private delegate int GdipAddPathClosedCurveI_delegate(HandleRef path, Point* points, int count);
-            private static FunctionWrapper<GdipAddPathClosedCurveI_delegate> GdipAddPathClosedCurveI_ptr;
-            internal static int GdipAddPathClosedCurveI(HandleRef path, Point* points, int count) => GdipAddPathClosedCurveI_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathPieI(HandleRef path, int x, int y, int width, int height, float startAngle, float sweepAngle);
 
-            private delegate int GdipAddPathClosedCurve2I_delegate(HandleRef path, Point* points, int count, float tension);
-            private static FunctionWrapper<GdipAddPathClosedCurve2I_delegate> GdipAddPathClosedCurve2I_ptr;
-            internal static int GdipAddPathClosedCurve2I(HandleRef path, Point* points, int count, float tension) => GdipAddPathClosedCurve2I_ptr.Delegate(path, points, count, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipAddPathPolygonI(HandleRef path, Point* points, int count);
 
-            private delegate int GdipAddPathRectangleI_delegate(HandleRef path, int x, int y, int width, int height);
-            private static FunctionWrapper<GdipAddPathRectangleI_delegate> GdipAddPathRectangleI_ptr;
-            internal static int GdipAddPathRectangleI(HandleRef path, int x, int y, int width, int height) => GdipAddPathRectangleI_ptr.Delegate(path, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFlattenPath(HandleRef path, HandleRef matrixfloat, float flatness);
 
-            private delegate int GdipAddPathRectanglesI_delegate(HandleRef path, Rectangle* rects, int count);
-            private static FunctionWrapper<GdipAddPathRectanglesI_delegate> GdipAddPathRectanglesI_ptr;
-            internal static int GdipAddPathRectanglesI(HandleRef path, Rectangle* rects, int count) => GdipAddPathRectanglesI_ptr.Delegate(path, rects, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipWidenPath(HandleRef path, HandleRef pen, HandleRef matrix, float flatness);
 
-            private delegate int GdipAddPathEllipseI_delegate(HandleRef path, int x, int y, int width, int height);
-            private static FunctionWrapper<GdipAddPathEllipseI_delegate> GdipAddPathEllipseI_ptr;
-            internal static int GdipAddPathEllipseI(HandleRef path, int x, int y, int width, int height) => GdipAddPathEllipseI_ptr.Delegate(path, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipWarpPath(HandleRef path, HandleRef matrix, PointF* points, int count, float srcX, float srcY, float srcWidth, float srcHeight, WarpMode warpMode, float flatness);
 
-            private delegate int GdipAddPathPieI_delegate(HandleRef path, int x, int y, int width, int height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipAddPathPieI_delegate> GdipAddPathPieI_ptr;
-            internal static int GdipAddPathPieI(HandleRef path, int x, int y, int width, int height, float startAngle, float sweepAngle) => GdipAddPathPieI_ptr.Delegate(path, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTransformPath(HandleRef path, HandleRef matrix);
 
-            private delegate int GdipAddPathPolygonI_delegate(HandleRef path, Point* points, int count);
-            private static FunctionWrapper<GdipAddPathPolygonI_delegate> GdipAddPathPolygonI_ptr;
-            internal static int GdipAddPathPolygonI(HandleRef path, Point* points, int count) => GdipAddPathPolygonI_ptr.Delegate(path, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathWorldBounds(HandleRef path, out RectangleF gprectf, HandleRef matrix, HandleRef pen);
 
-            private delegate int GdipFlattenPath_delegate(HandleRef path, HandleRef matrixfloat, float flatness);
-            private static FunctionWrapper<GdipFlattenPath_delegate> GdipFlattenPath_ptr;
-            internal static int GdipFlattenPath(HandleRef path, HandleRef matrixfloat, float flatness) => GdipFlattenPath_ptr.Delegate(path, matrixfloat, flatness);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsVisiblePathPoint(HandleRef path, float x, float y, HandleRef graphics, out bool result);
 
-            private delegate int GdipWidenPath_delegate(HandleRef path, HandleRef pen, HandleRef matrix, float flatness);
-            private static FunctionWrapper<GdipWidenPath_delegate> GdipWidenPath_ptr;
-            internal static int GdipWidenPath(HandleRef path, HandleRef pen, HandleRef matrix, float flatness) => GdipWidenPath_ptr.Delegate(path, pen, matrix, flatness);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsVisiblePathPointI(HandleRef path, int x, int y, HandleRef graphics, out bool result);
 
-            private delegate int GdipWarpPath_delegate(HandleRef path, HandleRef matrix, PointF* points, int count, float srcX, float srcY, float srcWidth, float srcHeight, WarpMode warpMode, float flatness);
-            private static FunctionWrapper<GdipWarpPath_delegate> GdipWarpPath_ptr;
-            internal static int GdipWarpPath(HandleRef path, HandleRef matrix, PointF* points, int count, float srcX, float srcY, float srcWidth, float srcHeight, WarpMode warpMode, float flatness) => GdipWarpPath_ptr.Delegate(path, matrix, points, count, srcX, srcY, srcWidth, srcHeight, warpMode, flatness);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsOutlineVisiblePathPoint(HandleRef path, float x, float y, HandleRef pen, HandleRef graphics, out bool result);
 
-            private delegate int GdipTransformPath_delegate(HandleRef path, HandleRef matrix);
-            private static FunctionWrapper<GdipTransformPath_delegate> GdipTransformPath_ptr;
-            internal static int GdipTransformPath(HandleRef path, HandleRef matrix) => GdipTransformPath_ptr.Delegate(path, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsOutlineVisiblePathPointI(HandleRef path, int x, int y, HandleRef pen, HandleRef graphics, out bool result);
 
-            private delegate int GdipGetPathWorldBounds_delegate(HandleRef path, out RectangleF gprectf, HandleRef matrix, HandleRef pen);
-            private static FunctionWrapper<GdipGetPathWorldBounds_delegate> GdipGetPathWorldBounds_ptr;
-            internal static int GdipGetPathWorldBounds(HandleRef path, out RectangleF gprectf, HandleRef matrix, HandleRef pen) => GdipGetPathWorldBounds_ptr.Delegate(path, out gprectf, matrix, pen);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeleteBrush(HandleRef brush);
 
-            private delegate int GdipIsVisiblePathPoint_delegate(HandleRef path, float x, float y, HandleRef graphics, out bool result);
-            private static FunctionWrapper<GdipIsVisiblePathPoint_delegate> GdipIsVisiblePathPoint_ptr;
-            internal static int GdipIsVisiblePathPoint(HandleRef path, float x, float y, HandleRef graphics, out bool result) => GdipIsVisiblePathPoint_ptr.Delegate(path, x, y, graphics, out result);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipLoadImageFromStream(Interop.Ole32.IStream stream, out IntPtr image);
 
-            private delegate int GdipIsVisiblePathPointI_delegate(HandleRef path, int x, int y, HandleRef graphics, out bool result);
-            private static FunctionWrapper<GdipIsVisiblePathPointI_delegate> GdipIsVisiblePathPointI_ptr;
-            internal static int GdipIsVisiblePathPointI(HandleRef path, int x, int y, HandleRef graphics, out bool result) => GdipIsVisiblePathPointI_ptr.Delegate(path, x, y, graphics, out result);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipLoadImageFromFile(string filename, out IntPtr image);
 
-            private delegate int GdipIsOutlineVisiblePathPoint_delegate(HandleRef path, float x, float y, HandleRef pen, HandleRef graphics, out bool result);
-            private static FunctionWrapper<GdipIsOutlineVisiblePathPoint_delegate> GdipIsOutlineVisiblePathPoint_ptr;
-            internal static int GdipIsOutlineVisiblePathPoint(HandleRef path, float x, float y, HandleRef pen, HandleRef graphics, out bool result) => GdipIsOutlineVisiblePathPoint_ptr.Delegate(path, x, y, pen, graphics, out result);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipLoadImageFromStreamICM(Interop.Ole32.IStream stream, out IntPtr image);
 
-            private delegate int GdipIsOutlineVisiblePathPointI_delegate(HandleRef path, int x, int y, HandleRef pen, HandleRef graphics, out bool result);
-            private static FunctionWrapper<GdipIsOutlineVisiblePathPointI_delegate> GdipIsOutlineVisiblePathPointI_ptr;
-            internal static int GdipIsOutlineVisiblePathPointI(HandleRef path, int x, int y, HandleRef pen, HandleRef graphics, out bool result) => GdipIsOutlineVisiblePathPointI_ptr.Delegate(path, x, y, pen, graphics, out result);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipLoadImageFromFileICM(string filename, out IntPtr image);
 
-            private delegate int GdipDeleteBrush_delegate(HandleRef brush);
-            private static FunctionWrapper<GdipDeleteBrush_delegate> GdipDeleteBrush_ptr;
-            internal static int IntGdipDeleteBrush(HandleRef brush) => GdipDeleteBrush_ptr.Delegate(brush);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCloneImage(HandleRef image, out IntPtr cloneimage);
 
-            private delegate int GdipLoadImageFromStream_delegate(Interop.Ole32.IStream stream, out IntPtr image);
-            private static FunctionWrapper<GdipLoadImageFromStream_delegate> GdipLoadImageFromStream_ptr;
-            internal static int GdipLoadImageFromStream(Interop.Ole32.IStream stream, out IntPtr image) => GdipLoadImageFromStream_ptr.Delegate(stream, out image);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDisposeImage(HandleRef image);
 
-            private delegate int GdipLoadImageFromFile_delegate([MarshalAs(UnmanagedType.LPWStr)]string filename, out IntPtr image);
-            private static FunctionWrapper<GdipLoadImageFromFile_delegate> GdipLoadImageFromFile_ptr;
-            internal static int GdipLoadImageFromFile(string filename, out IntPtr image) => GdipLoadImageFromFile_ptr.Delegate(filename, out image);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipSaveImageToFile(HandleRef image, string filename, ref Guid classId, HandleRef encoderParams);
 
-            private delegate int GdipLoadImageFromStreamICM_delegate(Interop.Ole32.IStream stream, out IntPtr image);
-            private static FunctionWrapper<GdipLoadImageFromStreamICM_delegate> GdipLoadImageFromStreamICM_ptr;
-            internal static int GdipLoadImageFromStreamICM(Interop.Ole32.IStream stream, out IntPtr image) => GdipLoadImageFromStreamICM_ptr.Delegate(stream, out image);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSaveImageToStream(HandleRef image, Interop.Ole32.IStream stream, ref Guid classId, HandleRef encoderParams);
 
-            private delegate int GdipLoadImageFromFileICM_delegate([MarshalAs(UnmanagedType.LPWStr)]string filename, out IntPtr image);
-            private static FunctionWrapper<GdipLoadImageFromFileICM_delegate> GdipLoadImageFromFileICM_ptr;
-            internal static int GdipLoadImageFromFileICM(string filename, out IntPtr image) => GdipLoadImageFromFileICM_ptr.Delegate(filename, out image);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSaveAdd(HandleRef image, HandleRef encoderParams);
 
-            private delegate int GdipCloneImage_delegate(HandleRef image, out IntPtr cloneimage);
-            private static FunctionWrapper<GdipCloneImage_delegate> GdipCloneImage_ptr;
-            internal static int GdipCloneImage(HandleRef image, out IntPtr cloneimage) => GdipCloneImage_ptr.Delegate(image, out cloneimage);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSaveAddImage(HandleRef image, HandleRef newImage, HandleRef encoderParams);
 
-            private delegate int GdipDisposeImage_delegate(HandleRef image);
-            private static FunctionWrapper<GdipDisposeImage_delegate> GdipDisposeImage_ptr;
-            internal static int IntGdipDisposeImage(HandleRef image) => GdipDisposeImage_ptr.Delegate(image);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageGraphicsContext(HandleRef image, out IntPtr graphics);
 
-            private delegate int GdipSaveImageToFile_delegate(HandleRef image, [MarshalAs(UnmanagedType.LPWStr)] string filename, ref Guid classId, HandleRef encoderParams);
-            private static FunctionWrapper<GdipSaveImageToFile_delegate> GdipSaveImageToFile_ptr;
-            internal static int GdipSaveImageToFile(HandleRef image, string filename, ref Guid classId, HandleRef encoderParams) => GdipSaveImageToFile_ptr.Delegate(image, filename, ref classId, encoderParams);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageBounds(HandleRef image, out RectangleF gprectf, out GraphicsUnit unit);
 
-            private delegate int GdipSaveImageToStream_delegate(HandleRef image, Interop.Ole32.IStream stream, ref Guid classId, HandleRef encoderParams);
-            private static FunctionWrapper<GdipSaveImageToStream_delegate> GdipSaveImageToStream_ptr;
-            internal static int GdipSaveImageToStream(HandleRef image, Interop.Ole32.IStream stream, ref Guid classId, HandleRef encoderParams) => GdipSaveImageToStream_ptr.Delegate(image, stream, ref classId, encoderParams);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageType(HandleRef image, out int type);
 
-            private delegate int GdipSaveAdd_delegate(HandleRef image, HandleRef encoderParams);
-            private static FunctionWrapper<GdipSaveAdd_delegate> GdipSaveAdd_ptr;
-            internal static int GdipSaveAdd(HandleRef image, HandleRef encoderParams) => GdipSaveAdd_ptr.Delegate(image, encoderParams);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageThumbnail(HandleRef image, int thumbWidth, int thumbHeight, out IntPtr thumbImage, Image.GetThumbnailImageAbort callback, IntPtr callbackdata);
 
-            private delegate int GdipSaveAddImage_delegate(HandleRef image, HandleRef newImage, HandleRef encoderParams);
-            private static FunctionWrapper<GdipSaveAddImage_delegate> GdipSaveAddImage_ptr;
-            internal static int GdipSaveAddImage(HandleRef image, HandleRef newImage, HandleRef encoderParams) => GdipSaveAddImage_ptr.Delegate(image, newImage, encoderParams);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetEncoderParameterListSize(HandleRef image, ref Guid clsid, out int size);
 
-            private delegate int GdipGetImageGraphicsContext_delegate(HandleRef image, out IntPtr graphics);
-            private static FunctionWrapper<GdipGetImageGraphicsContext_delegate> GdipGetImageGraphicsContext_ptr;
-            internal static int GdipGetImageGraphicsContext(HandleRef image, out IntPtr graphics) => GdipGetImageGraphicsContext_ptr.Delegate(image, out graphics);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetEncoderParameterList(HandleRef image, ref Guid clsid, int size, IntPtr buffer);
 
-            private delegate int GdipGetImageBounds_delegate(HandleRef image, out RectangleF gprectf, out GraphicsUnit unit);
-            private static FunctionWrapper<GdipGetImageBounds_delegate> GdipGetImageBounds_ptr;
-            internal static int GdipGetImageBounds(HandleRef image, out RectangleF gprectf, out GraphicsUnit unit) => GdipGetImageBounds_ptr.Delegate(image, out gprectf, out unit);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImagePalette(HandleRef image, IntPtr palette, int size);
 
-            private delegate int GdipGetImageType_delegate(HandleRef image, out int type);
-            private static FunctionWrapper<GdipGetImageType_delegate> GdipGetImageType_ptr;
-            internal static int GdipGetImageType(HandleRef image, out int type) => GdipGetImageType_ptr.Delegate(image, out type);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetImagePalette(HandleRef image, IntPtr palette);
 
-            private delegate int GdipGetImageThumbnail_delegate(HandleRef image, int thumbWidth, int thumbHeight, out IntPtr thumbImage, Image.GetThumbnailImageAbort callback, IntPtr callbackdata);
-            private static FunctionWrapper<GdipGetImageThumbnail_delegate> GdipGetImageThumbnail_ptr;
-            internal static int GdipGetImageThumbnail(HandleRef image, int thumbWidth, int thumbHeight, out IntPtr thumbImage, Image.GetThumbnailImageAbort callback, IntPtr callbackdata) => GdipGetImageThumbnail_ptr.Delegate(image, thumbWidth, thumbHeight, out thumbImage, callback, callbackdata);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImagePaletteSize(HandleRef image, out int size);
 
-            private delegate int GdipGetEncoderParameterListSize_delegate(HandleRef image, ref Guid clsid, out int size);
-            private static FunctionWrapper<GdipGetEncoderParameterListSize_delegate> GdipGetEncoderParameterListSize_ptr;
-            internal static int GdipGetEncoderParameterListSize(HandleRef image, ref Guid clsid, out int size) => GdipGetEncoderParameterListSize_ptr.Delegate(image, ref clsid, out size);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPropertyCount(HandleRef image, out int count);
 
-            private delegate int GdipGetEncoderParameterList_delegate(HandleRef image, ref Guid clsid, int size, IntPtr buffer);
-            private static FunctionWrapper<GdipGetEncoderParameterList_delegate> GdipGetEncoderParameterList_ptr;
-            internal static int GdipGetEncoderParameterList(HandleRef image, ref Guid clsid, int size, IntPtr buffer) => GdipGetEncoderParameterList_ptr.Delegate(image, ref clsid, size, buffer);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPropertyIdList(HandleRef image, int count, int[] list);
 
-            private delegate int GdipGetImagePalette_delegate(HandleRef image, IntPtr palette, int size);
-            private static FunctionWrapper<GdipGetImagePalette_delegate> GdipGetImagePalette_ptr;
-            internal static int GdipGetImagePalette(HandleRef image, IntPtr palette, int size) => GdipGetImagePalette_ptr.Delegate(image, palette, size);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPropertyItemSize(HandleRef image, int propid, out int size);
 
-            private delegate int GdipSetImagePalette_delegate(HandleRef image, IntPtr palette);
-            private static FunctionWrapper<GdipSetImagePalette_delegate> GdipSetImagePalette_ptr;
-            internal static int GdipSetImagePalette(HandleRef image, IntPtr palette) => GdipSetImagePalette_ptr.Delegate(image, palette);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPropertyItem(HandleRef image, int propid, int size, IntPtr buffer);
 
-            private delegate int GdipGetImagePaletteSize_delegate(HandleRef image, out int size);
-            private static FunctionWrapper<GdipGetImagePaletteSize_delegate> GdipGetImagePaletteSize_ptr;
-            internal static int GdipGetImagePaletteSize(HandleRef image, out int size) => GdipGetImagePaletteSize_ptr.Delegate(image, out size);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPropertySize(HandleRef image, out int totalSize, ref int count);
 
-            private delegate int GdipGetPropertyCount_delegate(HandleRef image, out int count);
-            private static FunctionWrapper<GdipGetPropertyCount_delegate> GdipGetPropertyCount_ptr;
-            internal static int GdipGetPropertyCount(HandleRef image, out int count) => GdipGetPropertyCount_ptr.Delegate(image, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetAllPropertyItems(HandleRef image, int totalSize, int count, IntPtr buffer);
 
-            private delegate int GdipGetPropertyIdList_delegate(HandleRef image, int count, int[] list);
-            private static FunctionWrapper<GdipGetPropertyIdList_delegate> GdipGetPropertyIdList_ptr;
-            internal static int GdipGetPropertyIdList(HandleRef image, int count, int[] list) => GdipGetPropertyIdList_ptr.Delegate(image, count, list);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPropertyItem(HandleRef image, PropertyItemInternal propitem);
 
-            private delegate int GdipGetPropertyItemSize_delegate(HandleRef image, int propid, out int size);
-            private static FunctionWrapper<GdipGetPropertyItemSize_delegate> GdipGetPropertyItemSize_ptr;
-            internal static int GdipGetPropertyItemSize(HandleRef image, int propid, out int size) => GdipGetPropertyItemSize_ptr.Delegate(image, propid, out size);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipImageForceValidation(HandleRef image);
 
-            private delegate int GdipGetPropertyItem_delegate(HandleRef image, int propid, int size, IntPtr buffer);
-            private static FunctionWrapper<GdipGetPropertyItem_delegate> GdipGetPropertyItem_ptr;
-            internal static int GdipGetPropertyItem(HandleRef image, int propid, int size, IntPtr buffer) => GdipGetPropertyItem_ptr.Delegate(image, propid, size, buffer);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateFromHDC(HandleRef hdc, out IntPtr graphics);
 
-            private delegate int GdipGetPropertySize_delegate(HandleRef image, out int totalSize, ref int count);
-            private static FunctionWrapper<GdipGetPropertySize_delegate> GdipGetPropertySize_ptr;
-            internal static int GdipGetPropertySize(HandleRef image, out int totalSize, ref int count) => GdipGetPropertySize_ptr.Delegate(image, out totalSize, ref count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateFromHDC2(HandleRef hdc, HandleRef hdevice, out IntPtr graphics);
 
-            private delegate int GdipGetAllPropertyItems_delegate(HandleRef image, int totalSize, int count, IntPtr buffer);
-            private static FunctionWrapper<GdipGetAllPropertyItems_delegate> GdipGetAllPropertyItems_ptr;
-            internal static int GdipGetAllPropertyItems(HandleRef image, int totalSize, int count, IntPtr buffer) => GdipGetAllPropertyItems_ptr.Delegate(image, totalSize, count, buffer);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateFromHWND(HandleRef hwnd, out IntPtr graphics);
 
-            private delegate int GdipSetPropertyItem_delegate(HandleRef image, PropertyItemInternal propitem);
-            private static FunctionWrapper<GdipSetPropertyItem_delegate> GdipSetPropertyItem_ptr;
-            internal static int GdipSetPropertyItem(HandleRef image, PropertyItemInternal propitem) => GdipSetPropertyItem_ptr.Delegate(image, propitem);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeleteGraphics(HandleRef graphics);
 
-            private delegate int GdipImageForceValidation_delegate(HandleRef image);
-            private static FunctionWrapper<GdipImageForceValidation_delegate> GdipImageForceValidation_ptr;
-            internal static int GdipImageForceValidation(HandleRef image) => GdipImageForceValidation_ptr.Delegate(image);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipReleaseDC(HandleRef graphics, HandleRef hdc);
 
-            private delegate int GdipCreateFromHDC_delegate(HandleRef hdc, out IntPtr graphics);
-            private static FunctionWrapper<GdipCreateFromHDC_delegate> GdipCreateFromHDC_ptr;
-            internal static int GdipCreateFromHDC(HandleRef hdc, out IntPtr graphics) => GdipCreateFromHDC_ptr.Delegate(hdc, out graphics);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTransformPoints(HandleRef graphics, int destSpace, int srcSpace, PointF* points, int count);
 
-            private delegate int GdipCreateFromHDC2_delegate(HandleRef hdc, HandleRef hdevice, out IntPtr graphics);
-            private static FunctionWrapper<GdipCreateFromHDC2_delegate> GdipCreateFromHDC2_ptr;
-            internal static int GdipCreateFromHDC2(HandleRef hdc, HandleRef hdevice, out IntPtr graphics) => GdipCreateFromHDC2_ptr.Delegate(hdc, hdevice, out graphics);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTransformPointsI(HandleRef graphics, int destSpace, int srcSpace, Point* points, int count);
 
-            private delegate int GdipCreateFromHWND_delegate(HandleRef hwnd, out IntPtr graphics);
-            private static FunctionWrapper<GdipCreateFromHWND_delegate> GdipCreateFromHWND_ptr;
-            internal static int GdipCreateFromHWND(HandleRef hwnd, out IntPtr graphics) => GdipCreateFromHWND_ptr.Delegate(hwnd, out graphics);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetNearestColor(HandleRef graphics, ref int color);
 
-            private delegate int GdipDeleteGraphics_delegate(HandleRef graphics);
-            private static FunctionWrapper<GdipDeleteGraphics_delegate> GdipDeleteGraphics_ptr;
-            internal static int IntGdipDeleteGraphics(HandleRef graphics) => GdipDeleteGraphics_ptr.Delegate(graphics);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern IntPtr GdipCreateHalftonePalette();
 
-            private delegate int GdipReleaseDC_delegate(HandleRef graphics, HandleRef hdc);
-            private static FunctionWrapper<GdipReleaseDC_delegate> GdipReleaseDC_ptr;
-            internal static int IntGdipReleaseDC(HandleRef graphics, HandleRef hdc) => GdipReleaseDC_ptr.Delegate(graphics, hdc);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawLine(HandleRef graphics, HandleRef pen, float x1, float y1, float x2, float y2);
 
-            private delegate int GdipTransformPoints_delegate(HandleRef graphics, int destSpace, int srcSpace, PointF* points, int count);
-            private static FunctionWrapper<GdipTransformPoints_delegate> GdipTransformPoints_ptr;
-            internal static int GdipTransformPoints(HandleRef graphics, int destSpace, int srcSpace, PointF* points, int count) => GdipTransformPoints_ptr.Delegate(graphics, destSpace, srcSpace, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawLineI(HandleRef graphics, HandleRef pen, int x1, int y1, int x2, int y2);
 
-            private delegate int GdipTransformPointsI_delegate(HandleRef graphics, int destSpace, int srcSpace, Point* points, int count);
-            private static FunctionWrapper<GdipTransformPointsI_delegate> GdipTransformPointsI_ptr;
-            internal static int GdipTransformPointsI(HandleRef graphics, int destSpace, int srcSpace, Point* points, int count) => GdipTransformPointsI_ptr.Delegate(graphics, destSpace, srcSpace, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawLines(HandleRef graphics, HandleRef pen, PointF* points, int count);
 
-            private delegate int GdipGetNearestColor_delegate(HandleRef graphics, ref int color);
-            private static FunctionWrapper<GdipGetNearestColor_delegate> GdipGetNearestColor_ptr;
-            internal static int GdipGetNearestColor(HandleRef graphics, ref int color) => GdipGetNearestColor_ptr.Delegate(graphics, ref color);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawLinesI(HandleRef graphics, HandleRef pen, Point* points, int count);
 
-            private delegate IntPtr GdipCreateHalftonePalette_delegate();
-            private static FunctionWrapper<GdipCreateHalftonePalette_delegate> GdipCreateHalftonePalette_ptr;
-            internal static IntPtr GdipCreateHalftonePalette() => GdipCreateHalftonePalette_ptr.Delegate();
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawArc(HandleRef graphics, HandleRef pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
 
-            private delegate int GdipDrawLine_delegate(HandleRef graphics, HandleRef pen, float x1, float y1, float x2, float y2);
-            private static FunctionWrapper<GdipDrawLine_delegate> GdipDrawLine_ptr;
-            internal static int GdipDrawLine(HandleRef graphics, HandleRef pen, float x1, float y1, float x2, float y2) => GdipDrawLine_ptr.Delegate(graphics, pen, x1, y1, x2, y2);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawArcI(HandleRef graphics, HandleRef pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
 
-            private delegate int GdipDrawLineI_delegate(HandleRef graphics, HandleRef pen, int x1, int y1, int x2, int y2);
-            private static FunctionWrapper<GdipDrawLineI_delegate> GdipDrawLineI_ptr;
-            internal static int GdipDrawLineI(HandleRef graphics, HandleRef pen, int x1, int y1, int x2, int y2) => GdipDrawLineI_ptr.Delegate(graphics, pen, x1, y1, x2, y2);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawBezier(HandleRef graphics, HandleRef pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
 
-            private delegate int GdipDrawLines_delegate(HandleRef graphics, HandleRef pen, PointF* points, int count);
-            private static FunctionWrapper<GdipDrawLines_delegate> GdipDrawLines_ptr;
-            internal static int GdipDrawLines(HandleRef graphics, HandleRef pen, PointF* points, int count) => GdipDrawLines_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawBeziers(HandleRef graphics, HandleRef pen, PointF* points, int count);
 
-            private delegate int GdipDrawLinesI_delegate(HandleRef graphics, HandleRef pen, Point* points, int count);
-            private static FunctionWrapper<GdipDrawLinesI_delegate> GdipDrawLinesI_ptr;
-            internal static int GdipDrawLinesI(HandleRef graphics, HandleRef pen, Point* points, int count) => GdipDrawLinesI_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawBeziersI(HandleRef graphics, HandleRef pen, Point* points, int count);
 
-            private delegate int GdipDrawArc_delegate(HandleRef graphics, HandleRef pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipDrawArc_delegate> GdipDrawArc_ptr;
-            internal static int GdipDrawArc(HandleRef graphics, HandleRef pen, float x, float y, float width, float height, float startAngle, float sweepAngle) => GdipDrawArc_ptr.Delegate(graphics, pen, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawRectangle(HandleRef graphics, HandleRef pen, float x, float y, float width, float height);
 
-            private delegate int GdipDrawArcI_delegate(HandleRef graphics, HandleRef pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipDrawArcI_delegate> GdipDrawArcI_ptr;
-            internal static int GdipDrawArcI(HandleRef graphics, HandleRef pen, int x, int y, int width, int height, float startAngle, float sweepAngle) => GdipDrawArcI_ptr.Delegate(graphics, pen, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawRectangleI(HandleRef graphics, HandleRef pen, int x, int y, int width, int height);
 
-            private delegate int GdipDrawBezier_delegate(HandleRef graphics, HandleRef pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
-            private static FunctionWrapper<GdipDrawBezier_delegate> GdipDrawBezier_ptr;
-            internal static int GdipDrawBezier(HandleRef graphics, HandleRef pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) => GdipDrawBezier_ptr.Delegate(graphics, pen, x1, y1, x2, y2, x3, y3, x4, y4);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawRectangles(HandleRef graphics, HandleRef pen, RectangleF* rects, int count);
 
-            private delegate int GdipDrawBeziers_delegate(HandleRef graphics, HandleRef pen, PointF* points, int count);
-            private static FunctionWrapper<GdipDrawBeziers_delegate> GdipDrawBeziers_ptr;
-            internal static int GdipDrawBeziers(HandleRef graphics, HandleRef pen, PointF* points, int count) => GdipDrawBeziers_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawRectanglesI(HandleRef graphics, HandleRef pen, Rectangle* rects, int count);
 
-            private delegate int GdipDrawBeziersI_delegate(HandleRef graphics, HandleRef pen, Point* points, int count);
-            private static FunctionWrapper<GdipDrawBeziersI_delegate> GdipDrawBeziersI_ptr;
-            internal static int GdipDrawBeziersI(HandleRef graphics, HandleRef pen, Point* points, int count) => GdipDrawBeziersI_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawEllipse(HandleRef graphics, HandleRef pen, float x, float y, float width, float height);
 
-            private delegate int GdipDrawRectangle_delegate(HandleRef graphics, HandleRef pen, float x, float y, float width, float height);
-            private static FunctionWrapper<GdipDrawRectangle_delegate> GdipDrawRectangle_ptr;
-            internal static int GdipDrawRectangle(HandleRef graphics, HandleRef pen, float x, float y, float width, float height) => GdipDrawRectangle_ptr.Delegate(graphics, pen, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawEllipseI(HandleRef graphics, HandleRef pen, int x, int y, int width, int height);
 
-            private delegate int GdipDrawRectangleI_delegate(HandleRef graphics, HandleRef pen, int x, int y, int width, int height);
-            private static FunctionWrapper<GdipDrawRectangleI_delegate> GdipDrawRectangleI_ptr;
-            internal static int GdipDrawRectangleI(HandleRef graphics, HandleRef pen, int x, int y, int width, int height) => GdipDrawRectangleI_ptr.Delegate(graphics, pen, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawPie(HandleRef graphics, HandleRef pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
 
-            private delegate int GdipDrawRectangles_delegate(HandleRef graphics, HandleRef pen, RectangleF* rects, int count);
-            private static FunctionWrapper<GdipDrawRectangles_delegate> GdipDrawRectangles_ptr;
-            internal static int GdipDrawRectangles(HandleRef graphics, HandleRef pen, RectangleF* rects, int count) => GdipDrawRectangles_ptr.Delegate(graphics, pen, rects, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawPieI(HandleRef graphics, HandleRef pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
 
-            private delegate int GdipDrawRectanglesI_delegate(HandleRef graphics, HandleRef pen, Rectangle* rects, int count);
-            private static FunctionWrapper<GdipDrawRectanglesI_delegate> GdipDrawRectanglesI_ptr;
-            internal static int GdipDrawRectanglesI(HandleRef graphics, HandleRef pen, Rectangle* rects, int count) => GdipDrawRectanglesI_ptr.Delegate(graphics, pen, rects, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawPolygon(HandleRef graphics, HandleRef pen, PointF* points, int count);
 
-            private delegate int GdipDrawEllipse_delegate(HandleRef graphics, HandleRef pen, float x, float y, float width, float height);
-            private static FunctionWrapper<GdipDrawEllipse_delegate> GdipDrawEllipse_ptr;
-            internal static int GdipDrawEllipse(HandleRef graphics, HandleRef pen, float x, float y, float width, float height) => GdipDrawEllipse_ptr.Delegate(graphics, pen, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawPolygonI(HandleRef graphics, HandleRef pen, Point* points, int count);
 
-            private delegate int GdipDrawEllipseI_delegate(HandleRef graphics, HandleRef pen, int x, int y, int width, int height);
-            private static FunctionWrapper<GdipDrawEllipseI_delegate> GdipDrawEllipseI_ptr;
-            internal static int GdipDrawEllipseI(HandleRef graphics, HandleRef pen, int x, int y, int width, int height) => GdipDrawEllipseI_ptr.Delegate(graphics, pen, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawPath(HandleRef graphics, HandleRef pen, HandleRef path);
 
-            private delegate int GdipDrawPie_delegate(HandleRef graphics, HandleRef pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipDrawPie_delegate> GdipDrawPie_ptr;
-            internal static int GdipDrawPie(HandleRef graphics, HandleRef pen, float x, float y, float width, float height, float startAngle, float sweepAngle) => GdipDrawPie_ptr.Delegate(graphics, pen, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawCurve(HandleRef graphics, HandleRef pen, PointF* points, int count);
 
-            private delegate int GdipDrawPieI_delegate(HandleRef graphics, HandleRef pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipDrawPieI_delegate> GdipDrawPieI_ptr;
-            internal static int GdipDrawPieI(HandleRef graphics, HandleRef pen, int x, int y, int width, int height, float startAngle, float sweepAngle) => GdipDrawPieI_ptr.Delegate(graphics, pen, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawCurveI(HandleRef graphics, HandleRef pen, Point* points, int count);
 
-            private delegate int GdipDrawPolygon_delegate(HandleRef graphics, HandleRef pen, PointF* points, int count);
-            private static FunctionWrapper<GdipDrawPolygon_delegate> GdipDrawPolygon_ptr;
-            internal static int GdipDrawPolygon(HandleRef graphics, HandleRef pen, PointF* points, int count) => GdipDrawPolygon_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawCurve2(HandleRef graphics, HandleRef pen, PointF* points, int count, float tension);
 
-            private delegate int GdipDrawPolygonI_delegate(HandleRef graphics, HandleRef pen, Point* points, int count);
-            private static FunctionWrapper<GdipDrawPolygonI_delegate> GdipDrawPolygonI_ptr;
-            internal static int GdipDrawPolygonI(HandleRef graphics, HandleRef pen, Point* points, int count) => GdipDrawPolygonI_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawCurve2I(HandleRef graphics, HandleRef pen, Point* points, int count, float tension);
 
-            private delegate int GdipDrawPath_delegate(HandleRef graphics, HandleRef pen, HandleRef path);
-            private static FunctionWrapper<GdipDrawPath_delegate> GdipDrawPath_ptr;
-            internal static int GdipDrawPath(HandleRef graphics, HandleRef pen, HandleRef path) => GdipDrawPath_ptr.Delegate(graphics, pen, path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawCurve3(HandleRef graphics, HandleRef pen, PointF* points, int count, int offset, int numberOfSegments, float tension);
 
-            private delegate int GdipDrawCurve_delegate(HandleRef graphics, HandleRef pen, PointF* points, int count);
-            private static FunctionWrapper<GdipDrawCurve_delegate> GdipDrawCurve_ptr;
-            internal static int GdipDrawCurve(HandleRef graphics, HandleRef pen, PointF* points, int count) => GdipDrawCurve_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawCurve3I(HandleRef graphics, HandleRef pen, Point* points, int count, int offset, int numberOfSegments, float tension);
 
-            private delegate int GdipDrawCurveI_delegate(HandleRef graphics, HandleRef pen, Point* points, int count);
-            private static FunctionWrapper<GdipDrawCurveI_delegate> GdipDrawCurveI_ptr;
-            internal static int GdipDrawCurveI(HandleRef graphics, HandleRef pen, Point* points, int count) => GdipDrawCurveI_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawClosedCurve(HandleRef graphics, HandleRef pen, PointF* points, int count);
 
-            private delegate int GdipDrawCurve2_delegate(HandleRef graphics, HandleRef pen, PointF* points, int count, float tension);
-            private static FunctionWrapper<GdipDrawCurve2_delegate> GdipDrawCurve2_ptr;
-            internal static int GdipDrawCurve2(HandleRef graphics, HandleRef pen, PointF* points, int count, float tension) => GdipDrawCurve2_ptr.Delegate(graphics, pen, points, count, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawClosedCurveI(HandleRef graphics, HandleRef pen, Point* points, int count);
 
-            private delegate int GdipDrawCurve2I_delegate(HandleRef graphics, HandleRef pen, Point* points, int count, float tension);
-            private static FunctionWrapper<GdipDrawCurve2I_delegate> GdipDrawCurve2I_ptr;
-            internal static int GdipDrawCurve2I(HandleRef graphics, HandleRef pen, Point* points, int count, float tension) => GdipDrawCurve2I_ptr.Delegate(graphics, pen, points, count, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawClosedCurve2(HandleRef graphics, HandleRef pen, PointF* points, int count, float tension);
 
-            private delegate int GdipDrawCurve3_delegate(HandleRef graphics, HandleRef pen, PointF* points, int count, int offset, int numberOfSegments, float tension);
-            private static FunctionWrapper<GdipDrawCurve3_delegate> GdipDrawCurve3_ptr;
-            internal static int GdipDrawCurve3(HandleRef graphics, HandleRef pen, PointF* points, int count, int offset, int numberOfSegments, float tension) => GdipDrawCurve3_ptr.Delegate(graphics, pen, points, count, offset, numberOfSegments, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawClosedCurve2I(HandleRef graphics, HandleRef pen, Point* points, int count, float tension);
 
-            private delegate int GdipDrawCurve3I_delegate(HandleRef graphics, HandleRef pen, Point* points, int count, int offset, int numberOfSegments, float tension);
-            private static FunctionWrapper<GdipDrawCurve3I_delegate> GdipDrawCurve3I_ptr;
-            internal static int GdipDrawCurve3I(HandleRef graphics, HandleRef pen, Point* points, int count, int offset, int numberOfSegments, float tension) => GdipDrawCurve3I_ptr.Delegate(graphics, pen, points, count, offset, numberOfSegments, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGraphicsClear(HandleRef graphics, int argb);
 
-            private delegate int GdipDrawClosedCurve_delegate(HandleRef graphics, HandleRef pen, PointF* points, int count);
-            private static FunctionWrapper<GdipDrawClosedCurve_delegate> GdipDrawClosedCurve_ptr;
-            internal static int GdipDrawClosedCurve(HandleRef graphics, HandleRef pen, PointF* points, int count) => GdipDrawClosedCurve_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillRectangle(HandleRef graphics, HandleRef brush, float x, float y, float width, float height);
 
-            private delegate int GdipDrawClosedCurveI_delegate(HandleRef graphics, HandleRef pen, Point* points, int count);
-            private static FunctionWrapper<GdipDrawClosedCurveI_delegate> GdipDrawClosedCurveI_ptr;
-            internal static int GdipDrawClosedCurveI(HandleRef graphics, HandleRef pen, Point* points, int count) => GdipDrawClosedCurveI_ptr.Delegate(graphics, pen, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillRectangleI(HandleRef graphics, HandleRef brush, int x, int y, int width, int height);
 
-            private delegate int GdipDrawClosedCurve2_delegate(HandleRef graphics, HandleRef pen, PointF* points, int count, float tension);
-            private static FunctionWrapper<GdipDrawClosedCurve2_delegate> GdipDrawClosedCurve2_ptr;
-            internal static int GdipDrawClosedCurve2(HandleRef graphics, HandleRef pen, PointF* points, int count, float tension) => GdipDrawClosedCurve2_ptr.Delegate(graphics, pen, points, count, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillRectangles(HandleRef graphics, HandleRef brush, RectangleF* rects, int count);
 
-            private delegate int GdipDrawClosedCurve2I_delegate(HandleRef graphics, HandleRef pen, Point* points, int count, float tension);
-            private static FunctionWrapper<GdipDrawClosedCurve2I_delegate> GdipDrawClosedCurve2I_ptr;
-            internal static int GdipDrawClosedCurve2I(HandleRef graphics, HandleRef pen, Point* points, int count, float tension) => GdipDrawClosedCurve2I_ptr.Delegate(graphics, pen, points, count, tension);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillRectanglesI(HandleRef graphics, HandleRef brush, Rectangle* rects, int count);
 
-            private delegate int GdipGraphicsClear_delegate(HandleRef graphics, int argb);
-            private static FunctionWrapper<GdipGraphicsClear_delegate> GdipGraphicsClear_ptr;
-            internal static int GdipGraphicsClear(HandleRef graphics, int argb) => GdipGraphicsClear_ptr.Delegate(graphics, argb);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillPolygon(HandleRef graphics, HandleRef brush, PointF* points, int count, FillMode brushMode);
 
-            private delegate int GdipFillRectangle_delegate(HandleRef graphics, HandleRef brush, float x, float y, float width, float height);
-            private static FunctionWrapper<GdipFillRectangle_delegate> GdipFillRectangle_ptr;
-            internal static int GdipFillRectangle(HandleRef graphics, HandleRef brush, float x, float y, float width, float height) => GdipFillRectangle_ptr.Delegate(graphics, brush, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillPolygonI(HandleRef graphics, HandleRef brush, Point* points, int count, FillMode brushMode);
 
-            private delegate int GdipFillRectangleI_delegate(HandleRef graphics, HandleRef brush, int x, int y, int width, int height);
-            private static FunctionWrapper<GdipFillRectangleI_delegate> GdipFillRectangleI_ptr;
-            internal static int GdipFillRectangleI(HandleRef graphics, HandleRef brush, int x, int y, int width, int height) => GdipFillRectangleI_ptr.Delegate(graphics, brush, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillEllipse(HandleRef graphics, HandleRef brush, float x, float y, float width, float height);
 
-            private delegate int GdipFillRectangles_delegate(HandleRef graphics, HandleRef brush, RectangleF* rects, int count);
-            private static FunctionWrapper<GdipFillRectangles_delegate> GdipFillRectangles_ptr;
-            internal static int GdipFillRectangles(HandleRef graphics, HandleRef brush, RectangleF* rects, int count) => GdipFillRectangles_ptr.Delegate(graphics, brush, rects, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillEllipseI(HandleRef graphics, HandleRef brush, int x, int y, int width, int height);
 
-            private delegate int GdipFillRectanglesI_delegate(HandleRef graphics, HandleRef brush, Rectangle* rects, int count);
-            private static FunctionWrapper<GdipFillRectanglesI_delegate> GdipFillRectanglesI_ptr;
-            internal static int GdipFillRectanglesI(HandleRef graphics, HandleRef brush, Rectangle* rects, int count) => GdipFillRectanglesI_ptr.Delegate(graphics, brush, rects, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillPie(HandleRef graphics, HandleRef brush, float x, float y, float width, float height, float startAngle, float sweepAngle);
 
-            private delegate int GdipFillPolygon_delegate(HandleRef graphics, HandleRef brush, PointF* points, int count, FillMode brushMode);
-            private static FunctionWrapper<GdipFillPolygon_delegate> GdipFillPolygon_ptr;
-            internal static int GdipFillPolygon(HandleRef graphics, HandleRef brush, PointF* points, int count, FillMode brushMode) => GdipFillPolygon_ptr.Delegate(graphics, brush, points, count, brushMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillPieI(HandleRef graphics, HandleRef brush, int x, int y, int width, int height, float startAngle, float sweepAngle);
 
-            private delegate int GdipFillPolygonI_delegate(HandleRef graphics, HandleRef brush, Point* points, int count, FillMode brushMode);
-            private static FunctionWrapper<GdipFillPolygonI_delegate> GdipFillPolygonI_ptr;
-            internal static int GdipFillPolygonI(HandleRef graphics, HandleRef brush, Point* points, int count, FillMode brushMode) => GdipFillPolygonI_ptr.Delegate(graphics, brush, points, count, brushMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillPath(HandleRef graphics, HandleRef brush, HandleRef path);
 
-            private delegate int GdipFillEllipse_delegate(HandleRef graphics, HandleRef brush, float x, float y, float width, float height);
-            private static FunctionWrapper<GdipFillEllipse_delegate> GdipFillEllipse_ptr;
-            internal static int GdipFillEllipse(HandleRef graphics, HandleRef brush, float x, float y, float width, float height) => GdipFillEllipse_ptr.Delegate(graphics, brush, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillClosedCurve(HandleRef graphics, HandleRef brush, PointF* points, int count);
 
-            private delegate int GdipFillEllipseI_delegate(HandleRef graphics, HandleRef brush, int x, int y, int width, int height);
-            private static FunctionWrapper<GdipFillEllipseI_delegate> GdipFillEllipseI_ptr;
-            internal static int GdipFillEllipseI(HandleRef graphics, HandleRef brush, int x, int y, int width, int height) => GdipFillEllipseI_ptr.Delegate(graphics, brush, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillClosedCurveI(HandleRef graphics, HandleRef brush, Point* points, int count);
 
-            private delegate int GdipFillPie_delegate(HandleRef graphics, HandleRef brush, float x, float y, float width, float height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipFillPie_delegate> GdipFillPie_ptr;
-            internal static int GdipFillPie(HandleRef graphics, HandleRef brush, float x, float y, float width, float height, float startAngle, float sweepAngle) => GdipFillPie_ptr.Delegate(graphics, brush, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillClosedCurve2(HandleRef graphics, HandleRef brush, PointF* points, int count, float tension, FillMode mode);
 
-            private delegate int GdipFillPieI_delegate(HandleRef graphics, HandleRef brush, int x, int y, int width, int height, float startAngle, float sweepAngle);
-            private static FunctionWrapper<GdipFillPieI_delegate> GdipFillPieI_ptr;
-            internal static int GdipFillPieI(HandleRef graphics, HandleRef brush, int x, int y, int width, int height, float startAngle, float sweepAngle) => GdipFillPieI_ptr.Delegate(graphics, brush, x, y, width, height, startAngle, sweepAngle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillClosedCurve2I(HandleRef graphics, HandleRef brush, Point* points, int count, float tension, FillMode mode);
 
-            private delegate int GdipFillPath_delegate(HandleRef graphics, HandleRef brush, HandleRef path);
-            private static FunctionWrapper<GdipFillPath_delegate> GdipFillPath_ptr;
-            internal static int GdipFillPath(HandleRef graphics, HandleRef brush, HandleRef path) => GdipFillPath_ptr.Delegate(graphics, brush, path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImage(HandleRef graphics, HandleRef image, float x, float y);
 
-            private delegate int GdipFillClosedCurve_delegate(HandleRef graphics, HandleRef brush, PointF* points, int count);
-            private static FunctionWrapper<GdipFillClosedCurve_delegate> GdipFillClosedCurve_ptr;
-            internal static int GdipFillClosedCurve(HandleRef graphics, HandleRef brush, PointF* points, int count) => GdipFillClosedCurve_ptr.Delegate(graphics, brush, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImageI(HandleRef graphics, HandleRef image, int x, int y);
 
-            private delegate int GdipFillClosedCurveI_delegate(HandleRef graphics, HandleRef brush, Point* points, int count);
-            private static FunctionWrapper<GdipFillClosedCurveI_delegate> GdipFillClosedCurveI_ptr;
-            internal static int GdipFillClosedCurveI(HandleRef graphics, HandleRef brush, Point* points, int count) => GdipFillClosedCurveI_ptr.Delegate(graphics, brush, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImageRect(HandleRef graphics, HandleRef image, float x, float y, float width, float height);
 
-            private delegate int GdipFillClosedCurve2_delegate(HandleRef graphics, HandleRef brush, PointF* points, int count, float tension, FillMode mode);
-            private static FunctionWrapper<GdipFillClosedCurve2_delegate> GdipFillClosedCurve2_ptr;
-            internal static int GdipFillClosedCurve2(HandleRef graphics, HandleRef brush, PointF* points, int count, float tension, FillMode mode) => GdipFillClosedCurve2_ptr.Delegate(graphics, brush, points, count, tension, mode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImageRectI(HandleRef graphics, HandleRef image, int x, int y, int width, int height);
 
-            private delegate int GdipFillClosedCurve2I_delegate(HandleRef graphics, HandleRef brush, Point* points, int count, float tension, FillMode mode);
-            private static FunctionWrapper<GdipFillClosedCurve2I_delegate> GdipFillClosedCurve2I_ptr;
-            internal static int GdipFillClosedCurve2I(HandleRef graphics, HandleRef brush, Point* points, int count, float tension, FillMode mode) => GdipFillClosedCurve2I_ptr.Delegate(graphics, brush, points, count, tension, mode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImagePoints(HandleRef graphics, HandleRef image, PointF* points, int count);
 
-            private delegate int GdipDrawImage_delegate(HandleRef graphics, HandleRef image, float x, float y);
-            private static FunctionWrapper<GdipDrawImage_delegate> GdipDrawImage_ptr;
-            internal static int GdipDrawImage(HandleRef graphics, HandleRef image, float x, float y) => GdipDrawImage_ptr.Delegate(graphics, image, x, y);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImagePointsI(HandleRef graphics, HandleRef image, Point* points, int count);
 
-            private delegate int GdipDrawImageI_delegate(HandleRef graphics, HandleRef image, int x, int y);
-            private static FunctionWrapper<GdipDrawImageI_delegate> GdipDrawImageI_ptr;
-            internal static int GdipDrawImageI(HandleRef graphics, HandleRef image, int x, int y) => GdipDrawImageI_ptr.Delegate(graphics, image, x, y);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImagePointRect(HandleRef graphics, HandleRef image, float x, float y, float srcx, float srcy, float srcwidth, float srcheight, int srcunit);
 
-            private delegate int GdipDrawImageRect_delegate(HandleRef graphics, HandleRef image, float x, float y, float width, float height);
-            private static FunctionWrapper<GdipDrawImageRect_delegate> GdipDrawImageRect_ptr;
-            internal static int GdipDrawImageRect(HandleRef graphics, HandleRef image, float x, float y, float width, float height) => GdipDrawImageRect_ptr.Delegate(graphics, image, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImagePointRectI(HandleRef graphics, HandleRef image, int x, int y, int srcx, int srcy, int srcwidth, int srcheight, int srcunit);
 
-            private delegate int GdipDrawImageRectI_delegate(HandleRef graphics, HandleRef image, int x, int y, int width, int height);
-            private static FunctionWrapper<GdipDrawImageRectI_delegate> GdipDrawImageRectI_ptr;
-            internal static int GdipDrawImageRectI(HandleRef graphics, HandleRef image, int x, int y, int width, int height) => GdipDrawImageRectI_ptr.Delegate(graphics, image, x, y, width, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImageRectRect(HandleRef graphics, HandleRef image, float dstx, float dsty, float dstwidth, float dstheight, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata);
 
-            private delegate int GdipDrawImagePoints_delegate(HandleRef graphics, HandleRef image, PointF* points, int count);
-            private static FunctionWrapper<GdipDrawImagePoints_delegate> GdipDrawImagePoints_ptr;
-            internal static int GdipDrawImagePoints(HandleRef graphics, HandleRef image, PointF* points, int count) => GdipDrawImagePoints_ptr.Delegate(graphics, image, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImageRectRectI(HandleRef graphics, HandleRef image, int dstx, int dsty, int dstwidth, int dstheight, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata);
 
-            private delegate int GdipDrawImagePointsI_delegate(HandleRef graphics, HandleRef image, Point* points, int count);
-            private static FunctionWrapper<GdipDrawImagePointsI_delegate> GdipDrawImagePointsI_ptr;
-            internal static int GdipDrawImagePointsI(HandleRef graphics, HandleRef image, Point* points, int count) => GdipDrawImagePointsI_ptr.Delegate(graphics, image, points, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImagePointsRect(HandleRef graphics, HandleRef image, PointF* points, int count, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata);
 
-            private delegate int GdipDrawImagePointRect_delegate(HandleRef graphics, HandleRef image, float x, float y, float srcx, float srcy, float srcwidth, float srcheight, int srcunit);
-            private static FunctionWrapper<GdipDrawImagePointRect_delegate> GdipDrawImagePointRect_ptr;
-            internal static int GdipDrawImagePointRect(HandleRef graphics, HandleRef image, float x, float y, float srcx, float srcy, float srcwidth, float srcheight, int srcunit) => GdipDrawImagePointRect_ptr.Delegate(graphics, image, x, y, srcx, srcy, srcwidth, srcheight, srcunit);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDrawImagePointsRectI(HandleRef graphics, HandleRef image, Point* points, int count, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata);
 
-            private delegate int GdipDrawImagePointRectI_delegate(HandleRef graphics, HandleRef image, int x, int y, int srcx, int srcy, int srcwidth, int srcheight, int srcunit);
-            private static FunctionWrapper<GdipDrawImagePointRectI_delegate> GdipDrawImagePointRectI_ptr;
-            internal static int GdipDrawImagePointRectI(HandleRef graphics, HandleRef image, int x, int y, int srcx, int srcy, int srcwidth, int srcheight, int srcunit) => GdipDrawImagePointRectI_ptr.Delegate(graphics, image, x, y, srcx, srcy, srcwidth, srcheight, srcunit);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipEnumerateMetafileDestPoint(HandleRef graphics, HandleRef metafile, ref PointF destPoint, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
 
-            private delegate int GdipDrawImageRectRect_delegate(HandleRef graphics, HandleRef image, float dstx, float dsty, float dstwidth, float dstheight, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata);
-            private static FunctionWrapper<GdipDrawImageRectRect_delegate> GdipDrawImageRectRect_ptr;
-            internal static int GdipDrawImageRectRect(HandleRef graphics, HandleRef image, float dstx, float dsty, float dstwidth, float dstheight, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata) => GdipDrawImageRectRect_ptr.Delegate(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcunit, imageAttributes, callback, callbackdata);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipEnumerateMetafileDestPointI(HandleRef graphics, HandleRef metafile, ref Point destPoint, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
 
-            private delegate int GdipDrawImageRectRectI_delegate(HandleRef graphics, HandleRef image, int dstx, int dsty, int dstwidth, int dstheight, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata);
-            private static FunctionWrapper<GdipDrawImageRectRectI_delegate> GdipDrawImageRectRectI_ptr;
-            internal static int GdipDrawImageRectRectI(HandleRef graphics, HandleRef image, int dstx, int dsty, int dstwidth, int dstheight, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata) => GdipDrawImageRectRectI_ptr.Delegate(graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcunit, imageAttributes, callback, callbackdata);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipEnumerateMetafileDestRect(HandleRef graphics, HandleRef metafile, ref RectangleF destRect, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
 
-            private delegate int GdipDrawImagePointsRect_delegate(HandleRef graphics, HandleRef image, PointF* points, int count, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata);
-            private static FunctionWrapper<GdipDrawImagePointsRect_delegate> GdipDrawImagePointsRect_ptr;
-            internal static int GdipDrawImagePointsRect(HandleRef graphics, HandleRef image, PointF* points, int count, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata) => GdipDrawImagePointsRect_ptr.Delegate(graphics, image, points, count, srcx, srcy, srcwidth, srcheight, srcunit, imageAttributes, callback, callbackdata);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipEnumerateMetafileDestRectI(HandleRef graphics, HandleRef metafile, ref Rectangle destRect, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
 
-            private delegate int GdipDrawImagePointsRectI_delegate(HandleRef graphics, HandleRef image, Point* points, int count, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata);
-            private static FunctionWrapper<GdipDrawImagePointsRectI_delegate> GdipDrawImagePointsRectI_ptr;
-            internal static int GdipDrawImagePointsRectI(HandleRef graphics, HandleRef image, Point* points, int count, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcunit, HandleRef imageAttributes, Graphics.DrawImageAbort callback, HandleRef callbackdata) => GdipDrawImagePointsRectI_ptr.Delegate(graphics, image, points, count, srcx, srcy, srcwidth, srcheight, srcunit, imageAttributes, callback, callbackdata);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipEnumerateMetafileDestPoints(HandleRef graphics, HandleRef metafile, PointF* destPoints, int count, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
 
-            private delegate int GdipEnumerateMetafileDestPoint_delegate(HandleRef graphics, HandleRef metafile, ref PointF destPoint, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
-            private static FunctionWrapper<GdipEnumerateMetafileDestPoint_delegate> GdipEnumerateMetafileDestPoint_ptr;
-            internal static int GdipEnumerateMetafileDestPoint(HandleRef graphics, HandleRef metafile, ref PointF destPoint, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes) => GdipEnumerateMetafileDestPoint_ptr.Delegate(graphics, metafile, ref destPoint, callback, callbackdata, imageattributes);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipEnumerateMetafileDestPointsI(HandleRef graphics, HandleRef metafile, Point* destPoints, int count, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
 
-            private delegate int GdipEnumerateMetafileDestPointI_delegate(HandleRef graphics, HandleRef metafile, ref Point destPoint, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
-            private static FunctionWrapper<GdipEnumerateMetafileDestPointI_delegate> GdipEnumerateMetafileDestPointI_ptr;
-            internal static int GdipEnumerateMetafileDestPointI(HandleRef graphics, HandleRef metafile, ref Point destPoint, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes) => GdipEnumerateMetafileDestPointI_ptr.Delegate(graphics, metafile, ref destPoint, callback, callbackdata, imageattributes);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipEnumerateMetafileSrcRectDestPoint(HandleRef graphics, HandleRef metafile, ref PointF destPoint, ref RectangleF srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
 
-            private delegate int GdipEnumerateMetafileDestRect_delegate(HandleRef graphics, HandleRef metafile, ref RectangleF destRect, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
-            private static FunctionWrapper<GdipEnumerateMetafileDestRect_delegate> GdipEnumerateMetafileDestRect_ptr;
-            internal static int GdipEnumerateMetafileDestRect(HandleRef graphics, HandleRef metafile, ref RectangleF destRect, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes) => GdipEnumerateMetafileDestRect_ptr.Delegate(graphics, metafile, ref destRect, callback, callbackdata, imageattributes);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipEnumerateMetafileSrcRectDestPointI(HandleRef graphics, HandleRef metafile, ref Point destPoint, ref Rectangle srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
 
-            private delegate int GdipEnumerateMetafileDestRectI_delegate(HandleRef graphics, HandleRef metafile, ref Rectangle destRect, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
-            private static FunctionWrapper<GdipEnumerateMetafileDestRectI_delegate> GdipEnumerateMetafileDestRectI_ptr;
-            internal static int GdipEnumerateMetafileDestRectI(HandleRef graphics, HandleRef metafile, ref Rectangle destRect, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes) => GdipEnumerateMetafileDestRectI_ptr.Delegate(graphics, metafile, ref destRect, callback, callbackdata, imageattributes);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipEnumerateMetafileSrcRectDestRect(HandleRef graphics, HandleRef metafile, ref RectangleF destRect, ref RectangleF srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
 
-            private delegate int GdipEnumerateMetafileDestPoints_delegate(HandleRef graphics, HandleRef metafile, PointF* destPoints, int count, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
-            private static FunctionWrapper<GdipEnumerateMetafileDestPoints_delegate> GdipEnumerateMetafileDestPoints_ptr;
-            internal static int GdipEnumerateMetafileDestPoints(HandleRef graphics, HandleRef metafile, PointF* destPoints, int count, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes) => GdipEnumerateMetafileDestPoints_ptr.Delegate(graphics, metafile, destPoints, count, callback, callbackdata, imageattributes);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipEnumerateMetafileSrcRectDestRectI(HandleRef graphics, HandleRef metafile, ref Rectangle destRect, ref Rectangle srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
 
-            private delegate int GdipEnumerateMetafileDestPointsI_delegate(HandleRef graphics, HandleRef metafile, Point* destPoints, int count, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
-            private static FunctionWrapper<GdipEnumerateMetafileDestPointsI_delegate> GdipEnumerateMetafileDestPointsI_ptr;
-            internal static int GdipEnumerateMetafileDestPointsI(HandleRef graphics, HandleRef metafile, Point* destPoints, int count, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes) => GdipEnumerateMetafileDestPointsI_ptr.Delegate(graphics, metafile, destPoints, count, callback, callbackdata, imageattributes);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipEnumerateMetafileSrcRectDestPoints(HandleRef graphics, HandleRef metafile, PointF* destPoints, int count, ref RectangleF srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
 
-            private delegate int GdipEnumerateMetafileSrcRectDestPoint_delegate(HandleRef graphics, HandleRef metafile, ref PointF destPoint, ref RectangleF srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
-            private static FunctionWrapper<GdipEnumerateMetafileSrcRectDestPoint_delegate> GdipEnumerateMetafileSrcRectDestPoint_ptr;
-            internal static int GdipEnumerateMetafileSrcRectDestPoint(HandleRef graphics, HandleRef metafile, ref PointF destPoint, ref RectangleF srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes) => GdipEnumerateMetafileSrcRectDestPoint_ptr.Delegate(graphics, metafile, ref destPoint, ref srcRect, pageUnit, callback, callbackdata, imageattributes);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipEnumerateMetafileSrcRectDestPointsI(HandleRef graphics, HandleRef metafile, Point* destPoints, int count, ref Rectangle srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
 
-            private delegate int GdipEnumerateMetafileSrcRectDestPointI_delegate(HandleRef graphics, HandleRef metafile, ref Point destPoint, ref Rectangle srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
-            private static FunctionWrapper<GdipEnumerateMetafileSrcRectDestPointI_delegate> GdipEnumerateMetafileSrcRectDestPointI_ptr;
-            internal static int GdipEnumerateMetafileSrcRectDestPointI(HandleRef graphics, HandleRef metafile, ref Point destPoint, ref Rectangle srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes) => GdipEnumerateMetafileSrcRectDestPointI_ptr.Delegate(graphics, metafile, ref destPoint, ref srcRect, pageUnit, callback, callbackdata, imageattributes);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipPlayMetafileRecord(HandleRef graphics, EmfPlusRecordType recordType, int flags, int dataSize, byte[] data);
 
-            private delegate int GdipEnumerateMetafileSrcRectDestRect_delegate(HandleRef graphics, HandleRef metafile, ref RectangleF destRect, ref RectangleF srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
-            private static FunctionWrapper<GdipEnumerateMetafileSrcRectDestRect_delegate> GdipEnumerateMetafileSrcRectDestRect_ptr;
-            internal static int GdipEnumerateMetafileSrcRectDestRect(HandleRef graphics, HandleRef metafile, ref RectangleF destRect, ref RectangleF srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes) => GdipEnumerateMetafileSrcRectDestRect_ptr.Delegate(graphics, metafile, ref destRect, ref srcRect, pageUnit, callback, callbackdata, imageattributes);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSaveGraphics(HandleRef graphics, out int state);
 
-            private delegate int GdipEnumerateMetafileSrcRectDestRectI_delegate(HandleRef graphics, HandleRef metafile, ref Rectangle destRect, ref Rectangle srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
-            private static FunctionWrapper<GdipEnumerateMetafileSrcRectDestRectI_delegate> GdipEnumerateMetafileSrcRectDestRectI_ptr;
-            internal static int GdipEnumerateMetafileSrcRectDestRectI(HandleRef graphics, HandleRef metafile, ref Rectangle destRect, ref Rectangle srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes) => GdipEnumerateMetafileSrcRectDestRectI_ptr.Delegate(graphics, metafile, ref destRect, ref srcRect, pageUnit, callback, callbackdata, imageattributes);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipRestoreGraphics(HandleRef graphics, int state);
 
-            private delegate int GdipEnumerateMetafileSrcRectDestPoints_delegate(HandleRef graphics, HandleRef metafile, PointF* destPoints, int count, ref RectangleF srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
-            private static FunctionWrapper<GdipEnumerateMetafileSrcRectDestPoints_delegate> GdipEnumerateMetafileSrcRectDestPoints_ptr;
-            internal static int GdipEnumerateMetafileSrcRectDestPoints(HandleRef graphics, HandleRef metafile, PointF* destPoints, int count, ref RectangleF srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes) => GdipEnumerateMetafileSrcRectDestPoints_ptr.Delegate(graphics, metafile, destPoints, count, ref srcRect, pageUnit, callback, callbackdata, imageattributes);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetMetafileHeaderFromWmf(HandleRef hMetafile, WmfPlaceableFileHeader wmfplaceable, [In] [Out] MetafileHeaderWmf metafileHeaderWmf);
 
-            private delegate int GdipEnumerateMetafileSrcRectDestPointsI_delegate(HandleRef graphics, HandleRef metafile, Point* destPoints, int count, ref Rectangle srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
-            private static FunctionWrapper<GdipEnumerateMetafileSrcRectDestPointsI_delegate> GdipEnumerateMetafileSrcRectDestPointsI_ptr;
-            internal static int GdipEnumerateMetafileSrcRectDestPointsI(HandleRef graphics, HandleRef metafile, Point* destPoints, int count, ref Rectangle srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes) => GdipEnumerateMetafileSrcRectDestPointsI_ptr.Delegate(graphics, metafile, destPoints, count, ref srcRect, pageUnit, callback, callbackdata, imageattributes);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetMetafileHeaderFromEmf(HandleRef hEnhMetafile, [In] [Out] MetafileHeaderEmf metafileHeaderEmf);
 
-            private delegate int GdipPlayMetafileRecord_delegate(HandleRef graphics, EmfPlusRecordType recordType, int flags, int dataSize, byte[] data);
-            private static FunctionWrapper<GdipPlayMetafileRecord_delegate> GdipPlayMetafileRecord_ptr;
-            internal static int GdipPlayMetafileRecord(HandleRef graphics, EmfPlusRecordType recordType, int flags, int dataSize, byte[] data) => GdipPlayMetafileRecord_ptr.Delegate(graphics, recordType, flags, dataSize, data);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipGetMetafileHeaderFromFile(string filename, IntPtr header);
 
-            private delegate int GdipSaveGraphics_delegate(HandleRef graphics, out int state);
-            private static FunctionWrapper<GdipSaveGraphics_delegate> GdipSaveGraphics_ptr;
-            internal static int GdipSaveGraphics(HandleRef graphics, out int state) => GdipSaveGraphics_ptr.Delegate(graphics, out state);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetMetafileHeaderFromStream(Interop.Ole32.IStream stream, IntPtr header);
 
-            private delegate int GdipRestoreGraphics_delegate(HandleRef graphics, int state);
-            private static FunctionWrapper<GdipRestoreGraphics_delegate> GdipRestoreGraphics_ptr;
-            internal static int GdipRestoreGraphics(HandleRef graphics, int state) => GdipRestoreGraphics_ptr.Delegate(graphics, state);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetMetafileHeaderFromMetafile(HandleRef metafile, IntPtr header);
 
-            private delegate int GdipGetMetafileHeaderFromWmf_delegate(HandleRef hMetafile, WmfPlaceableFileHeader wmfplaceable, [In] [Out] MetafileHeaderWmf metafileHeaderWmf);
-            private static FunctionWrapper<GdipGetMetafileHeaderFromWmf_delegate> GdipGetMetafileHeaderFromWmf_ptr;
-            internal static int GdipGetMetafileHeaderFromWmf(HandleRef hMetafile, WmfPlaceableFileHeader wmfplaceable, [In] [Out] MetafileHeaderWmf metafileHeaderWmf) => GdipGetMetafileHeaderFromWmf_ptr.Delegate(hMetafile, wmfplaceable, metafileHeaderWmf);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetHemfFromMetafile(HandleRef metafile, out IntPtr hEnhMetafile);
 
-            private delegate int GdipGetMetafileHeaderFromEmf_delegate(HandleRef hEnhMetafile, [In] [Out] MetafileHeaderEmf metafileHeaderEmf);
-            private static FunctionWrapper<GdipGetMetafileHeaderFromEmf_delegate> GdipGetMetafileHeaderFromEmf_ptr;
-            internal static int GdipGetMetafileHeaderFromEmf(HandleRef hEnhMetafile, [In] [Out] MetafileHeaderEmf metafileHeaderEmf) => GdipGetMetafileHeaderFromEmf_ptr.Delegate(hEnhMetafile, metafileHeaderEmf);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateMetafileFromWmf(HandleRef hMetafile, bool deleteWmf, WmfPlaceableFileHeader wmfplacealbeHeader, out IntPtr metafile);
 
-            private delegate int GdipGetMetafileHeaderFromFile_delegate([MarshalAs(UnmanagedType.LPWStr)]string filename, IntPtr header);
-            private static FunctionWrapper<GdipGetMetafileHeaderFromFile_delegate> GdipGetMetafileHeaderFromFile_ptr;
-            internal static int GdipGetMetafileHeaderFromFile(string filename, IntPtr header) => GdipGetMetafileHeaderFromFile_ptr.Delegate(filename, header);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateMetafileFromEmf(HandleRef hEnhMetafile, bool deleteEmf, out IntPtr metafile);
 
-            private delegate int GdipGetMetafileHeaderFromStream_delegate(Interop.Ole32.IStream stream, IntPtr header);
-            private static FunctionWrapper<GdipGetMetafileHeaderFromStream_delegate> GdipGetMetafileHeaderFromStream_ptr;
-            internal static int GdipGetMetafileHeaderFromStream(Interop.Ole32.IStream stream, IntPtr header) => GdipGetMetafileHeaderFromStream_ptr.Delegate(stream, header);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipCreateMetafileFromFile(string file, out IntPtr metafile);
 
-            private delegate int GdipGetMetafileHeaderFromMetafile_delegate(HandleRef metafile, IntPtr header);
-            private static FunctionWrapper<GdipGetMetafileHeaderFromMetafile_delegate> GdipGetMetafileHeaderFromMetafile_ptr;
-            internal static int GdipGetMetafileHeaderFromMetafile(HandleRef metafile, IntPtr header) => GdipGetMetafileHeaderFromMetafile_ptr.Delegate(metafile, header);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateMetafileFromStream(Interop.Ole32.IStream stream, out IntPtr metafile);
 
-            private delegate int GdipGetHemfFromMetafile_delegate(HandleRef metafile, out IntPtr hEnhMetafile);
-            private static FunctionWrapper<GdipGetHemfFromMetafile_delegate> GdipGetHemfFromMetafile_ptr;
-            internal static int GdipGetHemfFromMetafile(HandleRef metafile, out IntPtr hEnhMetafile) => GdipGetHemfFromMetafile_ptr.Delegate(metafile, out hEnhMetafile);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipRecordMetafile(HandleRef referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
 
-            private delegate int GdipCreateMetafileFromWmf_delegate(HandleRef hMetafile, [MarshalAs(UnmanagedType.Bool)]bool deleteWmf, WmfPlaceableFileHeader wmfplacealbeHeader, out IntPtr metafile);
-            private static FunctionWrapper<GdipCreateMetafileFromWmf_delegate> GdipCreateMetafileFromWmf_ptr;
-            internal static int GdipCreateMetafileFromWmf(HandleRef hMetafile, bool deleteWmf, WmfPlaceableFileHeader wmfplacealbeHeader, out IntPtr metafile) => GdipCreateMetafileFromWmf_ptr.Delegate(hMetafile, deleteWmf, wmfplacealbeHeader, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipRecordMetafile(HandleRef referenceHdc, EmfType emfType, HandleRef pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
 
-            private delegate int GdipCreateMetafileFromEmf_delegate(HandleRef hEnhMetafile, bool deleteEmf, out IntPtr metafile);
-            private static FunctionWrapper<GdipCreateMetafileFromEmf_delegate> GdipCreateMetafileFromEmf_ptr;
-            internal static int GdipCreateMetafileFromEmf(HandleRef hEnhMetafile, bool deleteEmf, out IntPtr metafile) => GdipCreateMetafileFromEmf_ptr.Delegate(hEnhMetafile, deleteEmf, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipRecordMetafileI(HandleRef referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
 
-            private delegate int GdipCreateMetafileFromFile_delegate([MarshalAs(UnmanagedType.LPWStr)]string file, out IntPtr metafile);
-            private static FunctionWrapper<GdipCreateMetafileFromFile_delegate> GdipCreateMetafileFromFile_ptr;
-            internal static int GdipCreateMetafileFromFile(string file, out IntPtr metafile) => GdipCreateMetafileFromFile_ptr.Delegate(file, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipRecordMetafileFileName(string fileName, HandleRef referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
 
-            private delegate int GdipCreateMetafileFromStream_delegate(Interop.Ole32.IStream stream, out IntPtr metafile);
-            private static FunctionWrapper<GdipCreateMetafileFromStream_delegate> GdipCreateMetafileFromStream_ptr;
-            internal static int GdipCreateMetafileFromStream(Interop.Ole32.IStream stream, out IntPtr metafile) => GdipCreateMetafileFromStream_ptr.Delegate(stream, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipRecordMetafileFileName(string fileName, HandleRef referenceHdc, EmfType emfType, HandleRef pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
 
-            private delegate int GdipRecordMetafile_delegate(HandleRef referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)]string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafile_delegate> GdipRecordMetafile_ptr;
-            internal static int GdipRecordMetafile(HandleRef referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile) => GdipRecordMetafile_ptr.Delegate(referenceHdc, emfType, ref frameRect, frameUnit, description, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipRecordMetafileFileNameI(string fileName, HandleRef referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
 
-            private delegate int GdipRecordMetafile2_delegate(HandleRef referenceHdc, EmfType emfType, HandleRef pframeRect, MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)]string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafile2_delegate> GdipRecordMetafile2_ptr;
-            internal static int GdipRecordMetafile(HandleRef referenceHdc, EmfType emfType, HandleRef pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile) => GdipRecordMetafile2_ptr.Delegate(referenceHdc, emfType, pframeRect, frameUnit, description, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipRecordMetafileStream(Interop.Ole32.IStream stream, HandleRef referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
 
-            private delegate int GdipRecordMetafileI_delegate(HandleRef referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)]string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafileI_delegate> GdipRecordMetafileI_ptr;
-            internal static int GdipRecordMetafileI(HandleRef referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile) => GdipRecordMetafileI_ptr.Delegate(referenceHdc, emfType, ref frameRect, frameUnit, description, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipRecordMetafileStream(Interop.Ole32.IStream stream, HandleRef referenceHdc, EmfType emfType, HandleRef pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
 
-            private delegate int GdipRecordMetafileFileName_delegate([MarshalAs(UnmanagedType.LPWStr)]string fileName, HandleRef referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)]string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafileFileName_delegate> GdipRecordMetafileFileName_ptr;
-            internal static int GdipRecordMetafileFileName(string fileName, HandleRef referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile) => GdipRecordMetafileFileName_ptr.Delegate(fileName, referenceHdc, emfType, ref frameRect, frameUnit, description, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipRecordMetafileStreamI(Interop.Ole32.IStream stream, HandleRef referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
 
-            private delegate int GdipRecordMetafileFileName2_delegate([MarshalAs(UnmanagedType.LPWStr)]string fileName, HandleRef referenceHdc, EmfType emfType, HandleRef pframeRect, MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)]string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafileFileName2_delegate> GdipRecordMetafileFileName2_ptr;
-            internal static int GdipRecordMetafileFileName(string fileName, HandleRef referenceHdc, EmfType emfType, HandleRef pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile) => GdipRecordMetafileFileName2_ptr.Delegate(fileName, referenceHdc, emfType, pframeRect, frameUnit, description, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipComment(HandleRef graphics, int sizeData, byte[] data);
 
-            private delegate int GdipRecordMetafileFileNameI_delegate([MarshalAs(UnmanagedType.LPWStr)]string fileName, HandleRef referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)]string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafileFileNameI_delegate> GdipRecordMetafileFileNameI_ptr;
-            internal static int GdipRecordMetafileFileNameI(string fileName, HandleRef referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile) => GdipRecordMetafileFileNameI_ptr.Delegate(fileName, referenceHdc, emfType, ref frameRect, frameUnit, description, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateFontFromDC(HandleRef hdc, ref IntPtr font);
 
-            private delegate int GdipRecordMetafileStream_delegate(Interop.Ole32.IStream stream, HandleRef referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)]string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafileStream_delegate> GdipRecordMetafileStream_ptr;
-            internal static int GdipRecordMetafileStream(Interop.Ole32.IStream stream, HandleRef referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)]string description, out IntPtr metafile) => GdipRecordMetafileStream_ptr.Delegate(stream, referenceHdc, emfType, ref frameRect, frameUnit, description, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipCreateFontFromLogfontW(HandleRef hdc, ref LOGFONT lf, out IntPtr font);
 
-            private delegate int GdipRecordMetafileStream2_delegate(Interop.Ole32.IStream stream, HandleRef referenceHdc, EmfType emfType, HandleRef pframeRect, MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)]string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafileStream2_delegate> GdipRecordMetafileStream2_ptr;
-            internal static int GdipRecordMetafileStream(Interop.Ole32.IStream stream, HandleRef referenceHdc, EmfType emfType, HandleRef pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile) => GdipRecordMetafileStream2_ptr.Delegate(stream, referenceHdc, emfType, pframeRect, frameUnit, description, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipDrawString(HandleRef graphics, string textString, int length, HandleRef font, ref RectangleF layoutRect, HandleRef stringFormat, HandleRef brush);
 
-            private delegate int GdipRecordMetafileStreamI_delegate(Interop.Ole32.IStream stream, HandleRef referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, [MarshalAs(UnmanagedType.LPWStr)]string description, out IntPtr metafile);
-            private static FunctionWrapper<GdipRecordMetafileStreamI_delegate> GdipRecordMetafileStreamI_ptr;
-            internal static int GdipRecordMetafileStreamI(Interop.Ole32.IStream stream, HandleRef referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile) => GdipRecordMetafileStreamI_ptr.Delegate(stream, referenceHdc, emfType, ref frameRect, frameUnit, description, out metafile);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipMeasureString(HandleRef graphics, string textString, int length, HandleRef font, ref RectangleF layoutRect, HandleRef stringFormat, ref RectangleF boundingBox, out int codepointsFitted, out int linesFilled);
 
-            private delegate int GdipComment_delegate(HandleRef graphics, int sizeData, byte[] data);
-            private static FunctionWrapper<GdipComment_delegate> GdipComment_ptr;
-            internal static int GdipComment(HandleRef graphics, int sizeData, byte[] data) => GdipComment_ptr.Delegate(graphics, sizeData, data);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipMeasureCharacterRanges(HandleRef graphics, string textString, int length, HandleRef font, ref RectangleF layoutRect, HandleRef stringFormat, int characterCount, [In] [Out] IntPtr[] region);
 
-            private delegate int GdipCreateFontFromDC_delegate(HandleRef hdc, ref IntPtr font);
-            private static FunctionWrapper<GdipCreateFontFromDC_delegate> GdipCreateFontFromDC_ptr;
-            internal static int GdipCreateFontFromDC(HandleRef hdc, ref IntPtr font) => GdipCreateFontFromDC_ptr.Delegate(hdc, ref font);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateBitmapFromStream(Interop.Ole32.IStream stream, out IntPtr bitmap);
 
-#pragma warning disable CS0618 // Legacy code: We don't care about using obsolete API's.
-            private delegate int GdipCreateFontFromLogfontW_delegate(HandleRef hdc, [In] [Out] [MarshalAs(UnmanagedType.AsAny)]object lf, out IntPtr font);
-#pragma warning restore CS0618
-            private static FunctionWrapper<GdipCreateFontFromLogfontW_delegate> GdipCreateFontFromLogfontW_ptr;
-            internal static int GdipCreateFontFromLogfontW(HandleRef hdc, [In] [Out] object lf, out IntPtr font) => GdipCreateFontFromLogfontW_ptr.Delegate(hdc, lf, out font);
-
-            private delegate int GdipDrawString_delegate(HandleRef graphics, [MarshalAs(UnmanagedType.LPWStr)]string textString, int length, HandleRef font, ref RectangleF layoutRect, HandleRef stringFormat, HandleRef brush);
-            private static FunctionWrapper<GdipDrawString_delegate> GdipDrawString_ptr;
-            internal static int GdipDrawString(HandleRef graphics, string textString, int length, HandleRef font, ref RectangleF layoutRect, HandleRef stringFormat, HandleRef brush) => GdipDrawString_ptr.Delegate(graphics, textString, length, font, ref layoutRect, stringFormat, brush);
-
-            private delegate int GdipMeasureString_delegate(HandleRef graphics, [MarshalAs(UnmanagedType.LPWStr)]string textString, int length, HandleRef font, ref RectangleF layoutRect, HandleRef stringFormat, ref RectangleF boundingBox, out int codepointsFitted, out int linesFilled);
-            private static FunctionWrapper<GdipMeasureString_delegate> GdipMeasureString_ptr;
-            internal static int GdipMeasureString(HandleRef graphics, string textString, int length, HandleRef font, ref RectangleF layoutRect, HandleRef stringFormat, ref RectangleF boundingBox, out int codepointsFitted, out int linesFilled) => GdipMeasureString_ptr.Delegate(graphics, textString, length, font, ref layoutRect, stringFormat, ref boundingBox, out codepointsFitted, out linesFilled);
-
-            private delegate int GdipMeasureCharacterRanges_delegate(HandleRef graphics, [MarshalAs(UnmanagedType.LPWStr)]string textString, int length, HandleRef font, ref RectangleF layoutRect, HandleRef stringFormat, int characterCount, [In] [Out] IntPtr[] region);
-            private static FunctionWrapper<GdipMeasureCharacterRanges_delegate> GdipMeasureCharacterRanges_ptr;
-            internal static int GdipMeasureCharacterRanges(HandleRef graphics, string textString, int length, HandleRef font, ref RectangleF layoutRect, HandleRef stringFormat, int characterCount, [In] [Out] IntPtr[] region) => GdipMeasureCharacterRanges_ptr.Delegate(graphics, textString, length, font, ref layoutRect, stringFormat, characterCount, region);
-
-            private delegate int GdipCreateBitmapFromStream_delegate(Interop.Ole32.IStream stream, out IntPtr bitmap);
-            private static FunctionWrapper<GdipCreateBitmapFromStream_delegate> GdipCreateBitmapFromStream_ptr;
-            internal static int GdipCreateBitmapFromStream(Interop.Ole32.IStream stream, out IntPtr bitmap) => GdipCreateBitmapFromStream_ptr.Delegate(stream, out bitmap);
-
-            private delegate int GdipCreateBitmapFromStreamICM_delegate(Interop.Ole32.IStream stream, out IntPtr bitmap);
-            private static FunctionWrapper<GdipCreateBitmapFromStreamICM_delegate> GdipCreateBitmapFromStreamICM_ptr;
-            internal static int GdipCreateBitmapFromStreamICM(Interop.Ole32.IStream stream, out IntPtr bitmap) => GdipCreateBitmapFromStreamICM_ptr.Delegate(stream, out bitmap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateBitmapFromStreamICM(Interop.Ole32.IStream stream, out IntPtr bitmap);
         }
     }
 }
index 3857ebb..2ed8e7e 100644 (file)
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-using System.Diagnostics;
+#pragma warning disable BCL0015
+
 using System.Drawing.Drawing2D;
 using System.Drawing.Imaging;
-using System.Drawing.Internal;
 using System.Drawing.Text;
 using System.Runtime.InteropServices;
-using System.Text;
 
 namespace System.Drawing
 {
     // Raw function imports for gdiplus
     // Functions are loaded manually in order to accomodate different shared library names on Unix.
-    internal unsafe partial class SafeNativeMethods
+    internal static unsafe partial class SafeNativeMethods
     {
-        internal partial class Gdip
+        internal static partial class Gdip
         {
-            private static IntPtr s_gdipModule;
-
-            private static void LoadSharedFunctionPointers()
-            {
-                GdipBeginContainer_ptr = FunctionWrapper.Load<GdipBeginContainer_delegate>(s_gdipModule, "GdipBeginContainer", LibraryName);
-                GdipBeginContainer2_ptr = FunctionWrapper.Load<GdipBeginContainer2_delegate>(s_gdipModule, "GdipBeginContainer2", LibraryName);
-                GdipBeginContainerI_ptr = FunctionWrapper.Load<GdipBeginContainerI_delegate>(s_gdipModule, "GdipBeginContainerI", LibraryName);
-                GdipEndContainer_ptr = FunctionWrapper.Load<GdipEndContainer_delegate>(s_gdipModule, "GdipEndContainer", LibraryName);
-                GdipCreateAdjustableArrowCap_ptr = FunctionWrapper.Load<GdipCreateAdjustableArrowCap_delegate>(s_gdipModule, "GdipCreateAdjustableArrowCap", LibraryName);
-                GdipGetAdjustableArrowCapHeight_ptr = FunctionWrapper.Load<GdipGetAdjustableArrowCapHeight_delegate>(s_gdipModule, "GdipGetAdjustableArrowCapHeight", LibraryName);
-                GdipSetAdjustableArrowCapHeight_ptr = FunctionWrapper.Load<GdipSetAdjustableArrowCapHeight_delegate>(s_gdipModule, "GdipSetAdjustableArrowCapHeight", LibraryName);
-                GdipSetAdjustableArrowCapWidth_ptr = FunctionWrapper.Load<GdipSetAdjustableArrowCapWidth_delegate>(s_gdipModule, "GdipSetAdjustableArrowCapWidth", LibraryName);
-                GdipGetAdjustableArrowCapWidth_ptr = FunctionWrapper.Load<GdipGetAdjustableArrowCapWidth_delegate>(s_gdipModule, "GdipGetAdjustableArrowCapWidth", LibraryName);
-                GdipSetAdjustableArrowCapMiddleInset_ptr = FunctionWrapper.Load<GdipSetAdjustableArrowCapMiddleInset_delegate>(s_gdipModule, "GdipSetAdjustableArrowCapMiddleInset", LibraryName);
-                GdipGetAdjustableArrowCapMiddleInset_ptr = FunctionWrapper.Load<GdipGetAdjustableArrowCapMiddleInset_delegate>(s_gdipModule, "GdipGetAdjustableArrowCapMiddleInset", LibraryName);
-                GdipSetAdjustableArrowCapFillState_ptr = FunctionWrapper.Load<GdipSetAdjustableArrowCapFillState_delegate>(s_gdipModule, "GdipSetAdjustableArrowCapFillState", LibraryName);
-                GdipGetAdjustableArrowCapFillState_ptr = FunctionWrapper.Load<GdipGetAdjustableArrowCapFillState_delegate>(s_gdipModule, "GdipGetAdjustableArrowCapFillState", LibraryName);
-                GdipGetCustomLineCapType_ptr = FunctionWrapper.Load<GdipGetCustomLineCapType_delegate>(s_gdipModule, "GdipGetCustomLineCapType", LibraryName);
-                GdipCreateCustomLineCap_ptr = FunctionWrapper.Load<GdipCreateCustomLineCap_delegate>(s_gdipModule, "GdipCreateCustomLineCap", LibraryName);
-                GdipDeleteCustomLineCap_ptr = FunctionWrapper.Load<GdipDeleteCustomLineCap_delegate>(s_gdipModule, "GdipDeleteCustomLineCap", LibraryName);
-                GdipCloneCustomLineCap_ptr = FunctionWrapper.Load<GdipCloneCustomLineCap_delegate>(s_gdipModule, "GdipCloneCustomLineCap", LibraryName);
-                GdipSetCustomLineCapStrokeCaps_ptr = FunctionWrapper.Load<GdipSetCustomLineCapStrokeCaps_delegate>(s_gdipModule, "GdipSetCustomLineCapStrokeCaps", LibraryName);
-                GdipGetCustomLineCapStrokeCaps_ptr = FunctionWrapper.Load<GdipGetCustomLineCapStrokeCaps_delegate>(s_gdipModule, "GdipGetCustomLineCapStrokeCaps", LibraryName);
-                GdipSetCustomLineCapStrokeJoin_ptr = FunctionWrapper.Load<GdipSetCustomLineCapStrokeJoin_delegate>(s_gdipModule, "GdipSetCustomLineCapStrokeJoin", LibraryName);
-                GdipGetCustomLineCapStrokeJoin_ptr = FunctionWrapper.Load<GdipGetCustomLineCapStrokeJoin_delegate>(s_gdipModule, "GdipGetCustomLineCapStrokeJoin", LibraryName);
-                GdipSetCustomLineCapBaseCap_ptr = FunctionWrapper.Load<GdipSetCustomLineCapBaseCap_delegate>(s_gdipModule, "GdipSetCustomLineCapBaseCap", LibraryName);
-                GdipGetCustomLineCapBaseCap_ptr = FunctionWrapper.Load<GdipGetCustomLineCapBaseCap_delegate>(s_gdipModule, "GdipGetCustomLineCapBaseCap", LibraryName);
-                GdipSetCustomLineCapBaseInset_ptr = FunctionWrapper.Load<GdipSetCustomLineCapBaseInset_delegate>(s_gdipModule, "GdipSetCustomLineCapBaseInset", LibraryName);
-                GdipGetCustomLineCapBaseInset_ptr = FunctionWrapper.Load<GdipGetCustomLineCapBaseInset_delegate>(s_gdipModule, "GdipGetCustomLineCapBaseInset", LibraryName);
-                GdipSetCustomLineCapWidthScale_ptr = FunctionWrapper.Load<GdipSetCustomLineCapWidthScale_delegate>(s_gdipModule, "GdipSetCustomLineCapWidthScale", LibraryName);
-                GdipGetCustomLineCapWidthScale_ptr = FunctionWrapper.Load<GdipGetCustomLineCapWidthScale_delegate>(s_gdipModule, "GdipGetCustomLineCapWidthScale", LibraryName);
-                GdipCreatePathIter_ptr = FunctionWrapper.Load<GdipCreatePathIter_delegate>(s_gdipModule, "GdipCreatePathIter", LibraryName);
-                GdipDeletePathIter_ptr = FunctionWrapper.Load<GdipDeletePathIter_delegate>(s_gdipModule, "GdipDeletePathIter", LibraryName);
-                GdipPathIterNextSubpath_ptr = FunctionWrapper.Load<GdipPathIterNextSubpath_delegate>(s_gdipModule, "GdipPathIterNextSubpath", LibraryName);
-                GdipPathIterNextSubpathPath_ptr = FunctionWrapper.Load<GdipPathIterNextSubpathPath_delegate>(s_gdipModule, "GdipPathIterNextSubpathPath", LibraryName);
-                GdipPathIterNextPathType_ptr = FunctionWrapper.Load<GdipPathIterNextPathType_delegate>(s_gdipModule, "GdipPathIterNextPathType", LibraryName);
-                GdipPathIterNextMarker_ptr = FunctionWrapper.Load<GdipPathIterNextMarker_delegate>(s_gdipModule, "GdipPathIterNextMarker", LibraryName);
-                GdipPathIterNextMarkerPath_ptr = FunctionWrapper.Load<GdipPathIterNextMarkerPath_delegate>(s_gdipModule, "GdipPathIterNextMarkerPath", LibraryName);
-                GdipPathIterGetCount_ptr = FunctionWrapper.Load<GdipPathIterGetCount_delegate>(s_gdipModule, "GdipPathIterGetCount", LibraryName);
-                GdipPathIterGetSubpathCount_ptr = FunctionWrapper.Load<GdipPathIterGetSubpathCount_delegate>(s_gdipModule, "GdipPathIterGetSubpathCount", LibraryName);
-                GdipPathIterHasCurve_ptr = FunctionWrapper.Load<GdipPathIterHasCurve_delegate>(s_gdipModule, "GdipPathIterHasCurve", LibraryName);
-                GdipPathIterRewind_ptr = FunctionWrapper.Load<GdipPathIterRewind_delegate>(s_gdipModule, "GdipPathIterRewind", LibraryName);
-                GdipPathIterEnumerate_ptr = FunctionWrapper.Load<GdipPathIterEnumerate_delegate>(s_gdipModule, "GdipPathIterEnumerate", LibraryName);
-                GdipPathIterCopyData_ptr = FunctionWrapper.Load<GdipPathIterCopyData_delegate>(s_gdipModule, "GdipPathIterCopyData", LibraryName);
-                GdipCreateHatchBrush_ptr = FunctionWrapper.Load<GdipCreateHatchBrush_delegate>(s_gdipModule, "GdipCreateHatchBrush", LibraryName);
-                GdipGetHatchStyle_ptr = FunctionWrapper.Load<GdipGetHatchStyle_delegate>(s_gdipModule, "GdipGetHatchStyle", LibraryName);
-                GdipGetHatchForegroundColor_ptr = FunctionWrapper.Load<GdipGetHatchForegroundColor_delegate>(s_gdipModule, "GdipGetHatchForegroundColor", LibraryName);
-                GdipGetHatchBackgroundColor_ptr = FunctionWrapper.Load<GdipGetHatchBackgroundColor_delegate>(s_gdipModule, "GdipGetHatchBackgroundColor", LibraryName);
-                GdipCreateLineBrush_ptr = FunctionWrapper.Load<GdipCreateLineBrush_delegate>(s_gdipModule, "GdipCreateLineBrush", LibraryName);
-                GdipCreateLineBrushI_ptr = FunctionWrapper.Load<GdipCreateLineBrushI_delegate>(s_gdipModule, "GdipCreateLineBrushI", LibraryName);
-                GdipCreateLineBrushFromRect_ptr = FunctionWrapper.Load<GdipCreateLineBrushFromRect_delegate>(s_gdipModule, "GdipCreateLineBrushFromRect", LibraryName);
-                GdipCreateLineBrushFromRectI_ptr = FunctionWrapper.Load<GdipCreateLineBrushFromRectI_delegate>(s_gdipModule, "GdipCreateLineBrushFromRectI", LibraryName);
-                GdipCreateLineBrushFromRectWithAngle_ptr = FunctionWrapper.Load<GdipCreateLineBrushFromRectWithAngle_delegate>(s_gdipModule, "GdipCreateLineBrushFromRectWithAngle", LibraryName);
-                GdipCreateLineBrushFromRectWithAngleI_ptr = FunctionWrapper.Load<GdipCreateLineBrushFromRectWithAngleI_delegate>(s_gdipModule, "GdipCreateLineBrushFromRectWithAngleI", LibraryName);
-                GdipSetLineColors_ptr = FunctionWrapper.Load<GdipSetLineColors_delegate>(s_gdipModule, "GdipSetLineColors", LibraryName);
-                GdipGetLineColors_ptr = FunctionWrapper.Load<GdipGetLineColors_delegate>(s_gdipModule, "GdipGetLineColors", LibraryName);
-                GdipGetLineRect_ptr = FunctionWrapper.Load<GdipGetLineRect_delegate>(s_gdipModule, "GdipGetLineRect", LibraryName);
-                GdipGetLineGammaCorrection_ptr = FunctionWrapper.Load<GdipGetLineGammaCorrection_delegate>(s_gdipModule, "GdipGetLineGammaCorrection", LibraryName);
-                GdipSetLineGammaCorrection_ptr = FunctionWrapper.Load<GdipSetLineGammaCorrection_delegate>(s_gdipModule, "GdipSetLineGammaCorrection", LibraryName);
-                GdipSetLineSigmaBlend_ptr = FunctionWrapper.Load<GdipSetLineSigmaBlend_delegate>(s_gdipModule, "GdipSetLineSigmaBlend", LibraryName);
-                GdipSetLineLinearBlend_ptr = FunctionWrapper.Load<GdipSetLineLinearBlend_delegate>(s_gdipModule, "GdipSetLineLinearBlend", LibraryName);
-                GdipGetLineBlendCount_ptr = FunctionWrapper.Load<GdipGetLineBlendCount_delegate>(s_gdipModule, "GdipGetLineBlendCount", LibraryName);
-                GdipGetLineBlend_ptr = FunctionWrapper.Load<GdipGetLineBlend_delegate>(s_gdipModule, "GdipGetLineBlend", LibraryName);
-                GdipSetLineBlend_ptr = FunctionWrapper.Load<GdipSetLineBlend_delegate>(s_gdipModule, "GdipSetLineBlend", LibraryName);
-                GdipGetLinePresetBlendCount_ptr = FunctionWrapper.Load<GdipGetLinePresetBlendCount_delegate>(s_gdipModule, "GdipGetLinePresetBlendCount", LibraryName);
-                GdipGetLinePresetBlend_ptr = FunctionWrapper.Load<GdipGetLinePresetBlend_delegate>(s_gdipModule, "GdipGetLinePresetBlend", LibraryName);
-                GdipSetLinePresetBlend_ptr = FunctionWrapper.Load<GdipSetLinePresetBlend_delegate>(s_gdipModule, "GdipSetLinePresetBlend", LibraryName);
-                GdipSetLineWrapMode_ptr = FunctionWrapper.Load<GdipSetLineWrapMode_delegate>(s_gdipModule, "GdipSetLineWrapMode", LibraryName);
-                GdipGetLineWrapMode_ptr = FunctionWrapper.Load<GdipGetLineWrapMode_delegate>(s_gdipModule, "GdipGetLineWrapMode", LibraryName);
-                GdipResetLineTransform_ptr = FunctionWrapper.Load<GdipResetLineTransform_delegate>(s_gdipModule, "GdipResetLineTransform", LibraryName);
-                GdipMultiplyLineTransform_ptr = FunctionWrapper.Load<GdipMultiplyLineTransform_delegate>(s_gdipModule, "GdipMultiplyLineTransform", LibraryName);
-                GdipGetLineTransform_ptr = FunctionWrapper.Load<GdipGetLineTransform_delegate>(s_gdipModule, "GdipGetLineTransform", LibraryName);
-                GdipSetLineTransform_ptr = FunctionWrapper.Load<GdipSetLineTransform_delegate>(s_gdipModule, "GdipSetLineTransform", LibraryName);
-                GdipTranslateLineTransform_ptr = FunctionWrapper.Load<GdipTranslateLineTransform_delegate>(s_gdipModule, "GdipTranslateLineTransform", LibraryName);
-                GdipScaleLineTransform_ptr = FunctionWrapper.Load<GdipScaleLineTransform_delegate>(s_gdipModule, "GdipScaleLineTransform", LibraryName);
-                GdipRotateLineTransform_ptr = FunctionWrapper.Load<GdipRotateLineTransform_delegate>(s_gdipModule, "GdipRotateLineTransform", LibraryName);
-                GdipCreatePathGradient_ptr = FunctionWrapper.Load<GdipCreatePathGradient_delegate>(s_gdipModule, "GdipCreatePathGradient", LibraryName);
-                GdipCreatePathGradientI_ptr = FunctionWrapper.Load<GdipCreatePathGradientI_delegate>(s_gdipModule, "GdipCreatePathGradientI", LibraryName);
-                GdipCreatePathGradientFromPath_ptr = FunctionWrapper.Load<GdipCreatePathGradientFromPath_delegate>(s_gdipModule, "GdipCreatePathGradientFromPath", LibraryName);
-                GdipGetPathGradientCenterColor_ptr = FunctionWrapper.Load<GdipGetPathGradientCenterColor_delegate>(s_gdipModule, "GdipGetPathGradientCenterColor", LibraryName);
-                GdipSetPathGradientCenterColor_ptr = FunctionWrapper.Load<GdipSetPathGradientCenterColor_delegate>(s_gdipModule, "GdipSetPathGradientCenterColor", LibraryName);
-                GdipGetPathGradientSurroundColorsWithCount_ptr = FunctionWrapper.Load<GdipGetPathGradientSurroundColorsWithCount_delegate>(s_gdipModule, "GdipGetPathGradientSurroundColorsWithCount", LibraryName);
-                GdipSetPathGradientSurroundColorsWithCount_ptr = FunctionWrapper.Load<GdipSetPathGradientSurroundColorsWithCount_delegate>(s_gdipModule, "GdipSetPathGradientSurroundColorsWithCount", LibraryName);
-                GdipGetPathGradientCenterPoint_ptr = FunctionWrapper.Load<GdipGetPathGradientCenterPoint_delegate>(s_gdipModule, "GdipGetPathGradientCenterPoint", LibraryName);
-                GdipSetPathGradientCenterPoint_ptr = FunctionWrapper.Load<GdipSetPathGradientCenterPoint_delegate>(s_gdipModule, "GdipSetPathGradientCenterPoint", LibraryName);
-                GdipGetPathGradientRect_ptr = FunctionWrapper.Load<GdipGetPathGradientRect_delegate>(s_gdipModule, "GdipGetPathGradientRect", LibraryName);
-                GdipGetPathGradientPointCount_ptr = FunctionWrapper.Load<GdipGetPathGradientPointCount_delegate>(s_gdipModule, "GdipGetPathGradientPointCount", LibraryName);
-                GdipGetPathGradientSurroundColorCount_ptr = FunctionWrapper.Load<GdipGetPathGradientSurroundColorCount_delegate>(s_gdipModule, "GdipGetPathGradientSurroundColorCount", LibraryName);
-                GdipGetPathGradientBlendCount_ptr = FunctionWrapper.Load<GdipGetPathGradientBlendCount_delegate>(s_gdipModule, "GdipGetPathGradientBlendCount", LibraryName);
-                GdipGetPathGradientBlend_ptr = FunctionWrapper.Load<GdipGetPathGradientBlend_delegate>(s_gdipModule, "GdipGetPathGradientBlend", LibraryName);
-                GdipSetPathGradientBlend_ptr = FunctionWrapper.Load<GdipSetPathGradientBlend_delegate>(s_gdipModule, "GdipSetPathGradientBlend", LibraryName);
-                GdipGetPathGradientPresetBlendCount_ptr = FunctionWrapper.Load<GdipGetPathGradientPresetBlendCount_delegate>(s_gdipModule, "GdipGetPathGradientPresetBlendCount", LibraryName);
-                GdipGetPathGradientPresetBlend_ptr = FunctionWrapper.Load<GdipGetPathGradientPresetBlend_delegate>(s_gdipModule, "GdipGetPathGradientPresetBlend", LibraryName);
-                GdipSetPathGradientPresetBlend_ptr = FunctionWrapper.Load<GdipSetPathGradientPresetBlend_delegate>(s_gdipModule, "GdipSetPathGradientPresetBlend", LibraryName);
-                GdipSetPathGradientSigmaBlend_ptr = FunctionWrapper.Load<GdipSetPathGradientSigmaBlend_delegate>(s_gdipModule, "GdipSetPathGradientSigmaBlend", LibraryName);
-                GdipSetPathGradientLinearBlend_ptr = FunctionWrapper.Load<GdipSetPathGradientLinearBlend_delegate>(s_gdipModule, "GdipSetPathGradientLinearBlend", LibraryName);
-                GdipSetPathGradientWrapMode_ptr = FunctionWrapper.Load<GdipSetPathGradientWrapMode_delegate>(s_gdipModule, "GdipSetPathGradientWrapMode", LibraryName);
-                GdipGetPathGradientWrapMode_ptr = FunctionWrapper.Load<GdipGetPathGradientWrapMode_delegate>(s_gdipModule, "GdipGetPathGradientWrapMode", LibraryName);
-                GdipSetPathGradientTransform_ptr = FunctionWrapper.Load<GdipSetPathGradientTransform_delegate>(s_gdipModule, "GdipSetPathGradientTransform", LibraryName);
-                GdipGetPathGradientTransform_ptr = FunctionWrapper.Load<GdipGetPathGradientTransform_delegate>(s_gdipModule, "GdipGetPathGradientTransform", LibraryName);
-                GdipResetPathGradientTransform_ptr = FunctionWrapper.Load<GdipResetPathGradientTransform_delegate>(s_gdipModule, "GdipResetPathGradientTransform", LibraryName);
-                GdipMultiplyPathGradientTransform_ptr = FunctionWrapper.Load<GdipMultiplyPathGradientTransform_delegate>(s_gdipModule, "GdipMultiplyPathGradientTransform", LibraryName);
-                GdipTranslatePathGradientTransform_ptr = FunctionWrapper.Load<GdipTranslatePathGradientTransform_delegate>(s_gdipModule, "GdipTranslatePathGradientTransform", LibraryName);
-                GdipScalePathGradientTransform_ptr = FunctionWrapper.Load<GdipScalePathGradientTransform_delegate>(s_gdipModule, "GdipScalePathGradientTransform", LibraryName);
-                GdipRotatePathGradientTransform_ptr = FunctionWrapper.Load<GdipRotatePathGradientTransform_delegate>(s_gdipModule, "GdipRotatePathGradientTransform", LibraryName);
-                GdipGetPathGradientFocusScales_ptr = FunctionWrapper.Load<GdipGetPathGradientFocusScales_delegate>(s_gdipModule, "GdipGetPathGradientFocusScales", LibraryName);
-                GdipSetPathGradientFocusScales_ptr = FunctionWrapper.Load<GdipSetPathGradientFocusScales_delegate>(s_gdipModule, "GdipSetPathGradientFocusScales", LibraryName);
-                GdipCloneBrush_ptr = FunctionWrapper.Load<GdipCloneBrush_delegate>(s_gdipModule, "GdipCloneBrush", LibraryName);
-                GdipCreateImageAttributes_ptr = FunctionWrapper.Load<GdipCreateImageAttributes_delegate>(s_gdipModule, "GdipCreateImageAttributes", LibraryName);
-                GdipCloneImageAttributes_ptr = FunctionWrapper.Load<GdipCloneImageAttributes_delegate>(s_gdipModule, "GdipCloneImageAttributes", LibraryName);
-                GdipDisposeImageAttributes_ptr = FunctionWrapper.Load<GdipDisposeImageAttributes_delegate>(s_gdipModule, "GdipDisposeImageAttributes", LibraryName);
-                GdipSetImageAttributesColorMatrix_ptr = FunctionWrapper.Load<GdipSetImageAttributesColorMatrix_delegate>(s_gdipModule, "GdipSetImageAttributesColorMatrix", LibraryName);
-                GdipSetImageAttributesThreshold_ptr = FunctionWrapper.Load<GdipSetImageAttributesThreshold_delegate>(s_gdipModule, "GdipSetImageAttributesThreshold", LibraryName);
-                GdipSetImageAttributesGamma_ptr = FunctionWrapper.Load<GdipSetImageAttributesGamma_delegate>(s_gdipModule, "GdipSetImageAttributesGamma", LibraryName);
-                GdipSetImageAttributesNoOp_ptr = FunctionWrapper.Load<GdipSetImageAttributesNoOp_delegate>(s_gdipModule, "GdipSetImageAttributesNoOp", LibraryName);
-                GdipSetImageAttributesColorKeys_ptr = FunctionWrapper.Load<GdipSetImageAttributesColorKeys_delegate>(s_gdipModule, "GdipSetImageAttributesColorKeys", LibraryName);
-                GdipSetImageAttributesOutputChannel_ptr = FunctionWrapper.Load<GdipSetImageAttributesOutputChannel_delegate>(s_gdipModule, "GdipSetImageAttributesOutputChannel", LibraryName);
-                GdipSetImageAttributesOutputChannelColorProfile_ptr = FunctionWrapper.Load<GdipSetImageAttributesOutputChannelColorProfile_delegate>(s_gdipModule, "GdipSetImageAttributesOutputChannelColorProfile", LibraryName);
-                GdipSetImageAttributesRemapTable_ptr = FunctionWrapper.Load<GdipSetImageAttributesRemapTable_delegate>(s_gdipModule, "GdipSetImageAttributesRemapTable", LibraryName);
-                GdipSetImageAttributesWrapMode_ptr = FunctionWrapper.Load<GdipSetImageAttributesWrapMode_delegate>(s_gdipModule, "GdipSetImageAttributesWrapMode", LibraryName);
-                GdipGetImageAttributesAdjustedPalette_ptr = FunctionWrapper.Load<GdipGetImageAttributesAdjustedPalette_delegate>(s_gdipModule, "GdipGetImageAttributesAdjustedPalette", LibraryName);
-                GdipGetImageDecodersSize_ptr = FunctionWrapper.Load<GdipGetImageDecodersSize_delegate>(s_gdipModule, "GdipGetImageDecodersSize", LibraryName);
-                GdipGetImageDecoders_ptr = FunctionWrapper.Load<GdipGetImageDecoders_delegate>(s_gdipModule, "GdipGetImageDecoders", LibraryName);
-                GdipGetImageEncodersSize_ptr = FunctionWrapper.Load<GdipGetImageEncodersSize_delegate>(s_gdipModule, "GdipGetImageEncodersSize", LibraryName);
-                GdipGetImageEncoders_ptr = FunctionWrapper.Load<GdipGetImageEncoders_delegate>(s_gdipModule, "GdipGetImageEncoders", LibraryName);
-                GdipCreateSolidFill_ptr = FunctionWrapper.Load<GdipCreateSolidFill_delegate>(s_gdipModule, "GdipCreateSolidFill", LibraryName);
-                GdipSetSolidFillColor_ptr = FunctionWrapper.Load<GdipSetSolidFillColor_delegate>(s_gdipModule, "GdipSetSolidFillColor", LibraryName);
-                GdipGetSolidFillColor_ptr = FunctionWrapper.Load<GdipGetSolidFillColor_delegate>(s_gdipModule, "GdipGetSolidFillColor", LibraryName);
-                GdipCreateTexture_ptr = FunctionWrapper.Load<GdipCreateTexture_delegate>(s_gdipModule, "GdipCreateTexture", LibraryName);
-                GdipCreateTexture2_ptr = FunctionWrapper.Load<GdipCreateTexture2_delegate>(s_gdipModule, "GdipCreateTexture2", LibraryName);
-                GdipCreateTextureIA_ptr = FunctionWrapper.Load<GdipCreateTextureIA_delegate>(s_gdipModule, "GdipCreateTextureIA", LibraryName);
-                GdipCreateTexture2I_ptr = FunctionWrapper.Load<GdipCreateTexture2I_delegate>(s_gdipModule, "GdipCreateTexture2I", LibraryName);
-                GdipCreateTextureIAI_ptr = FunctionWrapper.Load<GdipCreateTextureIAI_delegate>(s_gdipModule, "GdipCreateTextureIAI", LibraryName);
-                GdipSetTextureTransform_ptr = FunctionWrapper.Load<GdipSetTextureTransform_delegate>(s_gdipModule, "GdipSetTextureTransform", LibraryName);
-                GdipGetTextureTransform_ptr = FunctionWrapper.Load<GdipGetTextureTransform_delegate>(s_gdipModule, "GdipGetTextureTransform", LibraryName);
-                GdipResetTextureTransform_ptr = FunctionWrapper.Load<GdipResetTextureTransform_delegate>(s_gdipModule, "GdipResetTextureTransform", LibraryName);
-                GdipMultiplyTextureTransform_ptr = FunctionWrapper.Load<GdipMultiplyTextureTransform_delegate>(s_gdipModule, "GdipMultiplyTextureTransform", LibraryName);
-                GdipTranslateTextureTransform_ptr = FunctionWrapper.Load<GdipTranslateTextureTransform_delegate>(s_gdipModule, "GdipTranslateTextureTransform", LibraryName);
-                GdipScaleTextureTransform_ptr = FunctionWrapper.Load<GdipScaleTextureTransform_delegate>(s_gdipModule, "GdipScaleTextureTransform", LibraryName);
-                GdipRotateTextureTransform_ptr = FunctionWrapper.Load<GdipRotateTextureTransform_delegate>(s_gdipModule, "GdipRotateTextureTransform", LibraryName);
-                GdipSetTextureWrapMode_ptr = FunctionWrapper.Load<GdipSetTextureWrapMode_delegate>(s_gdipModule, "GdipSetTextureWrapMode", LibraryName);
-                GdipGetTextureWrapMode_ptr = FunctionWrapper.Load<GdipGetTextureWrapMode_delegate>(s_gdipModule, "GdipGetTextureWrapMode", LibraryName);
-                GdipGetTextureImage_ptr = FunctionWrapper.Load<GdipGetTextureImage_delegate>(s_gdipModule, "GdipGetTextureImage", LibraryName);
-                GdipGetFontCollectionFamilyCount_ptr = FunctionWrapper.Load<GdipGetFontCollectionFamilyCount_delegate>(s_gdipModule, "GdipGetFontCollectionFamilyCount", LibraryName);
-                GdipGetFontCollectionFamilyList_ptr = FunctionWrapper.Load<GdipGetFontCollectionFamilyList_delegate>(s_gdipModule, "GdipGetFontCollectionFamilyList", LibraryName);
-                GdipCloneFontFamily_ptr = FunctionWrapper.Load<GdipCloneFontFamily_delegate>(s_gdipModule, "GdipCloneFontFamily", LibraryName);
-                GdipCreateFontFamilyFromName_ptr = FunctionWrapper.Load<GdipCreateFontFamilyFromName_delegate>(s_gdipModule, "GdipCreateFontFamilyFromName", LibraryName);
-                GdipGetGenericFontFamilySansSerif_ptr = FunctionWrapper.Load<GdipGetGenericFontFamilySansSerif_delegate>(s_gdipModule, "GdipGetGenericFontFamilySansSerif", LibraryName);
-                GdipGetGenericFontFamilySerif_ptr = FunctionWrapper.Load<GdipGetGenericFontFamilySerif_delegate>(s_gdipModule, "GdipGetGenericFontFamilySerif", LibraryName);
-                GdipGetGenericFontFamilyMonospace_ptr = FunctionWrapper.Load<GdipGetGenericFontFamilyMonospace_delegate>(s_gdipModule, "GdipGetGenericFontFamilyMonospace", LibraryName);
-                GdipDeleteFontFamily_ptr = FunctionWrapper.Load<GdipDeleteFontFamily_delegate>(s_gdipModule, "GdipDeleteFontFamily", LibraryName);
-                GdipGetFamilyName_ptr = FunctionWrapper.Load<GdipGetFamilyName_delegate>(s_gdipModule, "GdipGetFamilyName", LibraryName);
-                GdipIsStyleAvailable_ptr = FunctionWrapper.Load<GdipIsStyleAvailable_delegate>(s_gdipModule, "GdipIsStyleAvailable", LibraryName);
-                GdipGetEmHeight_ptr = FunctionWrapper.Load<GdipGetEmHeight_delegate>(s_gdipModule, "GdipGetEmHeight", LibraryName);
-                GdipGetCellAscent_ptr = FunctionWrapper.Load<GdipGetCellAscent_delegate>(s_gdipModule, "GdipGetCellAscent", LibraryName);
-                GdipGetCellDescent_ptr = FunctionWrapper.Load<GdipGetCellDescent_delegate>(s_gdipModule, "GdipGetCellDescent", LibraryName);
-                GdipGetLineSpacing_ptr = FunctionWrapper.Load<GdipGetLineSpacing_delegate>(s_gdipModule, "GdipGetLineSpacing", LibraryName);
-                GdipNewInstalledFontCollection_ptr = FunctionWrapper.Load<GdipNewInstalledFontCollection_delegate>(s_gdipModule, "GdipNewInstalledFontCollection", LibraryName);
-                GdipNewPrivateFontCollection_ptr = FunctionWrapper.Load<GdipNewPrivateFontCollection_delegate>(s_gdipModule, "GdipNewPrivateFontCollection", LibraryName);
-                GdipDeletePrivateFontCollection_ptr = FunctionWrapper.Load<GdipDeletePrivateFontCollection_delegate>(s_gdipModule, "GdipDeletePrivateFontCollection", LibraryName);
-                GdipPrivateAddFontFile_ptr = FunctionWrapper.Load<GdipPrivateAddFontFile_delegate>(s_gdipModule, "GdipPrivateAddFontFile", LibraryName);
-                GdipPrivateAddMemoryFont_ptr = FunctionWrapper.Load<GdipPrivateAddMemoryFont_delegate>(s_gdipModule, "GdipPrivateAddMemoryFont", LibraryName);
-                GdipCreateFont_ptr = FunctionWrapper.Load<GdipCreateFont_delegate>(s_gdipModule, "GdipCreateFont", LibraryName);
-                GdipCloneFont_ptr = FunctionWrapper.Load<GdipCloneFont_delegate>(s_gdipModule, "GdipCloneFont", LibraryName);
-                GdipDeleteFont_ptr = FunctionWrapper.Load<GdipDeleteFont_delegate>(s_gdipModule, "GdipDeleteFont", LibraryName);
-                GdipGetFamily_ptr = FunctionWrapper.Load<GdipGetFamily_delegate>(s_gdipModule, "GdipGetFamily", LibraryName);
-                GdipGetFontStyle_ptr = FunctionWrapper.Load<GdipGetFontStyle_delegate>(s_gdipModule, "GdipGetFontStyle", LibraryName);
-                GdipGetFontSize_ptr = FunctionWrapper.Load<GdipGetFontSize_delegate>(s_gdipModule, "GdipGetFontSize", LibraryName);
-                GdipGetFontHeight_ptr = FunctionWrapper.Load<GdipGetFontHeight_delegate>(s_gdipModule, "GdipGetFontHeight", LibraryName);
-                GdipGetFontHeightGivenDPI_ptr = FunctionWrapper.Load<GdipGetFontHeightGivenDPI_delegate>(s_gdipModule, "GdipGetFontHeightGivenDPI", LibraryName);
-                GdipGetFontUnit_ptr = FunctionWrapper.Load<GdipGetFontUnit_delegate>(s_gdipModule, "GdipGetFontUnit", LibraryName);
-                GdipGetLogFontW_ptr = FunctionWrapper.Load<GdipGetLogFontW_delegate>(s_gdipModule, "GdipGetLogFontW", LibraryName);
-                GdipCreatePen1_ptr = FunctionWrapper.Load<GdipCreatePen1_delegate>(s_gdipModule, "GdipCreatePen1", LibraryName);
-                GdipCreatePen2_ptr = FunctionWrapper.Load<GdipCreatePen2_delegate>(s_gdipModule, "GdipCreatePen2", LibraryName);
-                GdipClonePen_ptr = FunctionWrapper.Load<GdipClonePen_delegate>(s_gdipModule, "GdipClonePen", LibraryName);
-                GdipDeletePen_ptr = FunctionWrapper.Load<GdipDeletePen_delegate>(s_gdipModule, "GdipDeletePen", LibraryName);
-                GdipSetPenMode_ptr = FunctionWrapper.Load<GdipSetPenMode_delegate>(s_gdipModule, "GdipSetPenMode", LibraryName);
-                GdipGetPenMode_ptr = FunctionWrapper.Load<GdipGetPenMode_delegate>(s_gdipModule, "GdipGetPenMode", LibraryName);
-                GdipSetPenWidth_ptr = FunctionWrapper.Load<GdipSetPenWidth_delegate>(s_gdipModule, "GdipSetPenWidth", LibraryName);
-                GdipGetPenWidth_ptr = FunctionWrapper.Load<GdipGetPenWidth_delegate>(s_gdipModule, "GdipGetPenWidth", LibraryName);
-                GdipSetPenLineCap197819_ptr = FunctionWrapper.Load<GdipSetPenLineCap197819_delegate>(s_gdipModule, "GdipSetPenLineCap197819", LibraryName);
-                GdipSetPenStartCap_ptr = FunctionWrapper.Load<GdipSetPenStartCap_delegate>(s_gdipModule, "GdipSetPenStartCap", LibraryName);
-                GdipSetPenEndCap_ptr = FunctionWrapper.Load<GdipSetPenEndCap_delegate>(s_gdipModule, "GdipSetPenEndCap", LibraryName);
-                GdipGetPenStartCap_ptr = FunctionWrapper.Load<GdipGetPenStartCap_delegate>(s_gdipModule, "GdipGetPenStartCap", LibraryName);
-                GdipGetPenEndCap_ptr = FunctionWrapper.Load<GdipGetPenEndCap_delegate>(s_gdipModule, "GdipGetPenEndCap", LibraryName);
-                GdipGetPenDashCap197819_ptr = FunctionWrapper.Load<GdipGetPenDashCap197819_delegate>(s_gdipModule, "GdipGetPenDashCap197819", LibraryName);
-                GdipSetPenDashCap197819_ptr = FunctionWrapper.Load<GdipSetPenDashCap197819_delegate>(s_gdipModule, "GdipSetPenDashCap197819", LibraryName);
-                GdipSetPenLineJoin_ptr = FunctionWrapper.Load<GdipSetPenLineJoin_delegate>(s_gdipModule, "GdipSetPenLineJoin", LibraryName);
-                GdipGetPenLineJoin_ptr = FunctionWrapper.Load<GdipGetPenLineJoin_delegate>(s_gdipModule, "GdipGetPenLineJoin", LibraryName);
-                GdipSetPenCustomStartCap_ptr = FunctionWrapper.Load<GdipSetPenCustomStartCap_delegate>(s_gdipModule, "GdipSetPenCustomStartCap", LibraryName);
-                GdipGetPenCustomStartCap_ptr = FunctionWrapper.Load<GdipGetPenCustomStartCap_delegate>(s_gdipModule, "GdipGetPenCustomStartCap", LibraryName);
-                GdipSetPenCustomEndCap_ptr = FunctionWrapper.Load<GdipSetPenCustomEndCap_delegate>(s_gdipModule, "GdipSetPenCustomEndCap", LibraryName);
-                GdipGetPenCustomEndCap_ptr = FunctionWrapper.Load<GdipGetPenCustomEndCap_delegate>(s_gdipModule, "GdipGetPenCustomEndCap", LibraryName);
-                GdipSetPenMiterLimit_ptr = FunctionWrapper.Load<GdipSetPenMiterLimit_delegate>(s_gdipModule, "GdipSetPenMiterLimit", LibraryName);
-                GdipGetPenMiterLimit_ptr = FunctionWrapper.Load<GdipGetPenMiterLimit_delegate>(s_gdipModule, "GdipGetPenMiterLimit", LibraryName);
-                GdipSetPenTransform_ptr = FunctionWrapper.Load<GdipSetPenTransform_delegate>(s_gdipModule, "GdipSetPenTransform", LibraryName);
-                GdipGetPenTransform_ptr = FunctionWrapper.Load<GdipGetPenTransform_delegate>(s_gdipModule, "GdipGetPenTransform", LibraryName);
-                GdipResetPenTransform_ptr = FunctionWrapper.Load<GdipResetPenTransform_delegate>(s_gdipModule, "GdipResetPenTransform", LibraryName);
-                GdipMultiplyPenTransform_ptr = FunctionWrapper.Load<GdipMultiplyPenTransform_delegate>(s_gdipModule, "GdipMultiplyPenTransform", LibraryName);
-                GdipTranslatePenTransform_ptr = FunctionWrapper.Load<GdipTranslatePenTransform_delegate>(s_gdipModule, "GdipTranslatePenTransform", LibraryName);
-                GdipScalePenTransform_ptr = FunctionWrapper.Load<GdipScalePenTransform_delegate>(s_gdipModule, "GdipScalePenTransform", LibraryName);
-                GdipRotatePenTransform_ptr = FunctionWrapper.Load<GdipRotatePenTransform_delegate>(s_gdipModule, "GdipRotatePenTransform", LibraryName);
-                GdipSetPenColor_ptr = FunctionWrapper.Load<GdipSetPenColor_delegate>(s_gdipModule, "GdipSetPenColor", LibraryName);
-                GdipGetPenColor_ptr = FunctionWrapper.Load<GdipGetPenColor_delegate>(s_gdipModule, "GdipGetPenColor", LibraryName);
-                GdipSetPenBrushFill_ptr = FunctionWrapper.Load<GdipSetPenBrushFill_delegate>(s_gdipModule, "GdipSetPenBrushFill", LibraryName);
-                GdipGetPenBrushFill_ptr = FunctionWrapper.Load<GdipGetPenBrushFill_delegate>(s_gdipModule, "GdipGetPenBrushFill", LibraryName);
-                GdipGetPenFillType_ptr = FunctionWrapper.Load<GdipGetPenFillType_delegate>(s_gdipModule, "GdipGetPenFillType", LibraryName);
-                GdipGetPenDashStyle_ptr = FunctionWrapper.Load<GdipGetPenDashStyle_delegate>(s_gdipModule, "GdipGetPenDashStyle", LibraryName);
-                GdipSetPenDashStyle_ptr = FunctionWrapper.Load<GdipSetPenDashStyle_delegate>(s_gdipModule, "GdipSetPenDashStyle", LibraryName);
-                GdipSetPenDashArray_ptr = FunctionWrapper.Load<GdipSetPenDashArray_delegate>(s_gdipModule, "GdipSetPenDashArray", LibraryName);
-                GdipGetPenDashOffset_ptr = FunctionWrapper.Load<GdipGetPenDashOffset_delegate>(s_gdipModule, "GdipGetPenDashOffset", LibraryName);
-                GdipSetPenDashOffset_ptr = FunctionWrapper.Load<GdipSetPenDashOffset_delegate>(s_gdipModule, "GdipSetPenDashOffset", LibraryName);
-                GdipGetPenDashCount_ptr = FunctionWrapper.Load<GdipGetPenDashCount_delegate>(s_gdipModule, "GdipGetPenDashCount", LibraryName);
-                GdipGetPenDashArray_ptr = FunctionWrapper.Load<GdipGetPenDashArray_delegate>(s_gdipModule, "GdipGetPenDashArray", LibraryName);
-                GdipGetPenCompoundCount_ptr = FunctionWrapper.Load<GdipGetPenCompoundCount_delegate>(s_gdipModule, "GdipGetPenCompoundCount", LibraryName);
-                GdipSetPenCompoundArray_ptr = FunctionWrapper.Load<GdipSetPenCompoundArray_delegate>(s_gdipModule, "GdipSetPenCompoundArray", LibraryName);
-                GdipGetPenCompoundArray_ptr = FunctionWrapper.Load<GdipGetPenCompoundArray_delegate>(s_gdipModule, "GdipGetPenCompoundArray", LibraryName);
-                GdipSetWorldTransform_ptr = FunctionWrapper.Load<GdipSetWorldTransform_delegate>(s_gdipModule, "GdipSetWorldTransform", LibraryName);
-                GdipResetWorldTransform_ptr = FunctionWrapper.Load<GdipResetWorldTransform_delegate>(s_gdipModule, "GdipResetWorldTransform", LibraryName);
-                GdipMultiplyWorldTransform_ptr = FunctionWrapper.Load<GdipMultiplyWorldTransform_delegate>(s_gdipModule, "GdipMultiplyWorldTransform", LibraryName);
-                GdipTranslateWorldTransform_ptr = FunctionWrapper.Load<GdipTranslateWorldTransform_delegate>(s_gdipModule, "GdipTranslateWorldTransform", LibraryName);
-                GdipScaleWorldTransform_ptr = FunctionWrapper.Load<GdipScaleWorldTransform_delegate>(s_gdipModule, "GdipScaleWorldTransform", LibraryName);
-                GdipRotateWorldTransform_ptr = FunctionWrapper.Load<GdipRotateWorldTransform_delegate>(s_gdipModule, "GdipRotateWorldTransform", LibraryName);
-                GdipGetWorldTransform_ptr = FunctionWrapper.Load<GdipGetWorldTransform_delegate>(s_gdipModule, "GdipGetWorldTransform", LibraryName);
-                GdipSetCompositingMode_ptr = FunctionWrapper.Load<GdipSetCompositingMode_delegate>(s_gdipModule, "GdipSetCompositingMode", LibraryName);
-                GdipSetTextRenderingHint_ptr = FunctionWrapper.Load<GdipSetTextRenderingHint_delegate>(s_gdipModule, "GdipSetTextRenderingHint", LibraryName);
-                GdipSetTextContrast_ptr = FunctionWrapper.Load<GdipSetTextContrast_delegate>(s_gdipModule, "GdipSetTextContrast", LibraryName);
-                GdipSetInterpolationMode_ptr = FunctionWrapper.Load<GdipSetInterpolationMode_delegate>(s_gdipModule, "GdipSetInterpolationMode", LibraryName);
-                GdipGetCompositingMode_ptr = FunctionWrapper.Load<GdipGetCompositingMode_delegate>(s_gdipModule, "GdipGetCompositingMode", LibraryName);
-                GdipSetRenderingOrigin_ptr = FunctionWrapper.Load<GdipSetRenderingOrigin_delegate>(s_gdipModule, "GdipSetRenderingOrigin", LibraryName);
-                GdipGetRenderingOrigin_ptr = FunctionWrapper.Load<GdipGetRenderingOrigin_delegate>(s_gdipModule, "GdipGetRenderingOrigin", LibraryName);
-                GdipSetCompositingQuality_ptr = FunctionWrapper.Load<GdipSetCompositingQuality_delegate>(s_gdipModule, "GdipSetCompositingQuality", LibraryName);
-                GdipGetCompositingQuality_ptr = FunctionWrapper.Load<GdipGetCompositingQuality_delegate>(s_gdipModule, "GdipGetCompositingQuality", LibraryName);
-                GdipSetSmoothingMode_ptr = FunctionWrapper.Load<GdipSetSmoothingMode_delegate>(s_gdipModule, "GdipSetSmoothingMode", LibraryName);
-                GdipGetSmoothingMode_ptr = FunctionWrapper.Load<GdipGetSmoothingMode_delegate>(s_gdipModule, "GdipGetSmoothingMode", LibraryName);
-                GdipSetPixelOffsetMode_ptr = FunctionWrapper.Load<GdipSetPixelOffsetMode_delegate>(s_gdipModule, "GdipSetPixelOffsetMode", LibraryName);
-                GdipGetPixelOffsetMode_ptr = FunctionWrapper.Load<GdipGetPixelOffsetMode_delegate>(s_gdipModule, "GdipGetPixelOffsetMode", LibraryName);
-                GdipGetTextRenderingHint_ptr = FunctionWrapper.Load<GdipGetTextRenderingHint_delegate>(s_gdipModule, "GdipGetTextRenderingHint", LibraryName);
-                GdipGetTextContrast_ptr = FunctionWrapper.Load<GdipGetTextContrast_delegate>(s_gdipModule, "GdipGetTextContrast", LibraryName);
-                GdipGetInterpolationMode_ptr = FunctionWrapper.Load<GdipGetInterpolationMode_delegate>(s_gdipModule, "GdipGetInterpolationMode", LibraryName);
-                GdipGetPageUnit_ptr = FunctionWrapper.Load<GdipGetPageUnit_delegate>(s_gdipModule, "GdipGetPageUnit", LibraryName);
-                GdipGetPageScale_ptr = FunctionWrapper.Load<GdipGetPageScale_delegate>(s_gdipModule, "GdipGetPageScale", LibraryName);
-                GdipSetPageUnit_ptr = FunctionWrapper.Load<GdipSetPageUnit_delegate>(s_gdipModule, "GdipSetPageUnit", LibraryName);
-                GdipSetPageScale_ptr = FunctionWrapper.Load<GdipSetPageScale_delegate>(s_gdipModule, "GdipSetPageScale", LibraryName);
-                GdipGetDpiX_ptr = FunctionWrapper.Load<GdipGetDpiX_delegate>(s_gdipModule, "GdipGetDpiX", LibraryName);
-                GdipGetDpiY_ptr = FunctionWrapper.Load<GdipGetDpiY_delegate>(s_gdipModule, "GdipGetDpiY", LibraryName);
-                GdipCreateMatrix_ptr = FunctionWrapper.Load<GdipCreateMatrix_delegate>(s_gdipModule, "GdipCreateMatrix", LibraryName);
-                GdipCreateMatrix2_ptr = FunctionWrapper.Load<GdipCreateMatrix2_delegate>(s_gdipModule, "GdipCreateMatrix2", LibraryName);
-                GdipCreateMatrix3_ptr = FunctionWrapper.Load<GdipCreateMatrix3_delegate>(s_gdipModule, "GdipCreateMatrix3", LibraryName);
-                GdipCreateMatrix3I_ptr = FunctionWrapper.Load<GdipCreateMatrix3I_delegate>(s_gdipModule, "GdipCreateMatrix3I", LibraryName);
-                GdipCloneMatrix_ptr = FunctionWrapper.Load<GdipCloneMatrix_delegate>(s_gdipModule, "GdipCloneMatrix", LibraryName);
-                GdipDeleteMatrix_ptr = FunctionWrapper.Load<GdipDeleteMatrix_delegate>(s_gdipModule, "GdipDeleteMatrix", LibraryName);
-                GdipSetMatrixElements_ptr = FunctionWrapper.Load<GdipSetMatrixElements_delegate>(s_gdipModule, "GdipSetMatrixElements", LibraryName);
-                GdipMultiplyMatrix_ptr = FunctionWrapper.Load<GdipMultiplyMatrix_delegate>(s_gdipModule, "GdipMultiplyMatrix", LibraryName);
-                GdipTranslateMatrix_ptr = FunctionWrapper.Load<GdipTranslateMatrix_delegate>(s_gdipModule, "GdipTranslateMatrix", LibraryName);
-                GdipScaleMatrix_ptr = FunctionWrapper.Load<GdipScaleMatrix_delegate>(s_gdipModule, "GdipScaleMatrix", LibraryName);
-                GdipRotateMatrix_ptr = FunctionWrapper.Load<GdipRotateMatrix_delegate>(s_gdipModule, "GdipRotateMatrix", LibraryName);
-                GdipShearMatrix_ptr = FunctionWrapper.Load<GdipShearMatrix_delegate>(s_gdipModule, "GdipShearMatrix", LibraryName);
-                GdipInvertMatrix_ptr = FunctionWrapper.Load<GdipInvertMatrix_delegate>(s_gdipModule, "GdipInvertMatrix", LibraryName);
-                GdipTransformMatrixPoints_ptr = FunctionWrapper.Load<GdipTransformMatrixPoints_delegate>(s_gdipModule, "GdipTransformMatrixPoints", LibraryName);
-                GdipTransformMatrixPointsI_ptr = FunctionWrapper.Load<GdipTransformMatrixPointsI_delegate>(s_gdipModule, "GdipTransformMatrixPointsI", LibraryName);
-                GdipVectorTransformMatrixPoints_ptr = FunctionWrapper.Load<GdipVectorTransformMatrixPoints_delegate>(s_gdipModule, "GdipVectorTransformMatrixPoints", LibraryName);
-                GdipVectorTransformMatrixPointsI_ptr = FunctionWrapper.Load<GdipVectorTransformMatrixPointsI_delegate>(s_gdipModule, "GdipVectorTransformMatrixPointsI", LibraryName);
-                GdipGetMatrixElements_ptr = FunctionWrapper.Load<GdipGetMatrixElements_delegate>(s_gdipModule, "GdipGetMatrixElements", LibraryName);
-                GdipIsMatrixInvertible_ptr = FunctionWrapper.Load<GdipIsMatrixInvertible_delegate>(s_gdipModule, "GdipIsMatrixInvertible", LibraryName);
-                GdipIsMatrixIdentity_ptr = FunctionWrapper.Load<GdipIsMatrixIdentity_delegate>(s_gdipModule, "GdipIsMatrixIdentity", LibraryName);
-                GdipIsMatrixEqual_ptr = FunctionWrapper.Load<GdipIsMatrixEqual_delegate>(s_gdipModule, "GdipIsMatrixEqual", LibraryName);
-                GdipCreateRegion_ptr = FunctionWrapper.Load<GdipCreateRegion_delegate>(s_gdipModule, "GdipCreateRegion", LibraryName);
-                GdipCreateRegionRect_ptr = FunctionWrapper.Load<GdipCreateRegionRect_delegate>(s_gdipModule, "GdipCreateRegionRect", LibraryName);
-                GdipCreateRegionRectI_ptr = FunctionWrapper.Load<GdipCreateRegionRectI_delegate>(s_gdipModule, "GdipCreateRegionRectI", LibraryName);
-                GdipCreateRegionPath_ptr = FunctionWrapper.Load<GdipCreateRegionPath_delegate>(s_gdipModule, "GdipCreateRegionPath", LibraryName);
-                GdipCreateRegionRgnData_ptr = FunctionWrapper.Load<GdipCreateRegionRgnData_delegate>(s_gdipModule, "GdipCreateRegionRgnData", LibraryName);
-                GdipCreateRegionHrgn_ptr = FunctionWrapper.Load<GdipCreateRegionHrgn_delegate>(s_gdipModule, "GdipCreateRegionHrgn", LibraryName);
-                GdipCloneRegion_ptr = FunctionWrapper.Load<GdipCloneRegion_delegate>(s_gdipModule, "GdipCloneRegion", LibraryName);
-                GdipDeleteRegion_ptr = FunctionWrapper.Load<GdipDeleteRegion_delegate>(s_gdipModule, "GdipDeleteRegion", LibraryName);
-                GdipFillRegion_ptr = FunctionWrapper.Load<GdipFillRegion_delegate>(s_gdipModule, "GdipFillRegion", LibraryName);
-                GdipSetInfinite_ptr = FunctionWrapper.Load<GdipSetInfinite_delegate>(s_gdipModule, "GdipSetInfinite", LibraryName);
-                GdipSetEmpty_ptr = FunctionWrapper.Load<GdipSetEmpty_delegate>(s_gdipModule, "GdipSetEmpty", LibraryName);
-                GdipCombineRegionRect_ptr = FunctionWrapper.Load<GdipCombineRegionRect_delegate>(s_gdipModule, "GdipCombineRegionRect", LibraryName);
-                GdipCombineRegionRectI_ptr = FunctionWrapper.Load<GdipCombineRegionRectI_delegate>(s_gdipModule, "GdipCombineRegionRectI", LibraryName);
-                GdipCombineRegionPath_ptr = FunctionWrapper.Load<GdipCombineRegionPath_delegate>(s_gdipModule, "GdipCombineRegionPath", LibraryName);
-                GdipCombineRegionRegion_ptr = FunctionWrapper.Load<GdipCombineRegionRegion_delegate>(s_gdipModule, "GdipCombineRegionRegion", LibraryName);
-                GdipTranslateRegion_ptr = FunctionWrapper.Load<GdipTranslateRegion_delegate>(s_gdipModule, "GdipTranslateRegion", LibraryName);
-                GdipTranslateRegionI_ptr = FunctionWrapper.Load<GdipTranslateRegionI_delegate>(s_gdipModule, "GdipTranslateRegionI", LibraryName);
-                GdipTransformRegion_ptr = FunctionWrapper.Load<GdipTransformRegion_delegate>(s_gdipModule, "GdipTransformRegion", LibraryName);
-                GdipGetRegionBounds_ptr = FunctionWrapper.Load<GdipGetRegionBounds_delegate>(s_gdipModule, "GdipGetRegionBounds", LibraryName);
-                GdipGetRegionHRgn_ptr = FunctionWrapper.Load<GdipGetRegionHRgn_delegate>(s_gdipModule, "GdipGetRegionHRgn", LibraryName);
-                GdipIsEmptyRegion_ptr = FunctionWrapper.Load<GdipIsEmptyRegion_delegate>(s_gdipModule, "GdipIsEmptyRegion", LibraryName);
-                GdipIsInfiniteRegion_ptr = FunctionWrapper.Load<GdipIsInfiniteRegion_delegate>(s_gdipModule, "GdipIsInfiniteRegion", LibraryName);
-                GdipIsEqualRegion_ptr = FunctionWrapper.Load<GdipIsEqualRegion_delegate>(s_gdipModule, "GdipIsEqualRegion", LibraryName);
-                GdipGetRegionDataSize_ptr = FunctionWrapper.Load<GdipGetRegionDataSize_delegate>(s_gdipModule, "GdipGetRegionDataSize", LibraryName);
-                GdipGetRegionData_ptr = FunctionWrapper.Load<GdipGetRegionData_delegate>(s_gdipModule, "GdipGetRegionData", LibraryName);
-                GdipIsVisibleRegionPoint_ptr = FunctionWrapper.Load<GdipIsVisibleRegionPoint_delegate>(s_gdipModule, "GdipIsVisibleRegionPoint", LibraryName);
-                GdipIsVisibleRegionPointI_ptr = FunctionWrapper.Load<GdipIsVisibleRegionPointI_delegate>(s_gdipModule, "GdipIsVisibleRegionPointI", LibraryName);
-                GdipIsVisibleRegionRect_ptr = FunctionWrapper.Load<GdipIsVisibleRegionRect_delegate>(s_gdipModule, "GdipIsVisibleRegionRect", LibraryName);
-                GdipIsVisibleRegionRectI_ptr = FunctionWrapper.Load<GdipIsVisibleRegionRectI_delegate>(s_gdipModule, "GdipIsVisibleRegionRectI", LibraryName);
-                GdipGetRegionScansCount_ptr = FunctionWrapper.Load<GdipGetRegionScansCount_delegate>(s_gdipModule, "GdipGetRegionScansCount", LibraryName);
-                GdipGetRegionScans_ptr = FunctionWrapper.Load<GdipGetRegionScans_delegate>(s_gdipModule, "GdipGetRegionScans", LibraryName);
-                GdipSetClipGraphics_ptr = FunctionWrapper.Load<GdipSetClipGraphics_delegate>(s_gdipModule, "GdipSetClipGraphics", LibraryName);
-                GdipSetClipRect_ptr = FunctionWrapper.Load<GdipSetClipRect_delegate>(s_gdipModule, "GdipSetClipRect", LibraryName);
-                GdipSetClipRectI_ptr = FunctionWrapper.Load<GdipSetClipRectI_delegate>(s_gdipModule, "GdipSetClipRectI", LibraryName);
-                GdipSetClipPath_ptr = FunctionWrapper.Load<GdipSetClipPath_delegate>(s_gdipModule, "GdipSetClipPath", LibraryName);
-                GdipSetClipRegion_ptr = FunctionWrapper.Load<GdipSetClipRegion_delegate>(s_gdipModule, "GdipSetClipRegion", LibraryName);
-                GdipResetClip_ptr = FunctionWrapper.Load<GdipResetClip_delegate>(s_gdipModule, "GdipResetClip", LibraryName);
-                GdipTranslateClip_ptr = FunctionWrapper.Load<GdipTranslateClip_delegate>(s_gdipModule, "GdipTranslateClip", LibraryName);
-                GdipGetClip_ptr = FunctionWrapper.Load<GdipGetClip_delegate>(s_gdipModule, "GdipGetClip", LibraryName);
-                GdipGetClipBounds_ptr = FunctionWrapper.Load<GdipGetClipBounds_delegate>(s_gdipModule, "GdipGetClipBounds", LibraryName);
-                GdipIsClipEmpty_ptr = FunctionWrapper.Load<GdipIsClipEmpty_delegate>(s_gdipModule, "GdipIsClipEmpty", LibraryName);
-                GdipGetVisibleClipBounds_ptr = FunctionWrapper.Load<GdipGetVisibleClipBounds_delegate>(s_gdipModule, "GdipGetVisibleClipBounds", LibraryName);
-                GdipIsVisibleClipEmpty_ptr = FunctionWrapper.Load<GdipIsVisibleClipEmpty_delegate>(s_gdipModule, "GdipIsVisibleClipEmpty", LibraryName);
-                GdipIsVisiblePoint_ptr = FunctionWrapper.Load<GdipIsVisiblePoint_delegate>(s_gdipModule, "GdipIsVisiblePoint", LibraryName);
-                GdipIsVisiblePointI_ptr = FunctionWrapper.Load<GdipIsVisiblePointI_delegate>(s_gdipModule, "GdipIsVisiblePointI", LibraryName);
-                GdipIsVisibleRect_ptr = FunctionWrapper.Load<GdipIsVisibleRect_delegate>(s_gdipModule, "GdipIsVisibleRect", LibraryName);
-                GdipIsVisibleRectI_ptr = FunctionWrapper.Load<GdipIsVisibleRectI_delegate>(s_gdipModule, "GdipIsVisibleRectI", LibraryName);
-                GdipFlush_ptr = FunctionWrapper.Load<GdipFlush_delegate>(s_gdipModule, "GdipFlush", LibraryName);
-                GdipGetDC_ptr = FunctionWrapper.Load<GdipGetDC_delegate>(s_gdipModule, "GdipGetDC", LibraryName);
-                GdipSetStringFormatMeasurableCharacterRanges_ptr = FunctionWrapper.Load<GdipSetStringFormatMeasurableCharacterRanges_delegate>(s_gdipModule, "GdipSetStringFormatMeasurableCharacterRanges", LibraryName);
-                GdipCreateStringFormat_ptr = FunctionWrapper.Load<GdipCreateStringFormat_delegate>(s_gdipModule, "GdipCreateStringFormat", LibraryName);
-                GdipStringFormatGetGenericDefault_ptr = FunctionWrapper.Load<GdipStringFormatGetGenericDefault_delegate>(s_gdipModule, "GdipStringFormatGetGenericDefault", LibraryName);
-                GdipStringFormatGetGenericTypographic_ptr = FunctionWrapper.Load<GdipStringFormatGetGenericTypographic_delegate>(s_gdipModule, "GdipStringFormatGetGenericTypographic", LibraryName);
-                GdipDeleteStringFormat_ptr = FunctionWrapper.Load<GdipDeleteStringFormat_delegate>(s_gdipModule, "GdipDeleteStringFormat", LibraryName);
-                GdipCloneStringFormat_ptr = FunctionWrapper.Load<GdipCloneStringFormat_delegate>(s_gdipModule, "GdipCloneStringFormat", LibraryName);
-                GdipSetStringFormatFlags_ptr = FunctionWrapper.Load<GdipSetStringFormatFlags_delegate>(s_gdipModule, "GdipSetStringFormatFlags", LibraryName);
-                GdipGetStringFormatFlags_ptr = FunctionWrapper.Load<GdipGetStringFormatFlags_delegate>(s_gdipModule, "GdipGetStringFormatFlags", LibraryName);
-                GdipSetStringFormatAlign_ptr = FunctionWrapper.Load<GdipSetStringFormatAlign_delegate>(s_gdipModule, "GdipSetStringFormatAlign", LibraryName);
-                GdipGetStringFormatAlign_ptr = FunctionWrapper.Load<GdipGetStringFormatAlign_delegate>(s_gdipModule, "GdipGetStringFormatAlign", LibraryName);
-                GdipSetStringFormatLineAlign_ptr = FunctionWrapper.Load<GdipSetStringFormatLineAlign_delegate>(s_gdipModule, "GdipSetStringFormatLineAlign", LibraryName);
-                GdipGetStringFormatLineAlign_ptr = FunctionWrapper.Load<GdipGetStringFormatLineAlign_delegate>(s_gdipModule, "GdipGetStringFormatLineAlign", LibraryName);
-                GdipSetStringFormatHotkeyPrefix_ptr = FunctionWrapper.Load<GdipSetStringFormatHotkeyPrefix_delegate>(s_gdipModule, "GdipSetStringFormatHotkeyPrefix", LibraryName);
-                GdipGetStringFormatHotkeyPrefix_ptr = FunctionWrapper.Load<GdipGetStringFormatHotkeyPrefix_delegate>(s_gdipModule, "GdipGetStringFormatHotkeyPrefix", LibraryName);
-                GdipSetStringFormatTabStops_ptr = FunctionWrapper.Load<GdipSetStringFormatTabStops_delegate>(s_gdipModule, "GdipSetStringFormatTabStops", LibraryName);
-                GdipGetStringFormatTabStops_ptr = FunctionWrapper.Load<GdipGetStringFormatTabStops_delegate>(s_gdipModule, "GdipGetStringFormatTabStops", LibraryName);
-                GdipGetStringFormatTabStopCount_ptr = FunctionWrapper.Load<GdipGetStringFormatTabStopCount_delegate>(s_gdipModule, "GdipGetStringFormatTabStopCount", LibraryName);
-                GdipGetStringFormatMeasurableCharacterRangeCount_ptr = FunctionWrapper.Load<GdipGetStringFormatMeasurableCharacterRangeCount_delegate>(s_gdipModule, "GdipGetStringFormatMeasurableCharacterRangeCount", LibraryName);
-                GdipSetStringFormatTrimming_ptr = FunctionWrapper.Load<GdipSetStringFormatTrimming_delegate>(s_gdipModule, "GdipSetStringFormatTrimming", LibraryName);
-                GdipGetStringFormatTrimming_ptr = FunctionWrapper.Load<GdipGetStringFormatTrimming_delegate>(s_gdipModule, "GdipGetStringFormatTrimming", LibraryName);
-                GdipSetStringFormatDigitSubstitution_ptr = FunctionWrapper.Load<GdipSetStringFormatDigitSubstitution_delegate>(s_gdipModule, "GdipSetStringFormatDigitSubstitution", LibraryName);
-                GdipGetStringFormatDigitSubstitution_ptr = FunctionWrapper.Load<GdipGetStringFormatDigitSubstitution_delegate>(s_gdipModule, "GdipGetStringFormatDigitSubstitution", LibraryName);
-                GdipGetImageDimension_ptr = FunctionWrapper.Load<GdipGetImageDimension_delegate>(s_gdipModule, "GdipGetImageDimension", LibraryName);
-                GdipGetImageWidth_ptr = FunctionWrapper.Load<GdipGetImageWidth_delegate>(s_gdipModule, "GdipGetImageWidth", LibraryName);
-                GdipGetImageHeight_ptr = FunctionWrapper.Load<GdipGetImageHeight_delegate>(s_gdipModule, "GdipGetImageHeight", LibraryName);
-                GdipGetImageHorizontalResolution_ptr = FunctionWrapper.Load<GdipGetImageHorizontalResolution_delegate>(s_gdipModule, "GdipGetImageHorizontalResolution", LibraryName);
-                GdipGetImageVerticalResolution_ptr = FunctionWrapper.Load<GdipGetImageVerticalResolution_delegate>(s_gdipModule, "GdipGetImageVerticalResolution", LibraryName);
-                GdipGetImageFlags_ptr = FunctionWrapper.Load<GdipGetImageFlags_delegate>(s_gdipModule, "GdipGetImageFlags", LibraryName);
-                GdipGetImageRawFormat_ptr = FunctionWrapper.Load<GdipGetImageRawFormat_delegate>(s_gdipModule, "GdipGetImageRawFormat", LibraryName);
-                GdipGetImagePixelFormat_ptr = FunctionWrapper.Load<GdipGetImagePixelFormat_delegate>(s_gdipModule, "GdipGetImagePixelFormat", LibraryName);
-                GdipImageGetFrameCount_ptr = FunctionWrapper.Load<GdipImageGetFrameCount_delegate>(s_gdipModule, "GdipImageGetFrameCount", LibraryName);
-                GdipImageSelectActiveFrame_ptr = FunctionWrapper.Load<GdipImageSelectActiveFrame_delegate>(s_gdipModule, "GdipImageSelectActiveFrame", LibraryName);
-                GdipImageRotateFlip_ptr = FunctionWrapper.Load<GdipImageRotateFlip_delegate>(s_gdipModule, "GdipImageRotateFlip", LibraryName);
-                GdipRemovePropertyItem_ptr = FunctionWrapper.Load<GdipRemovePropertyItem_delegate>(s_gdipModule, "GdipRemovePropertyItem", LibraryName);
-                GdipCreateBitmapFromFile_ptr = FunctionWrapper.Load<GdipCreateBitmapFromFile_delegate>(s_gdipModule, "GdipCreateBitmapFromFile", LibraryName);
-                GdipCreateBitmapFromFileICM_ptr = FunctionWrapper.Load<GdipCreateBitmapFromFileICM_delegate>(s_gdipModule, "GdipCreateBitmapFromFileICM", LibraryName);
-                GdipCreateBitmapFromScan0_ptr = FunctionWrapper.Load<GdipCreateBitmapFromScan0_delegate>(s_gdipModule, "GdipCreateBitmapFromScan0", LibraryName);
-                GdipCreateBitmapFromGraphics_ptr = FunctionWrapper.Load<GdipCreateBitmapFromGraphics_delegate>(s_gdipModule, "GdipCreateBitmapFromGraphics", LibraryName);
-                GdipCreateBitmapFromHBITMAP_ptr = FunctionWrapper.Load<GdipCreateBitmapFromHBITMAP_delegate>(s_gdipModule, "GdipCreateBitmapFromHBITMAP", LibraryName);
-                GdipCreateBitmapFromHICON_ptr = FunctionWrapper.Load<GdipCreateBitmapFromHICON_delegate>(s_gdipModule, "GdipCreateBitmapFromHICON", LibraryName);
-                GdipCreateBitmapFromResource_ptr = FunctionWrapper.Load<GdipCreateBitmapFromResource_delegate>(s_gdipModule, "GdipCreateBitmapFromResource", LibraryName);
-                GdipCreateHBITMAPFromBitmap_ptr = FunctionWrapper.Load<GdipCreateHBITMAPFromBitmap_delegate>(s_gdipModule, "GdipCreateHBITMAPFromBitmap", LibraryName);
-                GdipCreateHICONFromBitmap_ptr = FunctionWrapper.Load<GdipCreateHICONFromBitmap_delegate>(s_gdipModule, "GdipCreateHICONFromBitmap", LibraryName);
-                GdipCloneBitmapArea_ptr = FunctionWrapper.Load<GdipCloneBitmapArea_delegate>(s_gdipModule, "GdipCloneBitmapArea", LibraryName);
-                GdipCloneBitmapAreaI_ptr = FunctionWrapper.Load<GdipCloneBitmapAreaI_delegate>(s_gdipModule, "GdipCloneBitmapAreaI", LibraryName);
-                GdipBitmapLockBits_ptr = FunctionWrapper.Load<GdipBitmapLockBits_delegate>(s_gdipModule, "GdipBitmapLockBits", LibraryName);
-                GdipBitmapUnlockBits_ptr = FunctionWrapper.Load<GdipBitmapUnlockBits_delegate>(s_gdipModule, "GdipBitmapUnlockBits", LibraryName);
-                GdipBitmapGetPixel_ptr = FunctionWrapper.Load<GdipBitmapGetPixel_delegate>(s_gdipModule, "GdipBitmapGetPixel", LibraryName);
-                GdipBitmapSetPixel_ptr = FunctionWrapper.Load<GdipBitmapSetPixel_delegate>(s_gdipModule, "GdipBitmapSetPixel", LibraryName);
-                GdipBitmapSetResolution_ptr = FunctionWrapper.Load<GdipBitmapSetResolution_delegate>(s_gdipModule, "GdipBitmapSetResolution", LibraryName);
-                GdipImageGetFrameDimensionsCount_ptr = FunctionWrapper.Load<GdipImageGetFrameDimensionsCount_delegate>(s_gdipModule, "GdipImageGetFrameDimensionsCount", LibraryName);
-                GdipImageGetFrameDimensionsList_ptr = FunctionWrapper.Load<GdipImageGetFrameDimensionsList_delegate>(s_gdipModule, "GdipImageGetFrameDimensionsList", LibraryName);
-            }
-
             // Shared function imports (all platforms)
-            private delegate int GdipBeginContainer_delegate(HandleRef graphics, ref RectangleF dstRect, ref RectangleF srcRect, GraphicsUnit unit, out int state);
-            private static FunctionWrapper<GdipBeginContainer_delegate> GdipBeginContainer_ptr;
-            internal static int GdipBeginContainer(HandleRef graphics, ref RectangleF dstRect, ref RectangleF srcRect, GraphicsUnit unit, out int state) => GdipBeginContainer_ptr.Delegate(graphics, ref dstRect, ref srcRect, unit, out state);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipBeginContainer(HandleRef graphics, ref RectangleF dstRect, ref RectangleF srcRect, GraphicsUnit unit, out int state);
 
-            private delegate int GdipBeginContainer2_delegate(HandleRef graphics, out int state);
-            private static FunctionWrapper<GdipBeginContainer2_delegate> GdipBeginContainer2_ptr;
-            internal static int GdipBeginContainer2(HandleRef graphics, out int state) => GdipBeginContainer2_ptr.Delegate(graphics, out state);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipBeginContainer2(HandleRef graphics, out int state);
 
-            private delegate int GdipBeginContainerI_delegate(HandleRef graphics, ref Rectangle dstRect, ref Rectangle srcRect, GraphicsUnit unit, out int state);
-            private static FunctionWrapper<GdipBeginContainerI_delegate> GdipBeginContainerI_ptr;
-            internal static int GdipBeginContainerI(HandleRef graphics, ref Rectangle dstRect, ref Rectangle srcRect, GraphicsUnit unit, out int state) => GdipBeginContainerI_ptr.Delegate(graphics, ref dstRect, ref srcRect, unit, out state);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipBeginContainerI(HandleRef graphics, ref Rectangle dstRect, ref Rectangle srcRect, GraphicsUnit unit, out int state);
 
-            private delegate int GdipEndContainer_delegate(HandleRef graphics, int state);
-            private static FunctionWrapper<GdipEndContainer_delegate> GdipEndContainer_ptr;
-            internal static int GdipEndContainer(HandleRef graphics, int state) => GdipEndContainer_ptr.Delegate(graphics, state);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipEndContainer(HandleRef graphics, int state);
 
-            private delegate int GdipCreateAdjustableArrowCap_delegate(float height, float width, bool isFilled, out IntPtr adjustableArrowCap);
-            private static FunctionWrapper<GdipCreateAdjustableArrowCap_delegate> GdipCreateAdjustableArrowCap_ptr;
-            internal static int GdipCreateAdjustableArrowCap(float height, float width, bool isFilled, out IntPtr adjustableArrowCap) => GdipCreateAdjustableArrowCap_ptr.Delegate(height, width, isFilled, out adjustableArrowCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateAdjustableArrowCap(float height, float width, bool isFilled, out IntPtr adjustableArrowCap);
 
-            private delegate int GdipGetAdjustableArrowCapHeight_delegate(HandleRef adjustableArrowCap, out float height);
-            private static FunctionWrapper<GdipGetAdjustableArrowCapHeight_delegate> GdipGetAdjustableArrowCapHeight_ptr;
-            internal static int GdipGetAdjustableArrowCapHeight(HandleRef adjustableArrowCap, out float height) => GdipGetAdjustableArrowCapHeight_ptr.Delegate(adjustableArrowCap, out height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetAdjustableArrowCapHeight(HandleRef adjustableArrowCap, out float height);
 
-            private delegate int GdipSetAdjustableArrowCapHeight_delegate(HandleRef adjustableArrowCap, float height);
-            private static FunctionWrapper<GdipSetAdjustableArrowCapHeight_delegate> GdipSetAdjustableArrowCapHeight_ptr;
-            internal static int GdipSetAdjustableArrowCapHeight(HandleRef adjustableArrowCap, float height) => GdipSetAdjustableArrowCapHeight_ptr.Delegate(adjustableArrowCap, height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetAdjustableArrowCapHeight(HandleRef adjustableArrowCap, float height);
 
-            private delegate int GdipSetAdjustableArrowCapWidth_delegate(HandleRef adjustableArrowCap, float width);
-            private static FunctionWrapper<GdipSetAdjustableArrowCapWidth_delegate> GdipSetAdjustableArrowCapWidth_ptr;
-            internal static int GdipSetAdjustableArrowCapWidth(HandleRef adjustableArrowCap, float width) => GdipSetAdjustableArrowCapWidth_ptr.Delegate(adjustableArrowCap, width);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetAdjustableArrowCapWidth(HandleRef adjustableArrowCap, float width);
 
-            private delegate int GdipGetAdjustableArrowCapWidth_delegate(HandleRef adjustableArrowCap, out float width);
-            private static FunctionWrapper<GdipGetAdjustableArrowCapWidth_delegate> GdipGetAdjustableArrowCapWidth_ptr;
-            internal static int GdipGetAdjustableArrowCapWidth(HandleRef adjustableArrowCap, out float width) => GdipGetAdjustableArrowCapWidth_ptr.Delegate(adjustableArrowCap, out width);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetAdjustableArrowCapWidth(HandleRef adjustableArrowCap, out float width);
 
-            private delegate int GdipSetAdjustableArrowCapMiddleInset_delegate(HandleRef adjustableArrowCap, float middleInset);
-            private static FunctionWrapper<GdipSetAdjustableArrowCapMiddleInset_delegate> GdipSetAdjustableArrowCapMiddleInset_ptr;
-            internal static int GdipSetAdjustableArrowCapMiddleInset(HandleRef adjustableArrowCap, float middleInset) => GdipSetAdjustableArrowCapMiddleInset_ptr.Delegate(adjustableArrowCap, middleInset);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetAdjustableArrowCapMiddleInset(HandleRef adjustableArrowCap, float middleInset);
 
-            private delegate int GdipGetAdjustableArrowCapMiddleInset_delegate(HandleRef adjustableArrowCap, out float middleInset);
-            private static FunctionWrapper<GdipGetAdjustableArrowCapMiddleInset_delegate> GdipGetAdjustableArrowCapMiddleInset_ptr;
-            internal static int GdipGetAdjustableArrowCapMiddleInset(HandleRef adjustableArrowCap, out float middleInset) => GdipGetAdjustableArrowCapMiddleInset_ptr.Delegate(adjustableArrowCap, out middleInset);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetAdjustableArrowCapMiddleInset(HandleRef adjustableArrowCap, out float middleInset);
 
-            private delegate int GdipSetAdjustableArrowCapFillState_delegate(HandleRef adjustableArrowCap, bool fillState);
-            private static FunctionWrapper<GdipSetAdjustableArrowCapFillState_delegate> GdipSetAdjustableArrowCapFillState_ptr;
-            internal static int GdipSetAdjustableArrowCapFillState(HandleRef adjustableArrowCap, bool fillState) => GdipSetAdjustableArrowCapFillState_ptr.Delegate(adjustableArrowCap, fillState);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetAdjustableArrowCapFillState(HandleRef adjustableArrowCap, bool fillState);
 
-            private delegate int GdipGetAdjustableArrowCapFillState_delegate(HandleRef adjustableArrowCap, out bool fillState);
-            private static FunctionWrapper<GdipGetAdjustableArrowCapFillState_delegate> GdipGetAdjustableArrowCapFillState_ptr;
-            internal static int GdipGetAdjustableArrowCapFillState(HandleRef adjustableArrowCap, out bool fillState) => GdipGetAdjustableArrowCapFillState_ptr.Delegate(adjustableArrowCap, out fillState);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetAdjustableArrowCapFillState(HandleRef adjustableArrowCap, out bool fillState);
 
-            private delegate int GdipGetCustomLineCapType_delegate(HandleRef customCap, out CustomLineCapType capType);
-            private static FunctionWrapper<GdipGetCustomLineCapType_delegate> GdipGetCustomLineCapType_ptr;
-            internal static int GdipGetCustomLineCapType(HandleRef customCap, out CustomLineCapType capType) => GdipGetCustomLineCapType_ptr.Delegate(customCap, out capType);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetCustomLineCapType(HandleRef customCap, out CustomLineCapType capType);
 
-            private delegate int GdipCreateCustomLineCap_delegate(HandleRef fillpath, HandleRef strokepath, LineCap baseCap, float baseInset, out IntPtr customCap);
-            private static FunctionWrapper<GdipCreateCustomLineCap_delegate> GdipCreateCustomLineCap_ptr;
-            internal static int GdipCreateCustomLineCap(HandleRef fillpath, HandleRef strokepath, LineCap baseCap, float baseInset, out IntPtr customCap) => GdipCreateCustomLineCap_ptr.Delegate(fillpath, strokepath, baseCap, baseInset, out customCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateCustomLineCap(HandleRef fillpath, HandleRef strokepath, LineCap baseCap, float baseInset, out IntPtr customCap);
 
-            private delegate int GdipDeleteCustomLineCap_delegate(HandleRef customCap);
-            private static FunctionWrapper<GdipDeleteCustomLineCap_delegate> GdipDeleteCustomLineCap_ptr;
-            internal static int IntGdipDeleteCustomLineCap(HandleRef customCap) => GdipDeleteCustomLineCap_ptr.Delegate(customCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeleteCustomLineCap(HandleRef customCap);
 
-            private delegate int GdipCloneCustomLineCap_delegate(HandleRef customCap, out IntPtr clonedCap);
-            private static FunctionWrapper<GdipCloneCustomLineCap_delegate> GdipCloneCustomLineCap_ptr;
-            internal static int GdipCloneCustomLineCap(HandleRef customCap, out IntPtr clonedCap) => GdipCloneCustomLineCap_ptr.Delegate(customCap, out clonedCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCloneCustomLineCap(HandleRef customCap, out IntPtr clonedCap);
 
-            private delegate int GdipSetCustomLineCapStrokeCaps_delegate(HandleRef customCap, LineCap startCap, LineCap endCap);
-            private static FunctionWrapper<GdipSetCustomLineCapStrokeCaps_delegate> GdipSetCustomLineCapStrokeCaps_ptr;
-            internal static int GdipSetCustomLineCapStrokeCaps(HandleRef customCap, LineCap startCap, LineCap endCap) => GdipSetCustomLineCapStrokeCaps_ptr.Delegate(customCap, startCap, endCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetCustomLineCapStrokeCaps(HandleRef customCap, LineCap startCap, LineCap endCap);
 
-            private delegate int GdipGetCustomLineCapStrokeCaps_delegate(HandleRef customCap, out LineCap startCap, out LineCap endCap);
-            private static FunctionWrapper<GdipGetCustomLineCapStrokeCaps_delegate> GdipGetCustomLineCapStrokeCaps_ptr;
-            internal static int GdipGetCustomLineCapStrokeCaps(HandleRef customCap, out LineCap startCap, out LineCap endCap) => GdipGetCustomLineCapStrokeCaps_ptr.Delegate(customCap, out startCap, out endCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetCustomLineCapStrokeCaps(HandleRef customCap, out LineCap startCap, out LineCap endCap);
 
-            private delegate int GdipSetCustomLineCapStrokeJoin_delegate(HandleRef customCap, LineJoin lineJoin);
-            private static FunctionWrapper<GdipSetCustomLineCapStrokeJoin_delegate> GdipSetCustomLineCapStrokeJoin_ptr;
-            internal static int GdipSetCustomLineCapStrokeJoin(HandleRef customCap, LineJoin lineJoin) => GdipSetCustomLineCapStrokeJoin_ptr.Delegate(customCap, lineJoin);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetCustomLineCapStrokeJoin(HandleRef customCap, LineJoin lineJoin);
 
-            private delegate int GdipGetCustomLineCapStrokeJoin_delegate(HandleRef customCap, out LineJoin lineJoin);
-            private static FunctionWrapper<GdipGetCustomLineCapStrokeJoin_delegate> GdipGetCustomLineCapStrokeJoin_ptr;
-            internal static int GdipGetCustomLineCapStrokeJoin(HandleRef customCap, out LineJoin lineJoin) => GdipGetCustomLineCapStrokeJoin_ptr.Delegate(customCap, out lineJoin);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetCustomLineCapStrokeJoin(HandleRef customCap, out LineJoin lineJoin);
 
-            private delegate int GdipSetCustomLineCapBaseCap_delegate(HandleRef customCap, LineCap baseCap);
-            private static FunctionWrapper<GdipSetCustomLineCapBaseCap_delegate> GdipSetCustomLineCapBaseCap_ptr;
-            internal static int GdipSetCustomLineCapBaseCap(HandleRef customCap, LineCap baseCap) => GdipSetCustomLineCapBaseCap_ptr.Delegate(customCap, baseCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetCustomLineCapBaseCap(HandleRef customCap, LineCap baseCap);
 
-            private delegate int GdipGetCustomLineCapBaseCap_delegate(HandleRef customCap, out LineCap baseCap);
-            private static FunctionWrapper<GdipGetCustomLineCapBaseCap_delegate> GdipGetCustomLineCapBaseCap_ptr;
-            internal static int GdipGetCustomLineCapBaseCap(HandleRef customCap, out LineCap baseCap) => GdipGetCustomLineCapBaseCap_ptr.Delegate(customCap, out baseCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetCustomLineCapBaseCap(HandleRef customCap, out LineCap baseCap);
 
-            private delegate int GdipSetCustomLineCapBaseInset_delegate(HandleRef customCap, float inset);
-            private static FunctionWrapper<GdipSetCustomLineCapBaseInset_delegate> GdipSetCustomLineCapBaseInset_ptr;
-            internal static int GdipSetCustomLineCapBaseInset(HandleRef customCap, float inset) => GdipSetCustomLineCapBaseInset_ptr.Delegate(customCap, inset);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetCustomLineCapBaseInset(HandleRef customCap, float inset);
 
-            private delegate int GdipGetCustomLineCapBaseInset_delegate(HandleRef customCap, out float inset);
-            private static FunctionWrapper<GdipGetCustomLineCapBaseInset_delegate> GdipGetCustomLineCapBaseInset_ptr;
-            internal static int GdipGetCustomLineCapBaseInset(HandleRef customCap, out float inset) => GdipGetCustomLineCapBaseInset_ptr.Delegate(customCap, out inset);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetCustomLineCapBaseInset(HandleRef customCap, out float inset);
 
-            private delegate int GdipSetCustomLineCapWidthScale_delegate(HandleRef customCap, float widthScale);
-            private static FunctionWrapper<GdipSetCustomLineCapWidthScale_delegate> GdipSetCustomLineCapWidthScale_ptr;
-            internal static int GdipSetCustomLineCapWidthScale(HandleRef customCap, float widthScale) => GdipSetCustomLineCapWidthScale_ptr.Delegate(customCap, widthScale);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetCustomLineCapWidthScale(HandleRef customCap, float widthScale);
 
-            private delegate int GdipGetCustomLineCapWidthScale_delegate(HandleRef customCap, out float widthScale);
-            private static FunctionWrapper<GdipGetCustomLineCapWidthScale_delegate> GdipGetCustomLineCapWidthScale_ptr;
-            internal static int GdipGetCustomLineCapWidthScale(HandleRef customCap, out float widthScale) => GdipGetCustomLineCapWidthScale_ptr.Delegate(customCap, out widthScale);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetCustomLineCapWidthScale(HandleRef customCap, out float widthScale);
 
-            private delegate int GdipCreatePathIter_delegate(out IntPtr pathIter, HandleRef path);
-            private static FunctionWrapper<GdipCreatePathIter_delegate> GdipCreatePathIter_ptr;
-            internal static int GdipCreatePathIter(out IntPtr pathIter, HandleRef path) => GdipCreatePathIter_ptr.Delegate(out pathIter, path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreatePathIter(out IntPtr pathIter, HandleRef path);
 
-            private delegate int GdipDeletePathIter_delegate(HandleRef pathIter);
-            private static FunctionWrapper<GdipDeletePathIter_delegate> GdipDeletePathIter_ptr;
-            internal static int IntGdipDeletePathIter(HandleRef pathIter) => GdipDeletePathIter_ptr.Delegate(pathIter);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeletePathIter(HandleRef pathIter);
 
-            private delegate int GdipPathIterNextSubpath_delegate(HandleRef pathIter, out int resultCount, out int startIndex, out int endIndex, out bool isClosed);
-            private static FunctionWrapper<GdipPathIterNextSubpath_delegate> GdipPathIterNextSubpath_ptr;
-            internal static int GdipPathIterNextSubpath(HandleRef pathIter, out int resultCount, out int startIndex, out int endIndex, out bool isClosed) => GdipPathIterNextSubpath_ptr.Delegate(pathIter, out resultCount, out startIndex, out endIndex, out isClosed);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipPathIterNextSubpath(HandleRef pathIter, out int resultCount, out int startIndex, out int endIndex, out bool isClosed);
 
-            private delegate int GdipPathIterNextSubpathPath_delegate(HandleRef pathIter, out int resultCount, HandleRef path, out bool isClosed);
-            private static FunctionWrapper<GdipPathIterNextSubpathPath_delegate> GdipPathIterNextSubpathPath_ptr;
-            internal static int GdipPathIterNextSubpathPath(HandleRef pathIter, out int resultCount, HandleRef path, out bool isClosed) => GdipPathIterNextSubpathPath_ptr.Delegate(pathIter, out resultCount, path, out isClosed);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipPathIterNextSubpathPath(HandleRef pathIter, out int resultCount, HandleRef path, out bool isClosed);
 
-            private delegate int GdipPathIterNextPathType_delegate(HandleRef pathIter, out int resultCount, out byte pathType, out int startIndex, out int endIndex);
-            private static FunctionWrapper<GdipPathIterNextPathType_delegate> GdipPathIterNextPathType_ptr;
-            internal static int GdipPathIterNextPathType(HandleRef pathIter, out int resultCount, out byte pathType, out int startIndex, out int endIndex) => GdipPathIterNextPathType_ptr.Delegate(pathIter, out resultCount, out pathType, out startIndex, out endIndex);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipPathIterNextPathType(HandleRef pathIter, out int resultCount, out byte pathType, out int startIndex, out int endIndex);
 
-            private delegate int GdipPathIterNextMarker_delegate(HandleRef pathIter, out int resultCount, out int startIndex, out int endIndex);
-            private static FunctionWrapper<GdipPathIterNextMarker_delegate> GdipPathIterNextMarker_ptr;
-            internal static int GdipPathIterNextMarker(HandleRef pathIter, out int resultCount, out int startIndex, out int endIndex) => GdipPathIterNextMarker_ptr.Delegate(pathIter, out resultCount, out startIndex, out endIndex);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipPathIterNextMarker(HandleRef pathIter, out int resultCount, out int startIndex, out int endIndex);
 
-            private delegate int GdipPathIterNextMarkerPath_delegate(HandleRef pathIter, out int resultCount, HandleRef path);
-            private static FunctionWrapper<GdipPathIterNextMarkerPath_delegate> GdipPathIterNextMarkerPath_ptr;
-            internal static int GdipPathIterNextMarkerPath(HandleRef pathIter, out int resultCount, HandleRef path) => GdipPathIterNextMarkerPath_ptr.Delegate(pathIter, out resultCount, path);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipPathIterNextMarkerPath(HandleRef pathIter, out int resultCount, HandleRef path);
 
-            private delegate int GdipPathIterGetCount_delegate(HandleRef pathIter, out int count);
-            private static FunctionWrapper<GdipPathIterGetCount_delegate> GdipPathIterGetCount_ptr;
-            internal static int GdipPathIterGetCount(HandleRef pathIter, out int count) => GdipPathIterGetCount_ptr.Delegate(pathIter, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipPathIterGetCount(HandleRef pathIter, out int count);
 
-            private delegate int GdipPathIterGetSubpathCount_delegate(HandleRef pathIter, out int count);
-            private static FunctionWrapper<GdipPathIterGetSubpathCount_delegate> GdipPathIterGetSubpathCount_ptr;
-            internal static int GdipPathIterGetSubpathCount(HandleRef pathIter, out int count) => GdipPathIterGetSubpathCount_ptr.Delegate(pathIter, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipPathIterGetSubpathCount(HandleRef pathIter, out int count);
 
-            private delegate int GdipPathIterHasCurve_delegate(HandleRef pathIter, out bool hasCurve);
-            private static FunctionWrapper<GdipPathIterHasCurve_delegate> GdipPathIterHasCurve_ptr;
-            internal static int GdipPathIterHasCurve(HandleRef pathIter, out bool hasCurve) => GdipPathIterHasCurve_ptr.Delegate(pathIter, out hasCurve);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipPathIterHasCurve(HandleRef pathIter, out bool hasCurve);
 
-            private delegate int GdipPathIterRewind_delegate(HandleRef pathIter);
-            private static FunctionWrapper<GdipPathIterRewind_delegate> GdipPathIterRewind_ptr;
-            internal static int GdipPathIterRewind(HandleRef pathIter) => GdipPathIterRewind_ptr.Delegate(pathIter);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipPathIterRewind(HandleRef pathIter);
 
-            private delegate int GdipPathIterEnumerate_delegate(HandleRef pathIter, out int resultCount, PointF* points, byte* types, int count);
-            private static FunctionWrapper<GdipPathIterEnumerate_delegate> GdipPathIterEnumerate_ptr;
-            internal static int GdipPathIterEnumerate(HandleRef pathIter, out int resultCount, PointF* points, byte* types, int count) => GdipPathIterEnumerate_ptr.Delegate(pathIter, out resultCount, points, types, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipPathIterEnumerate(HandleRef pathIter, out int resultCount, PointF* points, byte* types, int count);
 
-            private delegate int GdipPathIterCopyData_delegate(HandleRef pathIter, out int resultCount, PointF* memoryPts, byte* types, int startIndex, int endIndex);
-            private static FunctionWrapper<GdipPathIterCopyData_delegate> GdipPathIterCopyData_ptr;
-            internal static int GdipPathIterCopyData(HandleRef pathIter, out int resultCount, PointF* points, byte* types, int startIndex, int endIndex) => GdipPathIterCopyData_ptr.Delegate(pathIter, out resultCount, points, types, startIndex, endIndex);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipPathIterCopyData(HandleRef pathIter, out int resultCount, PointF* points, byte* types, int startIndex, int endIndex);
 
-            private delegate int GdipCreateHatchBrush_delegate(int hatchstyle, int forecol, int backcol, out IntPtr brush);
-            private static FunctionWrapper<GdipCreateHatchBrush_delegate> GdipCreateHatchBrush_ptr;
-            internal static int GdipCreateHatchBrush(int hatchstyle, int forecol, int backcol, out IntPtr brush) => GdipCreateHatchBrush_ptr.Delegate(hatchstyle, forecol, backcol, out brush);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateHatchBrush(int hatchstyle, int forecol, int backcol, out IntPtr brush);
 
-            private delegate int GdipGetHatchStyle_delegate(HandleRef brush, out int hatchstyle);
-            private static FunctionWrapper<GdipGetHatchStyle_delegate> GdipGetHatchStyle_ptr;
-            internal static int GdipGetHatchStyle(HandleRef brush, out int hatchstyle) => GdipGetHatchStyle_ptr.Delegate(brush, out hatchstyle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetHatchStyle(HandleRef brush, out int hatchstyle);
 
-            private delegate int GdipGetHatchForegroundColor_delegate(HandleRef brush, out int forecol);
-            private static FunctionWrapper<GdipGetHatchForegroundColor_delegate> GdipGetHatchForegroundColor_ptr;
-            internal static int GdipGetHatchForegroundColor(HandleRef brush, out int forecol) => GdipGetHatchForegroundColor_ptr.Delegate(brush, out forecol);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetHatchForegroundColor(HandleRef brush, out int forecol);
 
-            private delegate int GdipGetHatchBackgroundColor_delegate(HandleRef brush, out int backcol);
-            private static FunctionWrapper<GdipGetHatchBackgroundColor_delegate> GdipGetHatchBackgroundColor_ptr;
-            internal static int GdipGetHatchBackgroundColor(HandleRef brush, out int backcol) => GdipGetHatchBackgroundColor_ptr.Delegate(brush, out backcol);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetHatchBackgroundColor(HandleRef brush, out int backcol);
 
-            private delegate int GdipCloneBrush_delegate(HandleRef brush, out IntPtr clonebrush);
-            private static FunctionWrapper<GdipCloneBrush_delegate> GdipCloneBrush_ptr;
-            internal static int GdipCloneBrush(HandleRef brush, out IntPtr clonebrush) => GdipCloneBrush_ptr.Delegate(brush, out clonebrush);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCloneBrush(HandleRef brush, out IntPtr clonebrush);
 
-            private delegate int GdipCreateLineBrush_delegate(ref PointF point1, ref PointF point2, int color1, int color2, WrapMode wrapMode, out IntPtr lineGradient);
-            private static FunctionWrapper<GdipCreateLineBrush_delegate> GdipCreateLineBrush_ptr;
-            internal static int GdipCreateLineBrush(ref PointF point1, ref PointF point2, int color1, int color2, WrapMode wrapMode, out IntPtr lineGradient) => GdipCreateLineBrush_ptr.Delegate(ref point1, ref point2, color1, color2, wrapMode, out lineGradient);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateLineBrush(ref PointF point1, ref PointF point2, int color1, int color2, WrapMode wrapMode, out IntPtr lineGradient);
 
-            private delegate int GdipCreateLineBrushI_delegate(ref Point point1, ref Point point2, int color1, int color2, WrapMode wrapMode, out IntPtr lineGradient);
-            private static FunctionWrapper<GdipCreateLineBrushI_delegate> GdipCreateLineBrushI_ptr;
-            internal static int GdipCreateLineBrushI(ref Point point1, ref Point point2, int color1, int color2, WrapMode wrapMode, out IntPtr lineGradient) => GdipCreateLineBrushI_ptr.Delegate(ref point1, ref point2, color1, color2, wrapMode, out lineGradient);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateLineBrushI(ref Point point1, ref Point point2, int color1, int color2, WrapMode wrapMode, out IntPtr lineGradient);
 
-            private delegate int GdipCreateLineBrushFromRect_delegate(ref RectangleF rect, int color1, int color2, LinearGradientMode lineGradientMode, WrapMode wrapMode, out IntPtr lineGradient);
-            private static FunctionWrapper<GdipCreateLineBrushFromRect_delegate> GdipCreateLineBrushFromRect_ptr;
-            internal static int GdipCreateLineBrushFromRect(ref RectangleF rect, int color1, int color2, LinearGradientMode lineGradientMode, WrapMode wrapMode, out IntPtr lineGradient) => GdipCreateLineBrushFromRect_ptr.Delegate(ref rect, color1, color2, lineGradientMode, wrapMode, out lineGradient);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateLineBrushFromRect(ref RectangleF rect, int color1, int color2, LinearGradientMode lineGradientMode, WrapMode wrapMode, out IntPtr lineGradient);
 
-            private delegate int GdipCreateLineBrushFromRectI_delegate(ref Rectangle rect, int color1, int color2, LinearGradientMode lineGradientMode, WrapMode wrapMode, out IntPtr lineGradient);
-            private static FunctionWrapper<GdipCreateLineBrushFromRectI_delegate> GdipCreateLineBrushFromRectI_ptr;
-            internal static int GdipCreateLineBrushFromRectI(ref Rectangle rect, int color1, int color2, LinearGradientMode lineGradientMode, WrapMode wrapMode, out IntPtr lineGradient) => GdipCreateLineBrushFromRectI_ptr.Delegate(ref rect, color1, color2, lineGradientMode, wrapMode, out lineGradient);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateLineBrushFromRectI(ref Rectangle rect, int color1, int color2, LinearGradientMode lineGradientMode, WrapMode wrapMode, out IntPtr lineGradient);
 
-            private delegate int GdipCreateLineBrushFromRectWithAngle_delegate(ref RectangleF rect, int color1, int color2, float angle, bool isAngleScaleable, WrapMode wrapMode, out IntPtr lineGradient);
-            private static FunctionWrapper<GdipCreateLineBrushFromRectWithAngle_delegate> GdipCreateLineBrushFromRectWithAngle_ptr;
-            internal static int GdipCreateLineBrushFromRectWithAngle(ref RectangleF rect, int color1, int color2, float angle, bool isAngleScaleable, WrapMode wrapMode, out IntPtr lineGradient) => GdipCreateLineBrushFromRectWithAngle_ptr.Delegate(ref rect, color1, color2, angle, isAngleScaleable, wrapMode, out lineGradient);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateLineBrushFromRectWithAngle(ref RectangleF rect, int color1, int color2, float angle, bool isAngleScaleable, WrapMode wrapMode, out IntPtr lineGradient);
 
-            private delegate int GdipCreateLineBrushFromRectWithAngleI_delegate(ref Rectangle rect, int color1, int color2, float angle, bool isAngleScaleable, WrapMode wrapMode, out IntPtr lineGradient);
-            private static FunctionWrapper<GdipCreateLineBrushFromRectWithAngleI_delegate> GdipCreateLineBrushFromRectWithAngleI_ptr;
-            internal static int GdipCreateLineBrushFromRectWithAngleI(ref Rectangle rect, int color1, int color2, float angle, bool isAngleScaleable, WrapMode wrapMode, out IntPtr lineGradient) => GdipCreateLineBrushFromRectWithAngleI_ptr.Delegate(ref rect, color1, color2, angle, isAngleScaleable, wrapMode, out lineGradient);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateLineBrushFromRectWithAngleI(ref Rectangle rect, int color1, int color2, float angle, bool isAngleScaleable, WrapMode wrapMode, out IntPtr lineGradient);
 
-            private delegate int GdipSetLineColors_delegate(HandleRef brush, int color1, int color2);
-            private static FunctionWrapper<GdipSetLineColors_delegate> GdipSetLineColors_ptr;
-            internal static int GdipSetLineColors(HandleRef brush, int color1, int color2) => GdipSetLineColors_ptr.Delegate(brush, color1, color2);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetLineColors(HandleRef brush, int color1, int color2);
 
-            private delegate int GdipGetLineColors_delegate(HandleRef brush, int[] colors);
-            private static FunctionWrapper<GdipGetLineColors_delegate> GdipGetLineColors_ptr;
-            internal static int GdipGetLineColors(HandleRef brush, int[] colors) => GdipGetLineColors_ptr.Delegate(brush, colors);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetLineColors(HandleRef brush, int[] colors);
 
-            private delegate int GdipGetLineRect_delegate(HandleRef brush, out RectangleF gprectf);
-            private static FunctionWrapper<GdipGetLineRect_delegate> GdipGetLineRect_ptr;
-            internal static int GdipGetLineRect(HandleRef brush, out RectangleF gprectf) => GdipGetLineRect_ptr.Delegate(brush, out gprectf);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetLineRect(HandleRef brush, out RectangleF gprectf);
 
-            private delegate int GdipGetLineGammaCorrection_delegate(HandleRef brush, out bool useGammaCorrection);
-            private static FunctionWrapper<GdipGetLineGammaCorrection_delegate> GdipGetLineGammaCorrection_ptr;
-            internal static int GdipGetLineGammaCorrection(HandleRef brush, out bool useGammaCorrection) => GdipGetLineGammaCorrection_ptr.Delegate(brush, out useGammaCorrection);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetLineGammaCorrection(HandleRef brush, out bool useGammaCorrection);
 
-            private delegate int GdipSetLineGammaCorrection_delegate(HandleRef brush, bool useGammaCorrection);
-            private static FunctionWrapper<GdipSetLineGammaCorrection_delegate> GdipSetLineGammaCorrection_ptr;
-            internal static int GdipSetLineGammaCorrection(HandleRef brush, bool useGammaCorrection) => GdipSetLineGammaCorrection_ptr.Delegate(brush, useGammaCorrection);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetLineGammaCorrection(HandleRef brush, bool useGammaCorrection);
 
-            private delegate int GdipSetLineSigmaBlend_delegate(HandleRef brush, float focus, float scale);
-            private static FunctionWrapper<GdipSetLineSigmaBlend_delegate> GdipSetLineSigmaBlend_ptr;
-            internal static int GdipSetLineSigmaBlend(HandleRef brush, float focus, float scale) => GdipSetLineSigmaBlend_ptr.Delegate(brush, focus, scale);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetLineSigmaBlend(HandleRef brush, float focus, float scale);
 
-            private delegate int GdipSetLineLinearBlend_delegate(HandleRef brush, float focus, float scale);
-            private static FunctionWrapper<GdipSetLineLinearBlend_delegate> GdipSetLineLinearBlend_ptr;
-            internal static int GdipSetLineLinearBlend(HandleRef brush, float focus, float scale) => GdipSetLineLinearBlend_ptr.Delegate(brush, focus, scale);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetLineLinearBlend(HandleRef brush, float focus, float scale);
 
-            private delegate int GdipGetLineBlendCount_delegate(HandleRef brush, out int count);
-            private static FunctionWrapper<GdipGetLineBlendCount_delegate> GdipGetLineBlendCount_ptr;
-            internal static int GdipGetLineBlendCount(HandleRef brush, out int count) => GdipGetLineBlendCount_ptr.Delegate(brush, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetLineBlendCount(HandleRef brush, out int count);
 
-            private delegate int GdipGetLineBlend_delegate(HandleRef brush, IntPtr blend, IntPtr positions, int count);
-            private static FunctionWrapper<GdipGetLineBlend_delegate> GdipGetLineBlend_ptr;
-            internal static int GdipGetLineBlend(HandleRef brush, IntPtr blend, IntPtr positions, int count) => GdipGetLineBlend_ptr.Delegate(brush, blend, positions, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetLineBlend(HandleRef brush, IntPtr blend, IntPtr positions, int count);
 
-            private delegate int GdipSetLineBlend_delegate(HandleRef brush, HandleRef blend, HandleRef positions, int count);
-            private static FunctionWrapper<GdipSetLineBlend_delegate> GdipSetLineBlend_ptr;
-            internal static int GdipSetLineBlend(HandleRef brush, HandleRef blend, HandleRef positions, int count) => GdipSetLineBlend_ptr.Delegate(brush, blend, positions, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetLineBlend(HandleRef brush, HandleRef blend, HandleRef positions, int count);
 
-            private delegate int GdipGetLinePresetBlendCount_delegate(HandleRef brush, out int count);
-            private static FunctionWrapper<GdipGetLinePresetBlendCount_delegate> GdipGetLinePresetBlendCount_ptr;
-            internal static int GdipGetLinePresetBlendCount(HandleRef brush, out int count) => GdipGetLinePresetBlendCount_ptr.Delegate(brush, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetLinePresetBlendCount(HandleRef brush, out int count);
 
-            private delegate int GdipGetLinePresetBlend_delegate(HandleRef brush, IntPtr blend, IntPtr positions, int count);
-            private static FunctionWrapper<GdipGetLinePresetBlend_delegate> GdipGetLinePresetBlend_ptr;
-            internal static int GdipGetLinePresetBlend(HandleRef brush, IntPtr blend, IntPtr positions, int count) => GdipGetLinePresetBlend_ptr.Delegate(brush, blend, positions, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetLinePresetBlend(HandleRef brush, IntPtr blend, IntPtr positions, int count);
 
-            private delegate int GdipSetLinePresetBlend_delegate(HandleRef brush, HandleRef blend, HandleRef positions, int count);
-            private static FunctionWrapper<GdipSetLinePresetBlend_delegate> GdipSetLinePresetBlend_ptr;
-            internal static int GdipSetLinePresetBlend(HandleRef brush, HandleRef blend, HandleRef positions, int count) => GdipSetLinePresetBlend_ptr.Delegate(brush, blend, positions, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetLinePresetBlend(HandleRef brush, HandleRef blend, HandleRef positions, int count);
 
-            private delegate int GdipSetLineWrapMode_delegate(HandleRef brush, int wrapMode);
-            private static FunctionWrapper<GdipSetLineWrapMode_delegate> GdipSetLineWrapMode_ptr;
-            internal static int GdipSetLineWrapMode(HandleRef brush, int wrapMode) => GdipSetLineWrapMode_ptr.Delegate(brush, wrapMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetLineWrapMode(HandleRef brush, int wrapMode);
 
-            private delegate int GdipGetLineWrapMode_delegate(HandleRef brush, out int wrapMode);
-            private static FunctionWrapper<GdipGetLineWrapMode_delegate> GdipGetLineWrapMode_ptr;
-            internal static int GdipGetLineWrapMode(HandleRef brush, out int wrapMode) => GdipGetLineWrapMode_ptr.Delegate(brush, out wrapMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetLineWrapMode(HandleRef brush, out int wrapMode);
 
-            private delegate int GdipResetLineTransform_delegate(HandleRef brush);
-            private static FunctionWrapper<GdipResetLineTransform_delegate> GdipResetLineTransform_ptr;
-            internal static int GdipResetLineTransform(HandleRef brush) => GdipResetLineTransform_ptr.Delegate(brush);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipResetLineTransform(HandleRef brush);
 
-            private delegate int GdipMultiplyLineTransform_delegate(HandleRef brush, HandleRef matrix, MatrixOrder order);
-            private static FunctionWrapper<GdipMultiplyLineTransform_delegate> GdipMultiplyLineTransform_ptr;
-            internal static int GdipMultiplyLineTransform(HandleRef brush, HandleRef matrix, MatrixOrder order) => GdipMultiplyLineTransform_ptr.Delegate(brush, matrix, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipMultiplyLineTransform(HandleRef brush, HandleRef matrix, MatrixOrder order);
 
-            private delegate int GdipGetLineTransform_delegate(HandleRef brush, HandleRef matrix);
-            private static FunctionWrapper<GdipGetLineTransform_delegate> GdipGetLineTransform_ptr;
-            internal static int GdipGetLineTransform(HandleRef brush, HandleRef matrix) => GdipGetLineTransform_ptr.Delegate(brush, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetLineTransform(HandleRef brush, HandleRef matrix);
 
-            private delegate int GdipSetLineTransform_delegate(HandleRef brush, HandleRef matrix);
-            private static FunctionWrapper<GdipSetLineTransform_delegate> GdipSetLineTransform_ptr;
-            internal static int GdipSetLineTransform(HandleRef brush, HandleRef matrix) => GdipSetLineTransform_ptr.Delegate(brush, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetLineTransform(HandleRef brush, HandleRef matrix);
 
-            private delegate int GdipTranslateLineTransform_delegate(HandleRef brush, float dx, float dy, MatrixOrder order);
-            private static FunctionWrapper<GdipTranslateLineTransform_delegate> GdipTranslateLineTransform_ptr;
-            internal static int GdipTranslateLineTransform(HandleRef brush, float dx, float dy, MatrixOrder order) => GdipTranslateLineTransform_ptr.Delegate(brush, dx, dy, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTranslateLineTransform(HandleRef brush, float dx, float dy, MatrixOrder order);
 
-            private delegate int GdipScaleLineTransform_delegate(HandleRef brush, float sx, float sy, MatrixOrder order);
-            private static FunctionWrapper<GdipScaleLineTransform_delegate> GdipScaleLineTransform_ptr;
-            internal static int GdipScaleLineTransform(HandleRef brush, float sx, float sy, MatrixOrder order) => GdipScaleLineTransform_ptr.Delegate(brush, sx, sy, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipScaleLineTransform(HandleRef brush, float sx, float sy, MatrixOrder order);
 
-            private delegate int GdipRotateLineTransform_delegate(HandleRef brush, float angle, MatrixOrder order);
-            private static FunctionWrapper<GdipRotateLineTransform_delegate> GdipRotateLineTransform_ptr;
-            internal static int GdipRotateLineTransform(HandleRef brush, float angle, MatrixOrder order) => GdipRotateLineTransform_ptr.Delegate(brush, angle, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipRotateLineTransform(HandleRef brush, float angle, MatrixOrder order);
 
-            private delegate int GdipCreatePathGradient_delegate(PointF* points, int count, WrapMode wrapMode, out IntPtr brush);
-            private static FunctionWrapper<GdipCreatePathGradient_delegate> GdipCreatePathGradient_ptr;
-            internal static int GdipCreatePathGradient(PointF* points, int count, WrapMode wrapMode, out IntPtr brush) => GdipCreatePathGradient_ptr.Delegate(points, count, wrapMode, out brush);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreatePathGradient(PointF* points, int count, WrapMode wrapMode, out IntPtr brush);
 
-            private delegate int GdipCreatePathGradientI_delegate(Point* points, int count, WrapMode wrapMode, out IntPtr brush);
-            private static FunctionWrapper<GdipCreatePathGradientI_delegate> GdipCreatePathGradientI_ptr;
-            internal static int GdipCreatePathGradientI(Point* points, int count, WrapMode wrapMode, out IntPtr brush) => GdipCreatePathGradientI_ptr.Delegate(points, count, wrapMode, out brush);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreatePathGradientI(Point* points, int count, WrapMode wrapMode, out IntPtr brush);
 
-            private delegate int GdipCreatePathGradientFromPath_delegate(HandleRef path, out IntPtr brush);
-            private static FunctionWrapper<GdipCreatePathGradientFromPath_delegate> GdipCreatePathGradientFromPath_ptr;
-            internal static int GdipCreatePathGradientFromPath(HandleRef path, out IntPtr brush) => GdipCreatePathGradientFromPath_ptr.Delegate(path, out brush);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreatePathGradientFromPath(HandleRef path, out IntPtr brush);
 
-            private delegate int GdipGetPathGradientCenterColor_delegate(HandleRef brush, out int color);
-            private static FunctionWrapper<GdipGetPathGradientCenterColor_delegate> GdipGetPathGradientCenterColor_ptr;
-            internal static int GdipGetPathGradientCenterColor(HandleRef brush, out int color) => GdipGetPathGradientCenterColor_ptr.Delegate(brush, out color);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathGradientCenterColor(HandleRef brush, out int color);
 
-            private delegate int GdipSetPathGradientCenterColor_delegate(HandleRef brush, int color);
-            private static FunctionWrapper<GdipSetPathGradientCenterColor_delegate> GdipSetPathGradientCenterColor_ptr;
-            internal static int GdipSetPathGradientCenterColor(HandleRef brush, int color) => GdipSetPathGradientCenterColor_ptr.Delegate(brush, color);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPathGradientCenterColor(HandleRef brush, int color);
 
-            private delegate int GdipGetPathGradientSurroundColorsWithCount_delegate(HandleRef brush, int[] color, ref int count);
-            private static FunctionWrapper<GdipGetPathGradientSurroundColorsWithCount_delegate> GdipGetPathGradientSurroundColorsWithCount_ptr;
-            internal static int GdipGetPathGradientSurroundColorsWithCount(HandleRef brush, int[] color, ref int count) => GdipGetPathGradientSurroundColorsWithCount_ptr.Delegate(brush, color, ref count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathGradientSurroundColorsWithCount(HandleRef brush, int[] color, ref int count);
 
-            private delegate int GdipSetPathGradientSurroundColorsWithCount_delegate(HandleRef brush, int[] argb, ref int count);
-            private static FunctionWrapper<GdipSetPathGradientSurroundColorsWithCount_delegate> GdipSetPathGradientSurroundColorsWithCount_ptr;
-            internal static int GdipSetPathGradientSurroundColorsWithCount(HandleRef brush, int[] argb, ref int count) => GdipSetPathGradientSurroundColorsWithCount_ptr.Delegate(brush, argb, ref count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPathGradientSurroundColorsWithCount(HandleRef brush, int[] argb, ref int count);
 
-            private delegate int GdipGetPathGradientCenterPoint_delegate(HandleRef brush, out PointF point);
-            private static FunctionWrapper<GdipGetPathGradientCenterPoint_delegate> GdipGetPathGradientCenterPoint_ptr;
-            internal static int GdipGetPathGradientCenterPoint(HandleRef brush, out PointF point) => GdipGetPathGradientCenterPoint_ptr.Delegate(brush, out point);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathGradientCenterPoint(HandleRef brush, out PointF point);
 
-            private delegate int GdipSetPathGradientCenterPoint_delegate(HandleRef brush, ref PointF point);
-            private static FunctionWrapper<GdipSetPathGradientCenterPoint_delegate> GdipSetPathGradientCenterPoint_ptr;
-            internal static int GdipSetPathGradientCenterPoint(HandleRef brush, ref PointF point) => GdipSetPathGradientCenterPoint_ptr.Delegate(brush, ref point);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPathGradientCenterPoint(HandleRef brush, ref PointF point);
 
-            private delegate int GdipGetPathGradientRect_delegate(HandleRef brush, out RectangleF gprectf);
-            private static FunctionWrapper<GdipGetPathGradientRect_delegate> GdipGetPathGradientRect_ptr;
-            internal static int GdipGetPathGradientRect(HandleRef brush, out RectangleF gprectf) => GdipGetPathGradientRect_ptr.Delegate(brush, out gprectf);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathGradientRect(HandleRef brush, out RectangleF gprectf);
 
-            private delegate int GdipGetPathGradientPointCount_delegate(HandleRef brush, out int count);
-            private static FunctionWrapper<GdipGetPathGradientPointCount_delegate> GdipGetPathGradientPointCount_ptr;
-            internal static int GdipGetPathGradientPointCount(HandleRef brush, out int count) => GdipGetPathGradientPointCount_ptr.Delegate(brush, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathGradientPointCount(HandleRef brush, out int count);
 
-            private delegate int GdipGetPathGradientSurroundColorCount_delegate(HandleRef brush, out int count);
-            private static FunctionWrapper<GdipGetPathGradientSurroundColorCount_delegate> GdipGetPathGradientSurroundColorCount_ptr;
-            internal static int GdipGetPathGradientSurroundColorCount(HandleRef brush, out int count) => GdipGetPathGradientSurroundColorCount_ptr.Delegate(brush, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathGradientSurroundColorCount(HandleRef brush, out int count);
 
-            private delegate int GdipGetPathGradientBlendCount_delegate(HandleRef brush, out int count);
-            private static FunctionWrapper<GdipGetPathGradientBlendCount_delegate> GdipGetPathGradientBlendCount_ptr;
-            internal static int GdipGetPathGradientBlendCount(HandleRef brush, out int count) => GdipGetPathGradientBlendCount_ptr.Delegate(brush, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathGradientBlendCount(HandleRef brush, out int count);
 
-            private delegate int GdipGetPathGradientBlend_delegate(HandleRef brush, float[] blend, float[] positions, int count);
-            private static FunctionWrapper<GdipGetPathGradientBlend_delegate> GdipGetPathGradientBlend_ptr;
-            internal static int GdipGetPathGradientBlend(HandleRef brush, float[] blend, float[] positions, int count) => GdipGetPathGradientBlend_ptr.Delegate(brush, blend, positions, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathGradientBlend(HandleRef brush, float[] blend, float[] positions, int count);
 
-            private delegate int GdipSetPathGradientBlend_delegate(HandleRef brush, HandleRef blend, HandleRef positions, int count);
-            private static FunctionWrapper<GdipSetPathGradientBlend_delegate> GdipSetPathGradientBlend_ptr;
-            internal static int GdipSetPathGradientBlend(HandleRef brush, HandleRef blend, HandleRef positions, int count) => GdipSetPathGradientBlend_ptr.Delegate(brush, blend, positions, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPathGradientBlend(HandleRef brush, HandleRef blend, HandleRef positions, int count);
 
-            private delegate int GdipGetPathGradientPresetBlendCount_delegate(HandleRef brush, out int count);
-            private static FunctionWrapper<GdipGetPathGradientPresetBlendCount_delegate> GdipGetPathGradientPresetBlendCount_ptr;
-            internal static int GdipGetPathGradientPresetBlendCount(HandleRef brush, out int count) => GdipGetPathGradientPresetBlendCount_ptr.Delegate(brush, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathGradientPresetBlendCount(HandleRef brush, out int count);
 
-            private delegate int GdipGetPathGradientPresetBlend_delegate(HandleRef brush, int[] blend, float[] positions, int count);
-            private static FunctionWrapper<GdipGetPathGradientPresetBlend_delegate> GdipGetPathGradientPresetBlend_ptr;
-            internal static int GdipGetPathGradientPresetBlend(HandleRef brush, int[] blend, float[] positions, int count) => GdipGetPathGradientPresetBlend_ptr.Delegate(brush, blend, positions, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathGradientPresetBlend(HandleRef brush, int[] blend, float[] positions, int count);
 
-            private delegate int GdipSetPathGradientPresetBlend_delegate(HandleRef brush, int[] blend, float[] positions, int count);
-            private static FunctionWrapper<GdipSetPathGradientPresetBlend_delegate> GdipSetPathGradientPresetBlend_ptr;
-            internal static int GdipSetPathGradientPresetBlend(HandleRef brush, int[] blend, float[] positions, int count) => GdipSetPathGradientPresetBlend_ptr.Delegate(brush, blend, positions, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPathGradientPresetBlend(HandleRef brush, int[] blend, float[] positions, int count);
 
-            private delegate int GdipSetPathGradientSigmaBlend_delegate(HandleRef brush, float focus, float scale);
-            private static FunctionWrapper<GdipSetPathGradientSigmaBlend_delegate> GdipSetPathGradientSigmaBlend_ptr;
-            internal static int GdipSetPathGradientSigmaBlend(HandleRef brush, float focus, float scale) => GdipSetPathGradientSigmaBlend_ptr.Delegate(brush, focus, scale);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPathGradientSigmaBlend(HandleRef brush, float focus, float scale);
 
-            private delegate int GdipSetPathGradientLinearBlend_delegate(HandleRef brush, float focus, float scale);
-            private static FunctionWrapper<GdipSetPathGradientLinearBlend_delegate> GdipSetPathGradientLinearBlend_ptr;
-            internal static int GdipSetPathGradientLinearBlend(HandleRef brush, float focus, float scale) => GdipSetPathGradientLinearBlend_ptr.Delegate(brush, focus, scale);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPathGradientLinearBlend(HandleRef brush, float focus, float scale);
 
-            private delegate int GdipSetPathGradientWrapMode_delegate(HandleRef brush, int wrapmode);
-            private static FunctionWrapper<GdipSetPathGradientWrapMode_delegate> GdipSetPathGradientWrapMode_ptr;
-            internal static int GdipSetPathGradientWrapMode(HandleRef brush, int wrapmode) => GdipSetPathGradientWrapMode_ptr.Delegate(brush, wrapmode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPathGradientWrapMode(HandleRef brush, int wrapmode);
 
-            private delegate int GdipGetPathGradientWrapMode_delegate(HandleRef brush, out int wrapmode);
-            private static FunctionWrapper<GdipGetPathGradientWrapMode_delegate> GdipGetPathGradientWrapMode_ptr;
-            internal static int GdipGetPathGradientWrapMode(HandleRef brush, out int wrapmode) => GdipGetPathGradientWrapMode_ptr.Delegate(brush, out wrapmode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathGradientWrapMode(HandleRef brush, out int wrapmode);
 
-            private delegate int GdipSetPathGradientTransform_delegate(HandleRef brush, HandleRef matrix);
-            private static FunctionWrapper<GdipSetPathGradientTransform_delegate> GdipSetPathGradientTransform_ptr;
-            internal static int GdipSetPathGradientTransform(HandleRef brush, HandleRef matrix) => GdipSetPathGradientTransform_ptr.Delegate(brush, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPathGradientTransform(HandleRef brush, HandleRef matrix);
 
-            private delegate int GdipGetPathGradientTransform_delegate(HandleRef brush, HandleRef matrix);
-            private static FunctionWrapper<GdipGetPathGradientTransform_delegate> GdipGetPathGradientTransform_ptr;
-            internal static int GdipGetPathGradientTransform(HandleRef brush, HandleRef matrix) => GdipGetPathGradientTransform_ptr.Delegate(brush, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathGradientTransform(HandleRef brush, HandleRef matrix);
 
-            private delegate int GdipResetPathGradientTransform_delegate(HandleRef brush);
-            private static FunctionWrapper<GdipResetPathGradientTransform_delegate> GdipResetPathGradientTransform_ptr;
-            internal static int GdipResetPathGradientTransform(HandleRef brush) => GdipResetPathGradientTransform_ptr.Delegate(brush);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipResetPathGradientTransform(HandleRef brush);
 
-            private delegate int GdipMultiplyPathGradientTransform_delegate(HandleRef brush, HandleRef matrix, MatrixOrder order);
-            private static FunctionWrapper<GdipMultiplyPathGradientTransform_delegate> GdipMultiplyPathGradientTransform_ptr;
-            internal static int GdipMultiplyPathGradientTransform(HandleRef brush, HandleRef matrix, MatrixOrder order) => GdipMultiplyPathGradientTransform_ptr.Delegate(brush, matrix, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipMultiplyPathGradientTransform(HandleRef brush, HandleRef matrix, MatrixOrder order);
 
-            private delegate int GdipTranslatePathGradientTransform_delegate(HandleRef brush, float dx, float dy, MatrixOrder order);
-            private static FunctionWrapper<GdipTranslatePathGradientTransform_delegate> GdipTranslatePathGradientTransform_ptr;
-            internal static int GdipTranslatePathGradientTransform(HandleRef brush, float dx, float dy, MatrixOrder order) => GdipTranslatePathGradientTransform_ptr.Delegate(brush, dx, dy, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTranslatePathGradientTransform(HandleRef brush, float dx, float dy, MatrixOrder order);
 
-            private delegate int GdipScalePathGradientTransform_delegate(HandleRef brush, float sx, float sy, MatrixOrder order);
-            private static FunctionWrapper<GdipScalePathGradientTransform_delegate> GdipScalePathGradientTransform_ptr;
-            internal static int GdipScalePathGradientTransform(HandleRef brush, float sx, float sy, MatrixOrder order) => GdipScalePathGradientTransform_ptr.Delegate(brush, sx, sy, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipScalePathGradientTransform(HandleRef brush, float sx, float sy, MatrixOrder order);
 
-            private delegate int GdipRotatePathGradientTransform_delegate(HandleRef brush, float angle, MatrixOrder order);
-            private static FunctionWrapper<GdipRotatePathGradientTransform_delegate> GdipRotatePathGradientTransform_ptr;
-            internal static int GdipRotatePathGradientTransform(HandleRef brush, float angle, MatrixOrder order) => GdipRotatePathGradientTransform_ptr.Delegate(brush, angle, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipRotatePathGradientTransform(HandleRef brush, float angle, MatrixOrder order);
 
-            private delegate int GdipGetPathGradientFocusScales_delegate(HandleRef brush, float[] xScale, float[] yScale);
-            private static FunctionWrapper<GdipGetPathGradientFocusScales_delegate> GdipGetPathGradientFocusScales_ptr;
-            internal static int GdipGetPathGradientFocusScales(HandleRef brush, float[] xScale, float[] yScale) => GdipGetPathGradientFocusScales_ptr.Delegate(brush, xScale, yScale);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPathGradientFocusScales(HandleRef brush, float[] xScale, float[] yScale);
 
-            private delegate int GdipSetPathGradientFocusScales_delegate(HandleRef brush, float xScale, float yScale);
-            private static FunctionWrapper<GdipSetPathGradientFocusScales_delegate> GdipSetPathGradientFocusScales_ptr;
-            internal static int GdipSetPathGradientFocusScales(HandleRef brush, float xScale, float yScale) => GdipSetPathGradientFocusScales_ptr.Delegate(brush, xScale, yScale);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPathGradientFocusScales(HandleRef brush, float xScale, float yScale);
 
-            private delegate int GdipCreateImageAttributes_delegate(out IntPtr imageattr);
-            private static FunctionWrapper<GdipCreateImageAttributes_delegate> GdipCreateImageAttributes_ptr;
-            internal static int GdipCreateImageAttributes(out IntPtr imageattr) => GdipCreateImageAttributes_ptr.Delegate(out imageattr);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateImageAttributes(out IntPtr imageattr);
 
-            private delegate int GdipCloneImageAttributes_delegate(HandleRef imageattr, out IntPtr cloneImageattr);
-            private static FunctionWrapper<GdipCloneImageAttributes_delegate> GdipCloneImageAttributes_ptr;
-            internal static int GdipCloneImageAttributes(HandleRef imageattr, out IntPtr cloneImageattr) => GdipCloneImageAttributes_ptr.Delegate(imageattr, out cloneImageattr);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCloneImageAttributes(HandleRef imageattr, out IntPtr cloneImageattr);
 
-            private delegate int GdipDisposeImageAttributes_delegate(HandleRef imageattr);
-            private static FunctionWrapper<GdipDisposeImageAttributes_delegate> GdipDisposeImageAttributes_ptr;
-            internal static int IntGdipDisposeImageAttributes(HandleRef imageattr) => GdipDisposeImageAttributes_ptr.Delegate(imageattr);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDisposeImageAttributes(HandleRef imageattr);
 
-            private delegate int GdipSetImageAttributesColorMatrix_delegate(HandleRef imageattr, ColorAdjustType type, bool enableFlag, ColorMatrix colorMatrix, ColorMatrix grayMatrix, ColorMatrixFlag flags);
-            private static FunctionWrapper<GdipSetImageAttributesColorMatrix_delegate> GdipSetImageAttributesColorMatrix_ptr;
-            internal static int GdipSetImageAttributesColorMatrix(HandleRef imageattr, ColorAdjustType type, bool enableFlag, ColorMatrix colorMatrix, ColorMatrix grayMatrix, ColorMatrixFlag flags) => GdipSetImageAttributesColorMatrix_ptr.Delegate(imageattr, type, enableFlag, colorMatrix, grayMatrix, flags);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetImageAttributesColorMatrix(HandleRef imageattr, ColorAdjustType type, bool enableFlag, ColorMatrix colorMatrix, ColorMatrix grayMatrix, ColorMatrixFlag flags);
 
-            private delegate int GdipSetImageAttributesThreshold_delegate(HandleRef imageattr, ColorAdjustType type, bool enableFlag, float threshold);
-            private static FunctionWrapper<GdipSetImageAttributesThreshold_delegate> GdipSetImageAttributesThreshold_ptr;
-            internal static int GdipSetImageAttributesThreshold(HandleRef imageattr, ColorAdjustType type, bool enableFlag, float threshold) => GdipSetImageAttributesThreshold_ptr.Delegate(imageattr, type, enableFlag, threshold);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetImageAttributesThreshold(HandleRef imageattr, ColorAdjustType type, bool enableFlag, float threshold);
 
-            private delegate int GdipSetImageAttributesGamma_delegate(HandleRef imageattr, ColorAdjustType type, bool enableFlag, float gamma);
-            private static FunctionWrapper<GdipSetImageAttributesGamma_delegate> GdipSetImageAttributesGamma_ptr;
-            internal static int GdipSetImageAttributesGamma(HandleRef imageattr, ColorAdjustType type, bool enableFlag, float gamma) => GdipSetImageAttributesGamma_ptr.Delegate(imageattr, type, enableFlag, gamma);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetImageAttributesGamma(HandleRef imageattr, ColorAdjustType type, bool enableFlag, float gamma);
 
-            private delegate int GdipSetImageAttributesNoOp_delegate(HandleRef imageattr, ColorAdjustType type, bool enableFlag);
-            private static FunctionWrapper<GdipSetImageAttributesNoOp_delegate> GdipSetImageAttributesNoOp_ptr;
-            internal static int GdipSetImageAttributesNoOp(HandleRef imageattr, ColorAdjustType type, bool enableFlag) => GdipSetImageAttributesNoOp_ptr.Delegate(imageattr, type, enableFlag);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetImageAttributesNoOp(HandleRef imageattr, ColorAdjustType type, bool enableFlag);
 
-            private delegate int GdipSetImageAttributesColorKeys_delegate(HandleRef imageattr, ColorAdjustType type, bool enableFlag, int colorLow, int colorHigh);
-            private static FunctionWrapper<GdipSetImageAttributesColorKeys_delegate> GdipSetImageAttributesColorKeys_ptr;
-            internal static int GdipSetImageAttributesColorKeys(HandleRef imageattr, ColorAdjustType type, bool enableFlag, int colorLow, int colorHigh) => GdipSetImageAttributesColorKeys_ptr.Delegate(imageattr, type, enableFlag, colorLow, colorHigh);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetImageAttributesColorKeys(HandleRef imageattr, ColorAdjustType type, bool enableFlag, int colorLow, int colorHigh);
 
-            private delegate int GdipSetImageAttributesOutputChannel_delegate(HandleRef imageattr, ColorAdjustType type, bool enableFlag, ColorChannelFlag flags);
-            private static FunctionWrapper<GdipSetImageAttributesOutputChannel_delegate> GdipSetImageAttributesOutputChannel_ptr;
-            internal static int GdipSetImageAttributesOutputChannel(HandleRef imageattr, ColorAdjustType type, bool enableFlag, ColorChannelFlag flags) => GdipSetImageAttributesOutputChannel_ptr.Delegate(imageattr, type, enableFlag, flags);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetImageAttributesOutputChannel(HandleRef imageattr, ColorAdjustType type, bool enableFlag, ColorChannelFlag flags);
 
-            private delegate int GdipSetImageAttributesOutputChannelColorProfile_delegate(HandleRef imageattr, ColorAdjustType type, bool enableFlag, [MarshalAs(UnmanagedType.LPWStr)]string colorProfileFilename);
-            private static FunctionWrapper<GdipSetImageAttributesOutputChannelColorProfile_delegate> GdipSetImageAttributesOutputChannelColorProfile_ptr;
-            internal static int GdipSetImageAttributesOutputChannelColorProfile(HandleRef imageattr, ColorAdjustType type, bool enableFlag, string colorProfileFilename) => GdipSetImageAttributesOutputChannelColorProfile_ptr.Delegate(imageattr, type, enableFlag, colorProfileFilename);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipSetImageAttributesOutputChannelColorProfile(HandleRef imageattr, ColorAdjustType type, bool enableFlag, string colorProfileFilename);
 
-            private delegate int GdipSetImageAttributesRemapTable_delegate(HandleRef imageattr, ColorAdjustType type, bool enableFlag, int mapSize, HandleRef map);
-            private static FunctionWrapper<GdipSetImageAttributesRemapTable_delegate> GdipSetImageAttributesRemapTable_ptr;
-            internal static int GdipSetImageAttributesRemapTable(HandleRef imageattr, ColorAdjustType type, bool enableFlag, int mapSize, HandleRef map) => GdipSetImageAttributesRemapTable_ptr.Delegate(imageattr, type, enableFlag, mapSize, map);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetImageAttributesRemapTable(HandleRef imageattr, ColorAdjustType type, bool enableFlag, int mapSize, HandleRef map);
 
-            private delegate int GdipSetImageAttributesWrapMode_delegate(HandleRef imageattr, int wrapmode, int argb, bool clamp);
-            private static FunctionWrapper<GdipSetImageAttributesWrapMode_delegate> GdipSetImageAttributesWrapMode_ptr;
-            internal static int GdipSetImageAttributesWrapMode(HandleRef imageattr, int wrapmode, int argb, bool clamp) => GdipSetImageAttributesWrapMode_ptr.Delegate(imageattr, wrapmode, argb, clamp);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetImageAttributesWrapMode(HandleRef imageattr, int wrapmode, int argb, bool clamp);
 
-            private delegate int GdipGetImageAttributesAdjustedPalette_delegate(HandleRef imageattr, HandleRef palette, ColorAdjustType type);
-            private static FunctionWrapper<GdipGetImageAttributesAdjustedPalette_delegate> GdipGetImageAttributesAdjustedPalette_ptr;
-            internal static int GdipGetImageAttributesAdjustedPalette(HandleRef imageattr, HandleRef palette, ColorAdjustType type) => GdipGetImageAttributesAdjustedPalette_ptr.Delegate(imageattr, palette, type);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageAttributesAdjustedPalette(HandleRef imageattr, HandleRef palette, ColorAdjustType type);
 
-            private delegate int GdipGetImageDecodersSize_delegate(out int numDecoders, out int size);
-            private static FunctionWrapper<GdipGetImageDecodersSize_delegate> GdipGetImageDecodersSize_ptr;
-            internal static int GdipGetImageDecodersSize(out int numDecoders, out int size) => GdipGetImageDecodersSize_ptr.Delegate(out numDecoders, out size);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageDecodersSize(out int numDecoders, out int size);
 
-            private delegate int GdipGetImageDecoders_delegate(int numDecoders, int size, IntPtr decoders);
-            private static FunctionWrapper<GdipGetImageDecoders_delegate> GdipGetImageDecoders_ptr;
-            internal static int GdipGetImageDecoders(int numDecoders, int size, IntPtr decoders) => GdipGetImageDecoders_ptr.Delegate(numDecoders, size, decoders);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageDecoders(int numDecoders, int size, IntPtr decoders);
 
-            private delegate int GdipGetImageEncodersSize_delegate(out int numEncoders, out int size);
-            private static FunctionWrapper<GdipGetImageEncodersSize_delegate> GdipGetImageEncodersSize_ptr;
-            internal static int GdipGetImageEncodersSize(out int numEncoders, out int size) => GdipGetImageEncodersSize_ptr.Delegate(out numEncoders, out size);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageEncodersSize(out int numEncoders, out int size);
 
-            private delegate int GdipGetImageEncoders_delegate(int numEncoders, int size, IntPtr encoders);
-            private static FunctionWrapper<GdipGetImageEncoders_delegate> GdipGetImageEncoders_ptr;
-            internal static int GdipGetImageEncoders(int numEncoders, int size, IntPtr encoders) => GdipGetImageEncoders_ptr.Delegate(numEncoders, size, encoders);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageEncoders(int numEncoders, int size, IntPtr encoders);
 
-            private delegate int GdipCreateSolidFill_delegate(int color, out IntPtr brush);
-            private static FunctionWrapper<GdipCreateSolidFill_delegate> GdipCreateSolidFill_ptr;
-            internal static int GdipCreateSolidFill(int color, out IntPtr brush) => GdipCreateSolidFill_ptr.Delegate(color, out brush);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateSolidFill(int color, out IntPtr brush);
 
-            private delegate int GdipSetSolidFillColor_delegate(HandleRef brush, int color);
-            private static FunctionWrapper<GdipSetSolidFillColor_delegate> GdipSetSolidFillColor_ptr;
-            internal static int GdipSetSolidFillColor(HandleRef brush, int color) => GdipSetSolidFillColor_ptr.Delegate(brush, color);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetSolidFillColor(HandleRef brush, int color);
 
-            private delegate int GdipGetSolidFillColor_delegate(HandleRef brush, out int color);
-            private static FunctionWrapper<GdipGetSolidFillColor_delegate> GdipGetSolidFillColor_ptr;
-            internal static int GdipGetSolidFillColor(HandleRef brush, out int color) => GdipGetSolidFillColor_ptr.Delegate(brush, out color);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetSolidFillColor(HandleRef brush, out int color);
 
 
-            private delegate int GdipCreateTexture_delegate(HandleRef bitmap, int wrapmode, out IntPtr texture);
-            private static FunctionWrapper<GdipCreateTexture_delegate> GdipCreateTexture_ptr;
-            internal static int GdipCreateTexture(HandleRef bitmap, int wrapmode, out IntPtr texture) => GdipCreateTexture_ptr.Delegate(bitmap, wrapmode, out texture);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateTexture(HandleRef bitmap, int wrapmode, out IntPtr texture);
 
-            private delegate int GdipCreateTexture2_delegate(HandleRef bitmap, int wrapmode, float x, float y, float width, float height, out IntPtr texture);
-            private static FunctionWrapper<GdipCreateTexture2_delegate> GdipCreateTexture2_ptr;
-            internal static int GdipCreateTexture2(HandleRef bitmap, int wrapmode, float x, float y, float width, float height, out IntPtr texture) => GdipCreateTexture2_ptr.Delegate(bitmap, wrapmode, x, y, width, height, out texture);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateTexture2(HandleRef bitmap, int wrapmode, float x, float y, float width, float height, out IntPtr texture);
 
-            private delegate int GdipCreateTextureIA_delegate(HandleRef bitmap, HandleRef imageAttrib, float x, float y, float width, float height, out IntPtr texture);
-            private static FunctionWrapper<GdipCreateTextureIA_delegate> GdipCreateTextureIA_ptr;
-            internal static int GdipCreateTextureIA(HandleRef bitmap, HandleRef imageAttrib, float x, float y, float width, float height, out IntPtr texture) => GdipCreateTextureIA_ptr.Delegate(bitmap, imageAttrib, x, y, width, height, out texture);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateTextureIA(HandleRef bitmap, HandleRef imageAttrib, float x, float y, float width, float height, out IntPtr texture);
 
-            private delegate int GdipCreateTexture2I_delegate(HandleRef bitmap, int wrapmode, int x, int y, int width, int height, out IntPtr texture);
-            private static FunctionWrapper<GdipCreateTexture2I_delegate> GdipCreateTexture2I_ptr;
-            internal static int GdipCreateTexture2I(HandleRef bitmap, int wrapmode, int x, int y, int width, int height, out IntPtr texture) => GdipCreateTexture2I_ptr.Delegate(bitmap, wrapmode, x, y, width, height, out texture);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateTexture2I(HandleRef bitmap, int wrapmode, int x, int y, int width, int height, out IntPtr texture);
 
-            private delegate int GdipCreateTextureIAI_delegate(HandleRef bitmap, HandleRef imageAttrib, int x, int y, int width, int height, out IntPtr texture);
-            private static FunctionWrapper<GdipCreateTextureIAI_delegate> GdipCreateTextureIAI_ptr;
-            internal static int GdipCreateTextureIAI(HandleRef bitmap, HandleRef imageAttrib, int x, int y, int width, int height, out IntPtr texture) => GdipCreateTextureIAI_ptr.Delegate(bitmap, imageAttrib, x, y, width, height, out texture);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateTextureIAI(HandleRef bitmap, HandleRef imageAttrib, int x, int y, int width, int height, out IntPtr texture);
 
-            private delegate int GdipSetTextureTransform_delegate(HandleRef brush, HandleRef matrix);
-            private static FunctionWrapper<GdipSetTextureTransform_delegate> GdipSetTextureTransform_ptr;
-            internal static int GdipSetTextureTransform(HandleRef brush, HandleRef matrix) => GdipSetTextureTransform_ptr.Delegate(brush, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetTextureTransform(HandleRef brush, HandleRef matrix);
 
-            private delegate int GdipGetTextureTransform_delegate(HandleRef brush, HandleRef matrix);
-            private static FunctionWrapper<GdipGetTextureTransform_delegate> GdipGetTextureTransform_ptr;
-            internal static int GdipGetTextureTransform(HandleRef brush, HandleRef matrix) => GdipGetTextureTransform_ptr.Delegate(brush, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetTextureTransform(HandleRef brush, HandleRef matrix);
 
-            private delegate int GdipResetTextureTransform_delegate(HandleRef brush);
-            private static FunctionWrapper<GdipResetTextureTransform_delegate> GdipResetTextureTransform_ptr;
-            internal static int GdipResetTextureTransform(HandleRef brush) => GdipResetTextureTransform_ptr.Delegate(brush);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipResetTextureTransform(HandleRef brush);
 
-            private delegate int GdipMultiplyTextureTransform_delegate(HandleRef brush, HandleRef matrix, MatrixOrder order);
-            private static FunctionWrapper<GdipMultiplyTextureTransform_delegate> GdipMultiplyTextureTransform_ptr;
-            internal static int GdipMultiplyTextureTransform(HandleRef brush, HandleRef matrix, MatrixOrder order) => GdipMultiplyTextureTransform_ptr.Delegate(brush, matrix, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipMultiplyTextureTransform(HandleRef brush, HandleRef matrix, MatrixOrder order);
 
-            private delegate int GdipTranslateTextureTransform_delegate(HandleRef brush, float dx, float dy, MatrixOrder order);
-            private static FunctionWrapper<GdipTranslateTextureTransform_delegate> GdipTranslateTextureTransform_ptr;
-            internal static int GdipTranslateTextureTransform(HandleRef brush, float dx, float dy, MatrixOrder order) => GdipTranslateTextureTransform_ptr.Delegate(brush, dx, dy, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTranslateTextureTransform(HandleRef brush, float dx, float dy, MatrixOrder order);
 
-            private delegate int GdipScaleTextureTransform_delegate(HandleRef brush, float sx, float sy, MatrixOrder order);
-            private static FunctionWrapper<GdipScaleTextureTransform_delegate> GdipScaleTextureTransform_ptr;
-            internal static int GdipScaleTextureTransform(HandleRef brush, float sx, float sy, MatrixOrder order) => GdipScaleTextureTransform_ptr.Delegate(brush, sx, sy, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipScaleTextureTransform(HandleRef brush, float sx, float sy, MatrixOrder order);
 
-            private delegate int GdipRotateTextureTransform_delegate(HandleRef brush, float angle, MatrixOrder order);
-            private static FunctionWrapper<GdipRotateTextureTransform_delegate> GdipRotateTextureTransform_ptr;
-            internal static int GdipRotateTextureTransform(HandleRef brush, float angle, MatrixOrder order) => GdipRotateTextureTransform_ptr.Delegate(brush, angle, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipRotateTextureTransform(HandleRef brush, float angle, MatrixOrder order);
 
-            private delegate int GdipSetTextureWrapMode_delegate(HandleRef brush, int wrapMode);
-            private static FunctionWrapper<GdipSetTextureWrapMode_delegate> GdipSetTextureWrapMode_ptr;
-            internal static int GdipSetTextureWrapMode(HandleRef brush, int wrapMode) => GdipSetTextureWrapMode_ptr.Delegate(brush, wrapMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetTextureWrapMode(HandleRef brush, int wrapMode);
 
-            private delegate int GdipGetTextureWrapMode_delegate(HandleRef brush, out int wrapMode);
-            private static FunctionWrapper<GdipGetTextureWrapMode_delegate> GdipGetTextureWrapMode_ptr;
-            internal static int GdipGetTextureWrapMode(HandleRef brush, out int wrapMode) => GdipGetTextureWrapMode_ptr.Delegate(brush, out wrapMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetTextureWrapMode(HandleRef brush, out int wrapMode);
 
-            private delegate int GdipGetTextureImage_delegate(HandleRef brush, out IntPtr image);
-            private static FunctionWrapper<GdipGetTextureImage_delegate> GdipGetTextureImage_ptr;
-            internal static int GdipGetTextureImage(HandleRef brush, out IntPtr image) => GdipGetTextureImage_ptr.Delegate(brush, out image);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetTextureImage(HandleRef brush, out IntPtr image);
 
-            private delegate int GdipGetFontCollectionFamilyCount_delegate(HandleRef fontCollection, out int numFound);
-            private static FunctionWrapper<GdipGetFontCollectionFamilyCount_delegate> GdipGetFontCollectionFamilyCount_ptr;
-            internal static int GdipGetFontCollectionFamilyCount(HandleRef fontCollection, out int numFound) => GdipGetFontCollectionFamilyCount_ptr.Delegate(fontCollection, out numFound);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetFontCollectionFamilyCount(HandleRef fontCollection, out int numFound);
 
-            private delegate int GdipGetFontCollectionFamilyList_delegate(HandleRef fontCollection, int numSought, IntPtr[] gpfamilies, out int numFound);
-            private static FunctionWrapper<GdipGetFontCollectionFamilyList_delegate> GdipGetFontCollectionFamilyList_ptr;
-            internal static int GdipGetFontCollectionFamilyList(HandleRef fontCollection, int numSought, IntPtr[] gpfamilies, out int numFound) => GdipGetFontCollectionFamilyList_ptr.Delegate(fontCollection, numSought, gpfamilies, out numFound);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetFontCollectionFamilyList(HandleRef fontCollection, int numSought, IntPtr[] gpfamilies, out int numFound);
 
-            private delegate int GdipCloneFontFamily_delegate(HandleRef fontfamily, out IntPtr clonefontfamily);
-            private static FunctionWrapper<GdipCloneFontFamily_delegate> GdipCloneFontFamily_ptr;
-            internal static int GdipCloneFontFamily(HandleRef fontfamily, out IntPtr clonefontfamily) => GdipCloneFontFamily_ptr.Delegate(fontfamily, out clonefontfamily);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCloneFontFamily(HandleRef fontfamily, out IntPtr clonefontfamily);
 
-            private delegate int GdipCreateFontFamilyFromName_delegate([MarshalAs(UnmanagedType.LPWStr)]string name, HandleRef fontCollection, out IntPtr FontFamily);
-            private static FunctionWrapper<GdipCreateFontFamilyFromName_delegate> GdipCreateFontFamilyFromName_ptr;
-            internal static int GdipCreateFontFamilyFromName(string name, HandleRef fontCollection, out IntPtr FontFamily) => GdipCreateFontFamilyFromName_ptr.Delegate(name, fontCollection, out FontFamily);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipCreateFontFamilyFromName(string name, HandleRef fontCollection, out IntPtr FontFamily);
 
-            private delegate int GdipGetGenericFontFamilySansSerif_delegate(out IntPtr fontfamily);
-            private static FunctionWrapper<GdipGetGenericFontFamilySansSerif_delegate> GdipGetGenericFontFamilySansSerif_ptr;
-            internal static int GdipGetGenericFontFamilySansSerif(out IntPtr fontfamily) => GdipGetGenericFontFamilySansSerif_ptr.Delegate(out fontfamily);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetGenericFontFamilySansSerif(out IntPtr fontfamily);
 
-            private delegate int GdipGetGenericFontFamilySerif_delegate(out IntPtr fontfamily);
-            private static FunctionWrapper<GdipGetGenericFontFamilySerif_delegate> GdipGetGenericFontFamilySerif_ptr;
-            internal static int GdipGetGenericFontFamilySerif(out IntPtr fontfamily) => GdipGetGenericFontFamilySerif_ptr.Delegate(out fontfamily);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetGenericFontFamilySerif(out IntPtr fontfamily);
 
-            private delegate int GdipGetGenericFontFamilyMonospace_delegate(out IntPtr fontfamily);
-            private static FunctionWrapper<GdipGetGenericFontFamilyMonospace_delegate> GdipGetGenericFontFamilyMonospace_ptr;
-            internal static int GdipGetGenericFontFamilyMonospace(out IntPtr fontfamily) => GdipGetGenericFontFamilyMonospace_ptr.Delegate(out fontfamily);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetGenericFontFamilyMonospace(out IntPtr fontfamily);
 
-            private delegate int GdipDeleteFontFamily_delegate(HandleRef fontFamily);
-            private static FunctionWrapper<GdipDeleteFontFamily_delegate> GdipDeleteFontFamily_ptr;
-            internal static int IntGdipDeleteFontFamily(HandleRef fontFamily) => GdipDeleteFontFamily_ptr.Delegate(fontFamily);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeleteFontFamily(HandleRef fontFamily);
 
-            private delegate int GdipGetFamilyName_delegate(HandleRef family, char* name, int language);
-            private static FunctionWrapper<GdipGetFamilyName_delegate> GdipGetFamilyName_ptr;
-            internal static int GdipGetFamilyName(HandleRef family, char* name, int language) => GdipGetFamilyName_ptr.Delegate(family, name, language);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipGetFamilyName(HandleRef family, char* name, int language);
 
-            private delegate int GdipIsStyleAvailable_delegate(HandleRef family, FontStyle style, out int isStyleAvailable);
-            private static FunctionWrapper<GdipIsStyleAvailable_delegate> GdipIsStyleAvailable_ptr;
-            internal static int GdipIsStyleAvailable(HandleRef family, FontStyle style, out int isStyleAvailable) => GdipIsStyleAvailable_ptr.Delegate(family, style, out isStyleAvailable);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsStyleAvailable(HandleRef family, FontStyle style, out int isStyleAvailable);
 
-            private delegate int GdipGetEmHeight_delegate(HandleRef family, FontStyle style, out int EmHeight);
-            private static FunctionWrapper<GdipGetEmHeight_delegate> GdipGetEmHeight_ptr;
-            internal static int GdipGetEmHeight(HandleRef family, FontStyle style, out int EmHeight) => GdipGetEmHeight_ptr.Delegate(family, style, out EmHeight);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetEmHeight(HandleRef family, FontStyle style, out int EmHeight);
 
-            private delegate int GdipGetCellAscent_delegate(HandleRef family, FontStyle style, out int CellAscent);
-            private static FunctionWrapper<GdipGetCellAscent_delegate> GdipGetCellAscent_ptr;
-            internal static int GdipGetCellAscent(HandleRef family, FontStyle style, out int CellAscent) => GdipGetCellAscent_ptr.Delegate(family, style, out CellAscent);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetCellAscent(HandleRef family, FontStyle style, out int CellAscent);
 
-            private delegate int GdipGetCellDescent_delegate(HandleRef family, FontStyle style, out int CellDescent);
-            private static FunctionWrapper<GdipGetCellDescent_delegate> GdipGetCellDescent_ptr;
-            internal static int GdipGetCellDescent(HandleRef family, FontStyle style, out int CellDescent) => GdipGetCellDescent_ptr.Delegate(family, style, out CellDescent);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetCellDescent(HandleRef family, FontStyle style, out int CellDescent);
 
-            private delegate int GdipGetLineSpacing_delegate(HandleRef family, FontStyle style, out int LineSpaceing);
-            private static FunctionWrapper<GdipGetLineSpacing_delegate> GdipGetLineSpacing_ptr;
-            internal static int GdipGetLineSpacing(HandleRef family, FontStyle style, out int LineSpaceing) => GdipGetLineSpacing_ptr.Delegate(family, style, out LineSpaceing);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetLineSpacing(HandleRef family, FontStyle style, out int LineSpaceing);
 
-            private delegate int GdipNewInstalledFontCollection_delegate(out IntPtr fontCollection);
-            private static FunctionWrapper<GdipNewInstalledFontCollection_delegate> GdipNewInstalledFontCollection_ptr;
-            internal static int GdipNewInstalledFontCollection(out IntPtr fontCollection) => GdipNewInstalledFontCollection_ptr.Delegate(out fontCollection);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipNewInstalledFontCollection(out IntPtr fontCollection);
 
-            private delegate int GdipNewPrivateFontCollection_delegate(out IntPtr fontCollection);
-            private static FunctionWrapper<GdipNewPrivateFontCollection_delegate> GdipNewPrivateFontCollection_ptr;
-            internal static int GdipNewPrivateFontCollection(out IntPtr fontCollection) => GdipNewPrivateFontCollection_ptr.Delegate(out fontCollection);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipNewPrivateFontCollection(out IntPtr fontCollection);
 
-            private delegate int GdipDeletePrivateFontCollection_delegate(ref IntPtr fontCollection);
-            private static FunctionWrapper<GdipDeletePrivateFontCollection_delegate> GdipDeletePrivateFontCollection_ptr;
-            internal static int IntGdipDeletePrivateFontCollection(ref IntPtr fontCollection) => GdipDeletePrivateFontCollection_ptr.Delegate(ref fontCollection);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeletePrivateFontCollection(ref IntPtr fontCollection);
 
-            private delegate int GdipPrivateAddFontFile_delegate(HandleRef fontCollection, [MarshalAs(UnmanagedType.LPWStr)]string filename);
-            private static FunctionWrapper<GdipPrivateAddFontFile_delegate> GdipPrivateAddFontFile_ptr;
-            internal static int GdipPrivateAddFontFile(HandleRef fontCollection, string filename) => GdipPrivateAddFontFile_ptr.Delegate(fontCollection, filename);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipPrivateAddFontFile(HandleRef fontCollection, string filename);
 
-            private delegate int GdipPrivateAddMemoryFont_delegate(HandleRef fontCollection, HandleRef memory, int length);
-            private static FunctionWrapper<GdipPrivateAddMemoryFont_delegate> GdipPrivateAddMemoryFont_ptr;
-            internal static int GdipPrivateAddMemoryFont(HandleRef fontCollection, HandleRef memory, int length) => GdipPrivateAddMemoryFont_ptr.Delegate(fontCollection, memory, length);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipPrivateAddMemoryFont(HandleRef fontCollection, HandleRef memory, int length);
 
-            private delegate int GdipCreateFont_delegate(HandleRef fontFamily, float emSize, FontStyle style, GraphicsUnit unit, out IntPtr font);
-            private static FunctionWrapper<GdipCreateFont_delegate> GdipCreateFont_ptr;
-            internal static int GdipCreateFont(HandleRef fontFamily, float emSize, FontStyle style, GraphicsUnit unit, out IntPtr font) => GdipCreateFont_ptr.Delegate(fontFamily, emSize, style, unit, out font);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateFont(HandleRef fontFamily, float emSize, FontStyle style, GraphicsUnit unit, out IntPtr font);
 
-            private delegate int GdipCloneFont_delegate(HandleRef font, out IntPtr cloneFont);
-            private static FunctionWrapper<GdipCloneFont_delegate> GdipCloneFont_ptr;
-            internal static int GdipCloneFont(HandleRef font, out IntPtr cloneFont) => GdipCloneFont_ptr.Delegate(font, out cloneFont);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCloneFont(HandleRef font, out IntPtr cloneFont);
 
-            private delegate int GdipDeleteFont_delegate(HandleRef font);
-            private static FunctionWrapper<GdipDeleteFont_delegate> GdipDeleteFont_ptr;
-            internal static int IntGdipDeleteFont(HandleRef font) => GdipDeleteFont_ptr.Delegate(font);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeleteFont(HandleRef font);
 
-            private delegate int GdipGetFamily_delegate(HandleRef font, out IntPtr family);
-            private static FunctionWrapper<GdipGetFamily_delegate> GdipGetFamily_ptr;
-            internal static int GdipGetFamily(HandleRef font, out IntPtr family) => GdipGetFamily_ptr.Delegate(font, out family);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetFamily(HandleRef font, out IntPtr family);
 
-            private delegate int GdipGetFontStyle_delegate(HandleRef font, out FontStyle style);
-            private static FunctionWrapper<GdipGetFontStyle_delegate> GdipGetFontStyle_ptr;
-            internal static int GdipGetFontStyle(HandleRef font, out FontStyle style) => GdipGetFontStyle_ptr.Delegate(font, out style);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetFontStyle(HandleRef font, out FontStyle style);
 
-            private delegate int GdipGetFontSize_delegate(HandleRef font, out float size);
-            private static FunctionWrapper<GdipGetFontSize_delegate> GdipGetFontSize_ptr;
-            internal static int GdipGetFontSize(HandleRef font, out float size) => GdipGetFontSize_ptr.Delegate(font, out size);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetFontSize(HandleRef font, out float size);
 
-            private delegate int GdipGetFontHeight_delegate(HandleRef font, HandleRef graphics, out float size);
-            private static FunctionWrapper<GdipGetFontHeight_delegate> GdipGetFontHeight_ptr;
-            internal static int GdipGetFontHeight(HandleRef font, HandleRef graphics, out float size) => GdipGetFontHeight_ptr.Delegate(font, graphics, out size);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetFontHeight(HandleRef font, HandleRef graphics, out float size);
 
-            private delegate int GdipGetFontHeightGivenDPI_delegate(HandleRef font, float dpi, out float size);
-            private static FunctionWrapper<GdipGetFontHeightGivenDPI_delegate> GdipGetFontHeightGivenDPI_ptr;
-            internal static int GdipGetFontHeightGivenDPI(HandleRef font, float dpi, out float size) => GdipGetFontHeightGivenDPI_ptr.Delegate(font, dpi, out size);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetFontHeightGivenDPI(HandleRef font, float dpi, out float size);
 
-            private delegate int GdipGetFontUnit_delegate(HandleRef font, out GraphicsUnit unit);
-            private static FunctionWrapper<GdipGetFontUnit_delegate> GdipGetFontUnit_ptr;
-            internal static int GdipGetFontUnit(HandleRef font, out GraphicsUnit unit) => GdipGetFontUnit_ptr.Delegate(font, out unit);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetFontUnit(HandleRef font, out GraphicsUnit unit);
 
-#pragma warning disable CS0618 // Legacy code: We don't care about using obsolete API's.
-            private delegate int GdipGetLogFontW_delegate(HandleRef font, HandleRef graphics, [In] [Out] [MarshalAs(UnmanagedType.AsAny)]object lf);
-#pragma warning restore CS0618
-            private static FunctionWrapper<GdipGetLogFontW_delegate> GdipGetLogFontW_ptr;
-            internal static int GdipGetLogFontW(HandleRef font, HandleRef graphics, [In] [Out] object lf) => GdipGetLogFontW_ptr.Delegate(font, graphics, lf);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetLogFontW(HandleRef font, HandleRef graphics, ref LOGFONT lf);
 
-            private delegate int GdipCreatePen1_delegate(int argb, float width, int unit, out IntPtr pen);
-            private static FunctionWrapper<GdipCreatePen1_delegate> GdipCreatePen1_ptr;
-            internal static int GdipCreatePen1(int argb, float width, int unit, out IntPtr pen) => GdipCreatePen1_ptr.Delegate(argb, width, unit, out pen);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreatePen1(int argb, float width, int unit, out IntPtr pen);
 
-            private delegate int GdipCreatePen2_delegate(HandleRef brush, float width, int unit, out IntPtr pen);
-            private static FunctionWrapper<GdipCreatePen2_delegate> GdipCreatePen2_ptr;
-            internal static int GdipCreatePen2(HandleRef brush, float width, int unit, out IntPtr pen) => GdipCreatePen2_ptr.Delegate(brush, width, unit, out pen);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreatePen2(HandleRef brush, float width, int unit, out IntPtr pen);
 
-            private delegate int GdipClonePen_delegate(HandleRef pen, out IntPtr clonepen);
-            private static FunctionWrapper<GdipClonePen_delegate> GdipClonePen_ptr;
-            internal static int GdipClonePen(HandleRef pen, out IntPtr clonepen) => GdipClonePen_ptr.Delegate(pen, out clonepen);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipClonePen(HandleRef pen, out IntPtr clonepen);
 
-            private delegate int GdipDeletePen_delegate(HandleRef Pen);
-            private static FunctionWrapper<GdipDeletePen_delegate> GdipDeletePen_ptr;
-            internal static int IntGdipDeletePen(HandleRef Pen) => GdipDeletePen_ptr.Delegate(Pen);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeletePen(HandleRef Pen);
 
-            private delegate int GdipSetPenMode_delegate(HandleRef pen, PenAlignment penAlign);
-            private static FunctionWrapper<GdipSetPenMode_delegate> GdipSetPenMode_ptr;
-            internal static int GdipSetPenMode(HandleRef pen, PenAlignment penAlign) => GdipSetPenMode_ptr.Delegate(pen, penAlign);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenMode(HandleRef pen, PenAlignment penAlign);
 
-            private delegate int GdipGetPenMode_delegate(HandleRef pen, out PenAlignment penAlign);
-            private static FunctionWrapper<GdipGetPenMode_delegate> GdipGetPenMode_ptr;
-            internal static int GdipGetPenMode(HandleRef pen, out PenAlignment penAlign) => GdipGetPenMode_ptr.Delegate(pen, out penAlign);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenMode(HandleRef pen, out PenAlignment penAlign);
 
-            private delegate int GdipSetPenWidth_delegate(HandleRef pen, float width);
-            private static FunctionWrapper<GdipSetPenWidth_delegate> GdipSetPenWidth_ptr;
-            internal static int GdipSetPenWidth(HandleRef pen, float width) => GdipSetPenWidth_ptr.Delegate(pen, width);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenWidth(HandleRef pen, float width);
 
-            private delegate int GdipGetPenWidth_delegate(HandleRef pen, float[] width);
-            private static FunctionWrapper<GdipGetPenWidth_delegate> GdipGetPenWidth_ptr;
-            internal static int GdipGetPenWidth(HandleRef pen, float[] width) => GdipGetPenWidth_ptr.Delegate(pen, width);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenWidth(HandleRef pen, float[] width);
 
-            private delegate int GdipSetPenLineCap197819_delegate(HandleRef pen, int startCap, int endCap, int dashCap);
-            private static FunctionWrapper<GdipSetPenLineCap197819_delegate> GdipSetPenLineCap197819_ptr;
-            internal static int GdipSetPenLineCap197819(HandleRef pen, int startCap, int endCap, int dashCap) => GdipSetPenLineCap197819_ptr.Delegate(pen, startCap, endCap, dashCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenLineCap197819(HandleRef pen, int startCap, int endCap, int dashCap);
 
-            private delegate int GdipSetPenStartCap_delegate(HandleRef pen, int startCap);
-            private static FunctionWrapper<GdipSetPenStartCap_delegate> GdipSetPenStartCap_ptr;
-            internal static int GdipSetPenStartCap(HandleRef pen, int startCap) => GdipSetPenStartCap_ptr.Delegate(pen, startCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenStartCap(HandleRef pen, int startCap);
 
-            private delegate int GdipSetPenEndCap_delegate(HandleRef pen, int endCap);
-            private static FunctionWrapper<GdipSetPenEndCap_delegate> GdipSetPenEndCap_ptr;
-            internal static int GdipSetPenEndCap(HandleRef pen, int endCap) => GdipSetPenEndCap_ptr.Delegate(pen, endCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenEndCap(HandleRef pen, int endCap);
 
-            private delegate int GdipGetPenStartCap_delegate(HandleRef pen, out int startCap);
-            private static FunctionWrapper<GdipGetPenStartCap_delegate> GdipGetPenStartCap_ptr;
-            internal static int GdipGetPenStartCap(HandleRef pen, out int startCap) => GdipGetPenStartCap_ptr.Delegate(pen, out startCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenStartCap(HandleRef pen, out int startCap);
 
-            private delegate int GdipGetPenEndCap_delegate(HandleRef pen, out int endCap);
-            private static FunctionWrapper<GdipGetPenEndCap_delegate> GdipGetPenEndCap_ptr;
-            internal static int GdipGetPenEndCap(HandleRef pen, out int endCap) => GdipGetPenEndCap_ptr.Delegate(pen, out endCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenEndCap(HandleRef pen, out int endCap);
 
-            private delegate int GdipGetPenDashCap197819_delegate(HandleRef pen, out int dashCap);
-            private static FunctionWrapper<GdipGetPenDashCap197819_delegate> GdipGetPenDashCap197819_ptr;
-            internal static int GdipGetPenDashCap197819(HandleRef pen, out int dashCap) => GdipGetPenDashCap197819_ptr.Delegate(pen, out dashCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenDashCap197819(HandleRef pen, out int dashCap);
 
-            private delegate int GdipSetPenDashCap197819_delegate(HandleRef pen, int dashCap);
-            private static FunctionWrapper<GdipSetPenDashCap197819_delegate> GdipSetPenDashCap197819_ptr;
-            internal static int GdipSetPenDashCap197819(HandleRef pen, int dashCap) => GdipSetPenDashCap197819_ptr.Delegate(pen, dashCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenDashCap197819(HandleRef pen, int dashCap);
 
-            private delegate int GdipSetPenLineJoin_delegate(HandleRef pen, int lineJoin);
-            private static FunctionWrapper<GdipSetPenLineJoin_delegate> GdipSetPenLineJoin_ptr;
-            internal static int GdipSetPenLineJoin(HandleRef pen, int lineJoin) => GdipSetPenLineJoin_ptr.Delegate(pen, lineJoin);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenLineJoin(HandleRef pen, int lineJoin);
 
-            private delegate int GdipGetPenLineJoin_delegate(HandleRef pen, out int lineJoin);
-            private static FunctionWrapper<GdipGetPenLineJoin_delegate> GdipGetPenLineJoin_ptr;
-            internal static int GdipGetPenLineJoin(HandleRef pen, out int lineJoin) => GdipGetPenLineJoin_ptr.Delegate(pen, out lineJoin);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenLineJoin(HandleRef pen, out int lineJoin);
 
-            private delegate int GdipSetPenCustomStartCap_delegate(HandleRef pen, HandleRef customCap);
-            private static FunctionWrapper<GdipSetPenCustomStartCap_delegate> GdipSetPenCustomStartCap_ptr;
-            internal static int GdipSetPenCustomStartCap(HandleRef pen, HandleRef customCap) => GdipSetPenCustomStartCap_ptr.Delegate(pen, customCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenCustomStartCap(HandleRef pen, HandleRef customCap);
 
-            private delegate int GdipGetPenCustomStartCap_delegate(HandleRef pen, out IntPtr customCap);
-            private static FunctionWrapper<GdipGetPenCustomStartCap_delegate> GdipGetPenCustomStartCap_ptr;
-            internal static int GdipGetPenCustomStartCap(HandleRef pen, out IntPtr customCap) => GdipGetPenCustomStartCap_ptr.Delegate(pen, out customCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenCustomStartCap(HandleRef pen, out IntPtr customCap);
 
-            private delegate int GdipSetPenCustomEndCap_delegate(HandleRef pen, HandleRef customCap);
-            private static FunctionWrapper<GdipSetPenCustomEndCap_delegate> GdipSetPenCustomEndCap_ptr;
-            internal static int GdipSetPenCustomEndCap(HandleRef pen, HandleRef customCap) => GdipSetPenCustomEndCap_ptr.Delegate(pen, customCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenCustomEndCap(HandleRef pen, HandleRef customCap);
 
-            private delegate int GdipGetPenCustomEndCap_delegate(HandleRef pen, out IntPtr customCap);
-            private static FunctionWrapper<GdipGetPenCustomEndCap_delegate> GdipGetPenCustomEndCap_ptr;
-            internal static int GdipGetPenCustomEndCap(HandleRef pen, out IntPtr customCap) => GdipGetPenCustomEndCap_ptr.Delegate(pen, out customCap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenCustomEndCap(HandleRef pen, out IntPtr customCap);
 
-            private delegate int GdipSetPenMiterLimit_delegate(HandleRef pen, float miterLimit);
-            private static FunctionWrapper<GdipSetPenMiterLimit_delegate> GdipSetPenMiterLimit_ptr;
-            internal static int GdipSetPenMiterLimit(HandleRef pen, float miterLimit) => GdipSetPenMiterLimit_ptr.Delegate(pen, miterLimit);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenMiterLimit(HandleRef pen, float miterLimit);
 
-            private delegate int GdipGetPenMiterLimit_delegate(HandleRef pen, float[] miterLimit);
-            private static FunctionWrapper<GdipGetPenMiterLimit_delegate> GdipGetPenMiterLimit_ptr;
-            internal static int GdipGetPenMiterLimit(HandleRef pen, float[] miterLimit) => GdipGetPenMiterLimit_ptr.Delegate(pen, miterLimit);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenMiterLimit(HandleRef pen, float[] miterLimit);
 
-            private delegate int GdipSetPenTransform_delegate(HandleRef pen, HandleRef matrix);
-            private static FunctionWrapper<GdipSetPenTransform_delegate> GdipSetPenTransform_ptr;
-            internal static int GdipSetPenTransform(HandleRef pen, HandleRef matrix) => GdipSetPenTransform_ptr.Delegate(pen, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenTransform(HandleRef pen, HandleRef matrix);
 
-            private delegate int GdipGetPenTransform_delegate(HandleRef pen, HandleRef matrix);
-            private static FunctionWrapper<GdipGetPenTransform_delegate> GdipGetPenTransform_ptr;
-            internal static int GdipGetPenTransform(HandleRef pen, HandleRef matrix) => GdipGetPenTransform_ptr.Delegate(pen, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenTransform(HandleRef pen, HandleRef matrix);
 
-            private delegate int GdipResetPenTransform_delegate(HandleRef brush);
-            private static FunctionWrapper<GdipResetPenTransform_delegate> GdipResetPenTransform_ptr;
-            internal static int GdipResetPenTransform(HandleRef brush) => GdipResetPenTransform_ptr.Delegate(brush);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipResetPenTransform(HandleRef brush);
 
-            private delegate int GdipMultiplyPenTransform_delegate(HandleRef brush, HandleRef matrix, MatrixOrder order);
-            private static FunctionWrapper<GdipMultiplyPenTransform_delegate> GdipMultiplyPenTransform_ptr;
-            internal static int GdipMultiplyPenTransform(HandleRef brush, HandleRef matrix, MatrixOrder order) => GdipMultiplyPenTransform_ptr.Delegate(brush, matrix, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipMultiplyPenTransform(HandleRef brush, HandleRef matrix, MatrixOrder order);
 
-            private delegate int GdipTranslatePenTransform_delegate(HandleRef brush, float dx, float dy, MatrixOrder order);
-            private static FunctionWrapper<GdipTranslatePenTransform_delegate> GdipTranslatePenTransform_ptr;
-            internal static int GdipTranslatePenTransform(HandleRef brush, float dx, float dy, MatrixOrder order) => GdipTranslatePenTransform_ptr.Delegate(brush, dx, dy, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTranslatePenTransform(HandleRef brush, float dx, float dy, MatrixOrder order);
 
-            private delegate int GdipScalePenTransform_delegate(HandleRef brush, float sx, float sy, MatrixOrder order);
-            private static FunctionWrapper<GdipScalePenTransform_delegate> GdipScalePenTransform_ptr;
-            internal static int GdipScalePenTransform(HandleRef brush, float sx, float sy, MatrixOrder order) => GdipScalePenTransform_ptr.Delegate(brush, sx, sy, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipScalePenTransform(HandleRef brush, float sx, float sy, MatrixOrder order);
 
-            private delegate int GdipRotatePenTransform_delegate(HandleRef brush, float angle, MatrixOrder order);
-            private static FunctionWrapper<GdipRotatePenTransform_delegate> GdipRotatePenTransform_ptr;
-            internal static int GdipRotatePenTransform(HandleRef brush, float angle, MatrixOrder order) => GdipRotatePenTransform_ptr.Delegate(brush, angle, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipRotatePenTransform(HandleRef brush, float angle, MatrixOrder order);
 
-            private delegate int GdipSetPenColor_delegate(HandleRef pen, int argb);
-            private static FunctionWrapper<GdipSetPenColor_delegate> GdipSetPenColor_ptr;
-            internal static int GdipSetPenColor(HandleRef pen, int argb) => GdipSetPenColor_ptr.Delegate(pen, argb);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenColor(HandleRef pen, int argb);
 
-            private delegate int GdipGetPenColor_delegate(HandleRef pen, out int argb);
-            private static FunctionWrapper<GdipGetPenColor_delegate> GdipGetPenColor_ptr;
-            internal static int GdipGetPenColor(HandleRef pen, out int argb) => GdipGetPenColor_ptr.Delegate(pen, out argb);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenColor(HandleRef pen, out int argb);
 
-            private delegate int GdipSetPenBrushFill_delegate(HandleRef pen, HandleRef brush);
-            private static FunctionWrapper<GdipSetPenBrushFill_delegate> GdipSetPenBrushFill_ptr;
-            internal static int GdipSetPenBrushFill(HandleRef pen, HandleRef brush) => GdipSetPenBrushFill_ptr.Delegate(pen, brush);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenBrushFill(HandleRef pen, HandleRef brush);
 
-            private delegate int GdipGetPenBrushFill_delegate(HandleRef pen, out IntPtr brush);
-            private static FunctionWrapper<GdipGetPenBrushFill_delegate> GdipGetPenBrushFill_ptr;
-            internal static int GdipGetPenBrushFill(HandleRef pen, out IntPtr brush) => GdipGetPenBrushFill_ptr.Delegate(pen, out brush);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenBrushFill(HandleRef pen, out IntPtr brush);
 
-            private delegate int GdipGetPenFillType_delegate(HandleRef pen, out int pentype);
-            private static FunctionWrapper<GdipGetPenFillType_delegate> GdipGetPenFillType_ptr;
-            internal static int GdipGetPenFillType(HandleRef pen, out int pentype) => GdipGetPenFillType_ptr.Delegate(pen, out pentype);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenFillType(HandleRef pen, out int pentype);
 
-            private delegate int GdipGetPenDashStyle_delegate(HandleRef pen, out int dashstyle);
-            private static FunctionWrapper<GdipGetPenDashStyle_delegate> GdipGetPenDashStyle_ptr;
-            internal static int GdipGetPenDashStyle(HandleRef pen, out int dashstyle) => GdipGetPenDashStyle_ptr.Delegate(pen, out dashstyle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenDashStyle(HandleRef pen, out int dashstyle);
 
-            private delegate int GdipSetPenDashStyle_delegate(HandleRef pen, int dashstyle);
-            private static FunctionWrapper<GdipSetPenDashStyle_delegate> GdipSetPenDashStyle_ptr;
-            internal static int GdipSetPenDashStyle(HandleRef pen, int dashstyle) => GdipSetPenDashStyle_ptr.Delegate(pen, dashstyle);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenDashStyle(HandleRef pen, int dashstyle);
 
-            private delegate int GdipSetPenDashArray_delegate(HandleRef pen, HandleRef memorydash, int count);
-            private static FunctionWrapper<GdipSetPenDashArray_delegate> GdipSetPenDashArray_ptr;
-            internal static int GdipSetPenDashArray(HandleRef pen, HandleRef memorydash, int count) => GdipSetPenDashArray_ptr.Delegate(pen, memorydash, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenDashArray(HandleRef pen, HandleRef memorydash, int count);
 
-            private delegate int GdipGetPenDashOffset_delegate(HandleRef pen, float[] dashoffset);
-            private static FunctionWrapper<GdipGetPenDashOffset_delegate> GdipGetPenDashOffset_ptr;
-            internal static int GdipGetPenDashOffset(HandleRef pen, float[] dashoffset) => GdipGetPenDashOffset_ptr.Delegate(pen, dashoffset);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenDashOffset(HandleRef pen, float[] dashoffset);
 
-            private delegate int GdipSetPenDashOffset_delegate(HandleRef pen, float dashoffset);
-            private static FunctionWrapper<GdipSetPenDashOffset_delegate> GdipSetPenDashOffset_ptr;
-            internal static int GdipSetPenDashOffset(HandleRef pen, float dashoffset) => GdipSetPenDashOffset_ptr.Delegate(pen, dashoffset);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenDashOffset(HandleRef pen, float dashoffset);
 
-            private delegate int GdipGetPenDashCount_delegate(HandleRef pen, out int dashcount);
-            private static FunctionWrapper<GdipGetPenDashCount_delegate> GdipGetPenDashCount_ptr;
-            internal static int GdipGetPenDashCount(HandleRef pen, out int dashcount) => GdipGetPenDashCount_ptr.Delegate(pen, out dashcount);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenDashCount(HandleRef pen, out int dashcount);
 
-            private delegate int GdipGetPenDashArray_delegate(HandleRef pen, float[] memorydash, int count);
-            private static FunctionWrapper<GdipGetPenDashArray_delegate> GdipGetPenDashArray_ptr;
-            internal static int GdipGetPenDashArray(HandleRef pen, float[] memorydash, int count) => GdipGetPenDashArray_ptr.Delegate(pen, memorydash, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenDashArray(HandleRef pen, float[] memorydash, int count);
 
-            private delegate int GdipGetPenCompoundCount_delegate(HandleRef pen, out int count);
-            private static FunctionWrapper<GdipGetPenCompoundCount_delegate> GdipGetPenCompoundCount_ptr;
-            internal static int GdipGetPenCompoundCount(HandleRef pen, out int count) => GdipGetPenCompoundCount_ptr.Delegate(pen, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenCompoundCount(HandleRef pen, out int count);
 
-            private delegate int GdipSetPenCompoundArray_delegate(HandleRef pen, float[] array, int count);
-            private static FunctionWrapper<GdipSetPenCompoundArray_delegate> GdipSetPenCompoundArray_ptr;
-            internal static int GdipSetPenCompoundArray(HandleRef pen, float[] array, int count) => GdipSetPenCompoundArray_ptr.Delegate(pen, array, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPenCompoundArray(HandleRef pen, float[] array, int count);
 
-            private delegate int GdipGetPenCompoundArray_delegate(HandleRef pen, float[] array, int count);
-            private static FunctionWrapper<GdipGetPenCompoundArray_delegate> GdipGetPenCompoundArray_ptr;
-            internal static int GdipGetPenCompoundArray(HandleRef pen, float[] array, int count) => GdipGetPenCompoundArray_ptr.Delegate(pen, array, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPenCompoundArray(HandleRef pen, float[] array, int count);
 
-            private delegate int GdipSetWorldTransform_delegate(HandleRef graphics, HandleRef matrix);
-            private static FunctionWrapper<GdipSetWorldTransform_delegate> GdipSetWorldTransform_ptr;
-            internal static int GdipSetWorldTransform(HandleRef graphics, HandleRef matrix) => GdipSetWorldTransform_ptr.Delegate(graphics, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetWorldTransform(HandleRef graphics, HandleRef matrix);
 
-            private delegate int GdipResetWorldTransform_delegate(HandleRef graphics);
-            private static FunctionWrapper<GdipResetWorldTransform_delegate> GdipResetWorldTransform_ptr;
-            internal static int GdipResetWorldTransform(HandleRef graphics) => GdipResetWorldTransform_ptr.Delegate(graphics);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipResetWorldTransform(HandleRef graphics);
 
-            private delegate int GdipMultiplyWorldTransform_delegate(HandleRef graphics, HandleRef matrix, MatrixOrder order);
-            private static FunctionWrapper<GdipMultiplyWorldTransform_delegate> GdipMultiplyWorldTransform_ptr;
-            internal static int GdipMultiplyWorldTransform(HandleRef graphics, HandleRef matrix, MatrixOrder order) => GdipMultiplyWorldTransform_ptr.Delegate(graphics, matrix, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipMultiplyWorldTransform(HandleRef graphics, HandleRef matrix, MatrixOrder order);
 
-            private delegate int GdipTranslateWorldTransform_delegate(HandleRef graphics, float dx, float dy, MatrixOrder order);
-            private static FunctionWrapper<GdipTranslateWorldTransform_delegate> GdipTranslateWorldTransform_ptr;
-            internal static int GdipTranslateWorldTransform(HandleRef graphics, float dx, float dy, MatrixOrder order) => GdipTranslateWorldTransform_ptr.Delegate(graphics, dx, dy, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTranslateWorldTransform(HandleRef graphics, float dx, float dy, MatrixOrder order);
 
-            private delegate int GdipScaleWorldTransform_delegate(HandleRef graphics, float sx, float sy, MatrixOrder order);
-            private static FunctionWrapper<GdipScaleWorldTransform_delegate> GdipScaleWorldTransform_ptr;
-            internal static int GdipScaleWorldTransform(HandleRef graphics, float sx, float sy, MatrixOrder order) => GdipScaleWorldTransform_ptr.Delegate(graphics, sx, sy, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipScaleWorldTransform(HandleRef graphics, float sx, float sy, MatrixOrder order);
 
-            private delegate int GdipRotateWorldTransform_delegate(HandleRef graphics, float angle, MatrixOrder order);
-            private static FunctionWrapper<GdipRotateWorldTransform_delegate> GdipRotateWorldTransform_ptr;
-            internal static int GdipRotateWorldTransform(HandleRef graphics, float angle, MatrixOrder order) => GdipRotateWorldTransform_ptr.Delegate(graphics, angle, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipRotateWorldTransform(HandleRef graphics, float angle, MatrixOrder order);
 
-            private delegate int GdipGetWorldTransform_delegate(HandleRef graphics, HandleRef matrix);
-            private static FunctionWrapper<GdipGetWorldTransform_delegate> GdipGetWorldTransform_ptr;
-            internal static int GdipGetWorldTransform(HandleRef graphics, HandleRef matrix) => GdipGetWorldTransform_ptr.Delegate(graphics, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetWorldTransform(HandleRef graphics, HandleRef matrix);
 
-            private delegate int GdipSetCompositingMode_delegate(HandleRef graphics, CompositingMode compositingMode);
-            private static FunctionWrapper<GdipSetCompositingMode_delegate> GdipSetCompositingMode_ptr;
-            internal static int GdipSetCompositingMode(HandleRef graphics, CompositingMode compositingMode) => GdipSetCompositingMode_ptr.Delegate(graphics, compositingMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetCompositingMode(HandleRef graphics, CompositingMode compositingMode);
 
-            private delegate int GdipSetTextRenderingHint_delegate(HandleRef graphics, TextRenderingHint textRenderingHint);
-            private static FunctionWrapper<GdipSetTextRenderingHint_delegate> GdipSetTextRenderingHint_ptr;
-            internal static int GdipSetTextRenderingHint(HandleRef graphics, TextRenderingHint textRenderingHint) => GdipSetTextRenderingHint_ptr.Delegate(graphics, textRenderingHint);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetTextRenderingHint(HandleRef graphics, TextRenderingHint textRenderingHint);
 
-            private delegate int GdipSetTextContrast_delegate(HandleRef graphics, int textContrast);
-            private static FunctionWrapper<GdipSetTextContrast_delegate> GdipSetTextContrast_ptr;
-            internal static int GdipSetTextContrast(HandleRef graphics, int textContrast) => GdipSetTextContrast_ptr.Delegate(graphics, textContrast);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetTextContrast(HandleRef graphics, int textContrast);
 
-            private delegate int GdipSetInterpolationMode_delegate(HandleRef graphics, InterpolationMode interpolationMode);
-            private static FunctionWrapper<GdipSetInterpolationMode_delegate> GdipSetInterpolationMode_ptr;
-            internal static int GdipSetInterpolationMode(HandleRef graphics, InterpolationMode interpolationMode) => GdipSetInterpolationMode_ptr.Delegate(graphics, interpolationMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetInterpolationMode(HandleRef graphics, InterpolationMode interpolationMode);
 
-            private delegate int GdipGetCompositingMode_delegate(HandleRef graphics, out CompositingMode compositingMode);
-            private static FunctionWrapper<GdipGetCompositingMode_delegate> GdipGetCompositingMode_ptr;
-            internal static int GdipGetCompositingMode(HandleRef graphics, out CompositingMode compositingMode) => GdipGetCompositingMode_ptr.Delegate(graphics, out compositingMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetCompositingMode(HandleRef graphics, out CompositingMode compositingMode);
 
-            private delegate int GdipSetRenderingOrigin_delegate(HandleRef graphics, int x, int y);
-            private static FunctionWrapper<GdipSetRenderingOrigin_delegate> GdipSetRenderingOrigin_ptr;
-            internal static int GdipSetRenderingOrigin(HandleRef graphics, int x, int y) => GdipSetRenderingOrigin_ptr.Delegate(graphics, x, y);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetRenderingOrigin(HandleRef graphics, int x, int y);
 
-            private delegate int GdipGetRenderingOrigin_delegate(HandleRef graphics, out int x, out int y);
-            private static FunctionWrapper<GdipGetRenderingOrigin_delegate> GdipGetRenderingOrigin_ptr;
-            internal static int GdipGetRenderingOrigin(HandleRef graphics, out int x, out int y) => GdipGetRenderingOrigin_ptr.Delegate(graphics, out x, out y);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetRenderingOrigin(HandleRef graphics, out int x, out int y);
 
-            private delegate int GdipSetCompositingQuality_delegate(HandleRef graphics, CompositingQuality quality);
-            private static FunctionWrapper<GdipSetCompositingQuality_delegate> GdipSetCompositingQuality_ptr;
-            internal static int GdipSetCompositingQuality(HandleRef graphics, CompositingQuality quality) => GdipSetCompositingQuality_ptr.Delegate(graphics, quality);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetCompositingQuality(HandleRef graphics, CompositingQuality quality);
 
-            private delegate int GdipGetCompositingQuality_delegate(HandleRef graphics, out CompositingQuality quality);
-            private static FunctionWrapper<GdipGetCompositingQuality_delegate> GdipGetCompositingQuality_ptr;
-            internal static int GdipGetCompositingQuality(HandleRef graphics, out CompositingQuality quality) => GdipGetCompositingQuality_ptr.Delegate(graphics, out quality);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetCompositingQuality(HandleRef graphics, out CompositingQuality quality);
 
-            private delegate int GdipSetSmoothingMode_delegate(HandleRef graphics, SmoothingMode smoothingMode);
-            private static FunctionWrapper<GdipSetSmoothingMode_delegate> GdipSetSmoothingMode_ptr;
-            internal static int GdipSetSmoothingMode(HandleRef graphics, SmoothingMode smoothingMode) => GdipSetSmoothingMode_ptr.Delegate(graphics, smoothingMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetSmoothingMode(HandleRef graphics, SmoothingMode smoothingMode);
 
-            private delegate int GdipGetSmoothingMode_delegate(HandleRef graphics, out SmoothingMode smoothingMode);
-            private static FunctionWrapper<GdipGetSmoothingMode_delegate> GdipGetSmoothingMode_ptr;
-            internal static int GdipGetSmoothingMode(HandleRef graphics, out SmoothingMode smoothingMode) => GdipGetSmoothingMode_ptr.Delegate(graphics, out smoothingMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetSmoothingMode(HandleRef graphics, out SmoothingMode smoothingMode);
 
-            private delegate int GdipSetPixelOffsetMode_delegate(HandleRef graphics, PixelOffsetMode pixelOffsetMode);
-            private static FunctionWrapper<GdipSetPixelOffsetMode_delegate> GdipSetPixelOffsetMode_ptr;
-            internal static int GdipSetPixelOffsetMode(HandleRef graphics, PixelOffsetMode pixelOffsetMode) => GdipSetPixelOffsetMode_ptr.Delegate(graphics, pixelOffsetMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPixelOffsetMode(HandleRef graphics, PixelOffsetMode pixelOffsetMode);
 
-            private delegate int GdipGetPixelOffsetMode_delegate(HandleRef graphics, out PixelOffsetMode pixelOffsetMode);
-            private static FunctionWrapper<GdipGetPixelOffsetMode_delegate> GdipGetPixelOffsetMode_ptr;
-            internal static int GdipGetPixelOffsetMode(HandleRef graphics, out PixelOffsetMode pixelOffsetMode) => GdipGetPixelOffsetMode_ptr.Delegate(graphics, out pixelOffsetMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPixelOffsetMode(HandleRef graphics, out PixelOffsetMode pixelOffsetMode);
 
-            private delegate int GdipGetTextRenderingHint_delegate(HandleRef graphics, out TextRenderingHint textRenderingHint);
-            private static FunctionWrapper<GdipGetTextRenderingHint_delegate> GdipGetTextRenderingHint_ptr;
-            internal static int GdipGetTextRenderingHint(HandleRef graphics, out TextRenderingHint textRenderingHint) => GdipGetTextRenderingHint_ptr.Delegate(graphics, out textRenderingHint);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetTextRenderingHint(HandleRef graphics, out TextRenderingHint textRenderingHint);
 
-            private delegate int GdipGetTextContrast_delegate(HandleRef graphics, out int textContrast);
-            private static FunctionWrapper<GdipGetTextContrast_delegate> GdipGetTextContrast_ptr;
-            internal static int GdipGetTextContrast(HandleRef graphics, out int textContrast) => GdipGetTextContrast_ptr.Delegate(graphics, out textContrast);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetTextContrast(HandleRef graphics, out int textContrast);
 
-            private delegate int GdipGetInterpolationMode_delegate(HandleRef graphics, out InterpolationMode interpolationMode);
-            private static FunctionWrapper<GdipGetInterpolationMode_delegate> GdipGetInterpolationMode_ptr;
-            internal static int GdipGetInterpolationMode(HandleRef graphics, out InterpolationMode interpolationMode) => GdipGetInterpolationMode_ptr.Delegate(graphics, out interpolationMode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetInterpolationMode(HandleRef graphics, out InterpolationMode interpolationMode);
 
-            private delegate int GdipGetPageUnit_delegate(HandleRef graphics, out GraphicsUnit unit);
-            private static FunctionWrapper<GdipGetPageUnit_delegate> GdipGetPageUnit_ptr;
-            internal static int GdipGetPageUnit(HandleRef graphics, out GraphicsUnit unit) => GdipGetPageUnit_ptr.Delegate(graphics, out unit);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPageUnit(HandleRef graphics, out GraphicsUnit unit);
 
-            private delegate int GdipGetPageScale_delegate(HandleRef graphics, out float scale);
-            private static FunctionWrapper<GdipGetPageScale_delegate> GdipGetPageScale_ptr;
-            internal static int GdipGetPageScale(HandleRef graphics, out float scale) => GdipGetPageScale_ptr.Delegate(graphics, out scale);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetPageScale(HandleRef graphics, out float scale);
 
-            private delegate int GdipSetPageUnit_delegate(HandleRef graphics, GraphicsUnit unit);
-            private static FunctionWrapper<GdipSetPageUnit_delegate> GdipSetPageUnit_ptr;
-            internal static int GdipSetPageUnit(HandleRef graphics, GraphicsUnit unit) => GdipSetPageUnit_ptr.Delegate(graphics, unit);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPageUnit(HandleRef graphics, GraphicsUnit unit);
 
-            private delegate int GdipSetPageScale_delegate(HandleRef graphics, float scale);
-            private static FunctionWrapper<GdipSetPageScale_delegate> GdipSetPageScale_ptr;
-            internal static int GdipSetPageScale(HandleRef graphics, float scale) => GdipSetPageScale_ptr.Delegate(graphics, scale);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetPageScale(HandleRef graphics, float scale);
 
-            private delegate int GdipGetDpiX_delegate(HandleRef graphics, out float dpi);
-            private static FunctionWrapper<GdipGetDpiX_delegate> GdipGetDpiX_ptr;
-            internal static int GdipGetDpiX(HandleRef graphics, out float dpi) => GdipGetDpiX_ptr.Delegate(graphics, out dpi);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetDpiX(HandleRef graphics, out float dpi);
 
-            private delegate int GdipGetDpiY_delegate(HandleRef graphics, out float dpi);
-            private static FunctionWrapper<GdipGetDpiY_delegate> GdipGetDpiY_ptr;
-            internal static int GdipGetDpiY(HandleRef graphics, out float dpi) => GdipGetDpiY_ptr.Delegate(graphics, out dpi);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetDpiY(HandleRef graphics, out float dpi);
 
-            private delegate int GdipCreateMatrix_delegate(out IntPtr matrix);
-            private static FunctionWrapper<GdipCreateMatrix_delegate> GdipCreateMatrix_ptr;
-            internal static int GdipCreateMatrix(out IntPtr matrix) => GdipCreateMatrix_ptr.Delegate(out matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateMatrix(out IntPtr matrix);
 
-            private delegate int GdipCreateMatrix2_delegate(float m11, float m12, float m21, float m22, float dx, float dy, out IntPtr matrix);
-            private static FunctionWrapper<GdipCreateMatrix2_delegate> GdipCreateMatrix2_ptr;
-            internal static int GdipCreateMatrix2(float m11, float m12, float m21, float m22, float dx, float dy, out IntPtr matrix) => GdipCreateMatrix2_ptr.Delegate(m11, m12, m21, m22, dx, dy, out matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateMatrix2(float m11, float m12, float m21, float m22, float dx, float dy, out IntPtr matrix);
 
-            private delegate int GdipCreateMatrix3_delegate(ref RectangleF rect, PointF* dstplg, out IntPtr matrix);
-            private static FunctionWrapper<GdipCreateMatrix3_delegate> GdipCreateMatrix3_ptr;
-            internal static int GdipCreateMatrix3(ref RectangleF rect, PointF* dstplg, out IntPtr matrix) => GdipCreateMatrix3_ptr.Delegate(ref rect, dstplg, out matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateMatrix3(ref RectangleF rect, PointF* dstplg, out IntPtr matrix);
 
-            private delegate int GdipCreateMatrix3I_delegate(ref Rectangle rect, Point* dstplg, out IntPtr matrix);
-            private static FunctionWrapper<GdipCreateMatrix3I_delegate> GdipCreateMatrix3I_ptr;
-            internal static int GdipCreateMatrix3I(ref Rectangle rect, Point* dstplg, out IntPtr matrix) => GdipCreateMatrix3I_ptr.Delegate(ref rect, dstplg, out matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateMatrix3I(ref Rectangle rect, Point* dstplg, out IntPtr matrix);
 
-            private delegate int GdipCloneMatrix_delegate(HandleRef matrix, out IntPtr cloneMatrix);
-            private static FunctionWrapper<GdipCloneMatrix_delegate> GdipCloneMatrix_ptr;
-            internal static int GdipCloneMatrix(HandleRef matrix, out IntPtr cloneMatrix) => GdipCloneMatrix_ptr.Delegate(matrix, out cloneMatrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCloneMatrix(HandleRef matrix, out IntPtr cloneMatrix);
 
-            private delegate int GdipDeleteMatrix_delegate(HandleRef matrix);
-            private static FunctionWrapper<GdipDeleteMatrix_delegate> GdipDeleteMatrix_ptr;
-            internal static int IntGdipDeleteMatrix(HandleRef matrix) => GdipDeleteMatrix_ptr.Delegate(matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeleteMatrix(HandleRef matrix);
 
-            private delegate int GdipSetMatrixElements_delegate(HandleRef matrix, float m11, float m12, float m21, float m22, float dx, float dy);
-            private static FunctionWrapper<GdipSetMatrixElements_delegate> GdipSetMatrixElements_ptr;
-            internal static int GdipSetMatrixElements(HandleRef matrix, float m11, float m12, float m21, float m22, float dx, float dy) => GdipSetMatrixElements_ptr.Delegate(matrix, m11, m12, m21, m22, dx, dy);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetMatrixElements(HandleRef matrix, float m11, float m12, float m21, float m22, float dx, float dy);
 
-            private delegate int GdipMultiplyMatrix_delegate(HandleRef matrix, HandleRef matrix2, MatrixOrder order);
-            private static FunctionWrapper<GdipMultiplyMatrix_delegate> GdipMultiplyMatrix_ptr;
-            internal static int GdipMultiplyMatrix(HandleRef matrix, HandleRef matrix2, MatrixOrder order) => GdipMultiplyMatrix_ptr.Delegate(matrix, matrix2, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipMultiplyMatrix(HandleRef matrix, HandleRef matrix2, MatrixOrder order);
 
-            private delegate int GdipTranslateMatrix_delegate(HandleRef matrix, float offsetX, float offsetY, MatrixOrder order);
-            private static FunctionWrapper<GdipTranslateMatrix_delegate> GdipTranslateMatrix_ptr;
-            internal static int GdipTranslateMatrix(HandleRef matrix, float offsetX, float offsetY, MatrixOrder order) => GdipTranslateMatrix_ptr.Delegate(matrix, offsetX, offsetY, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTranslateMatrix(HandleRef matrix, float offsetX, float offsetY, MatrixOrder order);
 
-            private delegate int GdipScaleMatrix_delegate(HandleRef matrix, float scaleX, float scaleY, MatrixOrder order);
-            private static FunctionWrapper<GdipScaleMatrix_delegate> GdipScaleMatrix_ptr;
-            internal static int GdipScaleMatrix(HandleRef matrix, float scaleX, float scaleY, MatrixOrder order) => GdipScaleMatrix_ptr.Delegate(matrix, scaleX, scaleY, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipScaleMatrix(HandleRef matrix, float scaleX, float scaleY, MatrixOrder order);
 
-            private delegate int GdipRotateMatrix_delegate(HandleRef matrix, float angle, MatrixOrder order);
-            private static FunctionWrapper<GdipRotateMatrix_delegate> GdipRotateMatrix_ptr;
-            internal static int GdipRotateMatrix(HandleRef matrix, float angle, MatrixOrder order) => GdipRotateMatrix_ptr.Delegate(matrix, angle, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipRotateMatrix(HandleRef matrix, float angle, MatrixOrder order);
 
-            private delegate int GdipShearMatrix_delegate(HandleRef matrix, float shearX, float shearY, MatrixOrder order);
-            private static FunctionWrapper<GdipShearMatrix_delegate> GdipShearMatrix_ptr;
-            internal static int GdipShearMatrix(HandleRef matrix, float shearX, float shearY, MatrixOrder order) => GdipShearMatrix_ptr.Delegate(matrix, shearX, shearY, order);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipShearMatrix(HandleRef matrix, float shearX, float shearY, MatrixOrder order);
 
-            private delegate int GdipInvertMatrix_delegate(HandleRef matrix);
-            private static FunctionWrapper<GdipInvertMatrix_delegate> GdipInvertMatrix_ptr;
-            internal static int GdipInvertMatrix(HandleRef matrix) => GdipInvertMatrix_ptr.Delegate(matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipInvertMatrix(HandleRef matrix);
 
-            private delegate int GdipTransformMatrixPoints_delegate(HandleRef matrix, PointF* pts, int count);
-            private static FunctionWrapper<GdipTransformMatrixPoints_delegate> GdipTransformMatrixPoints_ptr;
-            internal static int GdipTransformMatrixPoints(HandleRef matrix, PointF* pts, int count) => GdipTransformMatrixPoints_ptr.Delegate(matrix, pts, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTransformMatrixPoints(HandleRef matrix, PointF* pts, int count);
 
-            private delegate int GdipTransformMatrixPointsI_delegate(HandleRef matrix, Point* pts, int count);
-            private static FunctionWrapper<GdipTransformMatrixPointsI_delegate> GdipTransformMatrixPointsI_ptr;
-            internal static int GdipTransformMatrixPointsI(HandleRef matrix, Point* pts, int count) => GdipTransformMatrixPointsI_ptr.Delegate(matrix, pts, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTransformMatrixPointsI(HandleRef matrix, Point* pts, int count);
 
-            private delegate int GdipVectorTransformMatrixPoints_delegate(HandleRef matrix, PointF* pts, int count);
-            private static FunctionWrapper<GdipVectorTransformMatrixPoints_delegate> GdipVectorTransformMatrixPoints_ptr;
-            internal static int GdipVectorTransformMatrixPoints(HandleRef matrix, PointF* pts, int count) => GdipVectorTransformMatrixPoints_ptr.Delegate(matrix, pts, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipVectorTransformMatrixPoints(HandleRef matrix, PointF* pts, int count);
 
-            private delegate int GdipVectorTransformMatrixPointsI_delegate(HandleRef matrix, Point* pts, int count);
-            private static FunctionWrapper<GdipVectorTransformMatrixPointsI_delegate> GdipVectorTransformMatrixPointsI_ptr;
-            internal static int GdipVectorTransformMatrixPointsI(HandleRef matrix, Point* pts, int count) => GdipVectorTransformMatrixPointsI_ptr.Delegate(matrix, pts, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipVectorTransformMatrixPointsI(HandleRef matrix, Point* pts, int count);
 
-            private delegate int GdipGetMatrixElements_delegate(HandleRef matrix, IntPtr m);
-            private static FunctionWrapper<GdipGetMatrixElements_delegate> GdipGetMatrixElements_ptr;
-            internal static int GdipGetMatrixElements(HandleRef matrix, IntPtr m) => GdipGetMatrixElements_ptr.Delegate(matrix, m);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetMatrixElements(HandleRef matrix, IntPtr m);
 
-            private delegate int GdipIsMatrixInvertible_delegate(HandleRef matrix, out int boolean);
-            private static FunctionWrapper<GdipIsMatrixInvertible_delegate> GdipIsMatrixInvertible_ptr;
-            internal static int GdipIsMatrixInvertible(HandleRef matrix, out int boolean) => GdipIsMatrixInvertible_ptr.Delegate(matrix, out boolean);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsMatrixInvertible(HandleRef matrix, out int boolean);
 
-            private delegate int GdipIsMatrixIdentity_delegate(HandleRef matrix, out int boolean);
-            private static FunctionWrapper<GdipIsMatrixIdentity_delegate> GdipIsMatrixIdentity_ptr;
-            internal static int GdipIsMatrixIdentity(HandleRef matrix, out int boolean) => GdipIsMatrixIdentity_ptr.Delegate(matrix, out boolean);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsMatrixIdentity(HandleRef matrix, out int boolean);
 
-            private delegate int GdipIsMatrixEqual_delegate(HandleRef matrix, HandleRef matrix2, out int boolean);
-            private static FunctionWrapper<GdipIsMatrixEqual_delegate> GdipIsMatrixEqual_ptr;
-            internal static int GdipIsMatrixEqual(HandleRef matrix, HandleRef matrix2, out int boolean) => GdipIsMatrixEqual_ptr.Delegate(matrix, matrix2, out boolean);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsMatrixEqual(HandleRef matrix, HandleRef matrix2, out int boolean);
 
-            private delegate int GdipCreateRegion_delegate(out IntPtr region);
-            private static FunctionWrapper<GdipCreateRegion_delegate> GdipCreateRegion_ptr;
-            internal static int GdipCreateRegion(out IntPtr region) => GdipCreateRegion_ptr.Delegate(out region);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateRegion(out IntPtr region);
 
-            private delegate int GdipCreateRegionRect_delegate(ref RectangleF gprectf, out IntPtr region);
-            private static FunctionWrapper<GdipCreateRegionRect_delegate> GdipCreateRegionRect_ptr;
-            internal static int GdipCreateRegionRect(ref RectangleF gprectf, out IntPtr region) => GdipCreateRegionRect_ptr.Delegate(ref gprectf, out region);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateRegionRect(ref RectangleF gprectf, out IntPtr region);
 
-            private delegate int GdipCreateRegionRectI_delegate(ref Rectangle gprect, out IntPtr region);
-            private static FunctionWrapper<GdipCreateRegionRectI_delegate> GdipCreateRegionRectI_ptr;
-            internal static int GdipCreateRegionRectI(ref Rectangle gprect, out IntPtr region) => GdipCreateRegionRectI_ptr.Delegate(ref gprect, out region);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateRegionRectI(ref Rectangle gprect, out IntPtr region);
 
-            private delegate int GdipCreateRegionPath_delegate(HandleRef path, out IntPtr region);
-            private static FunctionWrapper<GdipCreateRegionPath_delegate> GdipCreateRegionPath_ptr;
-            internal static int GdipCreateRegionPath(HandleRef path, out IntPtr region) => GdipCreateRegionPath_ptr.Delegate(path, out region);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateRegionPath(HandleRef path, out IntPtr region);
 
-            private delegate int GdipCreateRegionRgnData_delegate(byte[] rgndata, int size, out IntPtr region);
-            private static FunctionWrapper<GdipCreateRegionRgnData_delegate> GdipCreateRegionRgnData_ptr;
-            internal static int GdipCreateRegionRgnData(byte[] rgndata, int size, out IntPtr region) => GdipCreateRegionRgnData_ptr.Delegate(rgndata, size, out region);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateRegionRgnData(byte[] rgndata, int size, out IntPtr region);
 
-            private delegate int GdipCreateRegionHrgn_delegate(HandleRef hRgn, out IntPtr region);
-            private static FunctionWrapper<GdipCreateRegionHrgn_delegate> GdipCreateRegionHrgn_ptr;
-            internal static int GdipCreateRegionHrgn(HandleRef hRgn, out IntPtr region) => GdipCreateRegionHrgn_ptr.Delegate(hRgn, out region);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateRegionHrgn(HandleRef hRgn, out IntPtr region);
 
-            private delegate int GdipCloneRegion_delegate(HandleRef region, out IntPtr cloneregion);
-            private static FunctionWrapper<GdipCloneRegion_delegate> GdipCloneRegion_ptr;
-            internal static int GdipCloneRegion(HandleRef region, out IntPtr cloneregion) => GdipCloneRegion_ptr.Delegate(region, out cloneregion);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCloneRegion(HandleRef region, out IntPtr cloneregion);
 
-            private delegate int GdipDeleteRegion_delegate(HandleRef region);
-            private static FunctionWrapper<GdipDeleteRegion_delegate> GdipDeleteRegion_ptr;
-            internal static int IntGdipDeleteRegion(HandleRef region) => GdipDeleteRegion_ptr.Delegate(region);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeleteRegion(HandleRef region);
 
-            private delegate int GdipFillRegion_delegate(HandleRef graphics, HandleRef brush, HandleRef region);
-            private static FunctionWrapper<GdipFillRegion_delegate> GdipFillRegion_ptr;
-            internal static int GdipFillRegion(HandleRef graphics, HandleRef brush, HandleRef region) => GdipFillRegion_ptr.Delegate(graphics, brush, region);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFillRegion(HandleRef graphics, HandleRef brush, HandleRef region);
 
-            private delegate int GdipSetInfinite_delegate(HandleRef region);
-            private static FunctionWrapper<GdipSetInfinite_delegate> GdipSetInfinite_ptr;
-            internal static int GdipSetInfinite(HandleRef region) => GdipSetInfinite_ptr.Delegate(region);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetInfinite(HandleRef region);
 
-            private delegate int GdipSetEmpty_delegate(HandleRef region);
-            private static FunctionWrapper<GdipSetEmpty_delegate> GdipSetEmpty_ptr;
-            internal static int GdipSetEmpty(HandleRef region) => GdipSetEmpty_ptr.Delegate(region);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetEmpty(HandleRef region);
 
-            private delegate int GdipCombineRegionRect_delegate(HandleRef region, ref RectangleF gprectf, CombineMode mode);
-            private static FunctionWrapper<GdipCombineRegionRect_delegate> GdipCombineRegionRect_ptr;
-            internal static int GdipCombineRegionRect(HandleRef region, ref RectangleF gprectf, CombineMode mode) => GdipCombineRegionRect_ptr.Delegate(region, ref gprectf, mode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCombineRegionRect(HandleRef region, ref RectangleF gprectf, CombineMode mode);
 
-            private delegate int GdipCombineRegionRectI_delegate(HandleRef region, ref Rectangle gprect, CombineMode mode);
-            private static FunctionWrapper<GdipCombineRegionRectI_delegate> GdipCombineRegionRectI_ptr;
-            internal static int GdipCombineRegionRectI(HandleRef region, ref Rectangle gprect, CombineMode mode) => GdipCombineRegionRectI_ptr.Delegate(region, ref gprect, mode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCombineRegionRectI(HandleRef region, ref Rectangle gprect, CombineMode mode);
 
-            private delegate int GdipCombineRegionPath_delegate(HandleRef region, HandleRef path, CombineMode mode);
-            private static FunctionWrapper<GdipCombineRegionPath_delegate> GdipCombineRegionPath_ptr;
-            internal static int GdipCombineRegionPath(HandleRef region, HandleRef path, CombineMode mode) => GdipCombineRegionPath_ptr.Delegate(region, path, mode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCombineRegionPath(HandleRef region, HandleRef path, CombineMode mode);
 
-            private delegate int GdipCombineRegionRegion_delegate(HandleRef region, HandleRef region2, CombineMode mode);
-            private static FunctionWrapper<GdipCombineRegionRegion_delegate> GdipCombineRegionRegion_ptr;
-            internal static int GdipCombineRegionRegion(HandleRef region, HandleRef region2, CombineMode mode) => GdipCombineRegionRegion_ptr.Delegate(region, region2, mode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCombineRegionRegion(HandleRef region, HandleRef region2, CombineMode mode);
 
-            private delegate int GdipTranslateRegion_delegate(HandleRef region, float dx, float dy);
-            private static FunctionWrapper<GdipTranslateRegion_delegate> GdipTranslateRegion_ptr;
-            internal static int GdipTranslateRegion(HandleRef region, float dx, float dy) => GdipTranslateRegion_ptr.Delegate(region, dx, dy);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTranslateRegion(HandleRef region, float dx, float dy);
 
-            private delegate int GdipTranslateRegionI_delegate(HandleRef region, int dx, int dy);
-            private static FunctionWrapper<GdipTranslateRegionI_delegate> GdipTranslateRegionI_ptr;
-            internal static int GdipTranslateRegionI(HandleRef region, int dx, int dy) => GdipTranslateRegionI_ptr.Delegate(region, dx, dy);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTranslateRegionI(HandleRef region, int dx, int dy);
 
-            private delegate int GdipTransformRegion_delegate(HandleRef region, HandleRef matrix);
-            private static FunctionWrapper<GdipTransformRegion_delegate> GdipTransformRegion_ptr;
-            internal static int GdipTransformRegion(HandleRef region, HandleRef matrix) => GdipTransformRegion_ptr.Delegate(region, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTransformRegion(HandleRef region, HandleRef matrix);
 
-            private delegate int GdipGetRegionBounds_delegate(HandleRef region, HandleRef graphics, out RectangleF gprectf);
-            private static FunctionWrapper<GdipGetRegionBounds_delegate> GdipGetRegionBounds_ptr;
-            internal static int GdipGetRegionBounds(HandleRef region, HandleRef graphics, out RectangleF gprectf) => GdipGetRegionBounds_ptr.Delegate(region, graphics, out gprectf);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetRegionBounds(HandleRef region, HandleRef graphics, out RectangleF gprectf);
 
-            private delegate int GdipGetRegionHRgn_delegate(HandleRef region, HandleRef graphics, out IntPtr hrgn);
-            private static FunctionWrapper<GdipGetRegionHRgn_delegate> GdipGetRegionHRgn_ptr;
-            internal static int GdipGetRegionHRgn(HandleRef region, HandleRef graphics, out IntPtr hrgn) => GdipGetRegionHRgn_ptr.Delegate(region, graphics, out hrgn);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetRegionHRgn(HandleRef region, HandleRef graphics, out IntPtr hrgn);
 
-            private delegate int GdipIsEmptyRegion_delegate(HandleRef region, HandleRef graphics, out int boolean);
-            private static FunctionWrapper<GdipIsEmptyRegion_delegate> GdipIsEmptyRegion_ptr;
-            internal static int GdipIsEmptyRegion(HandleRef region, HandleRef graphics, out int boolean) => GdipIsEmptyRegion_ptr.Delegate(region, graphics, out boolean);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsEmptyRegion(HandleRef region, HandleRef graphics, out int boolean);
 
-            private delegate int GdipIsInfiniteRegion_delegate(HandleRef region, HandleRef graphics, out int boolean);
-            private static FunctionWrapper<GdipIsInfiniteRegion_delegate> GdipIsInfiniteRegion_ptr;
-            internal static int GdipIsInfiniteRegion(HandleRef region, HandleRef graphics, out int boolean) => GdipIsInfiniteRegion_ptr.Delegate(region, graphics, out boolean);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsInfiniteRegion(HandleRef region, HandleRef graphics, out int boolean);
 
-            private delegate int GdipIsEqualRegion_delegate(HandleRef region, HandleRef region2, HandleRef graphics, out int boolean);
-            private static FunctionWrapper<GdipIsEqualRegion_delegate> GdipIsEqualRegion_ptr;
-            internal static int GdipIsEqualRegion(HandleRef region, HandleRef region2, HandleRef graphics, out int boolean) => GdipIsEqualRegion_ptr.Delegate(region, region2, graphics, out boolean);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsEqualRegion(HandleRef region, HandleRef region2, HandleRef graphics, out int boolean);
 
-            private delegate int GdipGetRegionDataSize_delegate(HandleRef region, out int bufferSize);
-            private static FunctionWrapper<GdipGetRegionDataSize_delegate> GdipGetRegionDataSize_ptr;
-            internal static int GdipGetRegionDataSize(HandleRef region, out int bufferSize) => GdipGetRegionDataSize_ptr.Delegate(region, out bufferSize);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetRegionDataSize(HandleRef region, out int bufferSize);
 
-            private delegate int GdipGetRegionData_delegate(HandleRef region, byte[] regionData, int bufferSize, out int sizeFilled);
-            private static FunctionWrapper<GdipGetRegionData_delegate> GdipGetRegionData_ptr;
-            internal static int GdipGetRegionData(HandleRef region, byte[] regionData, int bufferSize, out int sizeFilled) => GdipGetRegionData_ptr.Delegate(region, regionData, bufferSize, out sizeFilled);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetRegionData(HandleRef region, byte[] regionData, int bufferSize, out int sizeFilled);
 
-            private delegate int GdipIsVisibleRegionPoint_delegate(HandleRef region, float X, float Y, HandleRef graphics, out int boolean);
-            private static FunctionWrapper<GdipIsVisibleRegionPoint_delegate> GdipIsVisibleRegionPoint_ptr;
-            internal static int GdipIsVisibleRegionPoint(HandleRef region, float X, float Y, HandleRef graphics, out int boolean) => GdipIsVisibleRegionPoint_ptr.Delegate(region, X, Y, graphics, out boolean);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsVisibleRegionPoint(HandleRef region, float X, float Y, HandleRef graphics, out int boolean);
 
-            private delegate int GdipIsVisibleRegionPointI_delegate(HandleRef region, int X, int Y, HandleRef graphics, out int boolean);
-            private static FunctionWrapper<GdipIsVisibleRegionPointI_delegate> GdipIsVisibleRegionPointI_ptr;
-            internal static int GdipIsVisibleRegionPointI(HandleRef region, int X, int Y, HandleRef graphics, out int boolean) => GdipIsVisibleRegionPointI_ptr.Delegate(region, X, Y, graphics, out boolean);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsVisibleRegionPointI(HandleRef region, int X, int Y, HandleRef graphics, out int boolean);
 
-            private delegate int GdipIsVisibleRegionRect_delegate(HandleRef region, float X, float Y, float width, float height, HandleRef graphics, out int boolean);
-            private static FunctionWrapper<GdipIsVisibleRegionRect_delegate> GdipIsVisibleRegionRect_ptr;
-            internal static int GdipIsVisibleRegionRect(HandleRef region, float X, float Y, float width, float height, HandleRef graphics, out int boolean) => GdipIsVisibleRegionRect_ptr.Delegate(region, X, Y, width, height, graphics, out boolean);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsVisibleRegionRect(HandleRef region, float X, float Y, float width, float height, HandleRef graphics, out int boolean);
 
-            private delegate int GdipIsVisibleRegionRectI_delegate(HandleRef region, int X, int Y, int width, int height, HandleRef graphics, out int boolean);
-            private static FunctionWrapper<GdipIsVisibleRegionRectI_delegate> GdipIsVisibleRegionRectI_ptr;
-            internal static int GdipIsVisibleRegionRectI(HandleRef region, int X, int Y, int width, int height, HandleRef graphics, out int boolean) => GdipIsVisibleRegionRectI_ptr.Delegate(region, X, Y, width, height, graphics, out boolean);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsVisibleRegionRectI(HandleRef region, int X, int Y, int width, int height, HandleRef graphics, out int boolean);
 
-            private delegate int GdipGetRegionScansCount_delegate(HandleRef region, out int count, HandleRef matrix);
-            private static FunctionWrapper<GdipGetRegionScansCount_delegate> GdipGetRegionScansCount_ptr;
-            internal static int GdipGetRegionScansCount(HandleRef region, out int count, HandleRef matrix) => GdipGetRegionScansCount_ptr.Delegate(region, out count, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetRegionScansCount(HandleRef region, out int count, HandleRef matrix);
 
-            private delegate int GdipGetRegionScans_delegate(HandleRef region, RectangleF* rects, out int count, HandleRef matrix);
-            private static FunctionWrapper<GdipGetRegionScans_delegate> GdipGetRegionScans_ptr;
-            internal static int GdipGetRegionScans(HandleRef region, RectangleF* rects, out int count, HandleRef matrix) => GdipGetRegionScans_ptr.Delegate(region, rects, out count, matrix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetRegionScans(HandleRef region, RectangleF* rects, out int count, HandleRef matrix);
 
-            private delegate int GdipSetClipGraphics_delegate(HandleRef graphics, HandleRef srcgraphics, CombineMode mode);
-            private static FunctionWrapper<GdipSetClipGraphics_delegate> GdipSetClipGraphics_ptr;
-            internal static int GdipSetClipGraphics(HandleRef graphics, HandleRef srcgraphics, CombineMode mode) => GdipSetClipGraphics_ptr.Delegate(graphics, srcgraphics, mode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetClipGraphics(HandleRef graphics, HandleRef srcgraphics, CombineMode mode);
 
-            private delegate int GdipSetClipRect_delegate(HandleRef graphics, float x, float y, float width, float height, CombineMode mode);
-            private static FunctionWrapper<GdipSetClipRect_delegate> GdipSetClipRect_ptr;
-            internal static int GdipSetClipRect(HandleRef graphics, float x, float y, float width, float height, CombineMode mode) => GdipSetClipRect_ptr.Delegate(graphics, x, y, width, height, mode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetClipRect(HandleRef graphics, float x, float y, float width, float height, CombineMode mode);
 
-            private delegate int GdipSetClipRectI_delegate(HandleRef graphics, int x, int y, int width, int height, CombineMode mode);
-            private static FunctionWrapper<GdipSetClipRectI_delegate> GdipSetClipRectI_ptr;
-            internal static int GdipSetClipRectI(HandleRef graphics, int x, int y, int width, int height, CombineMode mode) => GdipSetClipRectI_ptr.Delegate(graphics, x, y, width, height, mode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetClipRectI(HandleRef graphics, int x, int y, int width, int height, CombineMode mode);
 
-            private delegate int GdipSetClipPath_delegate(HandleRef graphics, HandleRef path, CombineMode mode);
-            private static FunctionWrapper<GdipSetClipPath_delegate> GdipSetClipPath_ptr;
-            internal static int GdipSetClipPath(HandleRef graphics, HandleRef path, CombineMode mode) => GdipSetClipPath_ptr.Delegate(graphics, path, mode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetClipPath(HandleRef graphics, HandleRef path, CombineMode mode);
 
-            private delegate int GdipSetClipRegion_delegate(HandleRef graphics, HandleRef region, CombineMode mode);
-            private static FunctionWrapper<GdipSetClipRegion_delegate> GdipSetClipRegion_ptr;
-            internal static int GdipSetClipRegion(HandleRef graphics, HandleRef region, CombineMode mode) => GdipSetClipRegion_ptr.Delegate(graphics, region, mode);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetClipRegion(HandleRef graphics, HandleRef region, CombineMode mode);
 
-            private delegate int GdipResetClip_delegate(HandleRef graphics);
-            private static FunctionWrapper<GdipResetClip_delegate> GdipResetClip_ptr;
-            internal static int GdipResetClip(HandleRef graphics) => GdipResetClip_ptr.Delegate(graphics);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipResetClip(HandleRef graphics);
 
-            private delegate int GdipTranslateClip_delegate(HandleRef graphics, float dx, float dy);
-            private static FunctionWrapper<GdipTranslateClip_delegate> GdipTranslateClip_ptr;
-            internal static int GdipTranslateClip(HandleRef graphics, float dx, float dy) => GdipTranslateClip_ptr.Delegate(graphics, dx, dy);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipTranslateClip(HandleRef graphics, float dx, float dy);
 
-            private delegate int GdipGetClip_delegate(HandleRef graphics, HandleRef region);
-            private static FunctionWrapper<GdipGetClip_delegate> GdipGetClip_ptr;
-            internal static int GdipGetClip(HandleRef graphics, HandleRef region) => GdipGetClip_ptr.Delegate(graphics, region);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetClip(HandleRef graphics, HandleRef region);
 
-            private delegate int GdipGetClipBounds_delegate(HandleRef graphics, out RectangleF rect);
-            private static FunctionWrapper<GdipGetClipBounds_delegate> GdipGetClipBounds_ptr;
-            internal static int GdipGetClipBounds(HandleRef graphics, out RectangleF rect) => GdipGetClipBounds_ptr.Delegate(graphics, out rect);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetClipBounds(HandleRef graphics, out RectangleF rect);
 
-            private delegate int GdipIsClipEmpty_delegate(HandleRef graphics, out bool result);
-            private static FunctionWrapper<GdipIsClipEmpty_delegate> GdipIsClipEmpty_ptr;
-            internal static int GdipIsClipEmpty(HandleRef graphics, out bool result) => GdipIsClipEmpty_ptr.Delegate(graphics, out result);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsClipEmpty(HandleRef graphics, out bool result);
 
-            private delegate int GdipGetVisibleClipBounds_delegate(HandleRef graphics, out RectangleF rect);
-            private static FunctionWrapper<GdipGetVisibleClipBounds_delegate> GdipGetVisibleClipBounds_ptr;
-            internal static int GdipGetVisibleClipBounds(HandleRef graphics, out RectangleF rect) => GdipGetVisibleClipBounds_ptr.Delegate(graphics, out rect);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetVisibleClipBounds(HandleRef graphics, out RectangleF rect);
 
-            private delegate int GdipIsVisibleClipEmpty_delegate(HandleRef graphics, out bool result);
-            private static FunctionWrapper<GdipIsVisibleClipEmpty_delegate> GdipIsVisibleClipEmpty_ptr;
-            internal static int GdipIsVisibleClipEmpty(HandleRef graphics, out bool result) => GdipIsVisibleClipEmpty_ptr.Delegate(graphics, out result);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsVisibleClipEmpty(HandleRef graphics, out bool result);
 
-            private delegate int GdipIsVisiblePoint_delegate(HandleRef graphics, float x, float y, out bool result);
-            private static FunctionWrapper<GdipIsVisiblePoint_delegate> GdipIsVisiblePoint_ptr;
-            internal static int GdipIsVisiblePoint(HandleRef graphics, float x, float y, out bool result) => GdipIsVisiblePoint_ptr.Delegate(graphics, x, y, out result);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsVisiblePoint(HandleRef graphics, float x, float y, out bool result);
 
-            private delegate int GdipIsVisiblePointI_delegate(HandleRef graphics, int x, int y, out bool result);
-            private static FunctionWrapper<GdipIsVisiblePointI_delegate> GdipIsVisiblePointI_ptr;
-            internal static int GdipIsVisiblePointI(HandleRef graphics, int x, int y, out bool result) => GdipIsVisiblePointI_ptr.Delegate(graphics, x, y, out result);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsVisiblePointI(HandleRef graphics, int x, int y, out bool result);
 
-            private delegate int GdipIsVisibleRect_delegate(HandleRef graphics, float x, float y, float width, float height, out bool result);
-            private static FunctionWrapper<GdipIsVisibleRect_delegate> GdipIsVisibleRect_ptr;
-            internal static int GdipIsVisibleRect(HandleRef graphics, float x, float y, float width, float height, out bool result) => GdipIsVisibleRect_ptr.Delegate(graphics, x, y, width, height, out result);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsVisibleRect(HandleRef graphics, float x, float y, float width, float height, out bool result);
 
-            private delegate int GdipIsVisibleRectI_delegate(HandleRef graphics, int x, int y, int width, int height, out bool result);
-            private static FunctionWrapper<GdipIsVisibleRectI_delegate> GdipIsVisibleRectI_ptr;
-            internal static int GdipIsVisibleRectI(HandleRef graphics, int x, int y, int width, int height, out bool result) => GdipIsVisibleRectI_ptr.Delegate(graphics, x, y, width, height, out result);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipIsVisibleRectI(HandleRef graphics, int x, int y, int width, int height, out bool result);
 
-            private delegate int GdipFlush_delegate(HandleRef graphics, FlushIntention intention);
-            private static FunctionWrapper<GdipFlush_delegate> GdipFlush_ptr;
-            internal static int GdipFlush(HandleRef graphics, FlushIntention intention) => GdipFlush_ptr.Delegate(graphics, intention);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipFlush(HandleRef graphics, FlushIntention intention);
 
-            private delegate int GdipGetDC_delegate(HandleRef graphics, out IntPtr hdc);
-            private static FunctionWrapper<GdipGetDC_delegate> GdipGetDC_ptr;
-            internal static int GdipGetDC(HandleRef graphics, out IntPtr hdc) => GdipGetDC_ptr.Delegate(graphics, out hdc);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetDC(HandleRef graphics, out IntPtr hdc);
 
-            private delegate int GdipSetStringFormatMeasurableCharacterRanges_delegate(HandleRef format, int rangeCount, [In] [Out] CharacterRange[] range);
-            private static FunctionWrapper<GdipSetStringFormatMeasurableCharacterRanges_delegate> GdipSetStringFormatMeasurableCharacterRanges_ptr;
-            internal static int GdipSetStringFormatMeasurableCharacterRanges(HandleRef format, int rangeCount, [In] [Out] CharacterRange[] range) => GdipSetStringFormatMeasurableCharacterRanges_ptr.Delegate(format, rangeCount, range);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetStringFormatMeasurableCharacterRanges(HandleRef format, int rangeCount, [In] [Out] CharacterRange[] range);
 
-            private delegate int GdipCreateStringFormat_delegate(StringFormatFlags options, int language, out IntPtr format);
-            private static FunctionWrapper<GdipCreateStringFormat_delegate> GdipCreateStringFormat_ptr;
-            internal static int GdipCreateStringFormat(StringFormatFlags options, int language, out IntPtr format) => GdipCreateStringFormat_ptr.Delegate(options, language, out format);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateStringFormat(StringFormatFlags options, int language, out IntPtr format);
 
-            private delegate int GdipStringFormatGetGenericDefault_delegate(out IntPtr format);
-            private static FunctionWrapper<GdipStringFormatGetGenericDefault_delegate> GdipStringFormatGetGenericDefault_ptr;
-            internal static int GdipStringFormatGetGenericDefault(out IntPtr format) => GdipStringFormatGetGenericDefault_ptr.Delegate(out format);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipStringFormatGetGenericDefault(out IntPtr format);
 
-            private delegate int GdipStringFormatGetGenericTypographic_delegate(out IntPtr format);
-            private static FunctionWrapper<GdipStringFormatGetGenericTypographic_delegate> GdipStringFormatGetGenericTypographic_ptr;
-            internal static int GdipStringFormatGetGenericTypographic(out IntPtr format) => GdipStringFormatGetGenericTypographic_ptr.Delegate(out format);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipStringFormatGetGenericTypographic(out IntPtr format);
 
-            private delegate int GdipDeleteStringFormat_delegate(HandleRef format);
-            private static FunctionWrapper<GdipDeleteStringFormat_delegate> GdipDeleteStringFormat_ptr;
-            internal static int IntGdipDeleteStringFormat(HandleRef format) => GdipDeleteStringFormat_ptr.Delegate(format);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipDeleteStringFormat(HandleRef format);
 
-            private delegate int GdipCloneStringFormat_delegate(HandleRef format, out IntPtr newFormat);
-            private static FunctionWrapper<GdipCloneStringFormat_delegate> GdipCloneStringFormat_ptr;
-            internal static int GdipCloneStringFormat(HandleRef format, out IntPtr newFormat) => GdipCloneStringFormat_ptr.Delegate(format, out newFormat);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCloneStringFormat(HandleRef format, out IntPtr newFormat);
 
-            private delegate int GdipSetStringFormatFlags_delegate(HandleRef format, StringFormatFlags options);
-            private static FunctionWrapper<GdipSetStringFormatFlags_delegate> GdipSetStringFormatFlags_ptr;
-            internal static int GdipSetStringFormatFlags(HandleRef format, StringFormatFlags options) => GdipSetStringFormatFlags_ptr.Delegate(format, options);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetStringFormatFlags(HandleRef format, StringFormatFlags options);
 
-            private delegate int GdipGetStringFormatFlags_delegate(HandleRef format, out StringFormatFlags result);
-            private static FunctionWrapper<GdipGetStringFormatFlags_delegate> GdipGetStringFormatFlags_ptr;
-            internal static int GdipGetStringFormatFlags(HandleRef format, out StringFormatFlags result) => GdipGetStringFormatFlags_ptr.Delegate(format, out result);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetStringFormatFlags(HandleRef format, out StringFormatFlags result);
 
-            private delegate int GdipSetStringFormatAlign_delegate(HandleRef format, StringAlignment align);
-            private static FunctionWrapper<GdipSetStringFormatAlign_delegate> GdipSetStringFormatAlign_ptr;
-            internal static int GdipSetStringFormatAlign(HandleRef format, StringAlignment align) => GdipSetStringFormatAlign_ptr.Delegate(format, align);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetStringFormatAlign(HandleRef format, StringAlignment align);
 
-            private delegate int GdipGetStringFormatAlign_delegate(HandleRef format, out StringAlignment align);
-            private static FunctionWrapper<GdipGetStringFormatAlign_delegate> GdipGetStringFormatAlign_ptr;
-            internal static int GdipGetStringFormatAlign(HandleRef format, out StringAlignment align) => GdipGetStringFormatAlign_ptr.Delegate(format, out align);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetStringFormatAlign(HandleRef format, out StringAlignment align);
 
-            private delegate int GdipSetStringFormatLineAlign_delegate(HandleRef format, StringAlignment align);
-            private static FunctionWrapper<GdipSetStringFormatLineAlign_delegate> GdipSetStringFormatLineAlign_ptr;
-            internal static int GdipSetStringFormatLineAlign(HandleRef format, StringAlignment align) => GdipSetStringFormatLineAlign_ptr.Delegate(format, align);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetStringFormatLineAlign(HandleRef format, StringAlignment align);
 
-            private delegate int GdipGetStringFormatLineAlign_delegate(HandleRef format, out StringAlignment align);
-            private static FunctionWrapper<GdipGetStringFormatLineAlign_delegate> GdipGetStringFormatLineAlign_ptr;
-            internal static int GdipGetStringFormatLineAlign(HandleRef format, out StringAlignment align) => GdipGetStringFormatLineAlign_ptr.Delegate(format, out align);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetStringFormatLineAlign(HandleRef format, out StringAlignment align);
 
-            private delegate int GdipSetStringFormatHotkeyPrefix_delegate(HandleRef format, HotkeyPrefix hotkeyPrefix);
-            private static FunctionWrapper<GdipSetStringFormatHotkeyPrefix_delegate> GdipSetStringFormatHotkeyPrefix_ptr;
-            internal static int GdipSetStringFormatHotkeyPrefix(HandleRef format, HotkeyPrefix hotkeyPrefix) => GdipSetStringFormatHotkeyPrefix_ptr.Delegate(format, hotkeyPrefix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetStringFormatHotkeyPrefix(HandleRef format, HotkeyPrefix hotkeyPrefix);
 
-            private delegate int GdipGetStringFormatHotkeyPrefix_delegate(HandleRef format, out HotkeyPrefix hotkeyPrefix);
-            private static FunctionWrapper<GdipGetStringFormatHotkeyPrefix_delegate> GdipGetStringFormatHotkeyPrefix_ptr;
-            internal static int GdipGetStringFormatHotkeyPrefix(HandleRef format, out HotkeyPrefix hotkeyPrefix) => GdipGetStringFormatHotkeyPrefix_ptr.Delegate(format, out hotkeyPrefix);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetStringFormatHotkeyPrefix(HandleRef format, out HotkeyPrefix hotkeyPrefix);
 
-            private delegate int GdipSetStringFormatTabStops_delegate(HandleRef format, float firstTabOffset, int count, float[] tabStops);
-            private static FunctionWrapper<GdipSetStringFormatTabStops_delegate> GdipSetStringFormatTabStops_ptr;
-            internal static int GdipSetStringFormatTabStops(HandleRef format, float firstTabOffset, int count, float[] tabStops) => GdipSetStringFormatTabStops_ptr.Delegate(format, firstTabOffset, count, tabStops);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetStringFormatTabStops(HandleRef format, float firstTabOffset, int count, float[] tabStops);
 
-            private delegate int GdipGetStringFormatTabStops_delegate(HandleRef format, int count, out float firstTabOffset, [In] [Out] float[] tabStops);
-            private static FunctionWrapper<GdipGetStringFormatTabStops_delegate> GdipGetStringFormatTabStops_ptr;
-            internal static int GdipGetStringFormatTabStops(HandleRef format, int count, out float firstTabOffset, [In] [Out] float[] tabStops) => GdipGetStringFormatTabStops_ptr.Delegate(format, count, out firstTabOffset, tabStops);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetStringFormatTabStops(HandleRef format, int count, out float firstTabOffset, [In] [Out] float[] tabStops);
 
-            private delegate int GdipGetStringFormatTabStopCount_delegate(HandleRef format, out int count);
-            private static FunctionWrapper<GdipGetStringFormatTabStopCount_delegate> GdipGetStringFormatTabStopCount_ptr;
-            internal static int GdipGetStringFormatTabStopCount(HandleRef format, out int count) => GdipGetStringFormatTabStopCount_ptr.Delegate(format, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetStringFormatTabStopCount(HandleRef format, out int count);
 
-            private delegate int GdipGetStringFormatMeasurableCharacterRangeCount_delegate(HandleRef format, out int count);
-            private static FunctionWrapper<GdipGetStringFormatMeasurableCharacterRangeCount_delegate> GdipGetStringFormatMeasurableCharacterRangeCount_ptr;
-            internal static int GdipGetStringFormatMeasurableCharacterRangeCount(HandleRef format, out int count) => GdipGetStringFormatMeasurableCharacterRangeCount_ptr.Delegate(format, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetStringFormatMeasurableCharacterRangeCount(HandleRef format, out int count);
 
-            private delegate int GdipSetStringFormatTrimming_delegate(HandleRef format, StringTrimming trimming);
-            private static FunctionWrapper<GdipSetStringFormatTrimming_delegate> GdipSetStringFormatTrimming_ptr;
-            internal static int GdipSetStringFormatTrimming(HandleRef format, StringTrimming trimming) => GdipSetStringFormatTrimming_ptr.Delegate(format, trimming);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetStringFormatTrimming(HandleRef format, StringTrimming trimming);
 
-            private delegate int GdipGetStringFormatTrimming_delegate(HandleRef format, out StringTrimming trimming);
-            private static FunctionWrapper<GdipGetStringFormatTrimming_delegate> GdipGetStringFormatTrimming_ptr;
-            internal static int GdipGetStringFormatTrimming(HandleRef format, out StringTrimming trimming) => GdipGetStringFormatTrimming_ptr.Delegate(format, out trimming);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetStringFormatTrimming(HandleRef format, out StringTrimming trimming);
 
-            private delegate int GdipSetStringFormatDigitSubstitution_delegate(HandleRef format, int langID, StringDigitSubstitute sds);
-            private static FunctionWrapper<GdipSetStringFormatDigitSubstitution_delegate> GdipSetStringFormatDigitSubstitution_ptr;
-            internal static int GdipSetStringFormatDigitSubstitution(HandleRef format, int langID, StringDigitSubstitute sds) => GdipSetStringFormatDigitSubstitution_ptr.Delegate(format, langID, sds);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipSetStringFormatDigitSubstitution(HandleRef format, int langID, StringDigitSubstitute sds);
 
-            private delegate int GdipGetStringFormatDigitSubstitution_delegate(HandleRef format, out int langID, out StringDigitSubstitute sds);
-            private static FunctionWrapper<GdipGetStringFormatDigitSubstitution_delegate> GdipGetStringFormatDigitSubstitution_ptr;
-            internal static int GdipGetStringFormatDigitSubstitution(HandleRef format, out int langID, out StringDigitSubstitute sds) => GdipGetStringFormatDigitSubstitution_ptr.Delegate(format, out langID, out sds);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetStringFormatDigitSubstitution(HandleRef format, out int langID, out StringDigitSubstitute sds);
 
-            private delegate int GdipGetImageDimension_delegate(HandleRef image, out float width, out float height);
-            private static FunctionWrapper<GdipGetImageDimension_delegate> GdipGetImageDimension_ptr;
-            internal static int GdipGetImageDimension(HandleRef image, out float width, out float height) => GdipGetImageDimension_ptr.Delegate(image, out width, out height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageDimension(HandleRef image, out float width, out float height);
 
-            private delegate int GdipGetImageWidth_delegate(HandleRef image, out int width);
-            private static FunctionWrapper<GdipGetImageWidth_delegate> GdipGetImageWidth_ptr;
-            internal static int GdipGetImageWidth(HandleRef image, out int width) => GdipGetImageWidth_ptr.Delegate(image, out width);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageWidth(HandleRef image, out int width);
 
-            private delegate int GdipGetImageHeight_delegate(HandleRef image, out int height);
-            private static FunctionWrapper<GdipGetImageHeight_delegate> GdipGetImageHeight_ptr;
-            internal static int GdipGetImageHeight(HandleRef image, out int height) => GdipGetImageHeight_ptr.Delegate(image, out height);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageHeight(HandleRef image, out int height);
 
-            private delegate int GdipGetImageHorizontalResolution_delegate(HandleRef image, out float horzRes);
-            private static FunctionWrapper<GdipGetImageHorizontalResolution_delegate> GdipGetImageHorizontalResolution_ptr;
-            internal static int GdipGetImageHorizontalResolution(HandleRef image, out float horzRes) => GdipGetImageHorizontalResolution_ptr.Delegate(image, out horzRes);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageHorizontalResolution(HandleRef image, out float horzRes);
 
-            private delegate int GdipGetImageVerticalResolution_delegate(HandleRef image, out float vertRes);
-            private static FunctionWrapper<GdipGetImageVerticalResolution_delegate> GdipGetImageVerticalResolution_ptr;
-            internal static int GdipGetImageVerticalResolution(HandleRef image, out float vertRes) => GdipGetImageVerticalResolution_ptr.Delegate(image, out vertRes);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageVerticalResolution(HandleRef image, out float vertRes);
 
-            private delegate int GdipGetImageFlags_delegate(HandleRef image, out int flags);
-            private static FunctionWrapper<GdipGetImageFlags_delegate> GdipGetImageFlags_ptr;
-            internal static int GdipGetImageFlags(HandleRef image, out int flags) => GdipGetImageFlags_ptr.Delegate(image, out flags);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageFlags(HandleRef image, out int flags);
 
-            private delegate int GdipGetImageRawFormat_delegate(HandleRef image, ref Guid format);
-            private static FunctionWrapper<GdipGetImageRawFormat_delegate> GdipGetImageRawFormat_ptr;
-            internal static int GdipGetImageRawFormat(HandleRef image, ref Guid format) => GdipGetImageRawFormat_ptr.Delegate(image, ref format);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImageRawFormat(HandleRef image, ref Guid format);
 
-            private delegate int GdipGetImagePixelFormat_delegate(HandleRef image, out PixelFormat format);
-            private static FunctionWrapper<GdipGetImagePixelFormat_delegate> GdipGetImagePixelFormat_ptr;
-            internal static int GdipGetImagePixelFormat(HandleRef image, out PixelFormat format) => GdipGetImagePixelFormat_ptr.Delegate(image, out format);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipGetImagePixelFormat(HandleRef image, out PixelFormat format);
 
-            private delegate int GdipImageGetFrameCount_delegate(HandleRef image, ref Guid dimensionID, out int count);
-            private static FunctionWrapper<GdipImageGetFrameCount_delegate> GdipImageGetFrameCount_ptr;
-            internal static int GdipImageGetFrameCount(HandleRef image, ref Guid dimensionID, out int count) => GdipImageGetFrameCount_ptr.Delegate(image, ref dimensionID, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipImageGetFrameCount(HandleRef image, ref Guid dimensionID, out int count);
 
-            private delegate int GdipImageSelectActiveFrame_delegate(HandleRef image, ref Guid dimensionID, int frameIndex);
-            private static FunctionWrapper<GdipImageSelectActiveFrame_delegate> GdipImageSelectActiveFrame_ptr;
-            internal static int GdipImageSelectActiveFrame(HandleRef image, ref Guid dimensionID, int frameIndex) => GdipImageSelectActiveFrame_ptr.Delegate(image, ref dimensionID, frameIndex);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipImageSelectActiveFrame(HandleRef image, ref Guid dimensionID, int frameIndex);
 
-            private delegate int GdipImageRotateFlip_delegate(HandleRef image, int rotateFlipType);
-            private static FunctionWrapper<GdipImageRotateFlip_delegate> GdipImageRotateFlip_ptr;
-            internal static int GdipImageRotateFlip(HandleRef image, int rotateFlipType) => GdipImageRotateFlip_ptr.Delegate(image, rotateFlipType);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipImageRotateFlip(HandleRef image, int rotateFlipType);
 
-            private delegate int GdipRemovePropertyItem_delegate(HandleRef image, int propid);
-            private static FunctionWrapper<GdipRemovePropertyItem_delegate> GdipRemovePropertyItem_ptr;
-            internal static int GdipRemovePropertyItem(HandleRef image, int propid) => GdipRemovePropertyItem_ptr.Delegate(image, propid);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipRemovePropertyItem(HandleRef image, int propid);
 
-            private delegate int GdipCreateBitmapFromFile_delegate([MarshalAs(UnmanagedType.LPWStr)]string filename, out IntPtr bitmap);
-            private static FunctionWrapper<GdipCreateBitmapFromFile_delegate> GdipCreateBitmapFromFile_ptr;
-            internal static int GdipCreateBitmapFromFile(string filename, out IntPtr bitmap) => GdipCreateBitmapFromFile_ptr.Delegate(filename, out bitmap);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipCreateBitmapFromFile(string filename, out IntPtr bitmap);
 
-            private delegate int GdipCreateBitmapFromFileICM_delegate([MarshalAs(UnmanagedType.LPWStr)]string filename, out IntPtr bitmap);
-            private static FunctionWrapper<GdipCreateBitmapFromFileICM_delegate> GdipCreateBitmapFromFileICM_ptr;
-            internal static int GdipCreateBitmapFromFileICM(string filename, out IntPtr bitmap) => GdipCreateBitmapFromFileICM_ptr.Delegate(filename, out bitmap);
+            [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+            internal static extern int GdipCreateBitmapFromFileICM(string filename, out IntPtr bitmap);
 
-            private delegate int GdipCreateBitmapFromScan0_delegate(int width, int height, int stride, int format, HandleRef scan0, out IntPtr bitmap);
-            private static FunctionWrapper<GdipCreateBitmapFromScan0_delegate> GdipCreateBitmapFromScan0_ptr;
-            internal static int GdipCreateBitmapFromScan0(int width, int height, int stride, int format, HandleRef scan0, out IntPtr bitmap) => GdipCreateBitmapFromScan0_ptr.Delegate(width, height, stride, format, scan0, out bitmap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateBitmapFromScan0(int width, int height, int stride, int format, HandleRef scan0, out IntPtr bitmap);
 
-            private delegate int GdipCreateBitmapFromGraphics_delegate(int width, int height, HandleRef graphics, out IntPtr bitmap);
-            private static FunctionWrapper<GdipCreateBitmapFromGraphics_delegate> GdipCreateBitmapFromGraphics_ptr;
-            internal static int GdipCreateBitmapFromGraphics(int width, int height, HandleRef graphics, out IntPtr bitmap) => GdipCreateBitmapFromGraphics_ptr.Delegate(width, height, graphics, out bitmap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateBitmapFromGraphics(int width, int height, HandleRef graphics, out IntPtr bitmap);
 
-            private delegate int GdipCreateBitmapFromHBITMAP_delegate(HandleRef hbitmap, HandleRef hpalette, out IntPtr bitmap);
-            private static FunctionWrapper<GdipCreateBitmapFromHBITMAP_delegate> GdipCreateBitmapFromHBITMAP_ptr;
-            internal static int GdipCreateBitmapFromHBITMAP(HandleRef hbitmap, HandleRef hpalette, out IntPtr bitmap) => GdipCreateBitmapFromHBITMAP_ptr.Delegate(hbitmap, hpalette, out bitmap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateBitmapFromHBITMAP(HandleRef hbitmap, HandleRef hpalette, out IntPtr bitmap);
 
-            private delegate int GdipCreateBitmapFromHICON_delegate(HandleRef hicon, out IntPtr bitmap);
-            private static FunctionWrapper<GdipCreateBitmapFromHICON_delegate> GdipCreateBitmapFromHICON_ptr;
-            internal static int GdipCreateBitmapFromHICON(HandleRef hicon, out IntPtr bitmap) => GdipCreateBitmapFromHICON_ptr.Delegate(hicon, out bitmap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateBitmapFromHICON(HandleRef hicon, out IntPtr bitmap);
 
-            private delegate int GdipCreateBitmapFromResource_delegate(HandleRef hresource, HandleRef name, out IntPtr bitmap);
-            private static FunctionWrapper<GdipCreateBitmapFromResource_delegate> GdipCreateBitmapFromResource_ptr;
-            internal static int GdipCreateBitmapFromResource(HandleRef hresource, HandleRef name, out IntPtr bitmap) => GdipCreateBitmapFromResource_ptr.Delegate(hresource, name, out bitmap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateBitmapFromResource(HandleRef hresource, HandleRef name, out IntPtr bitmap);
 
-            private delegate int GdipCreateHBITMAPFromBitmap_delegate(HandleRef nativeBitmap, out IntPtr hbitmap, int argbBackground);
-            private static FunctionWrapper<GdipCreateHBITMAPFromBitmap_delegate> GdipCreateHBITMAPFromBitmap_ptr;
-            internal static int GdipCreateHBITMAPFromBitmap(HandleRef nativeBitmap, out IntPtr hbitmap, int argbBackground) => GdipCreateHBITMAPFromBitmap_ptr.Delegate(nativeBitmap, out hbitmap, argbBackground);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateHBITMAPFromBitmap(HandleRef nativeBitmap, out IntPtr hbitmap, int argbBackground);
 
-            private delegate int GdipCreateHICONFromBitmap_delegate(HandleRef nativeBitmap, out IntPtr hicon);
-            private static FunctionWrapper<GdipCreateHICONFromBitmap_delegate> GdipCreateHICONFromBitmap_ptr;
-            internal static int GdipCreateHICONFromBitmap(HandleRef nativeBitmap, out IntPtr hicon) => GdipCreateHICONFromBitmap_ptr.Delegate(nativeBitmap, out hicon);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCreateHICONFromBitmap(HandleRef nativeBitmap, out IntPtr hicon);
 
-            private delegate int GdipCloneBitmapArea_delegate(float x, float y, float width, float height, int format, HandleRef srcbitmap, out IntPtr dstbitmap);
-            private static FunctionWrapper<GdipCloneBitmapArea_delegate> GdipCloneBitmapArea_ptr;
-            internal static int GdipCloneBitmapArea(float x, float y, float width, float height, int format, HandleRef srcbitmap, out IntPtr dstbitmap) => GdipCloneBitmapArea_ptr.Delegate(x, y, width, height, format, srcbitmap, out dstbitmap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCloneBitmapArea(float x, float y, float width, float height, int format, HandleRef srcbitmap, out IntPtr dstbitmap);
 
-            private delegate int GdipCloneBitmapAreaI_delegate(int x, int y, int width, int height, int format, HandleRef srcbitmap, out IntPtr dstbitmap);
-            private static FunctionWrapper<GdipCloneBitmapAreaI_delegate> GdipCloneBitmapAreaI_ptr;
-            internal static int GdipCloneBitmapAreaI(int x, int y, int width, int height, int format, HandleRef srcbitmap, out IntPtr dstbitmap) => GdipCloneBitmapAreaI_ptr.Delegate(x, y, width, height, format, srcbitmap, out dstbitmap);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipCloneBitmapAreaI(int x, int y, int width, int height, int format, HandleRef srcbitmap, out IntPtr dstbitmap);
 
-            private delegate int GdipBitmapLockBits_delegate(HandleRef bitmap, ref Rectangle rect, ImageLockMode flags, PixelFormat format, [In] [Out] BitmapData lockedBitmapData);
-            private static FunctionWrapper<GdipBitmapLockBits_delegate> GdipBitmapLockBits_ptr;
-            internal static int GdipBitmapLockBits(HandleRef bitmap, ref Rectangle rect, ImageLockMode flags, PixelFormat format, [In] [Out] BitmapData lockedBitmapData) => GdipBitmapLockBits_ptr.Delegate(bitmap, ref rect, flags, format, lockedBitmapData);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipBitmapLockBits(HandleRef bitmap, ref Rectangle rect, ImageLockMode flags, PixelFormat format, [In] [Out] BitmapData lockedBitmapData);
 
-            private delegate int GdipBitmapUnlockBits_delegate(HandleRef bitmap, BitmapData lockedBitmapData);
-            private static FunctionWrapper<GdipBitmapUnlockBits_delegate> GdipBitmapUnlockBits_ptr;
-            internal static int GdipBitmapUnlockBits(HandleRef bitmap, BitmapData lockedBitmapData) => GdipBitmapUnlockBits_ptr.Delegate(bitmap, lockedBitmapData);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipBitmapUnlockBits(HandleRef bitmap, BitmapData lockedBitmapData);
 
-            private delegate int GdipBitmapGetPixel_delegate(HandleRef bitmap, int x, int y, out int argb);
-            private static FunctionWrapper<GdipBitmapGetPixel_delegate> GdipBitmapGetPixel_ptr;
-            internal static int GdipBitmapGetPixel(HandleRef bitmap, int x, int y, out int argb) => GdipBitmapGetPixel_ptr.Delegate(bitmap, x, y, out argb);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipBitmapGetPixel(HandleRef bitmap, int x, int y, out int argb);
 
-            private delegate int GdipBitmapSetPixel_delegate(HandleRef bitmap, int x, int y, int argb);
-            private static FunctionWrapper<GdipBitmapSetPixel_delegate> GdipBitmapSetPixel_ptr;
-            internal static int GdipBitmapSetPixel(HandleRef bitmap, int x, int y, int argb) => GdipBitmapSetPixel_ptr.Delegate(bitmap, x, y, argb);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipBitmapSetPixel(HandleRef bitmap, int x, int y, int argb);
 
-            private delegate int GdipBitmapSetResolution_delegate(HandleRef bitmap, float dpix, float dpiy);
-            private static FunctionWrapper<GdipBitmapSetResolution_delegate> GdipBitmapSetResolution_ptr;
-            internal static int GdipBitmapSetResolution(HandleRef bitmap, float dpix, float dpiy) => GdipBitmapSetResolution_ptr.Delegate(bitmap, dpix, dpiy);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipBitmapSetResolution(HandleRef bitmap, float dpix, float dpiy);
 
-            private delegate int GdipImageGetFrameDimensionsCount_delegate(HandleRef image, out int count);
-            private static FunctionWrapper<GdipImageGetFrameDimensionsCount_delegate> GdipImageGetFrameDimensionsCount_ptr;
-            internal static int GdipImageGetFrameDimensionsCount(HandleRef image, out int count) => GdipImageGetFrameDimensionsCount_ptr.Delegate(image, out count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipImageGetFrameDimensionsCount(HandleRef image, out int count);
 
-            private delegate int GdipImageGetFrameDimensionsList_delegate(HandleRef image, Guid* dimensionIDs, int count);
-            private static FunctionWrapper<GdipImageGetFrameDimensionsList_delegate> GdipImageGetFrameDimensionsList_ptr;
-            internal static int GdipImageGetFrameDimensionsList(HandleRef image, Guid* dimensionIDs, int count) => GdipImageGetFrameDimensionsList_ptr.Delegate(image, dimensionIDs, count);
+            [DllImport(LibraryName, ExactSpelling = true)]
+            internal static extern int GdipImageGetFrameDimensionsList(HandleRef image, Guid* dimensionIDs, int count);
         }
 
         [StructLayout(LayoutKind.Sequential)]
index 1582fc5..19dd2be 100644 (file)
@@ -256,7 +256,7 @@ namespace System.Drawing
                         maccontext.Release();
                 }
 
-                status = Gdip.GdipDeleteGraphics(NativeGraphics);
+                status = Gdip.GdipDeleteGraphics(new HandleRef(this, NativeGraphics));
                 NativeGraphics = IntPtr.Zero;
                 Gdip.CheckStatus(status);
                 disposed = true;
@@ -1805,7 +1805,7 @@ namespace System.Drawing
             int status = Gdip.InvalidParameter;
             if (hdc == _nativeHdc)
             {
-                status = Gdip.GdipReleaseDC(NativeGraphics, _nativeHdc);
+                status = Gdip.GdipReleaseDC(new HandleRef(this, NativeGraphics), new HandleRef(this, _nativeHdc));
                 _nativeHdc = IntPtr.Zero;
             }
             Gdip.CheckStatus(status);
index 2777f86..3eec118 100644 (file)
@@ -148,7 +148,8 @@ namespace System.Drawing
         [EditorBrowsable(EditorBrowsableState.Never)]
         public void ReleaseHdcInternal(IntPtr hdc)
         {
-            Gdip.CheckStatus(Gdip.GdipReleaseDC(new HandleRef(this, NativeGraphics), new HandleRef(null, hdc)));
+            Gdip.CheckStatus(!Gdip.Initialized ? Gdip.Ok :
+                Gdip.GdipReleaseDC(new HandleRef(this, NativeGraphics), new HandleRef(null, hdc)));
             _nativeHdc = IntPtr.Zero;
         }
 
@@ -194,7 +195,7 @@ namespace System.Drawing
                     }
 
 #if DEBUG
-                    int status =
+                    int status = !Gdip.Initialized ? Gdip.Ok :
 #endif
                     Gdip.GdipDeleteGraphics(new HandleRef(this, NativeGraphics));
 
index 3a396ae..82e1fc5 100644 (file)
@@ -2,19 +2,20 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+using System.Buffers;
 using System.ComponentModel;
 using System.Diagnostics;
 using System.Drawing.Imaging;
 using System.Drawing.Internal;
 using System.IO;
+using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Runtime.Serialization;
-using System.Text;
 
 namespace System.Drawing
 {
     [Serializable]
-    [System.Runtime.CompilerServices.TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
+    [TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
 #if netcoreapp
     [TypeConverter("System.Drawing.IconConverter, System.Windows.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")]
 #endif
@@ -32,13 +33,13 @@ namespace System.Drawing
 
         // Icon data
         private readonly byte[] _iconData;
-        private int _bestImageOffset;
-        private int _bestBitDepth;
-        private int _bestBytesInRes;
+        private uint _bestImageOffset;
+        private uint _bestBitDepth;
+        private uint _bestBytesInRes;
         private bool? _isBestImagePng = null;
         private Size _iconSize = Size.Empty;
         private IntPtr _handle = IntPtr.Zero;
-        private bool _ownHandle = true;
+        private readonly bool _ownHandle = true;
 
         private Icon() { }
 
@@ -159,42 +160,36 @@ namespace System.Drawing
 
         public static Icon ExtractAssociatedIcon(string filePath) => ExtractAssociatedIcon(filePath, 0);
 
-        private static Icon ExtractAssociatedIcon(string filePath, int index)
+        private unsafe static Icon ExtractAssociatedIcon(string filePath, int index)
         {
             if (filePath == null)
             {
                 throw new ArgumentNullException(nameof(filePath));
             }
 
-            Uri uri;
-            try
-            {
-                uri = new Uri(filePath);
-            }
-            catch (UriFormatException)
-            {
-                // It's a relative pathname, get its full path as a file. 
-                filePath = Path.GetFullPath(filePath);
-                uri = new Uri(filePath);
-            }
-
-            if (!uri.IsFile)
-            {
-                return null;
-            }
-
+            filePath = Path.GetFullPath(filePath);
             if (!File.Exists(filePath))
             {
-                throw new FileNotFoundException(filePath);
+                throw new FileNotFoundException(message: null, fileName: filePath);
             }
 
-            var sb = new StringBuilder(NativeMethods.MAX_PATH);
-            sb.Append(filePath);
+            // ExtractAssociatedIcon copies the loaded path into the buffer that it is passed.
+            // It isn't clear what the exact semantics are for copying back the path, a quick
+            // look at the code it might be hard coded to 128 chars for some cases. Leaving the
+            // historical MAX_PATH as a minimum to be safe.
 
-            IntPtr hIcon = SafeNativeMethods.ExtractAssociatedIcon(NativeMethods.NullHandleRef, sb, ref index);
-            if (hIcon != IntPtr.Zero)
+            char[] buffer = ArrayPool<char>.Shared.Rent(Math.Max(NativeMethods.MAX_PATH, filePath.Length));
+            filePath.CopyTo(0, buffer, 0, filePath.Length);
+            buffer[filePath.Length] = '\0';
+
+            fixed (char* b = buffer)
             {
-                return new Icon(hIcon, true);
+                IntPtr hIcon = SafeNativeMethods.ExtractAssociatedIcon(NativeMethods.NullHandleRef, b, ref index);
+                ArrayPool<char>.Shared.Return(buffer);
+                if (hIcon != IntPtr.Zero)
+                {
+                    return new Icon(hIcon, true);
+                }
             }
 
             return null;
@@ -216,26 +211,32 @@ namespace System.Drawing
         [Browsable(false)]
         public int Height => Size.Height;
 
-        public Size Size
+        public unsafe Size Size
         {
             get
             {
                 if (_iconSize.IsEmpty)
                 {
                     var info = new SafeNativeMethods.ICONINFO();
-                    SafeNativeMethods.GetIconInfo(new HandleRef(this, Handle), info);
-                    var bmp = new SafeNativeMethods.BITMAP();
+                    SafeNativeMethods.GetIconInfo(new HandleRef(this, Handle), ref info);
+                    var bitmap = new SafeNativeMethods.BITMAP();
 
                     if (info.hbmColor != IntPtr.Zero)
                     {
-                        SafeNativeMethods.GetObject(new HandleRef(null, info.hbmColor), Marshal.SizeOf(typeof(SafeNativeMethods.BITMAP)), bmp);
+                        SafeNativeMethods.GetObject(
+                            new HandleRef(null, info.hbmColor),
+                            sizeof(SafeNativeMethods.BITMAP),
+                            ref bitmap);
                         SafeNativeMethods.IntDeleteObject(new HandleRef(null, info.hbmColor));
-                        _iconSize = new Size(bmp.bmWidth, bmp.bmHeight);
+                        _iconSize = new Size((int)bitmap.bmWidth, (int)bitmap.bmHeight);
                     }
                     else if (info.hbmMask != IntPtr.Zero)
                     {
-                        SafeNativeMethods.GetObject(new HandleRef(null, info.hbmMask), Marshal.SizeOf(typeof(SafeNativeMethods.BITMAP)), bmp);
-                        _iconSize = new Size(bmp.bmWidth, bmp.bmHeight / 2);
+                        SafeNativeMethods.GetObject(
+                            new HandleRef(null, info.hbmMask),
+                            sizeof(SafeNativeMethods.BITMAP),
+                            ref bitmap);
+                        _iconSize = new Size((int)bitmap.bmWidth, (int)(bitmap.bmHeight / 2));
                     }
 
                     if (info.hbmMask != IntPtr.Zero)
@@ -421,39 +422,6 @@ namespace System.Drawing
 
         public static Icon FromHandle(IntPtr handle) => new Icon(handle);
 
-        private unsafe short GetShort(byte* pb)
-        {
-            int retval = 0;
-            if (0 != (unchecked((byte)pb) & 1))
-            {
-                retval = *pb;
-                pb++;
-                retval = unchecked(retval | (*pb << 8));
-            }
-            else
-            {
-                retval = unchecked(*(short*)pb);
-            }
-            return unchecked((short)retval);
-        }
-
-        private unsafe int GetInt(byte* pb)
-        {
-            int retval = 0;
-            if (0 != (unchecked((byte)pb) & 3))
-            {
-                retval = *pb; pb++;
-                retval = retval | (*pb << 8); pb++;
-                retval = retval | (*pb << 16); pb++;
-                retval = unchecked(retval | (*pb << 24));
-            }
-            else
-            {
-                retval = *(int*)pb;
-            }
-            return retval;
-        }
-
         // Initializes this Image object.  This is identical to calling the image's
         // constructor with picture, but this allows non-constructor initialization,
         // which may be necessary in some instances.
@@ -464,8 +432,7 @@ namespace System.Drawing
                 throw new InvalidOperationException(SR.Format(SR.IllegalState, GetType().Name));
             }
 
-            int icondirSize = Marshal.SizeOf(typeof(SafeNativeMethods.ICONDIR));
-            if (_iconData.Length < icondirSize)
+            if (_iconData.Length < sizeof(SafeNativeMethods.ICONDIR))
             {
                 throw new ArgumentException(SR.Format(SR.InvalidPictureType, "picture", nameof(Icon)));
             }
@@ -497,55 +464,40 @@ namespace System.Drawing
                 }
             }
 
-            fixed (byte* pbIconData = _iconData)
+            fixed (byte* b = _iconData)
             {
-                short idReserved = GetShort(pbIconData);
-                short idType = GetShort(pbIconData + 2);
-                short idCount = GetShort(pbIconData + 4);
+                SafeNativeMethods.ICONDIR* dir = (SafeNativeMethods.ICONDIR*)b;
 
-                if (idReserved != 0 || idType != 1 || idCount == 0)
+                if (dir->idReserved != 0 || dir->idType != 1 || dir->idCount == 0)
                 {
                     throw new ArgumentException(SR.Format(SR.InvalidPictureType, "picture", nameof(Icon)));
                 }
 
-                SafeNativeMethods.ICONDIRENTRY EntryTemp;
-
                 byte bestWidth = 0;
                 byte bestHeight = 0;
 
-                byte* pbIconDirEntry = unchecked(pbIconData + 6);
-                int icondirEntrySize = Marshal.SizeOf(typeof(SafeNativeMethods.ICONDIRENTRY));
-
-                if ((icondirEntrySize * (idCount - 1) + icondirSize) > _iconData.Length)
+                if (sizeof(SafeNativeMethods.ICONDIRENTRY) * (dir->idCount - 1) + sizeof(SafeNativeMethods.ICONDIR)
+                    > _iconData.Length)
                 {
                     throw new ArgumentException(SR.Format(SR.InvalidPictureType, "picture", nameof(Icon)));
                 }
 
-                for (int i = 0; i < idCount; i++)
+                var entries = new ReadOnlySpan<SafeNativeMethods.ICONDIRENTRY>(&dir->idEntries, dir->idCount);
+                foreach (SafeNativeMethods.ICONDIRENTRY entry in entries)
                 {
-                    // Fill in EntryTemp
-                    EntryTemp.bWidth = pbIconDirEntry[0];
-                    EntryTemp.bHeight = pbIconDirEntry[1];
-                    EntryTemp.bColorCount = pbIconDirEntry[2];
-                    EntryTemp.bReserved = pbIconDirEntry[3];
-                    EntryTemp.wPlanes = GetShort(pbIconDirEntry + 4);
-                    EntryTemp.wBitCount = GetShort(pbIconDirEntry + 6);
-                    EntryTemp.dwBytesInRes = GetInt(pbIconDirEntry + 8);
-                    EntryTemp.dwImageOffset = GetInt(pbIconDirEntry + 12);
-
                     bool fUpdateBestFit = false;
-                    int iconBitDepth = 0;
-                    if (EntryTemp.bColorCount != 0)
+                    uint iconBitDepth;
+                    if (entry.bColorCount != 0)
                     {
                         iconBitDepth = 4;
-                        if (EntryTemp.bColorCount < 0x10)
+                        if (entry.bColorCount < 0x10)
                         {
                             iconBitDepth = 1;
                         }
                     }
                     else
                     {
-                        iconBitDepth = EntryTemp.wBitCount;
+                        iconBitDepth = entry.wBitCount;
                     }
 
                     // If it looks like if nothing is specified at this point then set the bits per pixel to 8.
@@ -562,7 +514,6 @@ namespace System.Drawing
                     //  4.  If all icon color depth > display, lowest color depth is chosen.
                     //  5.  color depth of > 8bpp are all equal.
                     //  6.  Never choose an 8bpp icon on an 8bpp system.
-                    //
 
                     if (_bestBytesInRes == 0)
                     {
@@ -571,10 +522,10 @@ namespace System.Drawing
                     else
                     {
                         int bestDelta = Math.Abs(bestWidth - width) + Math.Abs(bestHeight - height);
-                        int thisDelta = Math.Abs(EntryTemp.bWidth - width) + Math.Abs(EntryTemp.bHeight - height);
+                        int thisDelta = Math.Abs(entry.bWidth - width) + Math.Abs(entry.bHeight - height);
 
                         if ((thisDelta < bestDelta) ||
-                            (thisDelta == bestDelta && (iconBitDepth <= s_bitDepth && iconBitDepth > _bestBitDepth || _bestBitDepth > s_bitDepth && iconBitDepth < _bestBitDepth)))
+                            (thisDelta == bestDelta && (0 <= s_bitDepth && 0 > _bestBitDepth || _bestBitDepth > s_bitDepth && 0 < _bestBitDepth)))
                         {
                             fUpdateBestFit = true;
                         }
@@ -582,27 +533,25 @@ namespace System.Drawing
 
                     if (fUpdateBestFit)
                     {
-                        bestWidth = EntryTemp.bWidth;
-                        bestHeight = EntryTemp.bHeight;
-                        _bestImageOffset = EntryTemp.dwImageOffset;
-                        _bestBytesInRes = EntryTemp.dwBytesInRes;
+                        bestWidth = entry.bWidth;
+                        bestHeight = entry.bHeight;
+                        _bestImageOffset = entry.dwImageOffset;
+                        _bestBytesInRes = entry.dwBytesInRes;
                         _bestBitDepth = iconBitDepth;
                     }
-
-                    pbIconDirEntry += icondirEntrySize;
                 }
 
-                if (_bestImageOffset < 0)
+                if (_bestImageOffset > int.MaxValue)
                 {
                     throw new ArgumentException(SR.Format(SR.InvalidPictureType, "picture", nameof(Icon)));
                 }
 
-                if (_bestBytesInRes < 0)
+                if (_bestBytesInRes > int.MaxValue)
                 {
                     throw new Win32Exception(SafeNativeMethods.ERROR_INVALID_PARAMETER);
                 }
 
-                int endOffset;
+                uint endOffset;
                 try
                 {
                     endOffset = checked(_bestImageOffset + _bestBytesInRes);
@@ -621,25 +570,27 @@ namespace System.Drawing
                 if ((_bestImageOffset % IntPtr.Size) != 0)
                 {
                     // Beginning of icon's content is misaligned.
-                    byte[] alignedBuffer = new byte[_bestBytesInRes];
+                    byte[] alignedBuffer = ArrayPool<byte>.Shared.Rent((int)_bestBytesInRes);
                     Array.Copy(_iconData, _bestImageOffset, alignedBuffer, 0, _bestBytesInRes);
 
                     fixed (byte* pbAlignedBuffer = alignedBuffer)
                     {
                         _handle = SafeNativeMethods.CreateIconFromResourceEx(pbAlignedBuffer, _bestBytesInRes, true, 0x00030000, 0, 0, 0);
                     }
+                    ArrayPool<byte>.Shared.Return(alignedBuffer);
                 }
                 else
                 {
                     try
                     {
-                        _handle = SafeNativeMethods.CreateIconFromResourceEx(checked(pbIconData + _bestImageOffset), _bestBytesInRes, true, 0x00030000, 0, 0, 0);
+                        _handle = SafeNativeMethods.CreateIconFromResourceEx(checked(b + _bestImageOffset), _bestBytesInRes, true, 0x00030000, 0, 0, 0);
                     }
                     catch (OverflowException)
                     {
                         throw new Win32Exception(SafeNativeMethods.ERROR_INVALID_PARAMETER);
                     }
                 }
+
                 if (_handle == IntPtr.Zero)
                 {
                     throw new Win32Exception();
@@ -747,7 +698,7 @@ namespace System.Drawing
             return BmpFrame();
         }
 
-        private Bitmap BmpFrame()
+        private unsafe Bitmap BmpFrame()
         {
             Bitmap bitmap = null;
             if (_iconData != null && _bestBitDepth == 32)
@@ -767,7 +718,7 @@ namespace System.Drawing
                         uint* pixelPtr = (uint*)bmpdata.Scan0.ToPointer();
 
                         // jumping the image header
-                        int newOffset = _bestImageOffset + Marshal.SizeOf(typeof(SafeNativeMethods.BITMAPINFOHEADER));
+                        int newOffset = (int)(_bestImageOffset + Marshal.SizeOf(typeof(SafeNativeMethods.BITMAPINFOHEADER)));
                         // there is no color table that we need to skip since we're 32bpp
 
                         int lineLength = Size.Width * 4;
@@ -790,13 +741,13 @@ namespace System.Drawing
             {
                 // This may be a 32bpp icon or an icon without any data.
                 var info = new SafeNativeMethods.ICONINFO();
-                SafeNativeMethods.GetIconInfo(new HandleRef(this, _handle), info);
+                SafeNativeMethods.GetIconInfo(new HandleRef(this, _handle), ref info);
                 var bmp = new SafeNativeMethods.BITMAP();
                 try
                 {
                     if (info.hbmColor != IntPtr.Zero)
                     {
-                        SafeNativeMethods.GetObject(new HandleRef(null, info.hbmColor), Marshal.SizeOf(typeof(SafeNativeMethods.BITMAP)), bmp);
+                        SafeNativeMethods.GetObject(new HandleRef(null, info.hbmColor), sizeof(SafeNativeMethods.BITMAP), ref bmp);
                         if (bmp.bmBitsPixel == 32)
                         {
                             Bitmap tmpBitmap = null;
@@ -898,7 +849,7 @@ namespace System.Drawing
             Debug.Assert(_iconData != null);
             using (var stream = new MemoryStream())
             {
-                stream.Write(_iconData, _bestImageOffset, _bestBytesInRes);
+                stream.Write(_iconData, (int)_bestImageOffset, (int)_bestBytesInRes);
                 return new Bitmap(stream);
             }
         }
@@ -909,8 +860,8 @@ namespace System.Drawing
             {
                 if (_iconData != null && _iconData.Length >= _bestImageOffset + 8)
                 {
-                    int iconSignature1 = BitConverter.ToInt32(_iconData, _bestImageOffset);
-                    int iconSignature2 = BitConverter.ToInt32(_iconData, _bestImageOffset + 4);
+                    int iconSignature1 = BitConverter.ToInt32(_iconData, (int)_bestImageOffset);
+                    int iconSignature2 = BitConverter.ToInt32(_iconData, (int)_bestImageOffset + 4);
                     _isBestImagePng = (iconSignature1 == PNGSignature1) && (iconSignature2 == PNGSignature2);
                 }
                 else
index b94224d..87861fc 100644 (file)
@@ -567,7 +567,7 @@ namespace System.Drawing
         {
             if (nativeImage != IntPtr.Zero)
             {
-                int status = Gdip.GdipDisposeImage(nativeImage);
+                int status = Gdip.GdipDisposeImage(new HandleRef(this, nativeImage));
                 // ... set nativeImage to null before (possibly) throwing an exception
                 nativeImage = IntPtr.Zero;
                 Gdip.CheckStatus(status);
index 1829495..1c3a8fd 100644 (file)
@@ -119,7 +119,7 @@ namespace System.Drawing
             try
             {
 #if DEBUG
-                int status =
+                int status = !Gdip.Initialized ? Gdip.Ok :
 #endif
                 Gdip.GdipDisposeImage(new HandleRef(this, nativeImage));
 #if DEBUG
index f8025e1..41e76b5 100644 (file)
@@ -91,7 +91,7 @@ namespace System.Drawing.Imaging
                 try
                 {
 #if DEBUG
-                    int status =
+                    int status = !Gdip.Initialized ? Gdip.Ok :
 #endif
                     Gdip.GdipDisposeImageAttributes(new HandleRef(this, nativeImageAttributes));
 #if DEBUG
index bc9c12a..f0e0f72 100644 (file)
@@ -102,15 +102,9 @@ namespace System.Drawing.Internal
             ActualizeVirtualPosition();
 
             // Stream Span API isn't available in 2.0
-#if netcoreapp20
-            byte[] buffer = ArrayPool<byte>.Shared.Rent(checked((int)cb));
-            int read = _dataStream.Read(buffer, 0, checked((int)cb));
-            Marshal.Copy(buffer, 0, (IntPtr)pv, read);
-            ArrayPool<byte>.Shared.Return(buffer);
-#else
             Span<byte> buffer = new Span<byte>(pv, checked((int)cb));
             int read = _dataStream.Read(buffer);
-#endif
+
             if (pcbRead != null)
                 *pcbRead = (uint)read;
         }
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/LibraryResolver.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/LibraryResolver.cs
new file mode 100644 (file)
index 0000000..bec1d8b
--- /dev/null
@@ -0,0 +1,34 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Drawing.Printing;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+namespace System.Drawing
+{
+    internal static class LibraryResolver
+    {
+        static LibraryResolver()
+        {
+            NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), DllImportResolver);
+        }
+
+        private static IntPtr DllImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
+        {
+            if (libraryName == LibcupsNative.LibraryName)
+                return LibcupsNative.LoadLibcups();
+            if (libraryName == SafeNativeMethods.Gdip.LibraryName)
+                return SafeNativeMethods.Gdip.LoadNativeLibrary();
+
+            return IntPtr.Zero;
+        }
+
+        internal static void EnsureRegistered()
+        {
+            // dummy call to trigger the static constructor
+        }
+    }
+}
index f4071aa..116808c 100644 (file)
@@ -24,10 +24,13 @@ namespace System.Drawing
                          BI_BITFIELDS = 3,
                          BI_RGB = 0,
                          BITMAPINFO_MAX_COLORSIZE = 256,
-                         SPI_GETICONTITLELOGFONT = 0x001F,
-                         SPI_GETNONCLIENTMETRICS = 41,
                          DEFAULT_GUI_FONT = 17;
 
+        internal const uint SPI_GETICONTITLELOGFONT = 0x001F;
+
+        // Gets metrics associated with the nonclient area of nonminimized windows
+        internal const uint SPI_GETNONCLIENTMETRICS = 41;
+
         [StructLayout(LayoutKind.Sequential)]
         internal struct BITMAPINFO_FLAT
         {
@@ -81,39 +84,27 @@ namespace System.Drawing
             public byte rgbReserved;
         }
 
-        [StructLayout(LayoutKind.Sequential)]
-        internal class NONCLIENTMETRICS
+        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+        internal struct NONCLIENTMETRICS
         {
-            public int cbSize = Marshal.SizeOf(typeof(NONCLIENTMETRICS));
+            public uint cbSize;
             public int iBorderWidth;
             public int iScrollWidth;
             public int iScrollHeight;
             public int iCaptionWidth;
             public int iCaptionHeight;
-#pragma warning disable CS0618 // Legacy code: We don't care about using obsolete API's.
-            [MarshalAs(UnmanagedType.Struct)]
-#pragma warning restore CS0618
             public SafeNativeMethods.LOGFONT lfCaptionFont;
             public int iSmCaptionWidth;
             public int iSmCaptionHeight;
-#pragma warning disable CS0618 // Legacy code: We don't care about using obsolete API's.
-            [MarshalAs(UnmanagedType.Struct)]
-#pragma warning restore CS0618
             public SafeNativeMethods.LOGFONT lfSmCaptionFont;
             public int iMenuWidth;
             public int iMenuHeight;
-#pragma warning disable CS0618 // Legacy code: We don't care about using obsolete API's.
-            [MarshalAs(UnmanagedType.Struct)]
-#pragma warning restore CS0618
             public SafeNativeMethods.LOGFONT lfMenuFont;
-#pragma warning disable CS0618 // Legacy code: We don't care about using obsolete API's.
-            [MarshalAs(UnmanagedType.Struct)]
-#pragma warning restore CS0618
             public SafeNativeMethods.LOGFONT lfStatusFont;
-#pragma warning disable CS0618 // Legacy code: We don't care about using obsolete API's.
-            [MarshalAs(UnmanagedType.Struct)]
-#pragma warning restore CS0618
             public SafeNativeMethods.LOGFONT lfMessageFont;
+
+            // This is supported on Windows vista and later
+            public int iPaddedBorderWidth;
         }
     }
 }
index d607781..0ac7ba5 100644 (file)
@@ -156,7 +156,7 @@ namespace System.Drawing
                 try
                 {
 #if DEBUG
-                    int status =
+                    int status = !Gdip.Initialized ? Gdip.Ok :
 #endif
                     Gdip.GdipDeletePen(new HandleRef(this, NativePen));
 #if DEBUG
index 6f0899f..65c000d 100644 (file)
@@ -9,87 +9,55 @@ namespace System.Drawing.Printing
 {
     internal static class LibcupsNative
     {
-        private const string LibraryName = "libcups";
-        private static IntPtr s_libcupsHandle = LoadLibcups();
+        internal const string LibraryName = "libcups";
 
-        private static IntPtr LoadLibcups()
+        static LibcupsNative()
+        {
+            LibraryResolver.EnsureRegistered();
+        }
+
+        internal static IntPtr LoadLibcups()
         {
             // We allow both "libcups.so" and "libcups.so.2" to be loaded.
-#if netcoreapp20
-            IntPtr lib = Interop.Libdl.dlopen("libcups.so", Interop.Libdl.RTLD_LAZY);
-            if (lib == IntPtr.Zero)
-            {
-                lib = Interop.Libdl.dlopen("libcups.so.2", Interop.Libdl.RTLD_LAZY);
-            }
-#else // use managed NativeLibrary API from .NET Core 3 onwards
             if (!NativeLibrary.TryLoad("libcups.so", out IntPtr lib))
             {
                 NativeLibrary.TryLoad("libcups.so.2", out lib);
             }
-#endif
+
             return lib;
         }
 
-        private delegate int cupsGetDests_delegate(ref IntPtr dests);
-        private static FunctionWrapper<cupsGetDests_delegate> cupsGetDests_ptr
-            = FunctionWrapper.Load<cupsGetDests_delegate>(s_libcupsHandle, "cupsGetDests", LibraryName);
-        internal static int cupsGetDests(ref IntPtr dests) => cupsGetDests_ptr.Delegate(ref dests);
-
-        private delegate int cupsFreeDests_delegate(int num_dests, IntPtr dests);
-        private static FunctionWrapper<cupsFreeDests_delegate> cupsFreeDests_ptr
-            = FunctionWrapper.Load<cupsFreeDests_delegate>(s_libcupsHandle, "cupsFreeDests", LibraryName);
-        internal static void cupsFreeDests(int num_dests, IntPtr dests) => cupsFreeDests_ptr.Delegate(num_dests, dests);
-
-        private delegate IntPtr cupsTempFd_delegate([MarshalAs(UnmanagedType.LPStr)]StringBuilder sb, int len);
-        private static FunctionWrapper<cupsTempFd_delegate> cupsTempFd_ptr
-            = FunctionWrapper.Load<cupsTempFd_delegate>(s_libcupsHandle, "cupsTempFd", LibraryName);
-        internal static IntPtr cupsTempFd(StringBuilder sb, int len) => cupsTempFd_ptr.Delegate(sb, len);
-
-        private delegate IntPtr cupsGetDefault_delegate();
-        private static FunctionWrapper<cupsGetDefault_delegate> cupsGetDefault_ptr
-            = FunctionWrapper.Load<cupsGetDefault_delegate>(s_libcupsHandle, "cupsGetDefault", LibraryName);
-        internal static IntPtr cupsGetDefault() => cupsGetDefault_ptr.Delegate();
-
-        private delegate int cupsPrintFile_delegate(
-            [MarshalAs(UnmanagedType.LPStr)]string printer,
-            [MarshalAs(UnmanagedType.LPStr)]string filename,
-            [MarshalAs(UnmanagedType.LPStr)]string title,
-            int num_options,
-            IntPtr options);
-        private static FunctionWrapper<cupsPrintFile_delegate> cupsPrintFile_ptr
-            = FunctionWrapper.Load<cupsPrintFile_delegate>(s_libcupsHandle, "cupsPrintFile", LibraryName);
-        internal static int cupsPrintFile(string printer, string filename, string title, int num_options, IntPtr options)
-            => cupsPrintFile_ptr.Delegate(printer, filename, title, num_options, options);
-
-        private delegate IntPtr cupsGetPPD_delegate([MarshalAs(UnmanagedType.LPStr)]string printer);
-        private static FunctionWrapper<cupsGetPPD_delegate> cupsGetPPD_ptr
-            = FunctionWrapper.Load<cupsGetPPD_delegate>(s_libcupsHandle, "cupsGetPPD", LibraryName);
-        internal static IntPtr cupsGetPPD(string printer) => cupsGetPPD_ptr.Delegate(printer);
-
-        private delegate IntPtr ppdOpenFile_delegate([MarshalAs(UnmanagedType.LPStr)]string filename);
-        private static FunctionWrapper<ppdOpenFile_delegate> ppdOpenFile_ptr
-            = FunctionWrapper.Load<ppdOpenFile_delegate>(s_libcupsHandle, "ppdOpenFile", LibraryName);
-        internal static IntPtr ppdOpenFile(string filename) => ppdOpenFile_ptr.Delegate(filename);
-
-        private delegate IntPtr ppdFindOption_delegate(IntPtr ppd_file, [MarshalAs(UnmanagedType.LPStr)]string keyword);
-        private static FunctionWrapper<ppdFindOption_delegate> ppdFindOption_ptr
-            = FunctionWrapper.Load<ppdFindOption_delegate>(s_libcupsHandle, "ppdFindOption", LibraryName);
-        internal static IntPtr ppdFindOption(IntPtr ppd_file, string keyword) => ppdFindOption_ptr.Delegate(ppd_file, keyword);
-
-        private delegate void ppdClose_delegate(IntPtr ppd);
-        private static FunctionWrapper<ppdClose_delegate> ppdClose_ptr
-            = FunctionWrapper.Load<ppdClose_delegate>(s_libcupsHandle, "ppdClose", LibraryName);
-        internal static void ppdClose(IntPtr ppd) => ppdClose_ptr.Delegate(ppd);
-
-        private delegate int cupsParseOptions_delegate([MarshalAs(UnmanagedType.LPStr)]string arg, int number_of_options, ref IntPtr options);
-        private static FunctionWrapper<cupsParseOptions_delegate> cupsParseOptions_ptr
-            = FunctionWrapper.Load<cupsParseOptions_delegate>(s_libcupsHandle, "cupsParseOptions", LibraryName);
-        internal static int cupsParseOptions(string arg, int number_of_options, ref IntPtr options)
-            => cupsParseOptions_ptr.Delegate(arg, number_of_options, ref options);
-
-        private delegate void cupsFreeOptions_delegate(int number_options, IntPtr options);
-        private static FunctionWrapper<cupsFreeOptions_delegate> cupsFreeOptions_ptr
-            = FunctionWrapper.Load<cupsFreeOptions_delegate>(s_libcupsHandle, "cupsFreeOptions", LibraryName);
-        internal static void cupsFreeOptions(int number_options, IntPtr options) => cupsFreeOptions_ptr.Delegate(number_options, options);
+        [DllImport(LibraryName, ExactSpelling = true)]
+        internal static extern int cupsGetDests(ref IntPtr dests);
+
+        [DllImport(LibraryName, ExactSpelling = true)]
+        internal static extern void cupsFreeDests(int num_dests, IntPtr dests);
+
+        [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Ansi)]
+        internal static extern IntPtr cupsTempFd(StringBuilder sb, int len);
+
+        [DllImport(LibraryName, ExactSpelling = true)]
+        internal static extern IntPtr cupsGetDefault();
+
+        [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Ansi)]
+        internal static extern int cupsPrintFile(string printer, string filename, string title, int num_options, IntPtr options);
+
+        [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Ansi)]
+        internal static extern IntPtr cupsGetPPD(string printer);
+
+        [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Ansi)]
+        internal static extern IntPtr ppdOpenFile(string filename);
+
+        [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Ansi)]
+        internal static extern IntPtr ppdFindOption(IntPtr ppd_file, string keyword);
+
+        [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Ansi)]
+        internal static extern void ppdClose(IntPtr ppd);
+
+        [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Ansi)]
+        internal static extern int cupsParseOptions(string arg, int number_of_options, ref IntPtr options);
+
+        [DllImport(LibraryName, ExactSpelling = true)]
+        internal static extern void cupsFreeOptions(int number_options, IntPtr options);
     }
 }
index 8635c23..7f4d6d5 100644 (file)
@@ -385,7 +385,7 @@ namespace System.Drawing.Printing
                 IntPtr modePointer = SafeNativeMethods.GlobalLock(new HandleRef(this, modeHandle));
                 SafeNativeMethods.DEVMODE mode = (SafeNativeMethods.DEVMODE)Marshal.PtrToStructure(modePointer, typeof(SafeNativeMethods.DEVMODE));
 
-                short result = mode.dmDriverExtra;
+                short result = mode?.dmDriverExtra ?? 0;
 
                 SafeNativeMethods.GlobalUnlock(new HandleRef(this, modeHandle));
                 SafeNativeMethods.GlobalFree(new HandleRef(this, modeHandle));
index b33ffd3..bec3ec9 100644 (file)
@@ -98,7 +98,7 @@ namespace System.Drawing
                 try
                 {
 #if DEBUG
-                    int status =
+                    int status = !Gdip.Initialized ? Gdip.Ok :
 #endif
                     Gdip.GdipDeleteRegion(new HandleRef(this, NativeRegion));
 #if DEBUG
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ScreenDC.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ScreenDC.cs
new file mode 100644 (file)
index 0000000..45e8873
--- /dev/null
@@ -0,0 +1,31 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Runtime.InteropServices;
+
+namespace System.Drawing
+{
+    /// <summary>
+    /// Simple wrapper to create a screen HDC within a using statement.
+    /// </summary>
+    internal struct ScreenDC : IDisposable
+    {
+        private IntPtr _handle;
+
+        public static ScreenDC Create()
+        {
+            return new ScreenDC
+            {
+                _handle = UnsafeNativeMethods.GetDC(NativeMethods.NullHandleRef)
+            };
+        }
+
+        public static implicit operator IntPtr(ScreenDC screenDC) => screenDC._handle;
+
+        public void Dispose()
+        {
+            UnsafeNativeMethods.ReleaseDC(NativeMethods.NullHandleRef, new HandleRef(null, _handle));
+        }
+    }
+}
index 92dd9ed..4ad993d 100644 (file)
@@ -83,7 +83,7 @@ namespace System.Drawing
                 try
                 {
 #if DEBUG
-                    int status =
+                    int status = !Gdip.Initialized ? Gdip.Ok :
 #endif
                     Gdip.GdipDeleteStringFormat(new HandleRef(this, nativeFormat));
 #if DEBUG
index fee85d9..7e990e9 100644 (file)
@@ -10,21 +10,27 @@ namespace System.Drawing
 {
     public static partial class SystemFonts
     {
+        private unsafe static bool GetNonClientMetrics(out NativeMethods.NONCLIENTMETRICS metrics)
+        {
+            metrics = new NativeMethods.NONCLIENTMETRICS { cbSize = (uint)sizeof(NativeMethods.NONCLIENTMETRICS) };
+            fixed (void* m = &metrics)
+            {
+                return UnsafeNativeMethods.SystemParametersInfo(NativeMethods.SPI_GETNONCLIENTMETRICS, metrics.cbSize, m, 0);
+            }
+        }
+
         public static Font CaptionFont
         {
             get
             {
                 Font captionFont = null;
 
-                var data = new NativeMethods.NONCLIENTMETRICS();
-                bool result = UnsafeNativeMethods.SystemParametersInfo(NativeMethods.SPI_GETNONCLIENTMETRICS, data.cbSize, data, 0);
-
-                if (result)
+                if (GetNonClientMetrics(out NativeMethods.NONCLIENTMETRICS metrics))
                 {
-                    captionFont = GetFontFromData(data.lfCaptionFont);
+                    captionFont = GetFontFromData(metrics.lfCaptionFont);
+                    captionFont.SetSystemFontName(nameof(CaptionFont));
                 }
 
-                captionFont.SetSystemFontName(nameof(CaptionFont));
                 return captionFont;
             }
         }
@@ -35,15 +41,12 @@ namespace System.Drawing
             {
                 Font smcaptionFont = null;
 
-                var data = new NativeMethods.NONCLIENTMETRICS();
-                bool result = UnsafeNativeMethods.SystemParametersInfo(NativeMethods.SPI_GETNONCLIENTMETRICS, data.cbSize, data, 0);
-
-                if (result)
+                if (GetNonClientMetrics(out NativeMethods.NONCLIENTMETRICS metrics))
                 {
-                    smcaptionFont = GetFontFromData(data.lfSmCaptionFont);
+                    smcaptionFont = GetFontFromData(metrics.lfSmCaptionFont);
+                    smcaptionFont.SetSystemFontName(nameof(SmallCaptionFont));
                 }
 
-                smcaptionFont.SetSystemFontName(nameof(SmallCaptionFont));
                 return smcaptionFont;
             }
         }
@@ -54,15 +57,12 @@ namespace System.Drawing
             {
                 Font menuFont = null;
 
-                var data = new NativeMethods.NONCLIENTMETRICS();
-                bool result = UnsafeNativeMethods.SystemParametersInfo(NativeMethods.SPI_GETNONCLIENTMETRICS, data.cbSize, data, 0);
-
-                if (result)
+                if (GetNonClientMetrics(out NativeMethods.NONCLIENTMETRICS metrics))
                 {
-                    menuFont = GetFontFromData(data.lfMenuFont);
+                    menuFont = GetFontFromData(metrics.lfMenuFont);
+                    menuFont.SetSystemFontName(nameof(MenuFont));
                 }
 
-                menuFont.SetSystemFontName(nameof(MenuFont));
                 return menuFont;
             }
         }
@@ -73,15 +73,12 @@ namespace System.Drawing
             {
                 Font statusFont = null;
 
-                var data = new NativeMethods.NONCLIENTMETRICS();
-                bool result = UnsafeNativeMethods.SystemParametersInfo(NativeMethods.SPI_GETNONCLIENTMETRICS, data.cbSize, data, 0);
-
-                if (result)
+                if (GetNonClientMetrics(out NativeMethods.NONCLIENTMETRICS metrics))
                 {
-                    statusFont = GetFontFromData(data.lfStatusFont);
+                    statusFont = GetFontFromData(metrics.lfStatusFont);
+                    statusFont.SetSystemFontName(nameof(StatusFont));
                 }
 
-                statusFont.SetSystemFontName(nameof(StatusFont));
                 return statusFont;
             }
         }
@@ -92,15 +89,12 @@ namespace System.Drawing
             {
                 Font messageBoxFont = null;
 
-                var data = new NativeMethods.NONCLIENTMETRICS();
-                bool result = UnsafeNativeMethods.SystemParametersInfo(NativeMethods.SPI_GETNONCLIENTMETRICS, data.cbSize, data, 0);
-
-                if (result)
+                if (GetNonClientMetrics(out NativeMethods.NONCLIENTMETRICS metrics))
                 {
-                    messageBoxFont = GetFontFromData(data.lfMessageFont);
+                    messageBoxFont = GetFontFromData(metrics.lfMessageFont);
+                    messageBoxFont.SetSystemFontName(nameof(MessageBoxFont));
                 }
 
-                messageBoxFont.SetSystemFontName(nameof(MessageBoxFont));
                 return messageBoxFont;
             }
         }
@@ -117,21 +111,19 @@ namespace System.Drawing
                 ex is FileNotFoundException);
         }
 
-        public static Font IconTitleFont
+        public static unsafe Font IconTitleFont
         {
             get
             {
                 Font iconTitleFont = null;
 
                 var itfont = new SafeNativeMethods.LOGFONT();
-                bool result = UnsafeNativeMethods.SystemParametersInfo(NativeMethods.SPI_GETICONTITLELOGFONT, Marshal.SizeOf(itfont), itfont, 0);
-
-                if (result)
+                if (UnsafeNativeMethods.SystemParametersInfo(NativeMethods.SPI_GETICONTITLELOGFONT, (uint)sizeof(SafeNativeMethods.LOGFONT), &itfont, 0))
                 {
                     iconTitleFont = GetFontFromData(itfont);
+                    iconTitleFont.SetSystemFontName(nameof(IconTitleFont));
                 }
 
-                iconTitleFont.SetSystemFontName(nameof(IconTitleFont));
                 return iconTitleFont;
             }
         }
@@ -141,10 +133,9 @@ namespace System.Drawing
             get
             {
                 Font defaultFont = null;
-                
+
                 // For Arabic systems, always return Tahoma 8.
-                bool systemDefaultLCIDIsArabic = (UnsafeNativeMethods.GetSystemDefaultLCID() & 0x3ff) == 0x0001;
-                if (systemDefaultLCIDIsArabic)
+                if ((ushort)UnsafeNativeMethods.GetSystemDefaultLCID() == 0x0001)
                 {
                     try
                     {
@@ -166,6 +157,7 @@ namespace System.Drawing
                     }
                     catch (ArgumentException)
                     {
+                        // This can happen in theory if we end up pulling a non-TrueType font
                     }
                 }
 
@@ -205,7 +197,7 @@ namespace System.Drawing
             {
                 Font dialogFont = null;
 
-                if ((UnsafeNativeMethods.GetSystemDefaultLCID() & 0x3ff) == 0x0011)
+                if ((ushort)UnsafeNativeMethods.GetSystemDefaultLCID() == 0x0011)
                 {
                     // Always return DefaultFont for Japanese cultures.
                     dialogFont = DefaultFont;
@@ -219,6 +211,7 @@ namespace System.Drawing
                     }
                     catch (ArgumentException)
                     {
+                        // This can happen in theory if we end up pulling a non-TrueType font
                     }
                 }
 
@@ -245,15 +238,10 @@ namespace System.Drawing
 
         private static Font GetFontFromData(SafeNativeMethods.LOGFONT logFont)
         {
-            if (logFont == null)
-            {
-                return null;
-            }
-
             Font font = null;
             try
             {
-                font = Font.FromLogFont(logFont);
+                font = Font.FromLogFont(ref logFont);
             }
             catch (Exception ex) when (!IsCriticalFontException(ex)) { }
 
index bebd51f..7c95373 100644 (file)
@@ -53,7 +53,7 @@ namespace System.Drawing
 
         private static Icon GetIcon(ref Icon icon, int iconId)
         {
-            return icon ?? (icon = new Icon(SafeNativeMethods.LoadIcon(NativeMethods.NullHandleRef, iconId)));
+            return icon ?? (icon = new Icon(SafeNativeMethods.LoadIcon(NativeMethods.NullHandleRef, (IntPtr)iconId)));
         }
     }
 }
index ff25c50..a78c707 100644 (file)
@@ -34,7 +34,7 @@ namespace System.Drawing.Text
                 try
                 {
 #if DEBUG
-                    int status =
+                    int status = !Gdip.Initialized ? Gdip.Ok :
 #endif
                     Gdip.GdipDeletePrivateFontCollection(ref _nativeFontCollection);
 #if DEBUG
index daa188d..0d3e197 100644 (file)
@@ -8,57 +8,32 @@ namespace System.Drawing
 {
     internal class UnsafeNativeMethods
     {
-        [DllImport(ExternDll.Kernel32, SetLastError = true, ExactSpelling = true, EntryPoint = "RtlMoveMemory", CharSet = CharSet.Auto)]
+        [DllImport(ExternDll.Kernel32, SetLastError = true, ExactSpelling = true, EntryPoint = "RtlMoveMemory")]
         public static extern void CopyMemory(HandleRef destData, HandleRef srcData, int size);
 
-        [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true, EntryPoint = "GetDC", CharSet = CharSet.Auto)]
-        private static extern IntPtr IntGetDC(HandleRef hWnd);
+        [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true)]
+        public static extern IntPtr GetDC(HandleRef hWnd);
 
-        public static IntPtr GetDC(HandleRef hWnd)
-        {
-            return System.Internal.HandleCollector.Add(IntGetDC(hWnd), SafeNativeMethods.CommonHandles.HDC);
-        }
+        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true)]
+        public static extern bool DeleteDC(HandleRef hDC);
 
-        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "DeleteDC", CharSet = CharSet.Auto)]
-        private static extern bool IntDeleteDC(HandleRef hDC);
+        [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true)]
+        public static extern int ReleaseDC(HandleRef hWnd, HandleRef hDC);
 
-        public static bool DeleteDC(HandleRef hDC)
-        {
-            System.Internal.HandleCollector.Remove((IntPtr)hDC, SafeNativeMethods.CommonHandles.GDI);
-            return IntDeleteDC(hDC);
-        }
+        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true)]
+        public static extern IntPtr CreateCompatibleDC(HandleRef hDC);
 
-        [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true, EntryPoint = "ReleaseDC", CharSet = CharSet.Auto)]
-        private static extern int IntReleaseDC(HandleRef hWnd, HandleRef hDC);
-
-        public static int ReleaseDC(HandleRef hWnd, HandleRef hDC)
-        {
-            System.Internal.HandleCollector.Remove((IntPtr)hDC, SafeNativeMethods.CommonHandles.HDC);
-            return IntReleaseDC(hWnd, hDC);
-        }
-
-        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "CreateCompatibleDC", CharSet = CharSet.Auto)]
-        private static extern IntPtr IntCreateCompatibleDC(HandleRef hDC);
-
-        public static IntPtr CreateCompatibleDC(HandleRef hDC)
-        {
-            return System.Internal.HandleCollector.Add(IntCreateCompatibleDC(hDC), SafeNativeMethods.CommonHandles.GDI);
-        }
-
-        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
+        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true)]
         public static extern IntPtr GetStockObject(int nIndex);
 
-        [DllImport(ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
+        [DllImport(ExternDll.Kernel32, SetLastError = true)]
         public static extern int GetSystemDefaultLCID();
 
-        [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
+        [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true)]
         public static extern int GetSystemMetrics(int nIndex);
 
-        [DllImport(ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
-        public static extern bool SystemParametersInfo(int uiAction, int uiParam, [In, Out] NativeMethods.NONCLIENTMETRICS pvParam, int fWinIni);
-
-        [DllImport(ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)]
-        public static extern bool SystemParametersInfo(int uiAction, int uiParam, [In, Out] SafeNativeMethods.LOGFONT pvParam, int fWinIni);
+        [DllImport(ExternDll.User32, SetLastError = true, CharSet = CharSet.Unicode)]
+        public static unsafe extern bool SystemParametersInfo(uint uiAction, uint uiParam, void* pvParam, uint fWinIni);
 
         [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
         public static extern int GetDeviceCaps(HandleRef hDC, int nIndex);
diff --git a/src/libraries/System.Drawing.Common/src/misc/DebugHandleTracker.cs b/src/libraries/System.Drawing.Common/src/misc/DebugHandleTracker.cs
deleted file mode 100644 (file)
index 62ffb3a..0000000
+++ /dev/null
@@ -1,468 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Collections;
-using System.ComponentModel;
-using System.Diagnostics;
-
-namespace System.Internal
-{
-    /// <summary>
-    /// The job of this class is to collect and track handle usage in windows forms. Ideally, a developer should never
-    /// have to call dispose() on any windows forms object. The problem in making this happen is in objects that are
-    /// very small to the VM garbage collector, but take up huge amounts of resources to the system. A good example of
-    /// this is a Win32 region handle. To the VM, a Region object is a small six ubyte object, so there isn't much need
-    /// to garbage collect it anytime soon. To Win32, however, a region handle consumes expensive USER and GDI
-    /// resources. Ideally we would like to be able to mark an object as "expensive" so it uses a different garbage
-    /// collection algorithm. In absence of that, we use the HandleCollector class, which runs a daemon thread to
-    /// garbage collect when handle usage goes up.
-    /// </summary>
-    internal class DebugHandleTracker
-    {
-        private static Hashtable s_handleTypes = new Hashtable();
-        private static DebugHandleTracker s_tracker;
-
-        static DebugHandleTracker()
-        {
-            s_tracker = new DebugHandleTracker();
-
-            if (CompModSwitches.HandleLeak.Level > TraceLevel.Off || CompModSwitches.TraceCollect.Enabled)
-            {
-                HandleCollector.HandleAdded += new HandleChangeEventHandler(s_tracker.OnHandleAdd);
-                HandleCollector.HandleRemoved += new HandleChangeEventHandler(s_tracker.OnHandleRemove);
-            }
-        }
-
-        private DebugHandleTracker()
-        {
-        }
-
-        private static object s_internalSyncObject = new object();
-
-        /// <summary>
-        /// All handles available at this time will be not be considered as leaks when CheckLeaks is called to report leaks.
-        /// </summary>
-        public static void IgnoreCurrentHandlesAsLeaks()
-        {
-            lock (s_internalSyncObject)
-            {
-                if (CompModSwitches.HandleLeak.Level >= TraceLevel.Warning)
-                {
-                    HandleType[] types = new HandleType[s_handleTypes.Values.Count];
-                    s_handleTypes.Values.CopyTo(types, 0);
-
-                    for (int i = 0; i < types.Length; i++)
-                    {
-                        types[i]?.IgnoreCurrentHandlesAsLeaks();
-                    }
-                }
-            }
-        }
-
-        /// <summary>
-        /// Called at shutdown to check for handles that are currently allocated. Normally, there should be none. 
-        /// This will print a list of all handle leaks.
-        /// </summary>
-        public static void CheckLeaks()
-        {
-            lock (s_internalSyncObject)
-            {
-                if (CompModSwitches.HandleLeak.Level >= TraceLevel.Warning)
-                {
-                    GC.Collect();
-                    GC.WaitForPendingFinalizers();
-                    HandleType[] types = new HandleType[s_handleTypes.Values.Count];
-                    s_handleTypes.Values.CopyTo(types, 0);
-
-                    Debug.WriteLine("------------Begin--CheckLeaks--------------------");
-                    for (int i = 0; i < types.Length; i++)
-                    {
-                        types[i]?.CheckLeaks();
-                    }
-                    Debug.WriteLine("-------------End--CheckLeaks---------------------");
-                }
-            }
-        }
-
-        /// <summary>
-        /// Ensures leak detection has been initialized.
-        /// </summary>
-        public static void Initialize()
-        {
-            // Calling this method forces the class to be loaded, thus running the
-            // static constructor which does all the work.
-        }
-
-        /// <summary>
-        /// Called by the Win32 handle collector when a new handle is created.
-        /// </summary>
-        private void OnHandleAdd(string handleName, IntPtr handle, int handleCount)
-        {
-            HandleType type = (HandleType)s_handleTypes[handleName];
-            if (type == null)
-            {
-                type = new HandleType(handleName);
-                s_handleTypes[handleName] = type;
-            }
-            type.Add(handle);
-        }
-
-        /// <summary>
-        /// Called by the Win32 handle collector when a new handle is created.
-        /// </summary>
-        private void OnHandleRemove(string handleName, IntPtr handle, int HandleCount)
-        {
-            HandleType type = (HandleType)s_handleTypes[handleName];
-
-            bool removed = false;
-            if (type != null)
-            {
-                removed = type.Remove(handle);
-            }
-
-            if (!removed)
-            {
-                if (CompModSwitches.HandleLeak.Level >= TraceLevel.Error)
-                {
-                    // It seems to me we shouldn't call HandleCollector.Remove more than once
-                    // for a given handle, but we do just that for HWND's (NativeWindow.DestroyWindow
-                    // and Control.WmNCDestroy).
-                    Debug.WriteLine("*************************************************");
-                    Debug.WriteLine("While removing, couldn't find handle: " + Convert.ToString(unchecked((int)handle), 16));
-                    Debug.WriteLine("Handle Type      : " + handleName);
-                    Debug.WriteLine(Environment.StackTrace);
-                    Debug.WriteLine("-------------------------------------------------");
-                }
-            }
-        }
-
-        /// <summary>
-        /// Represents a specific type of handle.
-        /// </summary>
-        private class HandleType
-        {
-            public readonly string name;
-
-            private int _handleCount;
-            private HandleEntry[] _buckets;
-
-            private const int NumberOfBuckets = 10;
-
-            /// <summary>
-            /// Creates a new handle type.
-            /// </summary>
-            public HandleType(string name)
-            {
-                this.name = name;
-                _buckets = new HandleEntry[NumberOfBuckets];
-            }
-
-            /// <summary>
-            /// Adds a handle to this handle type for monitoring.
-            /// </summary>
-            public void Add(IntPtr handle)
-            {
-                lock (this)
-                {
-                    int hash = ComputeHash(handle);
-                    if (CompModSwitches.HandleLeak.Level >= TraceLevel.Info)
-                    {
-                        Debug.WriteLine("-------------------------------------------------");
-                        Debug.WriteLine("Handle Allocating: " + Convert.ToString(unchecked((int)handle), 16));
-                        Debug.WriteLine("Handle Type      : " + name);
-                        if (CompModSwitches.HandleLeak.Level >= TraceLevel.Verbose)
-                            Debug.WriteLine(Environment.StackTrace);
-                    }
-
-                    HandleEntry entry = _buckets[hash];
-                    while (entry != null)
-                    {
-                        Debug.Assert(entry.handle != handle, "Duplicate handle of type " + name);
-                        entry = entry.next;
-                    }
-
-                    _buckets[hash] = new HandleEntry(_buckets[hash], handle);
-
-                    _handleCount++;
-                }
-            }
-
-            /// <summary>
-            /// Checks and reports leaks for handle monitoring.
-            /// </summary>
-            public void CheckLeaks()
-            {
-                lock (this)
-                {
-                    bool reportedFirstLeak = false;
-                    if (_handleCount > 0)
-                    {
-                        for (int i = 0; i < NumberOfBuckets; i++)
-                        {
-                            HandleEntry e = _buckets[i];
-                            while (e != null)
-                            {
-                                if (!e.ignorableAsLeak)
-                                {
-                                    if (!reportedFirstLeak)
-                                    {
-                                        Debug.WriteLine("\r\nHandle leaks detected for handles of type " + name + ":");
-                                        reportedFirstLeak = true;
-                                    }
-                                    Debug.WriteLine(e.ToString(this));
-                                }
-                                e = e.next;
-                            }
-                        }
-                    }
-                }
-            }
-
-            /// <summary>
-            /// Marks all the handles currently stored, as ignorable, so that they will not be reported as leaks later.
-            /// </summary>
-            public void IgnoreCurrentHandlesAsLeaks()
-            {
-                lock (this)
-                {
-                    if (_handleCount > 0)
-                    {
-                        for (int i = 0; i < NumberOfBuckets; i++)
-                        {
-                            HandleEntry e = _buckets[i];
-                            while (e != null)
-                            {
-                                e.ignorableAsLeak = true;
-                                e = e.next;
-                            }
-                        }
-                    }
-                }
-            }
-
-            /// <summary>
-            /// Computes the hash bucket for this handle.
-            /// </summary>
-            private int ComputeHash(IntPtr handle)
-            {
-                return (unchecked((int)handle) & 0xFFFF) % NumberOfBuckets;
-            }
-
-            /// <summary>
-            /// Removes the given handle from our monitor list.
-            /// </summary>
-            public bool Remove(IntPtr handle)
-            {
-                lock (this)
-                {
-                    int hash = ComputeHash(handle);
-                    if (CompModSwitches.HandleLeak.Level >= TraceLevel.Info)
-                    {
-                        Debug.WriteLine("-------------------------------------------------");
-                        Debug.WriteLine("Handle Releaseing: " + Convert.ToString(unchecked((int)handle), 16));
-                        Debug.WriteLine("Handle Type      : " + name);
-                        if (CompModSwitches.HandleLeak.Level >= TraceLevel.Verbose)
-                            Debug.WriteLine(Environment.StackTrace);
-                    }
-                    HandleEntry e = _buckets[hash];
-                    HandleEntry last = null;
-                    while (e != null && e.handle != handle)
-                    {
-                        last = e;
-                        e = e.next;
-                    }
-                    if (e != null)
-                    {
-                        if (last == null)
-                        {
-                            _buckets[hash] = e.next;
-                        }
-                        else
-                        {
-                            last.next = e.next;
-                        }
-                        _handleCount--;
-                        return true;
-                    }
-                    return false;
-                }
-            }
-
-            /// <summary>
-            /// Denotes a single entry in our handle list.
-            /// </summary>
-            private class HandleEntry
-            {
-                public readonly IntPtr handle;
-                public HandleEntry next;
-                public readonly string callStack;
-                public bool ignorableAsLeak;
-
-                /// <summary>
-                /// Creates a new handle entry
-                /// </summary>
-                public HandleEntry(HandleEntry next, IntPtr handle)
-                {
-                    this.handle = handle;
-                    this.next = next;
-
-                    if (CompModSwitches.HandleLeak.Level > TraceLevel.Off)
-                    {
-                        callStack = Environment.StackTrace;
-                    }
-                    else
-                    {
-                        callStack = null;
-                    }
-                }
-
-                /// <summary>
-                /// Converts this handle to a printable string.  the string consists of the handle value along with
-                /// the callstack for it's allocation.
-                /// </summary>
-                public string ToString(HandleType type)
-                {
-                    StackParser sp = new StackParser(callStack);
-
-                    // Discard all of the stack up to and including the "Handle.create" call
-                    sp.DiscardTo("HandleCollector.Add");
-
-                    // Skip the next call as it is always a debug wrapper
-                    sp.DiscardNext();
-
-                    // Now recreate the leak list with a lot of stack entries
-                    sp.Truncate(40);
-
-                    string description = "";
-
-                    return Convert.ToString(unchecked((int)handle), 16) + description + ": " + sp.ToString();
-                }
-
-                /// <summary>
-                /// Simple stack parsing class to manipulate our callstack.
-                /// </summary>
-                private class StackParser
-                {
-                    internal string releventStack;
-                    internal int startIndex;
-                    internal int endIndex;
-                    internal int length;
-
-                    /// <summary>
-                    /// Creates a new stackparser with the given callstack
-                    /// </summary>
-                    public StackParser(string callStack)
-                    {
-                        releventStack = callStack;
-                        length = releventStack.Length;
-                    }
-
-                    /// <summary>
-                    /// Determines if the given string contains token.  This is a case sensitive match.
-                    /// </summary>
-                    private static bool ContainsString(string str, string token)
-                    {
-                        int stringLength = str.Length;
-                        int tokenLength = token.Length;
-
-                        for (int s = 0; s < stringLength; s++)
-                        {
-                            int t = 0;
-                            while (t < tokenLength && str[s + t] == token[t])
-                            {
-                                t++;
-                            }
-                            if (t == tokenLength)
-                            {
-                                return true;
-                            }
-                        }
-                        return false;
-                    }
-
-                    /// <summary>
-                    /// Discards the next line of the stack trace.
-                    /// </summary>
-                    public void DiscardNext()
-                    {
-                        GetLine();
-                    }
-
-                    /// <summary>
-                    /// Discards all lines up to and including the line that contains discardText.
-                    /// </summary>
-                    public void DiscardTo(string discardText)
-                    {
-                        while (startIndex < length)
-                        {
-                            string line = GetLine();
-                            if (line == null || ContainsString(line, discardText))
-                            {
-                                break;
-                            }
-                        }
-                    }
-
-                    /// <summary>
-                    /// Retrieves the next line of the stack.
-                    /// </summary>
-                    private string GetLine()
-                    {
-                        endIndex = releventStack.IndexOf('\r', startIndex);
-                        if (endIndex < 0)
-                        {
-                            endIndex = length - 1;
-                        }
-
-                        string line = releventStack.Substring(startIndex, endIndex - startIndex);
-                        char ch;
-
-                        while (endIndex < length && ((ch = releventStack[endIndex]) == '\r' || ch == '\n'))
-                        {
-                            endIndex++;
-                        }
-                        if (startIndex == endIndex) return null;
-                        startIndex = endIndex;
-                        line = line.Replace('\t', ' ');
-                        return line;
-                    }
-
-                    /// <summary>
-                    /// Retrieves the string of the parsed stack trace
-                    /// </summary>
-                    public override string ToString()
-                    {
-                        return releventStack.Substring(startIndex);
-                    }
-
-                    /// <summary>
-                    /// Truncates the stack trace, saving the given # of lines.
-                    /// </summary>
-                    public void Truncate(int lines)
-                    {
-                        string truncatedStack = "";
-
-                        while (lines-- > 0 && startIndex < length)
-                        {
-                            if (truncatedStack == null)
-                            {
-                                truncatedStack = GetLine();
-                            }
-                            else
-                            {
-                                truncatedStack += ": " + GetLine();
-                            }
-                            truncatedStack += Environment.NewLine;
-                        }
-
-                        releventStack = truncatedStack;
-                        startIndex = 0;
-                        endIndex = 0;
-                        length = releventStack.Length;
-                    }
-                }
-            }
-        }
-    }
-}
index 521a26b..8df817d 100644 (file)
@@ -244,36 +244,17 @@ namespace System.Drawing.Internal
             {
                 case DeviceContextType.Display:
                     Debug.Assert(disposing, "WARNING: Finalizing a Display DeviceContext.\r\nReleaseDC may fail when not called from the same thread GetDC was called from.");
-
                     ((IDeviceContext)this).ReleaseHdc();
                     break;
-
                 case DeviceContextType.Information:
                 case DeviceContextType.NamedDevice:
-
-                    // CreateDC and CreateIC add an HDC handle to the HandleCollector; to remove it properly we need 
-                    // to call DeleteHDC.
-#if TRACK_HDC
-                    Debug.WriteLine( DbgUtil.StackTraceToStr( string.Format("DC.DeleteHDC(hdc=0x{0:x8})", unchecked((int) _hDC))));
-#endif
-
-                    IntUnsafeNativeMethods.DeleteHDC(new HandleRef(this, _hDC));
-
+                    IntUnsafeNativeMethods.DeleteDC(new HandleRef(this, _hDC));
                     _hDC = IntPtr.Zero;
                     break;
-
                 case DeviceContextType.Memory:
-
-                    // CreatCompatibleDC adds a GDI handle to HandleCollector, to remove it properly we need to call 
-                    // DeleteDC.
-#if TRACK_HDC
-                    Debug.WriteLine( DbgUtil.StackTraceToStr( string.Format("DC.DeleteDC(hdc=0x{0:x8})", unchecked((int) _hDC))));
-#endif
                     IntUnsafeNativeMethods.DeleteDC(new HandleRef(this, _hDC));
-
                     _hDC = IntPtr.Zero;
                     break;
-
                 // case DeviceContextType.Metafile: - not yet supported.
                 case DeviceContextType.Unknown:
                 default:
@@ -298,7 +279,7 @@ namespace System.Drawing.Internal
 
                 // Note: for common DCs, GetDC assigns default attributes to the DC each time it is retrieved. 
                 // For example, the default font is System.
-                _hDC = IntUnsafeNativeMethods.GetDC(new HandleRef(this, _hWnd));
+                _hDC = UnsafeNativeMethods.GetDC(new HandleRef(this, _hWnd));
 #if TRACK_HDC
                 Debug.WriteLine( DbgUtil.StackTraceToStr( string.Format("hdc[0x{0:x8}]=DC.GetHdc(hWnd=0x{1:x8})", unchecked((int) _hDC), unchecked((int) _hWnd))));
 #endif            
@@ -318,7 +299,7 @@ namespace System.Drawing.Internal
 #if TRACK_HDC
                 int retVal = 
 #endif
-                IntUnsafeNativeMethods.ReleaseDC(new HandleRef(this, _hWnd), new HandleRef(this, _hDC));
+                UnsafeNativeMethods.ReleaseDC(new HandleRef(this, _hWnd), new HandleRef(this, _hDC));
                 // Note: retVal == 0 means it was not released but doesn't necessarily means an error; class or private DCs are never released.
 #if TRACK_HDC
                 Debug.WriteLine( DbgUtil.StackTraceToStr( string.Format("[ret={0}]=DC.ReleaseDC(hDc=0x{1:x8}, hWnd=0x{2:x8})", retVal, unchecked((int) _hDC), unchecked((int) _hWnd))));
index ad9d033..b449658 100644 (file)
@@ -12,30 +12,7 @@ namespace System.Drawing.Internal
     /// </summary>
     internal static partial class IntSafeNativeMethods
     {
-        public sealed class CommonHandles
-        {
-            static CommonHandles() { }
-
-            /// <summary>
-            /// Handle type for GDI objects.
-            /// </summary>
-            public static readonly int GDI = System.Internal.HandleCollector.RegisterType("GDI", 90, 50);
-
-            /// <summary>
-            /// Handle type for HDC's that count against the Win98 limit of five DC's. HDC's which are not scarce,
-            /// such as HDC's for bitmaps, are counted as GDIHANDLE's.
-            /// </summary>
-            public static readonly int HDC = System.Internal.HandleCollector.RegisterType("HDC", 100, 2); // wait for 2 dc's before collecting
-        }
-
-        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "CreateRectRgn", CharSet = CharSet.Auto)]
-        public static extern IntPtr IntCreateRectRgn(int x1, int y1, int x2, int y2);
-
-        public static IntPtr CreateRectRgn(int x1, int y1, int x2, int y2)
-        {
-            IntPtr hRgn = System.Internal.HandleCollector.Add(IntCreateRectRgn(x1, y1, x2, y2), CommonHandles.GDI);
-            DbgUtil.AssertWin32(hRgn != IntPtr.Zero, "IntCreateRectRgn([x1={0}, y1={1}, x2={2}, y2={3}]) failed.", x1, y1, x2, y2);
-            return hRgn;
-        }
+        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true)]
+        public static extern IntPtr CreateRectRgn(int x1, int y1, int x2, int y2);
     }
 }
index eccc0ca..cbf33ef 100644 (file)
 
 using System.Diagnostics;
 using System.Runtime.InteropServices;
-using System.Security;
 
 namespace System.Drawing.Internal
 {
     internal static partial class IntUnsafeNativeMethods
     {
-        [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true, EntryPoint = "GetDC", CharSet = CharSet.Auto)]
-        public static extern IntPtr IntGetDC(HandleRef hWnd);
-
-        public static IntPtr GetDC(HandleRef hWnd)
-        {
-            IntPtr hdc = System.Internal.HandleCollector.Add(IntGetDC(hWnd), IntSafeNativeMethods.CommonHandles.HDC);
-            DbgUtil.AssertWin32(hdc != IntPtr.Zero, "GetHdc([hWnd=0x{0:X8}]) failed.", hWnd);
-            return hdc;
-        }
-
         /// <summary>
         /// NOTE: DeleteDC is to be used to delete the hdc created from CreateCompatibleDC ONLY. All other hdcs should
         /// be deleted with DeleteHDC.
         /// </summary>
-        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "DeleteDC", CharSet = CharSet.Auto)]
-        public static extern bool IntDeleteDC(HandleRef hDC);
-
-        public static bool DeleteDC(HandleRef hDC)
-        {
-            System.Internal.HandleCollector.Remove((IntPtr)hDC, IntSafeNativeMethods.CommonHandles.GDI);
-            bool retVal = IntDeleteDC(hDC);
-            DbgUtil.AssertWin32(retVal, "DeleteDC([hdc=0x{0:X8}]) failed.", hDC.Handle);
-            return retVal;
-        }
-
-        public static bool DeleteHDC(HandleRef hDC)
-        {
-            System.Internal.HandleCollector.Remove((IntPtr)hDC, IntSafeNativeMethods.CommonHandles.HDC);
-            bool retVal = IntDeleteDC(hDC);
-            DbgUtil.AssertWin32(retVal, "DeleteHDC([hdc=0x{0:X8}]) failed.", hDC.Handle);
-            return retVal;
-        }
-
-        [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true, EntryPoint = "ReleaseDC", CharSet = CharSet.Auto)]
-        public static extern int IntReleaseDC(HandleRef hWnd, HandleRef hDC);
+        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true)]
+        public static extern bool DeleteDC(HandleRef hDC);
 
-        public static int ReleaseDC(HandleRef hWnd, HandleRef hDC)
-        {
-            System.Internal.HandleCollector.Remove((IntPtr)hDC, IntSafeNativeMethods.CommonHandles.HDC);
-            // Note: retVal == 0 means it was not released but doesn't necessarily means an error; class or private DCs are never released.
-            return IntReleaseDC(hWnd, hDC);
-        }
+        [DllImport(ExternDll.Gdi32, SetLastError = true, CharSet = CharSet.Unicode)]
+        public static extern IntPtr CreateDC(string lpszDriverName, string lpszDeviceName, string lpszOutput, HandleRef /*DEVMODE*/ lpInitData);
 
-        [DllImport(ExternDll.Gdi32, SetLastError = true, EntryPoint = "CreateDC", CharSet = CharSet.Auto)]
-        public static extern IntPtr IntCreateDC(string lpszDriverName, string lpszDeviceName, string lpszOutput, HandleRef /*DEVMODE*/ lpInitData);
+        [DllImport(ExternDll.Gdi32, SetLastError = true, CharSet = CharSet.Unicode)]
+        public static extern IntPtr CreateIC(string lpszDriverName, string lpszDeviceName, string lpszOutput, HandleRef /*DEVMODE*/ lpInitData);
 
-        public static IntPtr CreateDC(string lpszDriverName, string lpszDeviceName, string lpszOutput, HandleRef /*DEVMODE*/ lpInitData)
-        {
-            IntPtr hdc = System.Internal.HandleCollector.Add(IntCreateDC(lpszDriverName, lpszDeviceName, lpszOutput, lpInitData), IntSafeNativeMethods.CommonHandles.HDC);
-            DbgUtil.AssertWin32(hdc != IntPtr.Zero, "CreateDC([driverName={0}], [deviceName={1}], [fileName={2}], [devMode={3}]) failed.", lpszDriverName, lpszDeviceName, lpszOutput, lpInitData.Handle);
-            return hdc;
-        }
+        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true)]
+        public static extern IntPtr CreateCompatibleDC(HandleRef hDC);
 
-        [DllImport(ExternDll.Gdi32, SetLastError = true, EntryPoint = "CreateIC", CharSet = CharSet.Auto)]
-        public static extern IntPtr IntCreateIC(string lpszDriverName, string lpszDeviceName, string lpszOutput, HandleRef /*DEVMODE*/ lpInitData);
+        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true)]
+        public static extern int SaveDC(HandleRef hDC);
 
-        public static IntPtr CreateIC(string lpszDriverName, string lpszDeviceName, string lpszOutput, HandleRef /*DEVMODE*/ lpInitData)
-        {
-            IntPtr hdc = System.Internal.HandleCollector.Add(IntCreateIC(lpszDriverName, lpszDeviceName, lpszOutput, lpInitData), IntSafeNativeMethods.CommonHandles.HDC);
-            DbgUtil.AssertWin32(hdc != IntPtr.Zero, "CreateIC([driverName={0}], [deviceName={1}], [fileName={2}], [devMode={3}]) failed.", lpszDriverName, lpszDeviceName, lpszOutput, lpInitData.Handle);
-            return hdc;
-        }
-
-        /// <summary>
-        /// CreateCompatibleDC requires to add a GDI handle instead of an HDC handle to avoid perf penalty in HandleCollector.
-        /// The hdc obtained from this method needs to be deleted with DeleteDC instead of DeleteHDC.
-        /// </summary>
-        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "CreateCompatibleDC", CharSet = CharSet.Auto)]
-        public static extern IntPtr IntCreateCompatibleDC(HandleRef hDC);
-
-        public static IntPtr CreateCompatibleDC(HandleRef hDC)
-        {
-            IntPtr compatibleDc = System.Internal.HandleCollector.Add(IntCreateCompatibleDC(hDC), IntSafeNativeMethods.CommonHandles.GDI);
-            DbgUtil.AssertWin32(compatibleDc != IntPtr.Zero, "CreateCompatibleDC([hdc=0x{0:X8}]) failed", hDC.Handle);
-            return compatibleDc;
-        }
-
-
-        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "SaveDC", CharSet = CharSet.Auto)]
-        public static extern int IntSaveDC(HandleRef hDC);
-
-        public static int SaveDC(HandleRef hDC)
-        {
-            int state = IntSaveDC(hDC);
-            DbgUtil.AssertWin32(state != 0, "SaveDC([hdc=0x{0:X8}]) failed", hDC.Handle);
-            return state;
-        }
-
-        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "RestoreDC", CharSet = CharSet.Auto)]
-        public static extern bool IntRestoreDC(HandleRef hDC, int nSavedDC);
-
-        public static bool RestoreDC(HandleRef hDC, int nSavedDC)
-        {
-            bool retVal = IntRestoreDC(hDC, nSavedDC);
-            // When a winforms app is closing, the cached MeasurementGraphics is finalized but it is possible that
-            // its DeviceContext is finalized first so when this method is called the DC has already been relesaed poping up the 
-            // assert window.  Need to find a way to work around this and enable the assert IF NEEDED.
-            // DbgUtil.AssertWin32(retVal, "RestoreDC([hdc=0x{0:X8}], [restoreState={1}]) failed.", (int)hDC.Handle, nSavedDC);
-            return retVal;
-        }
+        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true)]
+        public static extern bool RestoreDC(HandleRef hDC, int nSavedDC);
 
         [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true)]
         public static extern IntPtr WindowFromDC(HandleRef hDC);
@@ -175,22 +95,12 @@ namespace System.Drawing.Internal
 
         // Font.
 
-        [DllImport(ExternDll.Gdi32, SetLastError = true, EntryPoint = "CreateFontIndirect", CharSet = CharSet.Auto)]
-#pragma warning disable CS0618 // Legacy code: We don't care about using obsolete API's.
-        public static extern IntPtr IntCreateFontIndirect([In, Out, MarshalAs(UnmanagedType.AsAny)] object lf); // need object here since LOGFONT is not public.
-#pragma warning restore CS0618
+        [DllImport(ExternDll.Gdi32, SetLastError = true, CharSet = CharSet.Unicode)]
+        public static extern IntPtr CreateFontIndirect(ref SafeNativeMethods.LOGFONT lf);
 
         // Common.
-        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "DeleteObject", CharSet = CharSet.Auto)]
-        public static extern bool IntDeleteObject(HandleRef hObject);
-
-        public static bool DeleteObject(HandleRef hObject)
-        {
-            System.Internal.HandleCollector.Remove((IntPtr)hObject, IntSafeNativeMethods.CommonHandles.GDI);
-            bool retVal = IntDeleteObject(hObject);
-            DbgUtil.AssertWin32(retVal, "DeleteObject(hObj=[0x{0:X8}]) failed.", hObject.Handle);
-            return retVal;
-        }
+        [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true)]
+        public static extern bool DeleteObject(HandleRef hObject);
 
         [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, EntryPoint = "GetCurrentObject", CharSet = CharSet.Auto)]
         public static extern IntPtr IntGetCurrentObject(HandleRef hDC, int uObjectType);
index b994982..80efc91 100644 (file)
@@ -51,7 +51,6 @@ namespace System.Drawing.Internal
                 if (takeOwnership)
                 {
                     wr._ownHandle = true;
-                    System.Internal.HandleCollector.Add(hRegion, IntSafeNativeMethods.CommonHandles.GDI);
                 }
             }
             return wr;
diff --git a/src/libraries/System.Drawing.Common/src/misc/HandleCollector.cs b/src/libraries/System.Drawing.Common/src/misc/HandleCollector.cs
deleted file mode 100644 (file)
index 08c054b..0000000
+++ /dev/null
@@ -1,213 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-
-[module: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System.Internal")]
-
-namespace System.Internal
-{
-    internal sealed class HandleCollector
-    {
-        private static HandleType[] s_handleTypes;
-        private static int s_handleTypeCount;
-
-        internal static event HandleChangeEventHandler HandleAdded;
-
-        internal static event HandleChangeEventHandler HandleRemoved;
-
-        private static object s_internalSyncObject = new object();
-
-        /// <summary>
-        /// Adds the given handle to the handle collector. This keeps the handle on a "hot list" of objects that may
-        /// need to be garbage collected.
-        /// </summary>
-        internal static IntPtr Add(IntPtr handle, int type)
-        {
-            s_handleTypes[type - 1].Add(handle);
-            return handle;
-        }
-
-        /// <summary>
-        /// Registers a new type of handle with the handle collector.
-        /// </summary>
-        internal static int RegisterType(string typeName, int expense, int initialThreshold)
-        {
-            lock (s_internalSyncObject)
-            {
-                if (s_handleTypeCount == 0 || s_handleTypeCount == s_handleTypes.Length)
-                {
-                    HandleType[] newTypes = new HandleType[s_handleTypeCount + 10];
-                    if (s_handleTypes != null)
-                    {
-                        Array.Copy(s_handleTypes, 0, newTypes, 0, s_handleTypeCount);
-                    }
-
-                    s_handleTypes = newTypes;
-                }
-
-                s_handleTypes[s_handleTypeCount++] = new HandleType(typeName, expense, initialThreshold);
-                return s_handleTypeCount;
-            }
-        }
-
-        /// <summary>
-        /// Removes the given handle from the handle collector. Removing a handle removes it from our "hot list" of
-        /// objects that should be frequently garbage collected.
-        /// </summary>
-        internal static IntPtr Remove(IntPtr handle, int type)
-        {
-            return s_handleTypes[type - 1].Remove(handle);
-        }
-
-        /// <summary>
-        /// Represents a specific type of handle.
-        /// </summary>
-        private class HandleType
-        {
-            internal readonly string name;
-
-            private int _initialThreshHold;
-            private int _threshHold;
-            private int _handleCount;
-            private readonly int _deltaPercent;
-
-#if DEBUG_HANDLECOLLECTOR
-            private List<IntPtr> handles = new List<IntPtr>();
-#endif
-
-            /// <summary>
-            /// Creates a new handle type.
-            /// </summary>
-            internal HandleType(string name, int expense, int initialThreshHold)
-            {
-                this.name = name;
-                _initialThreshHold = initialThreshHold;
-                _threshHold = initialThreshHold;
-                _deltaPercent = 100 - expense;
-            }
-
-            /// <summary>
-            /// Adds a handle to this handle type for monitoring.
-            /// </summary>            
-            internal void Add(IntPtr handle)
-            {
-                if (handle == IntPtr.Zero)
-                {
-                    return;
-                }
-
-                bool performCollect = false;
-                int currentCount = 0;
-
-                lock (this)
-                {
-                    _handleCount++;
-#if DEBUG_HANDLECOLLECTOR
-                    Debug.Assert(!handles.Contains(handle));
-                    handles.Add(handle);
-#endif
-                    performCollect = NeedCollection();
-                    currentCount = _handleCount;
-                }
-                lock (s_internalSyncObject)
-                {
-                    HandleAdded?.Invoke(name, handle, currentCount);
-                }
-
-                if (!performCollect)
-                {
-                    return;
-                }
-
-
-                if (performCollect)
-                {
-#if DEBUG_HANDLECOLLECTOR
-                    Debug.WriteLine("HC> Forcing garbage collect");
-                    Debug.WriteLine("HC>     name        :" + name);
-                    Debug.WriteLine("HC>     threshHold  :" + (threshHold).ToString());
-                    Debug.WriteLine("HC>     handleCount :" + (handleCount).ToString());
-                    Debug.WriteLine("HC>     deltaPercent:" + (deltaPercent).ToString());
-#endif                  
-                    GC.Collect();
-
-                    // We just performed a GC.  If the main thread is in a tight
-                    // loop there is a this will cause us to increase handles forever and prevent handle collector
-                    // from doing its job.  Yield the thread here.  This won't totally cause
-                    // a finalization pass but it will effectively elevate the priority
-                    // of the finalizer thread just for an instant.  But how long should
-                    // we sleep?  We base it on how expensive the handles are because the
-                    // more expensive the handle, the more critical that it be reclaimed.
-                    int sleep = (100 - _deltaPercent) / 4;
-                    System.Threading.Thread.Sleep(sleep);
-                }
-            }
-
-            /// <summary>
-            /// Determines if this handle type needs a garbage collection pass.
-            /// </summary>
-            internal bool NeedCollection()
-            {
-                if (_handleCount > _threshHold)
-                {
-                    _threshHold = _handleCount + ((_handleCount * _deltaPercent) / 100);
-#if DEBUG_HANDLECOLLECTOR
-                    Debug.WriteLine("HC> NeedCollection: increase threshHold to " + threshHold);
-#endif                  
-                    return true;
-                }
-
-                // If handle count < threshHold, we don't
-                // need to collect, but if it 10% below the next lowest threshhold we
-                // will bump down a rung.  We need to choose a percentage here or else
-                // we will oscillate.
-                int oldThreshHold = (100 * _threshHold) / (100 + _deltaPercent);
-                if (oldThreshHold >= _initialThreshHold && _handleCount < (int)(oldThreshHold * .9F))
-                {
-#if DEBUG_HANDLECOLLECTOR
-                    Debug.WriteLine("HC> NeedCollection: throttle threshhold " + threshHold + " down to " + oldThreshHold);
-#endif                  
-                    _threshHold = oldThreshHold;
-                }
-
-                return false;
-            }
-
-            /// <summary>
-            /// Removes the given handle from our monitor list.
-            /// </summary>
-            internal IntPtr Remove(IntPtr handle)
-            {
-                if (handle == IntPtr.Zero)
-                {
-                    return handle;
-                }
-                int currentCount = 0;
-                lock (this)
-                {
-                    _handleCount--;
-#if DEBUG_HANDLECOLLECTOR
-                    Debug.Assert(handles.Contains(handle));
-                    handles.Remove(handle);
-#endif
-                    if (_handleCount < 0)
-                    {
-                        Debug.Fail("Handle collector underflow for type '" + name + "'");
-                        _handleCount = 0;
-                    }
-                    currentCount = _handleCount;
-                }
-                lock (s_internalSyncObject)
-                {
-                    HandleRemoved?.Invoke(name, handle, currentCount);
-                }
-                return handle;
-            }
-        }
-    }
-
-    internal delegate void HandleChangeEventHandler(string handleType, IntPtr handleValue, int currentHandleCount);
-}
diff --git a/src/libraries/System.Drawing.Common/src/misc/InvalidEnumArgumentException.cs b/src/libraries/System.Drawing.Common/src/misc/InvalidEnumArgumentException.cs
deleted file mode 100644 (file)
index 62de174..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Globalization;
-using System.Runtime.Serialization;
-
-namespace System.ComponentModel
-{
-    /// <summary>
-    /// The exception that is thrown when using invalid arguments that are enumerators.
-    /// </summary>
-    internal class InvalidEnumArgumentException : ArgumentException
-    {
-        /// <summary>
-        /// <para>Initializes a new instance of the <see cref='InvalidEnumArgumentException'/> class without a message.</para>
-        /// </summary>
-        public InvalidEnumArgumentException() : this(null)
-        {
-        }
-
-        /// <summary>
-        /// <para>Initializes a new instance of the <see cref='InvalidEnumArgumentException'/> class with 
-        ///    the specified message.</para>
-        /// </summary>
-        public InvalidEnumArgumentException(string message)
-            : base(message)
-        {
-        }
-
-        /// <summary>
-        ///     Initializes a new instance of the Exception class with a specified error message and a 
-        ///     reference to the inner exception that is the cause of this exception.
-        ///     FxCop CA1032: Multiple constructors are required to correctly implement a custom exception.
-        /// </summary>
-        public InvalidEnumArgumentException(string message, Exception innerException)
-            : base(message, innerException)
-        {
-        }
-
-        /// <summary>
-        /// <para>Initializes a new instance of the <see cref='InvalidEnumArgumentException'/> class with a 
-        ///    message generated from the argument, invalid value, and enumeration
-        ///    class.</para>
-        /// </summary>
-        public InvalidEnumArgumentException(string argumentName, int invalidValue, Type enumClass)
-            : base(SR.Format(SR.InvalidEnumArgument,
-                                argumentName,
-                                invalidValue.ToString(CultureInfo.CurrentCulture),
-                                enumClass.Name), argumentName)
-        {
-        }
-
-        /// <summary>
-        ///     Need this constructor since Exception implements ISerializable. We don't have any fields,
-        ///     so just forward this to base.
-        /// </summary>
-        protected InvalidEnumArgumentException(SerializationInfo info, StreamingContext context) : base(info, context)
-        {
-            throw new PlatformNotSupportedException();
-        }
-    }
-}
\ No newline at end of file
index c6e9b75..6211d93 100644 (file)
@@ -664,7 +664,7 @@ namespace System.Drawing.Tests
 
         [ActiveIssue(20884, TestPlatforms.AnyUnix)]
         [ConditionalFact(Helpers.IsDrawingSupported)]
-        public void FromLogFont_NullLogFont_ThrowsArgumentException()
+        public void FromLogFont_NullLogFont_ThrowsArgumentNullException()
         {
             using (var image = new Bitmap(10, 10))
             using (Graphics graphics = Graphics.FromImage(image))
@@ -672,8 +672,16 @@ namespace System.Drawing.Tests
                 IntPtr hdc = graphics.GetHdc();
                 try
                 {
-                    AssertExtensions.Throws<ArgumentException>(null, () => Font.FromLogFont(null));
-                    AssertExtensions.Throws<ArgumentException>(null, () => Font.FromLogFont(null, hdc));
+                    if (PlatformDetection.IsFullFramework)
+                    {
+                        AssertExtensions.Throws<ArgumentException>(null, () => Font.FromLogFont(null));
+                        AssertExtensions.Throws<ArgumentException>(null, () => Font.FromLogFont(null, hdc));
+                    }
+                    else
+                    {
+                        AssertExtensions.Throws<ArgumentNullException>("lf", () => Font.FromLogFont(null));
+                        AssertExtensions.Throws<ArgumentNullException>("lf", () => Font.FromLogFont(null, hdc));
+                    }
                 }
                 finally
                 {
@@ -796,16 +804,16 @@ namespace System.Drawing.Tests
 
         [ActiveIssue(20884, TestPlatforms.AnyUnix)]
         [ConditionalFact(Helpers.IsDrawingSupported)]
-        [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Exception is wrapped in a TargetInvocationException in the .NET Framework.")]
-        public void ToLogFont_NullLogFont_ThrowsAccessViolationException()
+        [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "AV Exception is wrapped in a TargetInvocationException in the .NET Framework.")]
+        public void ToLogFont_NullLogFont_ThrowsArgumentNullException()
         {
             using (FontFamily family = FontFamily.GenericMonospace)
             using (var font = new Font(family, 10))
             using (var image = new Bitmap(10, 10))
             using (Graphics graphics = Graphics.FromImage(image))
             {
-                Assert.Throws<AccessViolationException>(() => font.ToLogFont(null));
-                Assert.Throws<AccessViolationException>(() => font.ToLogFont(null, graphics));
+                Assert.Throws<ArgumentNullException>(() => font.ToLogFont(null));
+                Assert.Throws<ArgumentNullException>(() => font.ToLogFont(null, graphics));
             }
         }
 
index f01f72d..fc85c60 100644 (file)
 
 using System.Collections.Generic;
 using System.ComponentModel;
-using System.Diagnostics;
 using System.Drawing.Imaging;
 using System.IO;
-using System.Reflection;
 using System.Runtime.InteropServices;
-using System.Runtime.Serialization.Formatters.Binary;
 using Microsoft.DotNet.RemoteExecutor;
 using Xunit;
 
@@ -183,7 +180,14 @@ namespace System.Drawing.Tests
             yield return new object[] { new byte[] { 0, 0, 1, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, typeof(ArgumentException) };
 
             // The number of entries specified is negative.
-            yield return new object[] { new byte[] { 0, 0, 1, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, typeof(Win32Exception) };
+            yield return new object[]
+            {
+                new byte[] { 0, 0, 1, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+
+                // There is no such thing as a negative number in the native struct, we're throwing ArgumentException
+                // here now as the data size doesn't match what is expected (as other inputs above).
+                PlatformDetection.IsFullFramework ? typeof(Win32Exception) : typeof(ArgumentException)
+            };
 
             // The size of an entry is negative.
             yield return new object[] { new byte[] { 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0 }, typeof(Win32Exception) };
@@ -195,7 +199,13 @@ namespace System.Drawing.Tests
             yield return new object[] { new byte[] { 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 12, 0, 0, 0 }, typeof(ArgumentException) };
 
             // The size and offset of an entry overflows.
-            yield return new object[] { new byte[] { 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 127, 255, 255, 255, 127 }, typeof(Win32Exception) };
+            yield return new object[]
+            {
+                new byte[] { 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 127, 255, 255, 255, 127 },
+
+                // Another case where we weren't checking data integrity before invoking.
+                PlatformDetection.IsFullFramework ? typeof(Win32Exception) : typeof(ArgumentException)
+            };
 
             // The offset and the size of the list of entries overflows.
             yield return new object[] { new byte[] { 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 127 }, typeof(ArgumentException) };
@@ -425,9 +435,17 @@ namespace System.Drawing.Tests
 
         [ActiveIssue(20884, TestPlatforms.AnyUnix)]
         [ConditionalFact(Helpers.IsDrawingSupported)]
-        public void ExtractAssociatedIcon_NonFilePath_ReturnsNull()
+        public void ExtractAssociatedIcon_NonFilePath_ThrowsFileNotFound()
         {
-            Assert.Null(Icon.ExtractAssociatedIcon("http://microsoft.com"));
+            // Used to return null at the expense of creating a URI
+            if (PlatformDetection.IsFullFramework)
+            {
+                Assert.Null(Icon.ExtractAssociatedIcon("http://microsoft.com"));
+            }
+            else
+            {
+                Assert.Throws<FileNotFoundException>(() => Icon.ExtractAssociatedIcon("http://microsoft.com"));
+            }
         }
 
         [ConditionalFact(Helpers.IsDrawingSupported)]
index 10ab28b..093f828 100644 (file)
@@ -257,7 +257,7 @@ namespace System.Drawing.Printing.Tests
                     break;
             }
 
-            Assert.Equal(PrinterResolutionKind.Custom, pageSettings.PrinterResolution.Kind);
+            Assert.True(Enum.IsDefined(typeof(PrinterResolutionKind), pageSettings.PrinterResolution.Kind));
             Assert.True(pageSettings.PrinterSettings.IsDefaultPrinter);
         }