Skip to content

Clarification on bool marshalling with LibraryImport #99440

Answered by huoyaoyuan
sweemer asked this question in Q&A
Discussion options

You must be logged in to vote
  1. According to the Customize parameter marshalling documentation, MarshalAs has no effect when runtime marshalling is disabled.

MarshalAs has no effect on raw DllImport.

However, the paragraph above says that MarshalAs must be used when runtime marshalling is disabled, which seems to be a contradiction.

The source generator reads MarshalAs on LibraryImport declaration, and translate it into appropriate form in generated DllImport.

What about a managed delegate that either takes a bool argument and/or returns a bool value - does the marshalling need to be explicitly specified via MarshalAs when runtime marshalling is disabled? I ask because I'm not seeing any warnings when I pass such…

Replies: 4 comments 13 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by sweemer
Comment options

You must be logged in to vote
2 replies
@huoyaoyuan
Comment options

@sweemer
Comment options

Comment options

You must be logged in to vote
8 replies
@jkoritzinsky
Comment options

@sweemer
Comment options

@huoyaoyuan
Comment options

@sweemer
Comment options

@jkoritzinsky
Comment options

Comment options

You must be logged in to vote
3 replies
@jkoritzinsky
Comment options

@sweemer
Comment options

@jkoritzinsky
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment