Skip to content

Conversation

@am11
Copy link
Member

@am11 am11 commented Dec 27, 2025

Fix #122755.

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Dec 27, 2025
@jkotas
Copy link
Member

jkotas commented Dec 27, 2025

Can we treat these as errors so that they do not come back? Are there more outside corelib?

@am11 am11 changed the title Fix SYSLIB1092 in corelib Treat SYSLIB1092 as error in sources Dec 28, 2025
@am11 am11 force-pushed the chore/corelib/fix-SYSLIB1092 branch from d9b36df to 13c505d Compare December 28, 2025 09:51
@am11
Copy link
Member Author

am11 commented Dec 28, 2025

Can we treat these as errors so that they do not come back? Are there more outside corelib?

Enabled rule and fixed existing sources.

[return: MarshalUsing(typeof(UniqueComInterfaceMarshaller<IErrorInfo>))]
IErrorInfo GetErrorInfo(
[PreserveSig]
System.Data.OleDb.OleDbHResult GetErrorInfo(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[In][Out] weren't enough for COM as it was issuing another warning, so I had to align its with other methods in this file; PreserveSig+outarg (it was an odd one out).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What warning were you seeing before switching this to PreserveSig?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looked different from the others:

error SYSLIB1092: The return value in the managed definition will be converted to an 'out' parameter when calling the unmanaged COM method. If the return value is intended to be the HRESULT code returned by the unmanaged COM method, use '[PreserveSig]' on the method. (https://learn.microsoft.com/dotnet/fundamentals/syslib-diagnostics/syslib1092)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that one should only fire on return types of "int" or "int"-sized enums...

We shouldn't be forcing everyone to use PreserveSig.

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

Labels

area-System.Runtime.InteropServices community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Info warnings noise produced by LibraryImport generator

3 participants