-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Improve DisplayNameHelpers for NativeAOT #70084
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,10 +2,11 @@ | |
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Reflection.Metadata; | ||
| using System.Text; | ||
|
|
||
| using Internal.TypeSystem; | ||
|
|
||
| using Internal.TypeSystem.Ecma; | ||
| using Debug = System.Diagnostics.Debug; | ||
|
|
||
| namespace ILCompiler | ||
|
|
@@ -38,6 +39,12 @@ public static string GetDisplayName(this MethodDesc method) | |
| { | ||
| sb.Append(method.OwningType.GetDisplayNameWithoutNamespace()); | ||
| } | ||
| else if (method.GetPropertyForAccessor() is PropertyPseudoDesc property) | ||
| { | ||
| sb.Append(property.Name); | ||
| sb.Append('.'); | ||
| sb.Append(property.GetMethod.Name == method.Name ? "get" : "set"); | ||
|
||
| } | ||
| else | ||
| { | ||
| sb.Append(method.Name); | ||
|
|
@@ -68,6 +75,20 @@ public static string GetDisplayName(this MethodDesc method) | |
| return sb.ToString(); | ||
| } | ||
|
|
||
| public static string GetParameterDisplayName(this EcmaMethod method, int parameterIndex) | ||
| { | ||
| var reader = method.MetadataReader; | ||
| var methodDefinition = reader.GetMethodDefinition(method.Handle); | ||
| foreach (var parameterHandle in methodDefinition.GetParameters()) | ||
| { | ||
| var parameter = reader.GetParameter(parameterHandle); | ||
| if (parameter.SequenceNumber == parameterIndex + 1) | ||
| return reader.GetString(parameter.Name); | ||
| } | ||
|
|
||
| return $"#{parameterIndex}"; | ||
| } | ||
|
|
||
| public static string GetDisplayName(this FieldDesc field) | ||
| { | ||
| return new StringBuilder(field.OwningType.GetDisplayName()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: we tend to split
using Foo = ...from the regular usings with a newline.