-
Notifications
You must be signed in to change notification settings - Fork 142
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Actual behavior
CsWin32 generates this friendly extension method:
internal static unsafe void CopyPixels(this winmdroot.Graphics.Imaging.IWICBitmapSource @this, in winmdroot.Graphics.Imaging.WICRect prc, uint cbStride, byte[] pbBuffer)
Because the first parameter is in WICRect, I cannot pass NULL for the rectangle. If I use default(WICRect) instead, the call does not behave like passing NULL (it copies a 0x0 region / returns all zeros).
Expected behavior
The native signature is:
unsafe void CopyPixels(winmdroot.Graphics.Imaging.WICRect* prc, uint cbStride, uint cbBufferSize, [Out] [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] pbBuffer);
I expect CsWin32 to generate a safe overload that still allows passing a NULL rectangle (meaning “copy the whole image”), for example by using a nullable struct (WICRect?) or some other overload that can represent NULL.
Repro steps
NativeMethods.txtcontent:
// DXDemo1
GetModuleHandle
RegisterClass
CreateWindowEx
ShowWindow
PostQuitMessage
DefWindowProc
PeekMessage
TranslateMessage
DispatchMessage
WM_*
// DXDemo2
CoInitialize
D3D12GetDebugInterface
CreateDXGIFactory2
D3D12CreateDevice
MessageBox
CreateEvent
MsgWaitForMultipleObjects
ID3D12Debug
IDXGIFactory5
ID3D12Device4
ID3D12CommandQueue
ID3D12CommandAllocator
ID3D12GraphicsCommandList
ID3D12DescriptorHeap
IDXGISwapChain3
ID3D12Resource
ID3D12Fence
DXGI_ERROR_NOT_FOUND
INFINITE
// DXDemo3
D3D12SerializeRootSignature
D3DCompileFromFile
ID3D12PipelineState
D3D12_COLOR_WRITE_ENABLE
D3DCOMPILE_SKIP_OPTIMIZATION
D3DCOMPILE_DEBUG
D3D12_MIN_DEPTH
D3D12_MAX_DEPTH
// DXDemo4
CoCreateInstance
IWICImagingFactory
IWICPixelFormatInfo
CLSID_WICImagingFactory2
GUID_WICPixelFormat*
DXGI_FORMAT*
D3D12_TEXTURE_DATA_PITCH_ALIGNMENT
D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING
D3D12_FLOAT32_MAX
WaitForSingleObject
NativeMethods.jsoncontent (if present):
- Any of your own code that should be shared?
https://github.com/littletoxic/DXPractice/blob/master/DXDemo4/Program.cs#L467
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net10.0-windows10.0.17763.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<PublishAot>true</PublishAot>
<InvariantGlobalization>true</InvariantGlobalization>
<CsWin32RunAsBuildTask>true</CsWin32RunAsBuildTask>
<DisableRuntimeMarshalling>true</DisableRuntimeMarshalling>
</PropertyGroup>
Context
- CsWin32 version: 0.3.264
- Win32Metadata version (if explicitly set by project): default
- Target Framework: net10.0-windows10.0.17763.0
LangVersion(if explicitly set by project): default
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working