diff --git a/src-native-c/THNETII.WinApi.Sample.Native/main.c b/src-native-c/THNETII.WinApi.Sample.Native/main.c
index c4bf429f..82ad46a9 100644
--- a/src-native-c/THNETII.WinApi.Sample.Native/main.c
+++ b/src-native-c/THNETII.WinApi.Sample.Native/main.c
@@ -6,7 +6,7 @@ int main(int argc, char* argv[])
const int size = sizeof(instance);
const int value = FORMAT_MESSAGE_ALLOCATE_BUFFER;
- const void* ptr = FormatMessage;
+ const void* ptr = HeapFree;
return EXIT_SUCCESS;
}
diff --git a/src-native/THNETII.WinApi.Constants.WinBase/GlobalSuppressions.cs b/src-native/THNETII.WinApi.Constants.WinBase/GlobalSuppressions.cs
index d79dfb1f..14fdf918 100644
--- a/src-native/THNETII.WinApi.Constants.WinBase/GlobalSuppressions.cs
+++ b/src-native/THNETII.WinApi.Constants.WinBase/GlobalSuppressions.cs
@@ -1,4 +1,4 @@
-
+
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
@@ -6,5 +6,9 @@
using System.Diagnostics.CodeAnalysis;
-[assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")]
-[assembly: SuppressMessage("Design", "CA1051: Do not declare visible instance fields")]
+[assembly: SuppressMessage("Design",
+ "CA1051: Do not declare visible instance fields")]
+[assembly: SuppressMessage("Documentation",
+ "CA1200: Avoid using cref tags with a prefix")]
+[assembly: SuppressMessage("Naming",
+ "CA1707: Identifiers should not contain underscores")]
diff --git a/src-native/THNETII.WinApi.Constants.WinBase/WinBaseConstants.cs b/src-native/THNETII.WinApi.Constants.WinBase/WinBaseConstants.cs
index 0f97de66..66feb987 100644
--- a/src-native/THNETII.WinApi.Constants.WinBase/WinBaseConstants.cs
+++ b/src-native/THNETII.WinApi.Constants.WinBase/WinBaseConstants.cs
@@ -1,4 +1,4 @@
-namespace THNETII.WinApi.Native.WinBase
+namespace THNETII.WinApi.Native.WinBase
{
using static WinNT.WinNTConstants;
@@ -19,7 +19,7 @@ public static class WinBaseConstants
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinBase.h, line 2380
///
- /// requires use of
+ /// requires use of
///
public const int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100;
diff --git a/src-native/THNETII.WinApi.Constants.WinNT/WinNTConstants.cs b/src-native/THNETII.WinApi.Constants.WinNT/WinNTConstants.cs
index 5ee40f86..b994dc65 100644
--- a/src-native/THNETII.WinApi.Constants.WinNT/WinNTConstants.cs
+++ b/src-native/THNETII.WinApi.Constants.WinNT/WinNTConstants.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Security.Principal;
namespace THNETII.WinApi.Native.WinNT
@@ -284,7 +284,7 @@ public static class WinNTConstants
public const int LANG_BRETON = 0x7e;
/// Use with SUBLANG_BOSNIAN_* Sublanguage IDs
public const int LANG_BOSNIAN = 0x1a;
- /// Use with the function
+ /// Use with the function
public const int LANG_BOSNIAN_NEUTRAL = 0x781a;
public const int LANG_BULGARIAN = 0x02;
public const int LANG_CATALAN = 0x03;
@@ -292,9 +292,9 @@ public static class WinNTConstants
public const int LANG_CHEROKEE = 0x5c;
/// Use with SUBLANG_CHINESE_* Sublanguage IDs
public const int LANG_CHINESE = 0x04;
- /// Use with the function
+ /// Use with the function
public const int LANG_CHINESE_SIMPLIFIED = 0x04;
- /// Use with the function
+ /// Use with the function
public const int LANG_CHINESE_TRADITIONAL = 0x7c04;
public const int LANG_CORSICAN = 0x83;
public const int LANG_CROATIAN = 0x1a;
@@ -380,7 +380,7 @@ public static class WinNTConstants
public const int LANG_SCOTTISH_GAELIC = 0x91;
/// Use with the SUBLANG_SERBIAN_* Sublanguage IDs
public const int LANG_SERBIAN = 0x1a;
- /// Use with the function
+ /// Use with the function
public const int LANG_SERBIAN_NEUTRAL = 0x7c1a;
public const int LANG_SINDHI = 0x59;
public const int LANG_SINHALESE = 0x5b;
diff --git a/src-native/THNETII.WinApi.Headers.ErrHandlingApi/ErrHandlingApiFunctions.cs b/src-native/THNETII.WinApi.Headers.ErrHandlingApi/ErrHandlingApiFunctions.cs
index bfd65f05..9c000848 100644
--- a/src-native/THNETII.WinApi.Headers.ErrHandlingApi/ErrHandlingApiFunctions.cs
+++ b/src-native/THNETII.WinApi.Headers.ErrHandlingApi/ErrHandlingApiFunctions.cs
@@ -1,6 +1,7 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
+using THNETII.InteropServices.Memory;
using THNETII.WinApi.Native.WinBase;
#if NETSTANDARD1_6
@@ -165,27 +166,97 @@ SYSTEM_ERROR_MODE uMode
/// - Minimum supported server:Windows Server 2003 [desktop apps | UWP apps]
///
///
- /// Microsoft Docs page: FatalAppExit function
+ /// Microsoft Docs page: FatalAppExitW function
///
/// The native library containg the function could not be found.
/// Unable to find the entry point for the function in the native library.
+ /// Error Handling Functions
///
- public static void FatalAppExit(
- int uAction,
- string lpMessageText
- ) => FatalAppExitW(uAction, lpMessageText);
+#if !(NETSTANDARD1_3 || NETSTANDARD1_6)
+ [DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Auto)]
+ public static extern
+#else
+ public static
+#endif // !(NETSTANDARD1_3 || NETSTANDARD1_6)
+ void FatalAppExit(
+ [In] int uAction,
+ [In] string lpMessageText
+ )
+#if !(NETSTANDARD1_3 || NETSTANDARD1_6)
+ ;
+#else
+
+ {
+ switch (Marshal.SystemDefaultCharSize)
+ {
+ case 1:
+ FatalAppExitA(uAction, lpMessageText);
+ break;
+ case 2:
+ FatalAppExitW(uAction, lpMessageText);
+ break;
+ default: throw new PlatformNotSupportedException();
+ }
+ }
+#endif // !(NETSTANDARD1_3 || NETSTANDARD1_6)
+
///
[DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, EntryPoint = nameof(FatalAppExitA))]
public static extern void FatalAppExitA(
[In] int uAction,
[In, MarshalAs(UnmanagedType.LPStr)] string lpMessageText
);
+
///
[DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, EntryPoint = nameof(FatalAppExitW))]
public static extern void FatalAppExitW(
[In] int uAction,
[In, MarshalAs(UnmanagedType.LPWStr)] string lpMessageText
);
+
+ ///
+#if !(NETSTANDARD1_3 || NETSTANDARD1_6)
+ [DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Auto)]
+ public static extern
+#else
+ public static
+#endif // !(NETSTANDARD1_3 || NETSTANDARD1_6)
+ void FatalAppExit(
+ [In] int uAction,
+ [In] LPCTSTR lpMessageText
+ )
+#if !(NETSTANDARD1_3 || NETSTANDARD1_6)
+ ;
+#else
+
+ {
+ switch (Marshal.SystemDefaultCharSize)
+ {
+ case 1:
+ FatalAppExitA(uAction, Pointer.Create(lpMessageText.Pointer));
+ break;
+ case 2:
+ FatalAppExitW(uAction, Pointer.Create(lpMessageText.Pointer));
+ break;
+ default: throw new PlatformNotSupportedException();
+ }
+ }
+#endif // !(NETSTANDARD1_3 || NETSTANDARD1_6)
+
+ ///
+ [DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi)]
+ public static extern void FatalAppExitA(
+ [In] int uAction,
+ [In] LPCSTR lpMessageText
+ );
+
+
+ ///
+ [DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)]
+ public static extern void FatalAppExitW(
+ [In] int uAction,
+ [In] LPCWSTR lpMessageText
+ );
#endregion
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\errhandlingapi.h, line 250
#region GetThreadErrorMode function
diff --git a/src-native/THNETII.WinApi.Headers.ErrHandlingApi/GlobalSuppressions.cs b/src-native/THNETII.WinApi.Headers.ErrHandlingApi/GlobalSuppressions.cs
index 6b57a412..68adb720 100644
--- a/src-native/THNETII.WinApi.Headers.ErrHandlingApi/GlobalSuppressions.cs
+++ b/src-native/THNETII.WinApi.Headers.ErrHandlingApi/GlobalSuppressions.cs
@@ -1,12 +1,13 @@
-// This file is used by Code Analysis to maintain SuppressMessage
+// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
using System.Diagnostics.CodeAnalysis;
-[assembly: SuppressMessage("Interoperability", "CA1401: P/Invokes should not be visible")]
-[assembly: SuppressMessage("Usage", "PC003: Native API not available in UWP")]
[assembly: SuppressMessage("Documentation", "CA1200: Avoid using cref tags with a prefix")]
-[assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")]
+[assembly: SuppressMessage("Documentation", "CS0419: Ambiguous reference in cref attribute")]
[assembly: SuppressMessage("Globalization", "CA2101: Specify marshaling for P/Invoke string arguments")]
+[assembly: SuppressMessage("Interoperability", "CA1401: P/Invokes should not be visible")]
+[assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")]
+[assembly: SuppressMessage("Usage", "PC003: Native API not available in UWP")]
diff --git a/src-native/THNETII.WinApi.Headers.ErrHandlingApi/THNETII.WinApi.Headers.ErrHandlingApi.csproj b/src-native/THNETII.WinApi.Headers.ErrHandlingApi/THNETII.WinApi.Headers.ErrHandlingApi.csproj
index a1b396a8..9cc821b6 100644
--- a/src-native/THNETII.WinApi.Headers.ErrHandlingApi/THNETII.WinApi.Headers.ErrHandlingApi.csproj
+++ b/src-native/THNETII.WinApi.Headers.ErrHandlingApi/THNETII.WinApi.Headers.ErrHandlingApi.csproj
@@ -2,10 +2,10 @@
- 7.2
+ 8
netstandard1.3;netstandard1.6;netstandard2.0
true
- CS1591
+ $(NoWarn);CS1591;CS0419
THNETII.WinApi.Native.ErrHandlingApi
diff --git a/src-native/THNETII.WinApi.Headers.FileApi/FileApiFunctions.cs b/src-native/THNETII.WinApi.Headers.FileApi/FileApiFunctions.cs
index 6871afc8..f3543b86 100644
--- a/src-native/THNETII.WinApi.Headers.FileApi/FileApiFunctions.cs
+++ b/src-native/THNETII.WinApi.Headers.FileApi/FileApiFunctions.cs
@@ -1,8 +1,7 @@
-using Microsoft.Win32.SafeHandles;
using System;
-using System.IO;
using System.Runtime.InteropServices;
+using THNETII.InteropServices.Memory;
using THNETII.WinApi.Native.MinWinBase;
using THNETII.WinApi.Native.MinWinDef;
using THNETII.WinApi.Native.WinError;
@@ -59,49 +58,102 @@ in FILETIME lpFileTime2
#endregion
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\fileapi.h, line 56
#region CreateDirectoryA function
- ///
+ ///
[Obsolete(".NET Applications should not call " + nameof(CreateDirectoryA) + ". Instead the types in the System.IO namespace should be used.")]
[DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CreateDirectoryA(
- [In] LPCSTR lpPathName,
+ [In] string lpPathName,
[In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes
);
- ///
+
+ ///
[Obsolete(".NET Applications should not call " + nameof(CreateDirectoryA) + ". Instead the types in the System.IO namespace should be used.")]
- public static bool CreateDirectoryA(LPCSTR lpPathName) =>
+ public static bool CreateDirectoryA(string lpPathName) =>
CreateDirectoryA(lpPathName, IntPtr.Zero);
- ///
+
+ ///
[Obsolete(".NET Applications should not call " + nameof(CreateDirectoryA) + ". Instead the types in the System.IO namespace should be used.")]
[DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool CreateDirectoryA(
- [In] LPCSTR lpPathName,
+ [In] string lpPathName,
[In, Optional] IntPtr lpSecurityAttributes
);
- ///
+
+ ///
[Obsolete(".NET Applications should not call " + nameof(CreateDirectoryA) + ". Instead the types in the System.IO namespace should be used.")]
[DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CreateDirectoryA(
- [In, MarshalAs(UnmanagedType.LPStr)] string lpPathName,
+ [In] LPCSTR lpPathName,
[In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes
);
- ///
+
+ ///
[Obsolete(".NET Applications should not call " + nameof(CreateDirectoryA) + ". Instead the types in the System.IO namespace should be used.")]
- public static bool CreateDirectoryA(string lpPathName) =>
+ public static bool CreateDirectoryA(LPCSTR lpPathName) =>
CreateDirectoryA(lpPathName, IntPtr.Zero);
- ///
+
+ ///
[Obsolete(".NET Applications should not call " + nameof(CreateDirectoryA) + ". Instead the types in the System.IO namespace should be used.")]
[DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool CreateDirectoryA(
- [In, MarshalAs(UnmanagedType.LPStr)] string lpPathName,
+ [In] LPCSTR lpPathName,
[In, Optional] IntPtr lpSecurityAttributes
);
#endregion
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\fileapi.h, line 64
#region CreateDirectoryW function
+ ///
+ [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")]
+ [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool CreateDirectoryW(
+ [In] string lpPathName,
+ [In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes
+ );
+
+ ///
+ [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")]
+ public static bool CreateDirectoryW(string lpPathName) =>
+ CreateDirectoryW(lpPathName, IntPtr.Zero);
+
+ ///
+ [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")]
+ [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool CreateDirectoryW(
+ [In] string lpPathName,
+ [In, Optional] IntPtr lpSecurityAttributes
+ );
+
+ ///
+ [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")]
+ [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool CreateDirectoryW(
+ [In] LPCWSTR lpPathName,
+ [In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes
+ );
+
+ ///
+ [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")]
+ public static bool CreateDirectoryW(LPCWSTR lpPathName) =>
+ CreateDirectoryW(lpPathName, IntPtr.Zero);
+
+ ///
+ [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")]
+ [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool CreateDirectoryW(
+ [In] LPCWSTR lpPathName,
+ [In, Optional] IntPtr lpSecurityAttributes
+ );
+ #endregion
+ // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\fileapi.h, line 72
+ #region CreateDirectory function
///
/// Creates a new directory. If the underlying file system supports security on files and directories, the function applies a specified security descriptor to the new directory.
/// To specify a template directory, use the function.
@@ -163,92 +215,120 @@ private static extern bool CreateDirectoryA(
///
///
///
- [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")]
- [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool CreateDirectoryW(
- [In] LPCWSTR lpPathName,
- [In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes
- );
- ///
- [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")]
- public static bool CreateDirectoryW(LPCWSTR lpPathName) =>
- CreateDirectoryW(lpPathName, IntPtr.Zero);
- ///
- [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")]
- [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static extern bool CreateDirectoryW(
- [In] LPCWSTR lpPathName,
- [In, Optional] IntPtr lpSecurityAttributes
- );
- ///
- [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")]
- [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool CreateDirectoryW(
- [In, MarshalAs(UnmanagedType.LPWStr)] string lpPathName,
- [In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes
- );
- ///
- [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")]
- public static bool CreateDirectoryW(string lpPathName) =>
- CreateDirectoryW(lpPathName, IntPtr.Zero);
- ///
- [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")]
- [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static extern bool CreateDirectoryW(
- [In, MarshalAs(UnmanagedType.LPWStr)] string lpPathName,
- [In, Optional] IntPtr lpSecurityAttributes
- );
- #endregion
- // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\fileapi.h, line 72
- #region CreateDirectory function
- ///
[Obsolete(".NET Applications should not call " + nameof(CreateDirectory) + ". Instead the types in the System.IO namespace should be used.")]
- [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi)]
+#if !NETSTANDARD1_3
+ [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool CreateDirectory(
- [In] LPCTSTR lpPathName,
+ public static extern
+#else
+ public static
+#endif // NETSTANDARD1_3
+ bool CreateDirectory(
+ [In] string lpPathName,
[In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes
- );
- ///
+ )
+#if !NETSTANDARD1_3
+ ;
+#else
+ => Marshal.SystemDefaultCharSize switch
+ {
+ 1 => CreateDirectoryA(lpPathName, lpSecurityAttributes),
+ 2 => CreateDirectoryW(lpPathName, lpSecurityAttributes),
+ _ => throw new PlatformNotSupportedException(),
+ };
+#endif // NETSTANDARD1_3
+
+ ///
[Obsolete(".NET Applications should not call " + nameof(CreateDirectory) + ". Instead the types in the System.IO namespace should be used.")]
public static bool CreateDirectory(
- [In] LPCTSTR lpPathName
- ) =>
- CreateDirectory(lpPathName, IntPtr.Zero);
- ///
+ string lpPathName
+ ) => CreateDirectory(lpPathName, IntPtr.Zero);
+
+ ///
[Obsolete(".NET Applications should not call " + nameof(CreateDirectory) + ". Instead the types in the System.IO namespace should be used.")]
- [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi)]
+#if !NETSTANDARD1_3
+ [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
- private static extern bool CreateDirectory(
- [In] LPCTSTR lpPathName,
+ private static extern
+#else
+ private static
+#endif // NETSTANDARD1_3
+ bool CreateDirectory(
+ [In] string lpPathName,
[In, Optional] IntPtr lpSecurityAttributes
- );
+ )
#if !NETSTANDARD1_3
- ///
+ ;
+#else
+ => Marshal.SystemDefaultCharSize switch
+ {
+ 1 => CreateDirectoryA(lpPathName, lpSecurityAttributes),
+ 2 => CreateDirectoryW(lpPathName, lpSecurityAttributes),
+ _ => throw new PlatformNotSupportedException(),
+ };
+#endif // NETSTANDARD1_3
+
+ ///
[Obsolete(".NET Applications should not call " + nameof(CreateDirectory) + ". Instead the types in the System.IO namespace should be used.")]
+#if !NETSTANDARD1_3
[DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool CreateDirectory(
- [In, MarshalAs(UnmanagedType.LPTStr)] string lpPathName,
+ public static extern
+#else
+ public static
+#endif // NETSTANDARD1_3
+ bool CreateDirectory(
+ [In] LPCTSTR lpPathName,
[In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes
- );
- ///
+ )
+#if !NETSTANDARD1_3
+ ;
+#else
+ => Marshal.SystemDefaultCharSize switch
+ {
+ 1 => CreateDirectoryA(
+ Pointer.Create(lpPathName.Pointer),
+ lpSecurityAttributes),
+ 2 => CreateDirectoryW(
+ Pointer.Create(lpPathName.Pointer),
+ lpSecurityAttributes),
+ _ => throw new PlatformNotSupportedException(),
+ };
+#endif // NETSTANDARD1_3
+
+ ///
[Obsolete(".NET Applications should not call " + nameof(CreateDirectory) + ". Instead the types in the System.IO namespace should be used.")]
- public static bool CreateDirectory(string lpPathName) =>
- CreateDirectory(lpPathName, IntPtr.Zero);
- ///
+ public static bool CreateDirectory(
+ [In] LPCTSTR lpPathName
+ ) => CreateDirectory(lpPathName, IntPtr.Zero);
+
+ ///
[Obsolete(".NET Applications should not call " + nameof(CreateDirectory) + ". Instead the types in the System.IO namespace should be used.")]
+#if !NETSTANDARD1_3
[DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
- private static extern bool CreateDirectory(
- [In, MarshalAs(UnmanagedType.LPTStr)] string lpPathName,
+ private static extern
+#else
+ private static
+#endif // NETSTANDARD1_3
+ bool CreateDirectory(
+ [In] LPCTSTR lpPathName,
[In, Optional] IntPtr lpSecurityAttributes
- );
-#endif // !NETSTANDARD1_3
+ )
+#if !NETSTANDARD1_3
+ ;
+#else
+ => Marshal.SystemDefaultCharSize switch
+ {
+ 1 => CreateDirectoryA(
+ Pointer.Create(lpPathName.Pointer),
+ lpSecurityAttributes),
+ 2 => CreateDirectoryW(
+ Pointer.Create(lpPathName.Pointer),
+ lpSecurityAttributes),
+ _ => throw new PlatformNotSupportedException(),
+ };
+#endif // NETSTANDARD1_3
#endregion
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\fileapi.h, line 116
#region DefineDosDeviceW function
diff --git a/src-native/THNETII.WinApi.Headers.FileApi/GlobalSuppressions.cs b/src-native/THNETII.WinApi.Headers.FileApi/GlobalSuppressions.cs
index 24c1463b..ea973baf 100644
--- a/src-native/THNETII.WinApi.Headers.FileApi/GlobalSuppressions.cs
+++ b/src-native/THNETII.WinApi.Headers.FileApi/GlobalSuppressions.cs
@@ -1,11 +1,12 @@
-// This file is used by Code Analysis to maintain SuppressMessage
+// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
using System.Diagnostics.CodeAnalysis;
-[assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")]
-[assembly: SuppressMessage("Interoperability", "CA1401: P/Invokes should not be visible")]
+[assembly: SuppressMessage("Documentation", "CS0419: Ambiguous reference in cref attribute")]
[assembly: SuppressMessage("Globalization", "CA2101: Specify marshaling for P/Invoke string arguments", Justification = "Erroneously reported as not specified")]
+[assembly: SuppressMessage("Interoperability", "CA1401: P/Invokes should not be visible")]
+[assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")]
[assembly: SuppressMessage("Usage", "PC003: Native API not available in UWP")]
diff --git a/src-native/THNETII.WinApi.Headers.FileApi/THNETII.WinApi.Headers.FileApi.csproj b/src-native/THNETII.WinApi.Headers.FileApi/THNETII.WinApi.Headers.FileApi.csproj
index 9f091a2b..5622729d 100644
--- a/src-native/THNETII.WinApi.Headers.FileApi/THNETII.WinApi.Headers.FileApi.csproj
+++ b/src-native/THNETII.WinApi.Headers.FileApi/THNETII.WinApi.Headers.FileApi.csproj
@@ -1,11 +1,11 @@
-
+
- 7.2
+ 8
netstandard1.3;netstandard2.0
true
- CS1591
+ $(NoWarn);CS1591;CS0419
THNETII.WinApi.Native.FileApi
diff --git a/src-native/THNETII.WinApi.Headers.MinWinDef/MinWinDefMacros.cs b/src-native/THNETII.WinApi.Headers.MinWinDef/MinWinDefMacros.cs
index 134802c3..34bb2553 100644
--- a/src-native/THNETII.WinApi.Headers.MinWinDef/MinWinDefMacros.cs
+++ b/src-native/THNETII.WinApi.Headers.MinWinDef/MinWinDefMacros.cs
@@ -1,6 +1,3 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
using THNETII.InteropServices.Bitwise;
namespace THNETII.WinApi.Native.MinWinDef
diff --git a/src-native/THNETII.WinApi.Headers.SysInfoApi/COMPUTER_NAME_FORMAT.cs b/src-native/THNETII.WinApi.Headers.SysInfoApi/COMPUTER_NAME_FORMAT.cs
index 9867c3a6..bf4cc4ae 100644
--- a/src-native/THNETII.WinApi.Headers.SysInfoApi/COMPUTER_NAME_FORMAT.cs
+++ b/src-native/THNETII.WinApi.Headers.SysInfoApi/COMPUTER_NAME_FORMAT.cs
@@ -1,5 +1,7 @@
-namespace THNETII.WinApi.Native.SysInfoApi
+namespace THNETII.WinApi.Native.SysInfoApi
{
+ using static SysInfoApiFunctions;
+
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\sysinfoapi.h, line 296
///
/// Specifies a type of computer name.
diff --git a/src-native/THNETII.WinApi.Headers.SysInfoApi/GlobalSuppressions.cs b/src-native/THNETII.WinApi.Headers.SysInfoApi/GlobalSuppressions.cs
index 3295f902..decb72d3 100644
--- a/src-native/THNETII.WinApi.Headers.SysInfoApi/GlobalSuppressions.cs
+++ b/src-native/THNETII.WinApi.Headers.SysInfoApi/GlobalSuppressions.cs
@@ -1,4 +1,4 @@
-// This file is used by Code Analysis to maintain SuppressMessage
+// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
@@ -13,3 +13,4 @@
[assembly: SuppressMessage("Usage", "PC003: Native API not available in UWP")]
[assembly: SuppressMessage("Globalization", "CA2101: Specify marshaling for P/Invoke string arguments")]
[assembly: SuppressMessage("Documentation", "CA1200: Avoid using cref tags with a prefix")]
+[assembly: SuppressMessage("Documentation", "CS0419: Ambiguous cref reference")]
diff --git a/src-native/THNETII.WinApi.Headers.SysInfoApi/MEMORYSTATUSEX.cs b/src-native/THNETII.WinApi.Headers.SysInfoApi/MEMORYSTATUSEX.cs
index c3882fa8..cae246dd 100644
--- a/src-native/THNETII.WinApi.Headers.SysInfoApi/MEMORYSTATUSEX.cs
+++ b/src-native/THNETII.WinApi.Headers.SysInfoApi/MEMORYSTATUSEX.cs
@@ -1,10 +1,12 @@
-using System.ComponentModel;
+using System.ComponentModel;
using System.Runtime.InteropServices;
using THNETII.InteropServices.Memory;
namespace THNETII.WinApi.Native.SysInfoApi
{
+ using static SysInfoApiFunctions;
+
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\sysinfoapi.h, line 72
///
/// Contains information about the current state of both physical and virtual memory, including extended memory. The function stores information in this structure.
@@ -48,7 +50,7 @@ public double MemoryLoadPercentage
///
public ulong ullTotalPageFile;
///
- /// The maximum amount of memory the current process can commit, in bytes. This value is equal to or smaller than the system-wide available commit value. To calculate the system-wide available commit value, call and subtract the value of from the value of .
+ /// The maximum amount of memory the current process can commit, in bytes. This value is equal to or smaller than the system-wide available commit value. To calculate the system-wide available commit value, call and subtract the value of from the value of .
///
public ulong ullAvailPageFile;
///
diff --git a/src-native/THNETII.WinApi.Headers.SysInfoApi/SYSTEM_INFO.cs b/src-native/THNETII.WinApi.Headers.SysInfoApi/SYSTEM_INFO.cs
index a884f8f1..42d4b93b 100644
--- a/src-native/THNETII.WinApi.Headers.SysInfoApi/SYSTEM_INFO.cs
+++ b/src-native/THNETII.WinApi.Headers.SysInfoApi/SYSTEM_INFO.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
@@ -6,7 +6,9 @@
namespace THNETII.WinApi.Native.SysInfoApi
{
+ using static LOGICAL_PROCESSOR_RELATIONSHIP;
using static PROCESSOR_ARCHITECTURE;
+ using static SysInfoApiFunctions;
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\sysinfoapi.h, line 47
///
diff --git a/src-native/THNETII.WinApi.Headers.SysInfoApi/SysInfoApiFunctions.cs b/src-native/THNETII.WinApi.Headers.SysInfoApi/SysInfoApiFunctions.cs
index 0e2f0e90..e221b32b 100644
--- a/src-native/THNETII.WinApi.Headers.SysInfoApi/SysInfoApiFunctions.cs
+++ b/src-native/THNETII.WinApi.Headers.SysInfoApi/SysInfoApiFunctions.cs
@@ -1,8 +1,11 @@
-using Microsoft.Win32.SafeHandles;
using System;
using System.Runtime.InteropServices;
using System.Text;
+
+using Microsoft.Win32.SafeHandles;
+
using THNETII.InteropServices.Memory;
+using THNETII.WinApi.Native.ErrHandlingApi;
using THNETII.WinApi.Native.MinWinBase;
using THNETII.WinApi.Native.WinError;
using THNETII.WinApi.Native.WinNT;
@@ -14,6 +17,7 @@
namespace THNETII.WinApi.Native.SysInfoApi
{
using static COMPUTER_NAME_FORMAT;
+ using static ErrHandlingApiFunctions;
using static LOGICAL_PROCESSOR_RELATIONSHIP;
using static NativeLibraryNames;
using static WinErrorConstants;
diff --git a/src-native/THNETII.WinApi.Headers.SysInfoApi/THNETII.WinApi.Headers.SysInfoApi.csproj b/src-native/THNETII.WinApi.Headers.SysInfoApi/THNETII.WinApi.Headers.SysInfoApi.csproj
index ebf3ca8c..4e5d5bfe 100644
--- a/src-native/THNETII.WinApi.Headers.SysInfoApi/THNETII.WinApi.Headers.SysInfoApi.csproj
+++ b/src-native/THNETII.WinApi.Headers.SysInfoApi/THNETII.WinApi.Headers.SysInfoApi.csproj
@@ -6,7 +6,7 @@
7.3
netstandard1.3;netstandard1.6;netstandard2.0
true
- CS1591
+ $(NoWarn);CS0419;CS1591
THNETII.WinApi.Native.SysInfoApi
@@ -28,6 +28,12 @@
All
+
+ All
+
+
+ All
+