## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• Jun 09 20:13
AArnott labeled #580
• Jun 09 09:07
vyuzhanin opened #580
• May 31 14:16
AArnott labeled #579
• May 31 10:25
michael-damatov opened #579
• May 29 04:10
AArnott commented #565
• May 29 03:26
lostmsu commented #565
• May 29 03:26
lostmsu commented #565
• May 29 03:25
lostmsu commented #565
• May 29 03:25
lostmsu commented #565
• May 29 03:24
lostmsu commented #565
• May 29 03:23
lostmsu commented #565
• May 21 04:56
AArnott commented #578
• May 20 21:44
joffarex commented #578
• May 20 19:34
AArnott commented #578
• May 19 20:57
joffarex commented #578
• May 19 20:48
joffarex edited #578
• May 19 20:46
joffarex opened #578
• Apr 20 11:05
Fungusware commented #577
• Apr 20 11:04
Fungusware closed #577
• Apr 20 11:04
Fungusware edited #577
Andrew Arnott
@AArnott
Thanks. Finding it in the .h files themselves is good justification as well. There are sometimes .h constants defined that aren't documented online.
We can always add an enum value later. And in the meantime, someone could cast the enum to an int and check for -1 to get unblocked if it really does work.
yep
Shimmy
@weitzhandler

Hi,
I'm unable to load the projects in VS 2019.
I'm getting this error in the Solution output:

The expression "[System.IO.Path]::GetDirectoryName('')" cannot be evaluated. The path is not of a legal form. C:\Users\Shimmy.nuget\packages\msbuild.sdk.extras\2.0.54\Sdk\Sdk.props
Thank you!

What I wanna contribute is User32.EnumDisplaySettings, and maybe another few.
Shimmy
@weitzhandler
Please mention me with @ if/when you reply, so I get an email notification. Thanks.
Andrew Arnott
@AArnott
@weitzhandler Have you run the init script at the root of the repo? The easiest way to work is run init -installlocality machine from an elevated prompt.
Shimmy
@weitzhandler
Shimmy
@weitzhandler
Please update this to include information on how to trigger the analyzers to generate the shipped/unshipped stuff
Shimmy
@weitzhandler
When pressing Ctrl+period over the relevant items in code issuing the RS0016 warnings, I see no offer to apply auto-fix
Andrew Arnott
@AArnott
I'll look into that Ctrl+period not working. Thanks for reporting, @weitzhandler .
@weitzhandler: update complete: dotnet/pinvoke@b8977c1
Shimmy
@weitzhandler
You're awesome, thank you!
Shimmy
@weitzhandler
Where do structures from wingdi.h go? It's mainly used in User32, should I add them to this project?
In fact, the DISPLAY_DEVICE structure also belongs there. It's used by the EnumDisplayDevice function that was merged. I can move these structures to Gdi32, but we'll have to add a project dependency.
Shimmy
@weitzhandler
I see that Gdi32 rather depends on User32, so I'll keep them all in User32
Shimmy
@weitzhandler
From what I gather, the only dependency of Gdi32 on User32 is the SafeDCHandle. Isn't it something common that should be abstracted out to a lower level shared project?
Because really looking at the Windows API it seems User32 depends on Gdi32, not the other way around.
Another option would be including these interfaces in the Windows.Core lib?
Andrew Arnott
@AArnott
@weitzhandler Ya, these issues are little cumbersome to deal with in .NET assemblies. SafeDCHandle is defined in User32 because ReleaseDC is defined there.
I would tend to define structures from wingdi.h in Gdi32, and only move them into the User32 assembly if User32 needs access to these types.
Perhaps where there are structures that might get moved 'up' toward Windows.Core we should define them as top-level types in the PInvoke namespace instead of as a nested type. That would make 'promoting' them later much easier.
Shimmy
@weitzhandler
So where do you want me to create those interfaces (i.e. DEVMODE), in Windows? Or Gdi32 (which in case I'm gonna have to move the SafeDCHandle over, because currently Gdi32 references User32, not the other way around 🤔
Shimmy
@weitzhandler
Ok, I'm gonna start by adding them to the Windows.Core lib.

How do you deal with fns that have moved around from one apiset dll to another. For e.g., kernel32!FlushProcessWriteBuffers:

When I looked at the exports, l1-1-0 had the export, but l1-1-2, l1-1-1 did not have the export (this was on recent Windows Insider Dev Branch build; so I guess the exports aren't preserved out of compat consideration etc.).

Andrew Arnott
@AArnott
@vatsan-madhavan I haven't noticed that they move around API sets like that, but I'd say let's keep them in the oldest location for Win8 apps so that they work everywhere, since I must assume Microsoft wouldn't release breaking changes.
:thumbsup:
Shimmy
@weitzhandler

Hi,
I don't know what I screwed up, but I'm unable to open any projects in VS2019.
I get the following error when running Init:

❯ .\init -installlocality machine
The netcore Credential Provider is already in C:\Users\Shimmy.nuget\plugins
Installing .NET Core SDK 3.1.100...
Installing .NET Core 2.1...
Installing .NET Core 2.1...
Restoring NuGet packages
D:\Users\Shimmy\Source\Repos\weitzhandler\pinvoke\src\BCrypt\BCrypt.csproj : warning MSB4242: The SDK resolver "NuGetSdkResolver" failed to run. Unable to find fallback package folder 'C:\Microsoft\Xamarin\NuGet\'.
Write-Error: Failure while restoring packages.

Any ideas?

This helped. Just had to create a dummy folder at that location
Shimmy
@weitzhandler
@AArnott
I started working on the DEVMODE structure (in Windows.Core).
Can you please have a look and tell me if I'm headed the right direction. Here's what I wrote.
I guess it'll all be chopped up into small files with DEVMODE_ prefixes (or you tell me how), but please compare my code to the actual DEVMODE.
I'll also format the enum comments etc. and make it look nice after I get some comments from you if this is how you'd want it to be.
Thank you!
Andrew Arnott
@AArnott
@weitzhandler Thanks for working on DEVMODE. Union structs are tricky. You'll need to use an Explicit layout in order for .NET to actually overlap fields over the same memory the way union structs do in native code.
Also, while I appreciate the extra structure you gave it (nested structs), it's beyond the original API and we generally aren't trying to improve on the original header file APIs. The precedent in this repo is that union structs simply contain every field as a flat list, exposing the overlapping members the same way the .h file does.
Shimmy
@weitzhandler
@AArnott The problem with these unions is that they contain identical fields, such as dmPosition.
Andrew Arnott
@AArnott
Those identical fields are placed in the same memory location though, I suspect. I checked and it's at least true for dmPosition. In C, there can't really be multiple identical fields because there would be no way to distinguish them. So while a single field may appear in multiple options in a union, it must be placed at exactly the same location so that it doesn't matter which one the user is thinking of when they access it.
Shimmy
@weitzhandler
Andrew Arnott
@AArnott
Done. See the PR for my comments.
Thought I'd leave a note that I'm still working on part-3 of #491 but haven't made much progress recently. I expect to get back to it slowly as my day-job lets up a bit :-).
Andrew Arnott
@AArnott
Sounds good, @vatsan-madhavan. Thanks for contributing.
I just submitted a significant enhancement to code-gen. We now have Span<T> and ReadOnlySpan<T> friendly overloads where any native pointer was that represented an array. The friendly overload even removes the "length" parameter as it takes it from the span.
Next up: #286 for string-friendly overloads. We almost don't need these with the span overloads already there, since .NET Core implicitly converts string to ReadOnlySpan<char>, but on .NET Framework it's still something of a mild pain.
Cristian Giagante
@cristiangiagante
hello everybody
Andrew Arnott
@AArnott
Hi @cristiangiagante
Zavarkó Gábor
@zgabi
Hi,
The code fix for RS0016 is not offered by my VS. Do you have any idea why? I selected net45 as it is in the documentation.. I have the latest VS 2019.
(I changed it to errors, but it was the same when it was only a warning)
Andrew Arnott
@AArnott
@zgabi sorry, I don't know what would cause that. That is pretty debilitating though, since adding the APIs to publicapi.txt is far too tedious without it. I guess go ahead and send the PR without it and I'll push a commit to your PR that adds it.
Zavarkó Gábor
@zgabi
Thanks. I created a PR
However I'm not sure how to name the files... There is a WindowsStyles enum, and each control types has extra values in this enum... I created new enums for each control type... another solution would be to add the values to the "base" WindowStyles enum, but in that case everything would be in the same file, which is not a good idea... there is no enum inheritance in C# :( Please check it out, and I'll rename the files or refactor it if you have better idea
@zgabi , There are two places in Visual Studio where net45 can be selected and only one of those works. When I come back to dotnet/pinvoke development after a break I sometimes get confused between the two and experience this problem - then belatedly remember that I should be selecting net45 at another spot ;-) Please see my screenshot.
Andrew Arnott
@AArnott