Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@buyaa-n
Copy link

@buyaa-n buyaa-n commented Mar 27, 2019

No description provided.

@safern safern force-pushed the NullableFeature branch 3 times, most recently from c01bfd0 to 652234c Compare March 28, 2019 05:35
@buyaa-n buyaa-n force-pushed the nullable_for_type_class branch from d7a3ba4 to 15ac27f Compare March 28, 2019 18:56
@buyaa-n buyaa-n requested a review from tannergooding March 28, 2019 21:00
Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

Thanks for the initial work on this. I think there are a fair number of mistakes in the APIs, though, as derived types weren't factored in. Please add to this PR the other derivations of Type that are in corelib, and then the whole thing can be re-reviewed. Otherwise the annotation of Type isn't accurate.

@buyaa-n
Copy link
Author

buyaa-n commented Mar 29, 2019

@stephentoub should it cover immediate descendants or all derived type? I guess preferably all descendants but isn't it will become too big PR in that case?

@stephentoub
Copy link
Member

I guess preferably all descendants but isn't it will become too big PR in that case?

Ideally "all". Even if it ends up being bigger, it'll help us to be more efficient in the long run, because we won't need to keep revisiting the types. It'll also be easier to review when all related types are done together. And will help to validate the correctness of the changes being reviewed.

@buyaa-n buyaa-n force-pushed the nullable_for_type_class branch 2 times, most recently from 158c834 to f93f7be Compare April 1, 2019 21:32
@terrajobst terrajobst requested a review from a team April 2, 2019 00:30

private byte[] _IL = null!;
private ExceptionHandlingClause[] _exceptionHandlingClauses = null!;
private LocalVariableInfo[] _localVariables = null!;
Copy link
Author

Choose a reason for hiding this comment

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

The instance of this class only created using native call

FCIMPL2(RuntimeMethodBody *, RuntimeMethodHandle::GetMethodBody, ReflectMethodObject *pMethodUNSAFE, ReflectClassBaseObject *pDeclaringTypeUNSAFE)
where these values looks like set non null and here it passed to non nullable method parameters. So kept them non nullable

// "isDesignTime" will be "false" and "key" will point to a non-null
// license key.
public object AllocateAndValidateLicense(Type type, string? key, bool isDesignTime)
public object? AllocateAndValidateLicense(Type type, string? key, bool isDesignTime)
Copy link
Member

Choose a reason for hiding this comment

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

? [](start = 21, length = 1)

Can this be null? I'm curious because of the method name; it makes it sound like only a valid license would be returned, and I'm assuming (maybe incorrectly) that null would be an invalid license.

It doesn't matter much for this method itself, as it's internal; I just wonder whether this nullable-ness is flowing out and impacting the annotations we're adding to callers that are exposed publicly.

Copy link
Author

@buyaa-n buyaa-n Apr 25, 2019

Choose a reason for hiding this comment

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

Can this be null? I'm curious because of the method name; it makes it sound like only a valid license would be returned, and I'm assuming (maybe incorrectly) that null would be an invalid license.

marked nullable as MethodBase.Invoke(...) method called on return has nullable return. You mean if validation failed it would throw instead of returning null? From try catch most likely that is true

It doesn't matter much for this method itself, as it's internal; I just wonder whether this nullable-ness is flowing out and impacting the annotations we're adding to callers that are exposed publicly.

Checked publicly exposed method of IClassFactory and IClassFactory2 interface

void CreateInstance(
            [MarshalAs(UnmanagedType.Interface)] object? pUnkOuter,
            ref Guid riid,
            [MarshalAs(UnmanagedType.Interface)] out object? ppvObject);

Seems paramete out object? ppvObject should be non nullable

Copy link
Member

Choose a reason for hiding this comment

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

marked nullable as MethodBase.Invoke(...) method called on return has nullable return

That's because any method with any return value might be returned. You'd need to examine the particular method being invoked.

You mean if validation failed it would throw instead of returning null?

Yes, that's my question. Maybe @AaronRobinsonMSFT knows.

Seems paramete out object? ppvObject should be non nullable

The docs state:

If the object does not support the interface specified in riid, the implementation must set *ppvObject to NULL.

so I believe nullable here is correct. But that doesn't mean that it might be null for every use of this method, just that some uses could result in null.

Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT Apr 25, 2019

Choose a reason for hiding this comment

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

You mean if validation failed it would throw instead of returning null?

Yes, that's my question. Maybe @AaronRobinsonMSFT knows.

None of these COM functions can return null during allocation. In this scenario an Exception will be marshalled as an error HRESULT since the function method is marked as returning void. This can be observed in the exception below that throws CLASS_E_NOTLICENSED which will result in an error HRESULT to the caller - which means by COM semantics that all out parameters are in an undefined state.

Copy link
Author

Choose a reason for hiding this comment

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

thank you, updated only this method to return non null

@stephentoub
Copy link
Member

            internal void Insert(ref T[] list, string name, MemberListType listType)

null is getting passed in here explicitly, with null!. Seems like instead this should be string?, since obviously this method needs to be able to handle null getting passed in, as we are.


Refers to: src/System.Private.CoreLib/src/System/RtType.cs:367 in 6f10090. [](commit_id = 6f10090, deletion_comment = False)


#region Private Members
private string ConstructName(ref string name, TypeNameFormatFlags formatFlags)
private string ConstructName(ref string? name, TypeNameFormatFlags formatFlags)
Copy link
Member

Choose a reason for hiding this comment

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

ref string? name [](start = 41, length = 16)

Please add // TODO-NULLABLE: [https://github.com/dotnet/roslyn/issues/26761](https://github.com/dotnet/roslyn/issues/26761`) here

Copy link
Author

Choose a reason for hiding this comment

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

added

@stephentoub
Copy link
Member

I did another spot-check pass through and left some comments. Let's get the remaining comments addressed, as well as the build passing, and then get this merged. Thanks!

@buyaa-n buyaa-n merged commit 89ba33c into dotnet:NullableFeature Apr 25, 2019
krwq pushed a commit that referenced this pull request Apr 26, 2019
System.Type, System.Reflection nullability
krwq pushed a commit that referenced this pull request Apr 27, 2019
System.Type, System.Reflection nullability
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request Apr 30, 2019
System.Type, System.Reflection nullability

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
krwq pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request May 1, 2019
System.Type, System.Reflection nullability

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
krwq pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request May 1, 2019
System.Type, System.Reflection nullability

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
safern pushed a commit to dotnet/corefx that referenced this pull request May 1, 2019
System.Type, System.Reflection nullability

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corert that referenced this pull request May 2, 2019
System.Type, System.Reflection nullability

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/mono that referenced this pull request May 2, 2019
System.Type, System.Reflection nullability

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corert that referenced this pull request May 2, 2019
System.Type, System.Reflection nullability

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/mono that referenced this pull request May 2, 2019
System.Type, System.Reflection nullability

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
marek-safar pushed a commit to mono/mono that referenced this pull request May 2, 2019
System.Type, System.Reflection nullability

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
jkotas pushed a commit to dotnet/corert that referenced this pull request May 3, 2019
System.Type, System.Reflection nullability

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
System.Type, System.Reflection nullability


Commit migrated from dotnet/coreclr@56f38ea
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.