Skip to content

Compiler warnings CS1574 and CS1580 appear in generated code on <inheritdoc cref="x" /> #1658

@ramiabughazaleh

Description

@ramiabughazaleh

Hi.

Compiler warnings CS1574 and CS1580 appear in generated code on <inheritdoc cref="x" />.

I did not expect any compiler warnings to appear.

I can add CS1574 and CS1580 to the NoWarn msbuild property, but that will also ignore warnings for other, non-generated code, which is not ideal.

For example:
.\obj\Debug\net8.0-windows\generated\Microsoft.Windows.CsWin32\Microsoft.Windows.CsWin32.SourceGenerator\Windows.Win32.NativeMethods.ADVAPI32.dll.g.cs:

// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------

#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981
using global::System;
using global::System.Diagnostics;
using global::System.Diagnostics.CodeAnalysis;
using global::System.Runtime.CompilerServices;
using global::System.Runtime.InteropServices;
using global::System.Runtime.Versioning;
using winmdroot = global::Windows.Win32;
namespace Windows.Win32
{

	/// <content>
	/// Contains extern methods from "ADVAPI32.dll".
	/// </content>
	internal static partial class NativeMethods
	{
		/// <inheritdoc cref="ConvertStringSecurityDescriptorToSecurityDescriptor(winmdroot.Foundation.PCWSTR, uint, winmdroot.Security.PSECURITY_DESCRIPTOR*, uint*)"/>
		[SupportedOSPlatform("windows5.1.2600")]
		[OverloadResolutionPriority(1)]
		internal static unsafe winmdroot.Foundation.BOOL ConvertStringSecurityDescriptorToSecurityDescriptor(string StringSecurityDescriptor, uint StringSDRevision, out winmdroot.Security.PSECURITY_DESCRIPTOR SecurityDescriptor, uint* SecurityDescriptorSize)
		{
			fixed (winmdroot.Security.PSECURITY_DESCRIPTOR* SecurityDescriptorLocal = &SecurityDescriptor)
			{
				fixed (char* StringSecurityDescriptorLocal = StringSecurityDescriptor)
				{
					winmdroot.Foundation.BOOL __result = NativeMethods.ConvertStringSecurityDescriptorToSecurityDescriptor(StringSecurityDescriptorLocal, StringSDRevision, SecurityDescriptorLocal, SecurityDescriptorSize);
					return __result;
				}
			}
		}

		/// <summary>Converts a string-format security descriptor into a valid, functional security descriptor. (Unicode)</summary>
		/// <param name="StringSecurityDescriptor">
		/// <para>A pointer to a null-terminated string containing the <a href="https://docs.microsoft.com/windows/desktop/SecAuthZ/security-descriptor-string-format">string-format security descriptor</a> to convert.</para>
		/// <para><see href="https://learn.microsoft.com/windows/win32/api/sddl/nf-sddl-convertstringsecuritydescriptortosecuritydescriptorw#parameters">Read more on docs.microsoft.com</see>.</para>
		/// </param>
		/// <param name="StringSDRevision">Specifies the revision level of the <i>StringSecurityDescriptor</i> string. Currently this value must be SDDL_REVISION_1.</param>
		/// <param name="SecurityDescriptor">
		/// <para>A pointer to a variable that receives a pointer to the converted security descriptor. The returned security descriptor is <a href="https://docs.microsoft.com/windows/desktop/SecGloss/s-gly">self-relative</a>. To free the returned buffer, call the <a href="https://docs.microsoft.com/windows/desktop/api/winbase/nf-winbase-localfree">LocalFree</a> function. To convert the security descriptor to an <a href="https://docs.microsoft.com/windows/desktop/SecGloss/a-gly">absolute security descriptor</a>, use the <a href="https://docs.microsoft.com/windows/desktop/api/securitybaseapi/nf-securitybaseapi-makeabsolutesd">MakeAbsoluteSD</a> function.</para>
		/// <para><see href="https://learn.microsoft.com/windows/win32/api/sddl/nf-sddl-convertstringsecuritydescriptortosecuritydescriptorw#parameters">Read more on docs.microsoft.com</see>.</para>
		/// </param>
		/// <param name="SecurityDescriptorSize">A pointer to a variable that receives the size, in bytes, of the converted security descriptor. This parameter can be NULL.</param>
		/// <returns>
		/// <para>If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call <a href="https://docs.microsoft.com/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>. <b>GetLastError</b> may return one of the following error codes. </para>
		/// <para>This doc was truncated.</para>
		/// </returns>
		/// <remarks>
		/// <para>If <b>ace_type</b> is ACCESS_ALLOWED_OBJECT_ACE_TYPE and neither <b>object_guid</b> nor <b>inherit_object_guid</b> has a  <a href="https://docs.microsoft.com/windows/win32/api/guiddef/ns-guiddef-guid">GUID</a> specified, then <b>ConvertStringSecurityDescriptorToSecurityDescriptor</b> converts <b>ace_type</b> to ACCESS_ALLOWED_ACE_TYPE. For information about the  <b>ace_type</b>,  <b>object_guid</b>, and <b>inherit_object_guid</b> fields, see <a href="https://docs.microsoft.com/windows/desktop/SecAuthZ/ace-strings">Ace Strings</a>.</para>
		/// <para>> [!NOTE] > The sddl.h header defines ConvertStringSecurityDescriptorToSecurityDescriptor as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see [Conventions for Function Prototypes](/windows/win32/intl/conventions-for-function-prototypes).</para>
		/// <para><see href="https://learn.microsoft.com/windows/win32/api/sddl/nf-sddl-convertstringsecuritydescriptortosecuritydescriptorw#">Read more on docs.microsoft.com</see>.</para>
		/// </remarks>
		[DllImport("ADVAPI32.dll", ExactSpelling = true, EntryPoint = "ConvertStringSecurityDescriptorToSecurityDescriptorW", SetLastError = true),DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
		[SupportedOSPlatform("windows5.1.2600")]
		internal static extern unsafe winmdroot.Foundation.BOOL ConvertStringSecurityDescriptorToSecurityDescriptor(winmdroot.Foundation.PCWSTR StringSecurityDescriptor, uint StringSDRevision, winmdroot.Security.PSECURITY_DESCRIPTOR* SecurityDescriptor, [Optional] uint* SecurityDescriptorSize);
	}
}

Compiler output:

.\obj\Debug\net8.0-windows\generated\Microsoft.Windows.CsWin32\Microsoft.Windows.CsWin32.SourceGenerator\Windows.Win32.NativeMethods.ADVAPI32.dll.g.cs(26,77,26,104): warning CS1580: Invalid type for parameter winmdroot.Foundation.PCWSTR in XML comment cref attribute: 'ConvertStringSecurityDescriptorToSecurityDescriptor(winmdroot.Foundation.PCWSTR, uint, winmdroot.Security.PSECURITY_DESCRIPTOR*, uint*)'
.\obj\Debug\net8.0-windows\generated\Microsoft.Windows.CsWin32\Microsoft.Windows.CsWin32.SourceGenerator\Windows.Win32.NativeMethods.ADVAPI32.dll.g.cs(26,25,26,160): warning CS1574: XML comment has cref attribute 'ConvertStringSecurityDescriptorToSecurityDescriptor(winmdroot.Foundation.PCWSTR, uint, winmdroot.Security.PSECURITY_DESCRIPTOR*, uint*)' that could not be resolved

NativeMethods.txt:

ConvertStringSecurityDescriptorToSecurityDescriptor

NativeMethods.json:

{
    "$schema": "https://aka.ms/CsWin32.schema.json",
    "allowMarshaling": true,
    "friendlyOverloads": {
        "enabled": true
    },
    "multiTargetingFriendlyAPIs": false,
    "useSafeHandles": true,
    "wideCharOnly": true,
    "emitSingleFile": false,
    "className": "NativeMethods",
    "public": false
}

csproj:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net8.0-windows</TargetFramework>
        <LangVersion>latest</LangVersion>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
    </PropertyGroup>

    <ItemGroup>
      <AdditionalFiles Include="NativeMethods.json" />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.183">
            <PrivateAssets>all</PrivateAssets>
        </PackageReference>
    </ItemGroup>

</Project>

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions