Skip to content

Fix Documentation comment warnings for native APIs #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src-native-c/THNETII.WinApi.Sample.Native/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@


// 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("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")]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace THNETII.WinApi.Native.WinBase
namespace THNETII.WinApi.Native.WinBase
{
using static WinNT.WinNTConstants;

Expand All @@ -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
/// <summary>
/// <see cref="FORMAT_MESSAGE_ALLOCATE_BUFFER"/> requires use of <see cref="HeapFree"/>
/// <see cref="FORMAT_MESSAGE_ALLOCATE_BUFFER"/> requires use of <see cref="M:THNETII.WinApi.Native.HeapApi.HeapApiFunctions.HeapFree(THNETII.WinApi.Native.HeapApi.HEAP_HANDLE,THNETII.WinApi.Native.HeapApi.HEAP_FLAGS,THNETII.WinApi.Native.HeapApi.HEAP_MEMORY)"/>
/// </summary>
public const int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100;

Expand Down
10 changes: 5 additions & 5 deletions src-native/THNETII.WinApi.Constants.WinNT/WinNTConstants.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Security.Principal;

namespace THNETII.WinApi.Native.WinNT
Expand Down Expand Up @@ -284,17 +284,17 @@ public static class WinNTConstants
public const int LANG_BRETON = 0x7e;
/// <summary>Use with <strong>SUBLANG_BOSNIAN_*</strong> Sublanguage IDs</summary>
public const int LANG_BOSNIAN = 0x1a;
/// <summary>Use with the <see cref="ConvertDefaultLocale"/> function</summary>
/// <summary>Use with the <see cref="M:THNETII.WinApi.Native.WinNls.WinNlsFunctions.ConvertDefaultLocale(System.Int32)"/> function</summary>
public const int LANG_BOSNIAN_NEUTRAL = 0x781a;
public const int LANG_BULGARIAN = 0x02;
public const int LANG_CATALAN = 0x03;
public const int LANG_CENTRAL_KURDISH = 0x92;
public const int LANG_CHEROKEE = 0x5c;
/// <summary>Use with <strong>SUBLANG_CHINESE_*</strong> Sublanguage IDs</summary>
public const int LANG_CHINESE = 0x04;
/// <summary>Use with the <see cref="ConvertDefaultLocale"/> function</summary>
/// <summary>Use with the <see cref="M:THNETII.WinApi.Native.WinNls.WinNlsFunctions.ConvertDefaultLocale(System.Int32)"/> function</summary>
public const int LANG_CHINESE_SIMPLIFIED = 0x04;
/// <summary>Use with the <see cref="ConvertDefaultLocale"/> function</summary>
/// <summary>Use with the <see cref="M:THNETII.WinApi.Native.WinNls.WinNlsFunctions.ConvertDefaultLocale(System.Int32)"/> function</summary>
public const int LANG_CHINESE_TRADITIONAL = 0x7c04;
public const int LANG_CORSICAN = 0x83;
public const int LANG_CROATIAN = 0x1a;
Expand Down Expand Up @@ -380,7 +380,7 @@ public static class WinNTConstants
public const int LANG_SCOTTISH_GAELIC = 0x91;
/// <summary>Use with the <strong>SUBLANG_SERBIAN_*</strong> Sublanguage IDs</summary>
public const int LANG_SERBIAN = 0x1a;
/// <summary>Use with the <see cref="ConvertDefaultLocale"/> function</summary>
/// <summary>Use with the <see cref="M:THNETII.WinApi.Native.WinNls.WinNlsFunctions.ConvertDefaultLocale(System.Int32)"/> function</summary>
public const int LANG_SERBIAN_NEUTRAL = 0x7c1a;
public const int LANG_SINDHI = 0x59;
public const int LANG_SINHALESE = 0x5b;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -165,27 +166,97 @@ SYSTEM_ERROR_MODE uMode
/// <item><term><strong>Minimum supported server:</strong></term><description>Windows Server 2003 [desktop apps | UWP apps]</description></item>
/// </list>
/// </para>
/// <para>Microsoft Docs page: <a href="https://msdn.microsoft.com/en-us/library/ms679336.aspx">FatalAppExit function</a></para>
/// <para>Microsoft Docs page: <a href="https://docs.microsoft.com/en-gb/windows/win32/api/errhandlingapi/nf-errhandlingapi-fatalappexitw">FatalAppExitW function</a></para>
/// </remarks>
/// <exception cref="DllNotFoundException">The native library containg the function could not be found.</exception>
/// <exception cref="EntryPointNotFoundException">Unable to find the entry point for the function in the native library.</exception>
/// <seealso href="https://docs.microsoft.com/windows/desktop/Debug/error-handling-functions">Error Handling Functions</seealso>
/// <seealso cref="FatalExit"/>
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)

/// <inheritdoc cref="FatalAppExit"/>
[DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, EntryPoint = nameof(FatalAppExitA))]
public static extern void FatalAppExitA(
[In] int uAction,
[In, MarshalAs(UnmanagedType.LPStr)] string lpMessageText
);

/// <inheritdoc cref="FatalAppExit"/>
[DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, EntryPoint = nameof(FatalAppExitW))]
public static extern void FatalAppExitW(
[In] int uAction,
[In, MarshalAs(UnmanagedType.LPWStr)] string lpMessageText
);

/// <inheritdoc cref="FatalAppExit"/>
#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<LPCSTR>(lpMessageText.Pointer));
break;
case 2:
FatalAppExitW(uAction, Pointer.Create<LPCWSTR>(lpMessageText.Pointer));
break;
default: throw new PlatformNotSupportedException();
}
}
#endif // !(NETSTANDARD1_3 || NETSTANDARD1_6)

/// <inheritdoc cref="FatalAppExit"/>
[DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi)]
public static extern void FatalAppExitA(
[In] int uAction,
[In] LPCSTR lpMessageText
);


/// <inheritdoc cref="FatalAppExit"/>
[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
Expand Down
Original file line number Diff line number Diff line change
@@ -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")]
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<LangVersion>7.2</LangVersion>
<LangVersion>8</LangVersion>
<TargetFrameworks>netstandard1.3;netstandard1.6;netstandard2.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>CS1591</NoWarn>
<NoWarn>$(NoWarn);CS1591;CS0419</NoWarn>
<RootNamespace>THNETII.WinApi.Native.ErrHandlingApi</RootNamespace>
</PropertyGroup>

Expand Down
Loading