Commit 1a2d9bf
committed
[Java.Interop.Tools.Cecil] fix symbol loading in
Context: 7d42864d
Context: dotnet/android#8571
While debugging dotnet/android#8571, I found the usage of
`MemoryMappedFile` (from 7d42864) broke `.pdb` symbol loading. This is
OK, because we'll likely disable symbol loading anyway, but we should at
least address our bugs here for the future.
In order for the following code to load symbols:
AssemblyDefinition result = ModuleDefinition.ReadModule (viewStream, options).Assembly;
You would need the following `ReaderParameters`:
* `ReadSymbols=true`
* `SymbolStream` containing a valid `Stream` to the `.pdb` file
To make this work, I had to:
* Create a `List<IDisposable>` for bookkeeping.
* When successful, we transfer ownership of the `MemoryMappedFile` from
the `List<IDisposable>` of `MemoryMappedViewStream` to the
`viewStreams` collection.
* When unsuccessful, we'd just dispose of the `MemoryMappedViewStream`.
* If `ReadWrite=true`, we can just use `File.OpenRead()` for symbols,
versus `MemoryMappedViewStream`.
Other changes:
* Added tests to verify we can load a `.dll` and its symbols with
appropriate settings.
* Stop looking for `.mdb` files. We no longer support these in .NET 6+.
* Removed unnecessary `$""` string interpolation.DirectoryAssemblyResolver
1 parent d5afa0a commit 1a2d9bf
File tree
2 files changed
+106
-17
lines changed- src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil
- tests/Java.Interop.Tools.JavaCallableWrappers-Tests/Java.Interop.Tools.JavaCallableWrappers
2 files changed
+106
-17
lines changedLines changed: 53 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | 153 | | |
156 | 154 | | |
157 | 155 | | |
158 | 156 | | |
159 | 157 | | |
160 | 158 | | |
161 | 159 | | |
162 | | - | |
163 | 160 | | |
164 | 161 | | |
165 | 162 | | |
166 | | - | |
167 | 163 | | |
168 | 164 | | |
169 | 165 | | |
170 | 166 | | |
171 | 167 | | |
172 | 168 | | |
173 | 169 | | |
174 | | - | |
| 170 | + | |
175 | 171 | | |
176 | 172 | | |
| 173 | + | |
| 174 | + | |
177 | 175 | | |
178 | 176 | | |
179 | 177 | | |
180 | 178 | | |
181 | 179 | | |
182 | 180 | | |
183 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
187 | | - | |
| 188 | + | |
| 189 | + | |
188 | 190 | | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
194 | 194 | | |
| 195 | + | |
195 | 196 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
201 | 206 | | |
202 | 207 | | |
203 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
204 | 211 | | |
205 | 212 | | |
206 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
207 | 243 | | |
208 | 244 | | |
209 | 245 | | |
| |||
Lines changed: 53 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
0 commit comments