8
8
using System . Text ;
9
9
10
10
using Internal . TypeSystem ;
11
+ using Internal . TypeSystem . Ecma ;
11
12
12
13
namespace ILCompiler . Logging
13
14
{
@@ -210,21 +211,17 @@ public static void GetMatchingMembers(string id, ref int index, ModuleDesc modul
210
211
index = startIndex ;
211
212
}
212
213
213
- #if false
214
214
if ( memberTypes . HasFlag ( MemberType . Property ) )
215
215
{
216
216
GetMatchingProperties ( id , ref index , containingType , memberName , results , acceptName ) ;
217
217
endIndex = index ;
218
218
index = startIndex ;
219
219
}
220
- #endif
221
220
222
221
index = endIndex ;
223
222
224
- #if false
225
223
if ( memberTypes . HasFlag ( MemberType . Event ) )
226
224
GetMatchingEvents ( containingType , memberName , results ) ;
227
- #endif
228
225
229
226
if ( memberTypes . HasFlag ( MemberType . Field ) )
230
227
GetMatchingFields ( containingType , memberName , results ) ;
@@ -536,7 +533,7 @@ private static void GetMatchingTypes(ModuleDesc module, TypeDesc declaringType,
536
533
string namepart ;
537
534
if ( indexOfLastDot > 0 && indexOfLastDot < name . Length - 1 )
538
535
{
539
- namespacepart = name . Substring ( indexOfLastDot - 1 ) ;
536
+ namespacepart = name . Substring ( 0 , indexOfLastDot ) ;
540
537
namepart = name . Substring ( indexOfLastDot + 1 ) ;
541
538
}
542
539
else
@@ -631,10 +628,9 @@ private static void GetMatchingMethods(string id, ref int index, TypeDesc type,
631
628
index = endIndex ;
632
629
}
633
630
634
- #if false
635
- static void GetMatchingProperties ( string id , ref int index , TypeDesc type , string memberName , List < TypeSystemEntity > results , bool acceptName = false )
631
+ private static void GetMatchingProperties ( string id , ref int index , TypeDesc typeDesc , string memberName , List < TypeSystemEntity > results , bool acceptName = false )
636
632
{
637
- if ( type == null )
633
+ if ( typeDesc is not EcmaType type )
638
634
return ;
639
635
640
636
int startIndex = index ;
@@ -643,11 +639,14 @@ static void GetMatchingProperties(string id, ref int index, TypeDesc type, strin
643
639
List < string > parameters = null ;
644
640
// Unlike Roslyn, we don't need to decode property names because we are working
645
641
// directly with IL.
646
- foreach ( var property in type . Properties )
642
+ foreach ( var propertyHandle in type . MetadataReader . GetTypeDefinition ( type . Handle ) . GetProperties ( ) )
647
643
{
644
+ var p = new PropertyPseudoDesc ( type , propertyHandle ) ;
645
+
648
646
index = startIndex ;
649
- if ( property . Name != memberName )
647
+ if ( p . Name != memberName )
650
648
continue ;
649
+
651
650
if ( PeekNextChar ( id , index ) == '(' )
652
651
{
653
652
if ( parameters == null )
@@ -658,23 +657,22 @@ static void GetMatchingProperties(string id, ref int index, TypeDesc type, strin
658
657
{
659
658
parameters . Clear ( ) ;
660
659
}
661
- if ( ! ParseParameterList ( id , ref index , property . DeclaringType , parameters ) )
660
+ if ( ! ParseParameterList ( id , ref index , p . OwningType , parameters ) )
662
661
continue ;
663
- if ( ! AllParametersMatch ( property . Parameters , parameters ) )
662
+ if ( ! AllParametersMatch ( p . Signature , parameters ) )
664
663
continue ;
665
664
}
666
665
else
667
666
{
668
- if ( ! acceptName && property . Parameters . Count != 0 )
667
+ if ( ! acceptName && p . Signature . Length != 0 )
669
668
continue ;
670
669
}
671
- results . Add ( property ) ;
670
+ results . Add ( p ) ;
672
671
endIndex = index ;
673
672
}
674
673
675
674
index = endIndex ;
676
675
}
677
- #endif
678
676
679
677
private static void GetMatchingFields ( TypeDesc type , string memberName , List < TypeSystemEntity > results )
680
678
{
@@ -688,19 +686,19 @@ private static void GetMatchingFields(TypeDesc type, string memberName, List<Typ
688
686
}
689
687
}
690
688
691
- #if false
692
- static void GetMatchingEvents ( TypeDesc type , string memberName , List < TypeSystemEntity > results )
689
+ private static void GetMatchingEvents ( TypeDesc typeDesc , string memberName , List < TypeSystemEntity > results )
693
690
{
694
- if ( type == null )
691
+ if ( typeDesc is not EcmaType type )
695
692
return ;
696
- foreach ( var evt in type . Events )
693
+
694
+ foreach ( var eventHandle in type . MetadataReader . GetTypeDefinition ( type . Handle ) . GetEvents ( ) )
697
695
{
698
- if ( evt . Name != memberName )
696
+ var e = new EventPseudoDesc ( type , eventHandle ) ;
697
+ if ( e . Name != memberName )
699
698
continue ;
700
- results . Add ( evt ) ;
699
+ results . Add ( e ) ;
701
700
}
702
701
}
703
- #endif
704
702
705
703
private static bool AllParametersMatch ( MethodSignature methodParameters , List < string > expectedParameters )
706
704
{
@@ -716,6 +714,20 @@ private static bool AllParametersMatch(MethodSignature methodParameters, List<st
716
714
return true ;
717
715
}
718
716
717
+ private static bool AllParametersMatch ( PropertySignature propertyParameters , List < string > expectedParameters )
718
+ {
719
+ if ( propertyParameters . Length != expectedParameters . Count )
720
+ return false ;
721
+
722
+ for ( int i = 0 ; i < expectedParameters . Count ; i ++ )
723
+ {
724
+ if ( GetSignaturePart ( propertyParameters [ i ] ) != expectedParameters [ i ] )
725
+ return false ;
726
+ }
727
+
728
+ return true ;
729
+ }
730
+
719
731
private static bool ParseParameterList ( string id , ref int index , TypeSystemEntity typeParameterContext , List < string > parameters )
720
732
{
721
733
Debug . Assert ( typeParameterContext != null ) ;
0 commit comments