-
Notifications
You must be signed in to change notification settings - Fork 571
[TrimmableTypeMap] Fix inherited generic base typemap refs #11749
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
Open
simonrozsival
wants to merge
8
commits into
dotnet:main
Choose a base branch
from
simonrozsival:android-fix-trimmable-typemap-constructed-generic-base-codegen
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+740
−139
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
96c3692
Fix inherited generic base typemap refs
simonrozsival 098bbda
Address inherited generic typemap review feedback
simonrozsival db2255c
Add structured generic export dispatch regression
simonrozsival 859b099
Keep AssemblyInput for trimmable typemap generator
simonrozsival a57b4ee
Fix trimmable typemap build errors
simonrozsival dee6f8c
Fix generic base typemap callback matching
simonrozsival 7e39b8e
Address generic typemap review feedback
simonrozsival 6ef53aa
Compare typemap override signatures structurally
simonrozsival File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| using System.Reflection.PortableExecutable; | ||
|
|
||
| namespace Microsoft.Android.Sdk.TrimmableTypeMap; | ||
|
|
||
| public readonly record struct AssemblyInput (string Name, string Path, PEReader Reader); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
|
|
||
| namespace Microsoft.Android.Sdk.TrimmableTypeMap; | ||
|
|
||
|
|
@@ -186,11 +187,75 @@ sealed record TypeRefData | |
| public required string AssemblyName { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// True if this type — or, for array types, the element type — is an enum. | ||
| /// Generic arguments for a constructed generic type. Empty for non-generic | ||
| /// types and open generic definitions. | ||
| /// </summary> | ||
| public IReadOnlyList<TypeRefData> GenericArguments { get; init; } = []; | ||
|
|
||
| /// <summary> | ||
| /// True if this type — or, for array types, the element type — is a value type. | ||
| /// Used by the IL emitter to encode the type as <c>ELEMENT_TYPE_VALUETYPE</c> | ||
| /// rather than <c>ELEMENT_TYPE_CLASS</c> in member references and signatures. | ||
| /// </summary> | ||
| public bool IsValueType { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// True if this type — or, for array types, the element type — is an enum. | ||
| /// Used by JNI signature generation to map enum values to their underlying | ||
| /// primitive ABI type. | ||
| /// </summary> | ||
| public bool IsEnum { get; init; } | ||
|
|
||
| public bool EncodeAsValueType => IsValueType || IsEnum; | ||
|
|
||
| public string DisplayName { | ||
| get { | ||
| if (ManagedTypeName.EndsWith ("[]", StringComparison.Ordinal)) { | ||
| return $"{(this with { ManagedTypeName = ManagedTypeName.Substring (0, ManagedTypeName.Length - 2) }).DisplayName}[]"; | ||
| } | ||
| return GenericArguments.Count == 0 | ||
| ? ManagedTypeName | ||
| : $"{ManagedTypeName}<{string.Join (",", GenericArguments.Select (t => t.DisplayName))}>"; | ||
| } | ||
| } | ||
|
|
||
| public bool Equals (TypeRefData? other) | ||
| { | ||
| if (ReferenceEquals (this, other)) { | ||
| return true; | ||
| } | ||
| if (other is null) { | ||
| return false; | ||
| } | ||
| if (!string.Equals (ManagedTypeName, other.ManagedTypeName, StringComparison.Ordinal) || | ||
| !string.Equals (AssemblyName, other.AssemblyName, StringComparison.Ordinal) || | ||
| IsValueType != other.IsValueType || | ||
| IsEnum != other.IsEnum || | ||
| GenericArguments.Count != other.GenericArguments.Count) { | ||
| return false; | ||
| } | ||
| for (int i = 0; i < GenericArguments.Count; i++) { | ||
| if (!GenericArguments [i].Equals (other.GenericArguments [i])) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| public override int GetHashCode () | ||
| { | ||
| unchecked { | ||
| int hash = 17; | ||
| hash = hash * 31 + StringComparer.Ordinal.GetHashCode (ManagedTypeName); | ||
| hash = hash * 31 + StringComparer.Ordinal.GetHashCode (AssemblyName); | ||
| hash = hash * 31 + IsValueType.GetHashCode (); | ||
| hash = hash * 31 + IsEnum.GetHashCode (); | ||
| foreach (var argument in GenericArguments) { | ||
| hash = hash * 31 + argument.GetHashCode (); | ||
| } | ||
| return hash; | ||
| } | ||
| } | ||
|
Comment on lines
+245
to
+258
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a blocker, but supposedly we can do: Then use |
||
| } | ||
|
|
||
| /// <summary> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.