Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CA1060 - Move P/Invokes to NativeMethods class #1338

Open
pomianowski opened this issue Feb 4, 2025 · 2 comments
Open

Remove CA1060 - Move P/Invokes to NativeMethods class #1338

pomianowski opened this issue Feb 4, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@pomianowski
Copy link
Member

Describe the bug

Native invocations should be moved to different class https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1060

To Reproduce

Open the Wpf.Ui.sln
Select the Build...Clean Solution menu item
Press Ctrl+F5 to build the solution and run it, without connecting the debugger. F5 to build and connect the debugger.
Observe the warnings listed above

Expected behavior

No warnings are generated when building.

Screenshots

No response

OS version

11 2610

.NET version

9.0.200-preview.0.25057.12

WPF-UI NuGet version

4.0.0

Additional context

No response

@pomianowski pomianowski added the bug Something isn't working label Feb 4, 2025
@JohnTasler
Copy link
Collaborator

Some or many of these interop methods are not even used. Also, some duplicate system-provided interop, such as all three of the ones defined in Kernel32:
Kernel32.GetLastError -> System.Runtime.InteropServices.Marshal.GetLastSystemError
Kernel32.SetLastError -> System.Runtime.InteropServices.Marshal.SetLastSystemError
IsDebuggerPresent -> System.Diagnostics.Debugger.IsAttached and/or System.Diagnostics.Debugger.IsLogging
Also, the latter 2 have no references, and the former most has only 3 references, all from within comments of User32

I get that perhaps this is meant as just a "placeholder" class for possible future interop methods.

@chucker
Copy link
Collaborator

chucker commented Feb 6, 2025

Consider migrating to https://github.com/microsoft/CsWin32 so you don’t have to write the native method headers yourself at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants