Skip to content
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

CA1418: The platform 'Windows ' is not a known platform name #747

Closed
jnm2 opened this issue Nov 18, 2021 · 5 comments
Closed

CA1418: The platform 'Windows ' is not a known platform name #747

jnm2 opened this issue Nov 18, 2021 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@jnm2
Copy link

jnm2 commented Nov 18, 2021

Windows.Win32.PInvoke.Msi.g.cs contains [SupportedOSPlatform("Windows 8")] which the .NET SDK does not like as of v6.

Generated file (click to expand)
// ------------------------------------------------------------------------------
// <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
namespace Windows.Win32
{
	using global::System;
	using global::System.Diagnostics;
	using global::System.Runtime.CompilerServices;
	using global::System.Runtime.InteropServices;
	using global::System.Runtime.Versioning;
	using winmdroot = global::Windows.Win32;


	/// <content>
	/// Contains extern methods from "Msi.dll".
	/// </content>
	internal static partial class PInvoke
	{
		/// <inheritdoc cref="MsiGetComponentPath(winmdroot.Foundation.PCWSTR, winmdroot.Foundation.PCWSTR, winmdroot.Foundation.PWSTR, uint*)"/>
		[SupportedOSPlatform("Windows 8")]
		internal static unsafe winmdroot.System.ApplicationInstallationAndServicing.INSTALLSTATE MsiGetComponentPath(string szProduct, string szComponent, winmdroot.Foundation.PWSTR lpPathBuf, uint* pcchBuf)
		{
			fixed (char* szComponentLocal = szComponent)
			{
				fixed (char* szProductLocal = szProduct)
				{
					winmdroot.System.ApplicationInstallationAndServicing.INSTALLSTATE __result = PInvoke.MsiGetComponentPath(szProductLocal, szComponentLocal, lpPathBuf, pcchBuf);
					return __result;
				}
			}
		}

		/// <summary>The MsiGetComponentPath function returns the full path to an installed component. If the key path for the component is a registry key then the registry key is returned.</summary>
		/// <param name="szProduct">Specifies the product code for the client product.</param>
		/// <param name="szComponent">Specifies the component ID of the component to be located.</param>
		/// <param name="lpPathBuf">
		/// <para>Pointer to a variable that receives the path to the component. This parameter can be null. If the component is a registry key, the registry roots are represented numerically. If this is a registry subkey path, there is a backslash at the end of the Key Path. If this is a registry value key path, there is no backslash at the end. For example, a registry path on a 32-bit operating system of <b>HKEY_CURRENT_USER</b>&#92;<b>SOFTWARE</b>&#92;<b>Microsoft</b> is returned as "01:\SOFTWARE\Microsoft\". The registry roots returned on 32-bit operating systems are defined as shown in the following table.</para>
		/// <para><div class="alert"><b>Note</b>  On 64-bit operating systems, a value of 20 is added to the numerical registry roots in this table to distinguish them from registry key paths on 32-bit operating systems. For example, a registry key path of <b>HKEY_CURRENT_USER</b>&#92;<b>SOFTWARE</b>&#92;<b>Microsoft</b> is returned as "21:\SOFTWARE\Microsoft\", if the component path is a registry key on a 64-bit operating system.</div> <div> </div></para>
		/// <para></para>
		/// <para>This doc was truncated.</para>
		/// <para><see href="https://docs.microsoft.com/windows/win32/api//msi/nf-msi-msigetcomponentpathw#parameters">Read more on docs.microsoft.com</see>.</para>
		/// </param>
		/// <param name="pcchBuf">
		/// <para>Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the <i>lpPathBuf</i> parameter. On input, this is the full size of the buffer, including a space for a terminating null character. If the buffer passed in is too small, the count returned does not include the terminating null character.</para>
		/// <para>If <i>lpPathBuf</i> is null, <i>pcchBuf</i> can be null.</para>
		/// <para><see href="https://docs.microsoft.com/windows/win32/api//msi/nf-msi-msigetcomponentpathw#parameters">Read more on docs.microsoft.com</see>.</para>
		/// </param>
		/// <returns>
		/// <para>The <b>MsiGetComponentPath</b> function returns the following values.</para>
		/// <para></para>
		/// <para>This doc was truncated.</para>
		/// </returns>
		/// <remarks>
		/// <para><see href="https://docs.microsoft.com/windows/win32/api//msi/nf-msi-msigetcomponentpathw">Learn more about this API from docs.microsoft.com</see>.</para>
		/// </remarks>
		[DllImport("Msi", ExactSpelling = true, EntryPoint = "MsiGetComponentPathW")]
		[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
		[SupportedOSPlatform("Windows 8")]
		internal static extern unsafe winmdroot.System.ApplicationInstallationAndServicing.INSTALLSTATE MsiGetComponentPath(winmdroot.Foundation.PCWSTR szProduct, winmdroot.Foundation.PCWSTR szComponent, winmdroot.Foundation.PWSTR lpPathBuf, [Optional] uint* pcchBuf);

		/// <inheritdoc cref="MsiGetShortcutTarget(winmdroot.Foundation.PCWSTR, winmdroot.Foundation.PWSTR, winmdroot.Foundation.PWSTR, winmdroot.Foundation.PWSTR)"/>
		[SupportedOSPlatform("Windows 8")]
		internal static unsafe uint MsiGetShortcutTarget(string szShortcutPath, winmdroot.Foundation.PWSTR szProductCode, winmdroot.Foundation.PWSTR szFeatureId, winmdroot.Foundation.PWSTR szComponentCode)
		{
			fixed (char* szShortcutPathLocal = szShortcutPath)
			{
				uint __result = PInvoke.MsiGetShortcutTarget(szShortcutPathLocal, szProductCode, szFeatureId, szComponentCode);
				return __result;
			}
		}

		/// <summary>The MsiGetShortcutTarget function examines a shortcut and returns its product, feature name, and component if available.</summary>
		/// <param name="szShortcutPath">A null-terminated string specifying the full path to a shortcut.</param>
		/// <param name="szProductCode">
		/// <para>A GUID for the product code of the shortcut. This string buffer must be 39 characters long. The first 38 characters are for the <a href="https://docs.microsoft.com/windows/desktop/Msi/guid">GUID</a>, and the last character is for the terminating null character. This parameter can be null.</para>
		/// <para><see href="https://docs.microsoft.com/windows/win32/api//msi/nf-msi-msigetshortcuttargetw#parameters">Read more on docs.microsoft.com</see>.</para>
		/// </param>
		/// <param name="szFeatureId">The feature name of the shortcut. The string buffer must be MAX_FEATURE_CHARS+1 characters long. This parameter can be null.</param>
		/// <param name="szComponentCode">
		/// <para>A GUID of the component code. This string buffer must be 39 characters long. The first 38 characters are for the <a href="https://docs.microsoft.com/windows/desktop/Msi/guid">GUID</a>, and the last character is for the terminating null character. This parameter can be null.</para>
		/// <para><see href="https://docs.microsoft.com/windows/win32/api//msi/nf-msi-msigetshortcuttargetw#parameters">Read more on docs.microsoft.com</see>.</para>
		/// </param>
		/// <returns>This function returns UINT.</returns>
		/// <remarks>
		/// <para><see href="https://docs.microsoft.com/windows/win32/api//msi/nf-msi-msigetshortcuttargetw">Learn more about this API from docs.microsoft.com</see>.</para>
		/// </remarks>
		[DllImport("Msi", ExactSpelling = true, EntryPoint = "MsiGetShortcutTargetW")]
		[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
		[SupportedOSPlatform("Windows 8")]
		internal static extern uint MsiGetShortcutTarget(winmdroot.Foundation.PCWSTR szShortcutPath, winmdroot.Foundation.PWSTR szProductCode, winmdroot.Foundation.PWSTR szFeatureId, winmdroot.Foundation.PWSTR szComponentCode);
	}
}

Repro steps

  1. NativeMethods.txt content:
MsiGetComponentPath
MsiGetShortcutTarget

Context

  • CsWin32 version: 0.1.619-beta
  • Target Framework: net6.0-windows
@AArnott
Copy link
Member

AArnott commented Nov 19, 2021

This comes from the metadata. Moving to that repo.

@AArnott AArnott transferred this issue from microsoft/CsWin32 Nov 19, 2021
@riverar
Copy link
Collaborator

riverar commented Nov 19, 2021

@jnm2 What does "does not like" mean here? I don't like pineapple on pizza but sometimes you got to eat, ya know? 😄

@kennykerr
Copy link
Contributor

You don't like pineapple on pizza? What kind of monster are you?!

@jnm2
Copy link
Author

jnm2 commented Nov 19, 2021

Oh shoot, I'm sorry, I forgot to include the error somehow. It fails the build:

Error CA1418: The platform 'Windows ' is not a known platform name

@mikebattista
Copy link
Collaborator

I think we just need to change the value to "windows8.0" instead of "Windows 8" in supportedOS.rsp.

@mikebattista mikebattista self-assigned this Nov 29, 2021
@mikebattista mikebattista added the bug Something isn't working label Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants