-
Notifications
You must be signed in to change notification settings - Fork 90
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
CS1503: Argument cannot convert from System.GUID to System.GUID* at TFM net35 #888
Comments
Thanks for using CsWin32 and reporting on your experience. |
The generated code is invalid C# ( Invalid generated code: // ------------------------------------------------------------------------------
// <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 winmdroot = global::Windows.Win32;
namespace Windows.Win32
{
/// <content>
/// Contains extern methods from "OLE32.dll".
/// </content>
[global::System.CodeDom.Compiler.GeneratedCode("Microsoft.Windows.CsWin32", "0.2.188-beta+852e176a3b")]
internal static partial class PInvoke
{
/// <inheritdoc cref="CoCreateInstance(Guid*, object, global::Windows.Win32.System.Com.CLSCTX, Guid*, out object)"/>
internal static unsafe global::Windows.Win32.Foundation.HRESULT CoCreateInstance<T>(in Guid rclsid, object pUnkOuter, global::Windows.Win32.System.Com.CLSCTX dwClsContext, out T ppv)
where T : class
{
global::Windows.Win32.Foundation.HRESULT hr = CoCreateInstance(rclsid, pUnkOuter, dwClsContext, typeof(T).GUID, out object o);
ppv = (T)o;
return hr;
}
/// <inheritdoc cref="CoCreateInstance(global::System.Guid*, object, winmdroot.System.Com.CLSCTX, global::System.Guid*, out object)"/>
internal static unsafe winmdroot.Foundation.HRESULT CoCreateInstance(in global::System.Guid rclsid, object pUnkOuter, winmdroot.System.Com.CLSCTX dwClsContext, in global::System.Guid riid, out object ppv)
{
fixed (global::System.Guid* riidLocal = &riid)
{
fixed (global::System.Guid* rclsidLocal = &rclsid)
{
winmdroot.Foundation.HRESULT __result = PInvoke.CoCreateInstance(rclsidLocal, pUnkOuter, dwClsContext, riidLocal, out ppv);
return __result;
}
}
}
/// <summary>Creates a single uninitialized object of the class associated with a specified CLSID.</summary>
/// <param name="rclsid">The CLSID associated with the data and code that will be used to create the object.</param>
/// <param name="pUnkOuter">If <b>NULL</b>, indicates that the object is not being created as part of an aggregate. If non-<b>NULL</b>, pointer to the aggregate object's <a href="https://docs.microsoft.com/windows/desktop/api/unknwn/nn-unknwn-iunknown">IUnknown</a> interface (the controlling <b>IUnknown</b>).</param>
/// <param name="dwClsContext">Context in which the code that manages the newly created object will run. The values are taken from the enumeration <a href="https://docs.microsoft.com/windows/desktop/api/wtypesbase/ne-wtypesbase-clsctx">CLSCTX</a>.</param>
/// <param name="riid">A reference to the identifier of the interface to be used to communicate with the object.</param>
/// <param name="ppv">Address of pointer variable that receives the interface pointer requested in <i>riid</i>. Upon successful return, *<i>ppv</i> contains the requested interface pointer. Upon failure, *<i>ppv</i> contains <b>NULL</b>.</param>
/// <returns>
/// <para>This function can return the following values. </para>
/// <para>This doc was truncated.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//combaseapi/nf-combaseapi-cocreateinstance">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("OLE32.dll", ExactSpelling = true)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
internal static extern unsafe winmdroot.Foundation.HRESULT CoCreateInstance(global::System.Guid* rclsid, [MarshalAs(UnmanagedType.IUnknown)] object pUnkOuter, winmdroot.System.Com.CLSCTX dwClsContext, global::System.Guid* riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv);
}
} |
The C# syntax is valid, but the code isn't coherent, which doesn't surprise me because we barely test net35 code generation, whereas we thoroughly test code generation for net472, netstandard2.0 and net6.0. CsWin32/test/Microsoft.Windows.CsWin32.Tests/FullGenerationTests.cs Lines 23 to 27 in 27f494b
CsWin32/test/Microsoft.Windows.CsWin32.Tests/GeneratorTestBase.cs Lines 50 to 56 in 27f494b
The fact that this works on net462 is on target. net461 is not a goal, as Microsoft doesn't support that version as a runtime any more. Microsoft does support net35 as a runtime, but CsWin32 does not, except as I mentioned earlier. The cost/benefit ratio for adding net35 as a fully supported target simply isn't a good bargain. |
Yes, no one should be targeting net40-net461, but it could be useful in tracking down what makes the difference. (E.g. the presence of an API from the System.Memory package?) |
We were excluding certain friendly overloads on net35 on the basis that `Span<T>` isn't supported there, even when the friendly overloads didn't require that type. With this change, we have fine-tuned the exclusion to only restrict the friendly overloads' parameter changes that would require `Span<T>`. This fixes #888.
Actual behavior
CS1503: Argument cannot convert from System.GUID to System.GUID*
Expected behavior
Everything works well after changing to TFM net7.0
Repro steps
https://github.com/peaceshi/CsWin32-Issue
Context
0.2.188-beta
net35
Images
The text was updated successfully, but these errors were encountered: