@@ -76,6 +76,18 @@ public static int GetUserEntryPoint(this ISymUnmanagedReader reader)
7676 return entryPoint ;
7777 }
7878
79+ public static ISymUnmanagedDocument GetDocument ( this ISymUnmanagedReader reader , string name )
80+ {
81+ if ( reader == null )
82+ {
83+ throw new ArgumentNullException ( nameof ( reader ) ) ;
84+ }
85+
86+ ISymUnmanagedDocument document ;
87+ ThrowExceptionForHR ( reader . GetDocument ( name , default ( Guid ) , default ( Guid ) , default ( Guid ) , out document ) ) ;
88+ return document ;
89+ }
90+
7991 public static ISymUnmanagedDocument [ ] GetDocuments ( this ISymUnmanagedReader reader )
8092 {
8193 if ( reader == null )
@@ -100,7 +112,27 @@ public static ISymUnmanagedMethod[] GetMethodsInDocument(this ISymUnmanagedReade
100112
101113 public static ISymUnmanagedMethod GetMethod ( this ISymUnmanagedReader reader , int methodToken )
102114 {
103- return GetMethodByVersion ( reader , methodToken , methodVersion : 1 ) ;
115+ if ( reader == null )
116+ {
117+ throw new ArgumentNullException ( nameof ( reader ) ) ;
118+ }
119+
120+ ISymUnmanagedMethod method ;
121+ int hr = reader . GetMethod ( methodToken , out method ) ;
122+ ThrowExceptionForHR ( hr ) ;
123+
124+ if ( hr < 0 )
125+ {
126+ // method has no symbol info
127+ return null ;
128+ }
129+
130+ if ( method == null )
131+ {
132+ throw new InvalidOperationException ( ) ;
133+ }
134+
135+ return method ;
104136 }
105137
106138 public static ISymUnmanagedMethod GetMethodByVersion ( this ISymUnmanagedReader reader , int methodToken , int methodVersion )
@@ -110,7 +142,7 @@ public static ISymUnmanagedMethod GetMethodByVersion(this ISymUnmanagedReader re
110142 throw new ArgumentNullException ( nameof ( reader ) ) ;
111143 }
112144
113- ISymUnmanagedMethod method = null ;
145+ ISymUnmanagedMethod method ;
114146 int hr = reader . GetMethodByVersion ( methodToken , methodVersion , out method ) ;
115147 ThrowExceptionForHR ( hr ) ;
116148
@@ -127,5 +159,17 @@ public static ISymUnmanagedMethod GetMethodByVersion(this ISymUnmanagedReader re
127159
128160 return method ;
129161 }
162+
163+ public static int GetMethodVersion ( this ISymUnmanagedReader reader , ISymUnmanagedMethod method )
164+ {
165+ if ( reader == null )
166+ {
167+ throw new ArgumentNullException ( nameof ( reader ) ) ;
168+ }
169+
170+ int version ;
171+ ThrowExceptionForHR ( reader . GetMethodVersion ( method , out version ) ) ;
172+ return version ;
173+ }
130174 }
131175}
0 commit comments