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

Nullable annotate for Microsoft.Win32.Registry #2351

Merged

Conversation

manne
Copy link
Contributor

@manne manne commented Jan 29, 2020

Contributes to #2339

@eiriktsarpalis eiriktsarpalis added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Jan 29, 2020
@eiriktsarpalis
Copy link
Member

Please hold off from merging, Microsoft.Win32.Registry has a dependency on System.Security.Principal.Windows, whose nullable annotation is still WIP.

@eiriktsarpalis eiriktsarpalis removed the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Feb 3, 2020
@eiriktsarpalis
Copy link
Member

System.Security.Principal.Windows annotations have been merged to master, could you please rebase your branch on top of the latest master?

@manne manne force-pushed the feature/nullable_microsoft_win32_registry branch from 6f42d9d to 0bd572b Compare February 5, 2020 20:07
@manne
Copy link
Contributor Author

manne commented Feb 5, 2020

@eiriktsarpalis Have I done the correct thing?

@buyaa-n
Copy link
Contributor

buyaa-n commented Feb 6, 2020

@manne please update files for Linux / Mac versions too, if you are using VS change your project context to Linux/OSX respectively to see the files in VS

@eiriktsarpalis
Copy link
Member

There seem to be nullability related build errors on windows too. They might be related to the newly annotated dependencies.

@eiriktsarpalis
Copy link
Member

Hi @manne, and thank you for your contribution.

What is the status of this PR? As part of our ongoing annotation work we are looking to get this project done asap. Will you able to complete it soon? If not, would you mind if we took this over, either by creating a separate PR or pushing commits to your branch?

@manne
Copy link
Contributor Author

manne commented Feb 11, 2020

@eiriktsarpalis I am working on it right now

@manne manne force-pushed the feature/nullable_microsoft_win32_registry branch from 0bd572b to 2ac937d Compare February 11, 2020 19:30
@@ -83,22 +82,20 @@ private void FlushCore()
}
}

private unsafe RegistryKey CreateSubKeyInternalCore(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions)
private unsafe RegistryKey? CreateSubKeyInternalCore(string subkey, RegistryKeyPermissionCheck permissionCheck, RegistryOptions registryOptions)
Copy link
Member

Choose a reason for hiding this comment

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

Looks like the return type is annotated as nullable on account of the code path on line 121. But it seems clear by the assertion above that this is not expected to happen unless there is a bug. I think non-nullability should be asserted.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point, if this not return null then all public RegistryKey CreateSubKey(...) overloads not return null

{
int type = 0;
int datasize = 0;
int ret = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, (byte[])null, ref datasize);
int ret = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, (byte[])null!, ref datasize);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
int ret = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, (byte[])null!, ref datasize);
int ret = Interop.Advapi32.RegQueryValueEx(_hkey, name, null, ref type, (byte[]?)null, ref datasize);

public Microsoft.Win32.RegistryKey? CreateSubKey(string subkey, Microsoft.Win32.RegistryKeyPermissionCheck permissionCheck, Microsoft.Win32.RegistryOptions registryOptions, System.Security.AccessControl.RegistrySecurity? registrySecurity) { throw null; }
public Microsoft.Win32.RegistryKey? CreateSubKey(string subkey, Microsoft.Win32.RegistryKeyPermissionCheck permissionCheck, System.Security.AccessControl.RegistrySecurity? registrySecurity) { throw null; }
public Microsoft.Win32.RegistryKey? CreateSubKey(string subkey, bool writable) { throw null; }
public Microsoft.Win32.RegistryKey? CreateSubKey(string subkey, bool writable, Microsoft.Win32.RegistryOptions options) { throw null; }
Copy link
Contributor

Choose a reason for hiding this comment

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

As per @eiriktsarpalis's comment https://github.com/dotnet/runtime/pull/2351/files#r378221011 all this CreateSubKey(...) overloads not return null

Copy link
Contributor

@buyaa-n buyaa-n left a comment

Choose a reason for hiding this comment

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

Except @eiriktsarpalis's comment and updates related to that change overall looks great, thank you @manne

@eiriktsarpalis
Copy link
Member

LGTM. If you could just fix the merge conflicts we should be ready to merge your changes.

Thank you!

@eiriktsarpalis eiriktsarpalis merged commit 446c224 into dotnet:master Feb 18, 2020
@manne
Copy link
Contributor Author

manne commented Feb 18, 2020

Thx

@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
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.

6 participants