Skip to content

_Field_size_full_ struct member annotation is ignored #547

Closed

Description

For example:

typedef struct D3D12_ROOT_DESCRIPTOR_TABLE
    {
    UINT NumDescriptorRanges;
    _Field_size_full_(NumDescriptorRanges)  const D3D12_DESCRIPTOR_RANGE *pDescriptorRanges;
    } 	D3D12_ROOT_DESCRIPTOR_TABLE;

Becomes:

public struct D3D12_ROOT_DESCRIPTOR_TABLE1
{
	public uint NumDescriptorRanges;

	[Const]
	public unsafe D3D12_DESCRIPTOR_RANGE1* pDescriptorRanges;
}

It would be good to have some metadata here associating these two fields to allow projections to do the right thing. See for example microsoft/windows-rs#907.

Activity

  1. riverar commented on Apr 16, 2022

    @riverar
    Collaborator

    What's the proposed change here? Are you looking to see something like this?

    public struct D3D12_ROOT_DESCRIPTOR_TABLE1
    {
    	public uint NumDescriptorRanges;
    
    	[Const]
    	[NativeArrayInfo(CountParamName = "NumDescriptorRanges")]
    	public unsafe D3D12_DESCRIPTOR_RANGE1* pDescriptorRanges;
    }
  2. kennykerr commented on Jul 22, 2022

    @kennykerr
    Contributor

    Any progress on this issue? Would love to bind this up in Rust so we can treat this as an array.

  3. kennykerr commented on Jul 22, 2022

    @kennykerr
    Contributor

    I noticed I have both microsoft/windows-rs#907 and microsoft/windows-rs#443 blocked on this issue. 😢

  4. sotteson1 commented on Jul 22, 2022

    @sotteson1
    Contributor

    Any progress on this issue? Would love to bind this up in Rust so we can treat this as an array.

    Would what Rafael Rivera (@riverar) suggested work? I haven't had a lot of time for this project lately, unfortunately. I'm not sure when I'll be able to get to this.

  5. kennykerr commented on Jul 22, 2022

    @kennykerr
    Contributor

    Yep, an attribute like that would be enough to make it work - thanks!

  6. mikebattista commented on Mar 21, 2023

    @mikebattista
    Contributor

    I don't see any CppAttributeList for this annotation.

    public unsafe partial struct D3D12_ROOT_DESCRIPTOR_TABLE
    {
        public uint NumDescriptorRanges;
    
        [NativeTypeName("const D3D12_DESCRIPTOR_RANGE *")]
        public D3D12_DESCRIPTOR_RANGE* pDescriptorRanges;
    }

    Tanner Gooding (@tannergooding) SAL annotations are expected to surface in the CppAttributeList attribute right? That's how we process other SAL annotations but I don't see the attribute in this case.

  7. mikebattista commented on Apr 14, 2023

    @mikebattista
    Contributor

    There was a manageable enough set of these in d3d12.h that I defined them manually for now. We have CountFieldName for this scenario.

    public struct D3D12_ROOT_DESCRIPTOR_TABLE
    {
    	public uint NumDescriptorRanges;
    
    	[Const]
    	[NativeArrayInfo(CountFieldName = "NumDescriptorRanges")]
    	public unsafe D3D12_DESCRIPTOR_RANGE* pDescriptorRanges;
    }
    

    Tanner Gooding (@tannergooding) I filed a bug in your repo for generating CppAttributeList on structs so we can detect this automatically for the rest of the API surface.

  8. added a commit that references this issue on Mar 28, 2026
    33a64f6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions