Thread for Generation Issues (To keep
Thread for Generation Issues (To keep nice and contained)
1 Reply
1. we are seeing in generation is the
rgbyData
span in MIB_OPAQUE_INFO
looks like this:
Where AsSpan requires a length argument which isn't supplied
TerraFX has the following:
There are a few other cases like this where a length variable does exist but isn't named clearly (NumberEntries or some such), likely leading to a similar scenario of the generator not knowing what to do. TerraFX in each of these cases has an appropriate value filled.
---------------------------------------
2.An example of a class where the IID was missing with generation:
Out of curiosity is the MIDL_INTERFACE not something you can pull from clang? as all the IIDs I had to add had this, which does expand to
struct __declspec(uuid("80b47b17-ec8b-5653-850b-7508a01f52e7")) __declspec(novtable)
------------------------------------------------------------
3. There is a couple functions (in Windows\shared\ws2ipdef\Windows.gen.cs) which generate like this
Byte is _Byte_eFixedBuffer but Fill expects a void*
TerraFX has the following:
This is a valid solution for the instances in Silk as well, not sure what is happening here.
----------------------------------------------
4. We have some ambiguous cref in generated comments (PR already in clangsharp)
Anytime there are two overrides with the same name we get this issue
----------------------------------------------------
5. INativeGuid, that get attached to classes with Guids but a definition for it isn't given anywhere as far as I could find. It is easy enough to replicate but still would be nice even if it is a clangsharp class that we have to reference or copy to our project.
--------------------------------------------------
6. Some defaultParameterValue attributes are trying to cast causing failure
(HRESULT)(0) isn't valid but just 0 is. I believe it is looking for a compile-time constant here, but not exactly sure.
--------------------------------------------------
7. No clue what happened here but it is very upset (Windows/um/WinUser/Windows.gen.cs)
The DllImport is where the problem exists. The triple set of quotes is causing problems
TerraFX just doesn't include this function so here is the original C
--------------------------------------------------
8.
There are a few functions like this but they are all the same issue (in Windows/Shared/strsafe/Windows.gen.cs)
```
public static HRESULT StringCchPrintfA([NativeTypeName("STRSAFE_LPSTR")] sbyte* pszDest, [NativeTypeName("size_t")] nuint cchDest, [NativeTypeName("STRSAFE_LPCSTR")] sbyte* pszFormat, arglist)
{
HRESULT hr;
hr = StringValidateDestA(pszDest, cchDest, 2147483647);
if ((((HRESULT)(hr)) >= 0))
{
sbyte* argList;
((void)(new vcrt_assert_va_start_is_not_reference(), ((void)(va_start(&argList, pszFormat)))));
hr = StringVPrintfWorkerA(pszDest, cchDest, null, pszFormat, argList);
(unchecked((void)(argList = (sbyte*)(0))));
}
else if (cchDest > 0)
{
pszDest = (sbyte)('\0');
}
return hr;
}
((void)(new vcrt_assert_va_start_is_not_reference(), ((void)(va_start(&argList, pszFormat)))));
hr = StringVPrintfWorkerA(pszDest, cchDest, null, pszFormat, argList);
(unchecked((void)(argList = (sbyte)(0))));
STRSAFEAPI
StringCchPrintfA(
_Outwrites(cchDest) Always(_Postz) STRSAFE_LPSTR pszDest,
In size_t cchDest,
In _Printf_formatstring STRSAFE_LPCSTR pszFormat,
...)
{
HRESULT hr;
hr = StringValidateDestA(pszDest, cchDest, STRSAFE_MAX_CCH);
if (SUCCEEDED(hr))
{
va_list argList;
va_start(argList, pszFormat);
hr = StringVPrintfWorkerA(pszDest,
cchDest,
NULL,
pszFormat,
argList);
va_end(argList);
}
else if (cchDest > 0)
{
pszDest = '\0';
}
return hr;
}
#define crt_va_start(ap, x) ((void)(vcrt_assert_va_start_is_not_reference<decltype(x)>(), crt_va_start_a(ap, x)))
#define crt_va_end(ap) ((void)(ap = (va_list)0))
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(29)]
public void Dispose()
{
((delegate unmanaged<CHttpModule, void>)((lpVtbl)[29]))(
(CHttpModule)Unsafe.AsPointer(ref this)
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(30)]
public void Dispose()
{
((delegate unmanaged<CHttpModule, void>)((lpVtbl)[30]))(
(CHttpModule)Unsafe.AsPointer(ref this)
);
}
virtual
VOID
Dispose(
VOID
)
{
delete this;
}
[NativeTypeName("const IID &")]
public static Guid IID_IWebAuthenticationAddAccountResponse =
typeof(IWebAuthenticationAddAccountResponse).GUID;
public static ref readonly Guid IID_IWebAuthenticationAddAccountResponse
{
get
{
ReadOnlySpan<byte> data =
[
0xE8,
0x13,
0xB0,
0x7F,
0xD8,
0x0B,
0x2B,
0x54,
0xB4,
0x86,
0x83,
0x23,
0x16,
0x3A,
0x4B,
0x85,
];
Debug.Assert(data.Length == Unsafe.SizeOf<Guid>());
return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(6)]
public HRESULT TryGetTransformTo(
[NativeTypeName("ABI::Windows::Perception::Spatial::ISpatialCoordinateSystem ")]
ISpatialCoordinateSystem target,
[NativeTypeName(
"ABI::Windows::Foundation::FIReference_1_WindowsCFoundationCNumericsCMatrix4x4_t "
)]
IReference<Matrix4x4> value
)
{
return (
(delegate unmanaged<
ISpatialCoordinateSystem,
ISpatialCoordinateSystem,
IReference<Matrix4x4>*,
int>)((lpVtbl)[6])
)(this, target, value);
}
```
uses Matrix4x4 but it isn't defined without System.Numerics
@tannergooding These are the issues we had during generation. Most were fixed via pulling TerraFX versions as our base but it would be nice to generate correctly.
The only outstanding issue is #4 which I already put in a PR for and it is only generating a warning.