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

Consider NativeIntegerAttribute in CopyTypeCustomModifiers() #47536

Merged
merged 5 commits into from
Sep 17, 2020

Conversation

cston
Copy link
Member

@cston cston commented Sep 8, 2020

Fixes #42500.
Fixes #44358.

@cston cston requested a review from a team as a code owner September 8, 2020 22:05
@cston cston added this to the 16.8 milestone Sep 8, 2020
return _transformFlags[_index++] ? type.AsNativeInteger() : type;
return _transformFlags[_index++] ?
type.AsNativeInteger() :
(type.NativeIntegerUnderlyingType ?? type);
Copy link
Member

@jcouv jcouv Sep 8, 2020

Choose a reason for hiding this comment

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

Is it correct that this change is so that we can handle all four cases: type is nint or IntPtr, and transform flag is set or not?
If so, I don't understand why we would get a nint type. I would expect only IntPtr here. #Closed

Copy link
Member Author

@cston cston Sep 8, 2020

Choose a reason for hiding this comment

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

Yes, all four cases are possible from CopyTypeCustomModifiers(). Updated.


In reply to: 485230638 [](ancestors = 485230638)

TypeSymbol typeWithDynamic = DynamicTypeDecoder.TransformTypeWithoutCustomModifierFlags(sourceType, containingAssembly, refKind, flags);
TypeSymbol resultType = DynamicTypeDecoder.TransformTypeWithoutCustomModifierFlags(sourceType, containingAssembly, refKind, flags);

var builder = ArrayBuilder<bool>.GetInstance();
Copy link
Member

@jcouv jcouv Sep 8, 2020

Choose a reason for hiding this comment

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

nit: consider adding an overload of NativeIntegerTransformsEncoder.Encode that returns flags as an immutable array (similarly to dynamic and tuple decoders) #Closed

Copy link
Member Author

Choose a reason for hiding this comment

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

This would be the only use of that overload. Let's add later if there are other uses.


In reply to: 485231913 [](ancestors = 485231913)

{
public override void F1(System.IntPtr i) { }
public override void F2(nint i) { }
}";
Copy link
Member

@jcouv jcouv Sep 8, 2020

Choose a reason for hiding this comment

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

Could we complete the four permutations : base has modified IntPtr vs. nint, and override has unmodified IntPt vs. nint?
Could we also add one nested case? #Closed

Copy link
Member Author

Choose a reason for hiding this comment

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

Added all four permutations. Nested cases are covered in the preceding test.


In reply to: 485234664 [](ancestors = 485234664)

Copy link
Member

Choose a reason for hiding this comment

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

The problem with the preceding case is it doesn't have modifiers to copy. Are we even entering the CopyTypeCustomModifiers method?


In reply to: 485239131 [](ancestors = 485239131,485234664)

Copy link
Member Author

Choose a reason for hiding this comment

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

CopyTypeCustomModifiers() is called for overrides and explicit implementations, even without custom modifiers. I've changed the last test here to cover nested cases as well.


In reply to: 485242939 [](ancestors = 485242939,485239131,485234664)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks


In reply to: 485245803 [](ancestors = 485245803,485242939,485239131,485234664)

@jcouv jcouv self-assigned this Sep 8, 2020
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

Done with review pass (iteration 2)

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

LGTM Thanks (iteration 2) with a test question remaining

@cston cston requested a review from a team September 10, 2020 16:30
@cston
Copy link
Member Author

cston commented Sep 12, 2020

@dotnet/roslyn-compiler, please review, thanks.

@RikkiGibson RikkiGibson self-requested a review September 12, 2020 00:14
@cston cston requested review from a team and removed request for a team September 15, 2020 19:09
@RikkiGibson RikkiGibson assigned RikkiGibson and jcouv and unassigned jcouv Sep 17, 2020
@@ -74,18 +74,17 @@ internal static TypeSymbol CopyTypeCustomModifiers(TypeSymbol sourceType, TypeSy
// code gen uses and then passing them to the dynamic type decoder that metadata reading uses.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Consider revising the <param name="destinationType"> comment on line 63 to delete its last sentence "May differ in object/dynamic.", since there are several other scenarios that this method handles, possibly more in the future, and we don't want to give an impression that object/dynamic is all that we're handling here.

Copy link
Member Author

@cston cston Sep 17, 2020

Choose a reason for hiding this comment

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

Updated comments in #47576.


In reply to: 490547894 [](ancestors = 490547894)

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (iteration 5)

@cston cston merged commit 60dc82d into dotnet:master Sep 17, 2020
@ghost ghost modified the milestones: 16.8, Next Sep 17, 2020
@cston cston deleted the 42500 branch September 17, 2020 20:51
@dibarbet dibarbet removed this from the Next milestone Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants