Skip to content

Commit be82e82

Browse files
authored
Fix documentation for DlllImportAttribute.PreserveSig (dotnet#5303)
- Note behavior for methods with return value - Delete references to "retval return value" that did not make sense
1 parent 9878fe4 commit be82e82

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

xml/System.Runtime.InteropServices/DllImportAttribute.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,16 +483,16 @@
483483
<ReturnType>System.Boolean</ReturnType>
484484
</ReturnValue>
485485
<Docs>
486-
<summary>Indicates whether unmanaged methods that have <see langword="HRESULT" /> or <see langword="retval" /> return values are directly translated or whether <see langword="HRESULT" /> or <see langword="retval" /> return values are automatically converted to exceptions.</summary>
486+
<summary>Indicates whether unmanaged methods that have <see langword="HRESULT" /> return values are directly translated or whether <see langword="HRESULT" /> return values are automatically converted to exceptions.</summary>
487487
<remarks>
488488
<format type="text/markdown"><![CDATA[
489489
490490
## Remarks
491-
Set the <xref:System.Runtime.InteropServices.DllImportAttribute.PreserveSig> field to `true` to directly translate unmanaged signatures with `HRESULT` or `retval` values; set it to `false` to automatically convert `HRESULT` or `retval` values to exceptions. By default, the <xref:System.Runtime.InteropServices.DllImportAttribute.PreserveSig> field is `true`.
491+
Set the <xref:System.Runtime.InteropServices.DllImportAttribute.PreserveSig> field to `true` to translate unmanaged signatures with `HRESULT` values directly; set it to `false` to automatically convert `HRESULT` return values to exceptions. By default, the <xref:System.Runtime.InteropServices.DllImportAttribute.PreserveSig> field is `true`.
492492
493-
When `true`, the resulting method signature returns an integer value that contains the `HRESULT` value. In this case, you must manually inspect the return value and respond accordingly in your application.
493+
When `true`, the managed method signature returns an integer value that contains the `HRESULT` value. In this case, you must manually inspect the return value and respond accordingly in your application.
494494
495-
When you set the <xref:System.Runtime.InteropServices.DllImportAttribute.PreserveSig> field to `false`, the resulting method signature contains a void return type instead of an integer (`HRESULT`) return type. When the unmanaged method produces an `HRESULT`, the runtime automatically ignores a return value of `S_OK` (or 0) and does not throw an exception. For `HRESULT`s other than `S_OK`, the runtime automatically throws an exception that corresponds to the `HRESULT`. Note that the <xref:System.Runtime.InteropServices.DllImportAttribute> attribute only performs this conversion to methods that return an `HRESULT`.
495+
When you set the <xref:System.Runtime.InteropServices.DllImportAttribute.PreserveSig> field to `false`, the managed method signature has a void return type or the type of the last unmanaged [out, retval] parameter. When the unmanaged method produces an `HRESULT`, the runtime automatically ignores a return value of `S_OK` (or 0) and does not throw an exception. For `HRESULT`s other than `S_OK`, the runtime automatically throws an exception that corresponds to the `HRESULT`.
496496
497497
You might decide to change the default error reporting behavior from `HRESULT`s to exceptions in cases where exceptions better fit the error reporting structure of your application.
498498

xml/System.Runtime.InteropServices/PreserveSigAttribute.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</Attribute>
4949
</Attributes>
5050
<Docs>
51-
<summary>Indicates that the HRESULT or <see langword="retval" /> signature transformation that takes place during COM interop calls should be suppressed.</summary>
51+
<summary>Indicates that the HRESULT signature transformation that takes place during COM interop calls should be suppressed.</summary>
5252
<remarks>
5353
<format type="text/markdown"><![CDATA[
5454

0 commit comments

Comments
 (0)