Skip to content

Conversation

@elinor-fung
Copy link
Member

  • Reuse existing p/invokes and structs from Common directory
  • Convert DllImport to GeneratedDllImport

I didn't try to move all the existing p/invokes into Common - that can be done separately. I wanted to get through the switch to GeneratedDllImport first.

@AaronRobinsonMSFT @jkoritzinsky

@elinor-fung elinor-fung force-pushed the convertSystemDirectoryServices branch from ace3523 to 8b3815e Compare November 23, 2021 17:36
public int wki100_ver_minor;
};

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
Copy link
Member

Choose a reason for hiding this comment

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

Is the CharSet needed here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope.

using System.Text;
using System.Diagnostics.CodeAnalysis;

using Kernel32 = Interop.Kernel32;
Copy link
Member

Choose a reason for hiding this comment

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

We generally don't do this elsewhere. Can we just spell out Interop.Kernel32 at each use site?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did it because there is also System.DirectoryServices.Interop and having global::Interop.* everywhere looked obnoxious to me. I can do global::Interop.* at each use site if that is preferred.

using Microsoft.Win32.SafeHandles;

using Advapi32 = Interop.Advapi32;
using Kernel32 = Interop.Kernel32;
Copy link
Member

Choose a reason for hiding this comment

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

Ditto for all of these.

[DllImport(global::Interop.Libraries.Kernel32, EntryPoint = "GetVersionExW", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool GetVersionEx(
[In, Out] OSVersionInfoEx ver);
[GeneratedDllImport(global::Interop.Libraries.Dnsapi, CharSet = CharSet.Unicode)]
Copy link
Member

Choose a reason for hiding this comment

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

Why is the global:: needed on all of these?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I had wondered the same thing - there's a System.DirectoryServices.Interop, so these all had the global::

internal static partial uint LsaCallAuthenticationPackage(
LsaLogonProcessSafeHandle lsaHandle,
int authenticationPackage,
in NegotiateCallerNameRequest protocolSubmitBuffer,
Copy link
Member

Choose a reason for hiding this comment

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

How are we choosing when to use 'in' and when to use 'ref'? There was another recent PR where this was discussed and IIRC that one stayed ref even though it was previously similarly '[In]'.

Copy link
Member Author

@elinor-fung elinor-fung Nov 23, 2021

Choose a reason for hiding this comment

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

It has been somewhat opportunistic on our end as a 'could be nice to do' thing where we change it if we notice it would make sense to be in instead of ref (in a recent PR, when @jkoritzinsky pointed it out, I did switch the ref to in).

Copy link
Member

@jkoritzinsky jkoritzinsky left a comment

Choose a reason for hiding this comment

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

LGTM once @stephentoub's feedback is resolved.

@elinor-fung elinor-fung merged commit a61c1a3 into dotnet:main Dec 2, 2021
@elinor-fung elinor-fung deleted the convertSystemDirectoryServices branch December 2, 2021 05:52
@ghost ghost locked as resolved and limited conversation to collaborators Jan 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants