Commit e1f3f5a
committed
Avoid unnecessarily creating TypeReferences on import
When importing a TypeSpecification, an element type or generic argument could be a TypeDefinition within the current module.
When this happens, a new TypeReference does not need to be created. This can lead to a TypeReference being added to the typeref table for
a type that is already in the assembly. This seems to hold together, although I don't think it's ideal. And really my goal is to avoid failing this logic in the ILLink test framework https://github.com/dotnet/runtime/blob/cec44d6dff9de95421f199f65bbc80b8296da1c0/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs#L56
This fix superceeds #138. I've left that fix in since that API is exposed publically and others could be depending on it.
While I was adjusting this logic, I thought I would apply the same logic to a TypeReference where the scope is the current modules assembly.
This case is a bit contrived as it shouldn't happen, but if it did, it would result in the same circular reference problem as #1381 parent 3136847 commit e1f3f5a
File tree
2 files changed
+63
-1
lines changed- Mono.Cecil
- Test/Mono.Cecil.Tests
2 files changed
+63
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
509 | 519 | | |
510 | 520 | | |
511 | 521 | | |
| |||
535 | 545 | | |
536 | 546 | | |
537 | 547 | | |
| 548 | + | |
| 549 | + | |
538 | 550 | | |
539 | 551 | | |
540 | 552 | | |
| |||
809 | 821 | | |
810 | 822 | | |
811 | 823 | | |
812 | | - | |
| 824 | + | |
813 | 825 | | |
814 | 826 | | |
815 | 827 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
289 | 334 | | |
290 | 335 | | |
291 | 336 | | |
| |||
319 | 364 | | |
320 | 365 | | |
321 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
322 | 372 | | |
323 | 373 | | |
324 | 374 | | |
| |||
0 commit comments