mirror of
https://github.com/icsharpcode/ILSpy.git
synced 2026-10-12 02:15:58 +00:00
Apply suggestions from Claude code review
This commit is contained in:
@@ -90,12 +90,14 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
|
||||
Point point = new Point(3, 4);
|
||||
Console.WriteLine(point.X);
|
||||
Console.WriteLine(point.Y);
|
||||
// TODO implement use-site transformation
|
||||
//Console.WriteLine(point.Magnitude);
|
||||
}
|
||||
|
||||
public static void TestExtensionMethods()
|
||||
{
|
||||
List<string> collection = new List<string>();
|
||||
// TODO implement use-site transformation
|
||||
//Console.WriteLine(collection.IsEmpty);
|
||||
collection.AddIfNotNull("Hello");
|
||||
collection.AddIfNotNull(null);
|
||||
|
||||
@@ -955,8 +955,12 @@ namespace ICSharpCode.Decompiler.CSharp
|
||||
foreach (var h in methods)
|
||||
{
|
||||
var m = metadata.GetMethodDefinition(h);
|
||||
if (metadata.StringComparer.Equals(m.Name, name))
|
||||
return h;
|
||||
if (!metadata.StringComparer.Equals(m.Name, name))
|
||||
continue;
|
||||
|
||||
// TODO : use SignatureBlobComparer to ensure that the correct method is resolved
|
||||
|
||||
return h;
|
||||
}
|
||||
return default;
|
||||
}
|
||||
|
||||
@@ -260,9 +260,11 @@ namespace ICSharpCode.Decompiler.TypeSystem
|
||||
IEnumerable<IMember> GetMembers()
|
||||
{
|
||||
var markerType = marker.DeclaringTypeDefinition;
|
||||
Debug.Assert(markerType != null, "Marker should always be contained in a type");
|
||||
|
||||
foreach (var info in extensionMemberMap.Values)
|
||||
{
|
||||
if (!markerType!.Equals(info.ExtensionMarkerType))
|
||||
if (!markerType.Equals(info.ExtensionMarkerType))
|
||||
continue;
|
||||
var subst = new TypeParameterSubstitution(info.ExtensionGroupingTypeParameters, null);
|
||||
if (info.ExtensionMember.IsAccessor)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
@@ -878,7 +879,8 @@ namespace ICSharpCode.Decompiler.TypeSystem
|
||||
{
|
||||
throw new ArgumentNullException(nameof(member));
|
||||
}
|
||||
var td = member.DeclaringTypeDefinition!;
|
||||
var td = member.DeclaringTypeDefinition;
|
||||
Debug.Assert(td != null, "IMember.DeclaringTypeDefinition should never be null");
|
||||
return td.DeclaringTypeDefinition?.ExtensionInfo ?? td.DeclaringTypeDefinition?.DeclaringTypeDefinition?.ExtensionInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,19 +61,20 @@ namespace ICSharpCode.ILSpy.TreeNodes
|
||||
return ((MetadataModule)ParentAssemblyNode.LoadedAssembly
|
||||
.GetMetadataFileOrNull()
|
||||
?.GetTypeSystemWithCurrentOptionsOrNull(SettingsService, AssemblyTreeModel.CurrentLanguageVersion)
|
||||
?.MainModule)?.GetDefinition((SRM.TypeDefinitionHandle)MarkerMethod.DeclaringTypeDefinition.MetadataToken);
|
||||
?.MainModule)?.GetDefinition((SRM.TypeDefinitionHandle)MarkerMethod.DeclaringTypeDefinition.MetadataToken)
|
||||
?? MarkerMethod.DeclaringTypeDefinition;
|
||||
}
|
||||
|
||||
protected override void LoadChildren()
|
||||
{
|
||||
var extensionInfo = ContainerTypeDefinition.ExtensionInfo;
|
||||
var subst = new TypeParameterSubstitution(TypeParameters, null);
|
||||
var members = extensionInfo.GetMembersOfGroup(MarkerMethod).ToList();
|
||||
|
||||
foreach (var property in extensionInfo.GetMembersOfGroup(MarkerMethod).OfType<IProperty>().OrderBy(p => p.Name, NaturalStringComparer.Instance))
|
||||
foreach (var property in members.OfType<IProperty>().OrderBy(p => p.Name, NaturalStringComparer.Instance))
|
||||
{
|
||||
this.Children.Add(new PropertyTreeNode(property));
|
||||
}
|
||||
foreach (var method in extensionInfo.GetMembersOfGroup(MarkerMethod).OfType<IMethod>().OrderBy(m => m.Name, NaturalStringComparer.Instance))
|
||||
foreach (var method in members.OfType<IMethod>().OrderBy(m => m.Name, NaturalStringComparer.Instance))
|
||||
{
|
||||
if (method.MetadataToken.IsNil)
|
||||
continue;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Windows.Media;
|
||||
|
||||
@@ -69,6 +70,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
|
||||
public static ImageSource GetIcon(IProperty property)
|
||||
{
|
||||
IMethod accessor = property.Getter ?? property.Setter;
|
||||
Debug.Assert(accessor != null, "Property must have at least one accessor");
|
||||
bool isExtension = property.ResolveExtensionInfo()?.InfoOfExtensionMember((IMethod)accessor.MemberDefinition) != null;
|
||||
return Images.GetIcon(property.IsIndexer ? MemberIcon.Indexer : MemberIcon.Property,
|
||||
Images.GetOverlayIcon(property.Accessibility), property.IsStatic, isExtension);
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
|
||||
var extensionInfo = TypeDefinition.ExtensionInfo;
|
||||
if (extensionInfo != null)
|
||||
{
|
||||
foreach (var extensionGroup in TypeDefinition.ExtensionInfo?.ExtensionGroups ?? [])
|
||||
foreach (var extensionGroup in extensionInfo.ExtensionGroups)
|
||||
{
|
||||
this.Children.Add(new ExtensionTreeNode(TypeDefinition, extensionGroup, ParentAssemblyNode));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user