Expose specific members of System.[U]IntPtr from native integer types#43766
Expose specific members of System.[U]IntPtr from native integer types#43766cston merged 16 commits intodotnet:masterfrom
Conversation
|
@cston I think the title of the PR is confusing. It doesn't exclude members it includes them, but not all of them. Consider renaming the PR before people start commenting on it and adjusting PR's description to accurately reflect the nature of the changes. #Closed |
|
Also, if I remember correctly, a number of issues were raised on a previous PR that tried to expose members. Were they taken into consideration in this PR? #Closed |
I wanted the title to reflect the resulting behavior, that a few specific members are excluded, rather than the previous behavior where specific members were included. I agree it's not completely clear though. |
I believe that the previous behavior (before this PR) is that none of the members were included. What am I missing? #Closed |
Sorry, you are correct. I was thinking of virtual members defined on |
The previous PR was #41728. I've updated this PR based on that feedback, thanks. |
|
|
||
| return methodRef; | ||
| } | ||
| else if (methodSymbol is NativeIntegerMethodSymbol { UnderlyingMethod: MethodSymbol underlyingMethod }) |
There was a problem hiding this comment.
else if (methodSymbol is NativeIntegerMethodSymbol { UnderlyingMethod: MethodSymbol underlyingMethod }) [](start = 16, length = 103)
Please make sure we have a test for an expression lambda using the method, including the case when the method is generic. #Closed
There was a problem hiding this comment.
It feels like we might need to do something here for a constructed generic method. Please add a test like that. #Closed Refers to: src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs:1182 in 08c6617. [](commit_id = 08c6617, deletion_comment = False) |
| considerCallingConvention: false, //ignore static-ness | ||
| considerRefKindDifferences: false, | ||
| typeComparison: TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes | TypeCompareKind.IgnoreDynamic); | ||
| typeComparison: TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes | TypeCompareKind.IgnoreDynamic | TypeCompareKind.IgnoreNativeIntegers); |
There was a problem hiding this comment.
TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes | TypeCompareKind.IgnoreDynamic | TypeCompareKind.IgnoreNativeIntegers [](start = 28, length = 194)
TypeCompareKind.AllIgnoreOptions & ~TypeCompareKind.IgnoreTupleNames? #Closed
AllIgnoreComparer? #Closed Refers to: src/Compilers/CSharp/Portable/Symbols/MemberSignatureComparer.cs:146 in 08c6617. [](commit_id = 08c6617, deletion_comment = False) |
| considerCallingConvention: false, //ignore static-ness | ||
| considerRefKindDifferences: false, | ||
| typeComparison: TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes | TypeCompareKind.IgnoreDynamicAndTupleNames); | ||
| typeComparison: TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes | TypeCompareKind.IgnoreDynamicAndTupleNames | TypeCompareKind.IgnoreNativeIntegers); |
There was a problem hiding this comment.
TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes | TypeCompareKind.IgnoreDynamicAndTupleNames | TypeCompareKind.IgnoreNativeIntegers [](start = 28, length = 207)
TypeCompareKind.AllIgnoreOptions? It looks like other comparers could also use the same simplification. #Closed
The name of this comparer (and the next one) is somewhat misleading consider renaming. For example, this could be name IgnoreAllButTupleNamesComparer #Closed Refers to: src/Compilers/CSharp/Portable/Symbols/MemberSignatureComparer.cs:133 in 08c6617. [](commit_id = 08c6617, deletion_comment = False) |
I see that we do not expose generic methods at the moment, consider adding an assert here that In reply to: 622124666 [](ancestors = 622124666) Refers to: src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs:1182 in 08c6617. [](commit_id = 08c6617, deletion_comment = False) |
| } | ||
| } | ||
| break; | ||
| case MethodKind.ExplicitInterfaceImplementation: |
There was a problem hiding this comment.
MethodKind.ExplicitInterfaceImplementation [](start = 37, length = 42)
I do not think we can trust this completely. I.e. I think it is possible to have a different kind and still be explicit interface implementation. What exactly are we trying to accomplish here? Perhaps we should simply add everything that is MetadataVirtual, that would take care of all overrides and interface implementations. #Closed
It does not include In reply to: 622132199 [](ancestors = 622132199) Refers to: src/Compilers/CSharp/Portable/Symbols/MemberSignatureComparer.cs:146 in 08c6617. [](commit_id = 08c6617, deletion_comment = False) |
| { | ||
| var builder = ArrayBuilder<Symbol>.GetInstance(); | ||
| builder.Add(new SynthesizedInstanceConstructor(this)); | ||
| foreach (var underlyingMember in underlyingMembers) |
There was a problem hiding this comment.
foreach (var underlyingMember in underlyingMembers) [](start = 16, length = 51)
Are we interested in cloning static members? #Closed
There was a problem hiding this comment.
When we use TypeCompareKind.IgnoreNullableModifiersForReferenceTypes, presence or absence of TypeCompareKind.ObliviousNullableModifierMatchesAny makes no difference and we should include it anyway for completeness. In reply to: 622145910 [](ancestors = 622145910,622132199) Refers to: src/Compilers/CSharp/Portable/Symbols/MemberSignatureComparer.cs:146 in 08c6617. [](commit_id = 08c6617, deletion_comment = False) |
| { | ||
| var builder = ArrayBuilder<Symbol>.GetInstance(); | ||
| builder.Add(new SynthesizedInstanceConstructor(this)); | ||
| foreach (var underlyingMember in underlyingMembers) |
There was a problem hiding this comment.
foreach (var underlyingMember in underlyingMembers) [](start = 16, length = 51)
Are we interested in cloning members inaccessible outside the type? #Closed
| internal sealed override NamedTypeSymbol NativeIntegerUnderlyingType => _underlyingType; | ||
|
|
||
| internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison, IReadOnlyDictionary<TypeParameterSymbol, bool>? isValueTypeOverrideOpt = null) => _underlyingType.Equals(t2, comparison, isValueTypeOverrideOpt); | ||
| internal override bool Equals(TypeSymbol? other, TypeCompareKind comparison, IReadOnlyDictionary<TypeParameterSymbol, bool>? isValueTypeOverrideOpt = null) |
There was a problem hiding this comment.
Equals [](start = 31, length = 6)
I would expect us to also override equality for error types representing native/regular ints. #Closed
Do we have a symbol comparer that compares In reply to: 623747048 [](ancestors = 623747048) Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs:618 in cb1ed0e. [](commit_id = cb1ed0e, deletion_comment = False) |
These are going to be private and will be filtered out. It is not clear how exactly we are testing Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs:2160 in cb1ed0e. [](commit_id = cb1ed0e, deletion_comment = False) |
I am not sure how should I interpret closing the thread "By Design" with a question. If there is question, should the thread be kept active?
Would In reply to: 623749896 [](ancestors = 623749896,623747048) Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs:618 in cb1ed0e. [](commit_id = cb1ed0e, deletion_comment = False) |
|
Done with review pass (iteration 13) #Closed |
We should ignore accessors for properties that are ignored. In reply to: 623744738 [](ancestors = 623744738) Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs:400 in cb1ed0e. [](commit_id = cb1ed0e, deletion_comment = False) |
The comparer wasn't used after all. In reply to: 623753405 [](ancestors = 623753405,623749896,623747048) Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs:618 in cb1ed0e. [](commit_id = cb1ed0e, deletion_comment = False) |
This thread is marked as resolved without any response or obviously related code change. Could you please elaborate? In reply to: 623748417 [](ancestors = 623748417) Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs:1470 in cb1ed0e. [](commit_id = cb1ed0e, deletion_comment = False) |
Are we actually testing what the original comment "ExplicitImplementations properties are empty on native integer types." used to imply? Methods and properties with ExplicitImplementations do not have to be private. #Closed Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs:2110 in cb1ed0e. [](commit_id = cb1ed0e, deletion_comment = False) |
Line 537 checks In reply to: 624149990 [](ancestors = 624149990) Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs:2110 in cb7b6ac. [](commit_id = cb7b6ac, deletion_comment = False) |
But do we test a scenario where the original method/property that we clone has non empty ExplicitImplementations? In reply to: 624151322 [](ancestors = 624151322,624149990) Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/NativeIntegerTests.cs:2110 in cb1ed0e. [](commit_id = cb1ed0e, deletion_comment = False) |
|
Done with review pass (iteration 15) #Closed |
* upstream/master: (495 commits) Simplify PEPropertySymbol constructor (dotnet#43990) Remove duplicate calls to ThrowIfCancellationRequested Allow msbuild to pass properties and metadata as analyzerconfig: (dotnet#43617) Use a private exception type for error types encountered instead of ArgumentException. Remove unnecessary check Code review feedback Adding tests and expanding side effect cases Expose specific members of System.[U]IntPtr from native integer types (dotnet#43766) Remove trailing space from BoundDecisionDagNode Don't cache FileInfo instances. Add 16.7 Preview 1 to the publish data config Bump prerelease version for 16.7 preview 2 Only run code style analyzers when nullable warnings are enabled Remove Code review feedback Lint Undo Fix regression in global:: qualified constant in a switch case. Fixes dotnet#43960 Undo Simplify ...
Only exclude a few specific members from the underlying types from native integer types. (Previously, only a few specific members were included.) Include all interfaces implemented by the underlying types.
Fixes #42453
Fixes #42957
Fixes #43657
Test plan #38821