Closed jnm2 closed 5 years ago
@jbevain Is there a way we can get Cecil to treat this as an opaque/unresolved error type that is simply preserved when we write the modified assembly back to disk?
@jnm2 Worst case, we can make it report a warning like it does for other skipped assemblies. The build author can control whether the warning is treated as a build error.
@sharwell I think this happens because you use the Immediate mode that creates the entire DOM, including custom attributes.
If you use the delayed one, it might be able to optimize the reading/writing of the custom attributes straight to bytes.
What happens here is that Cecil reads a custom attribute with an enum, and there's no way to know the size of the enum unless you resolve its type definition.
Interestingly, there are a ton of "Failed to resolve assembly" messages when building an empty net451
project on Windows. These are at the info level rather than the error caused by the uncaught AssemblyResolutionException when building on Ubuntu. I wonder why Cecil on Windows isn't throwing AssemblyResolutionException the same way.
[...]
Cannot find a matching type for System.Configuration.IriParsingElement
Failed to resolve assembly: 'System.Configuration.ConfigurationManager, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
Cannot find a matching type for System.Configuration.IdnElement
Failed to resolve assembly: 'System.Configuration.ConfigurationManager, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
Cannot find a matching type for System.Net.Mail.SmtpAccess
Failed to resolve assembly: 'System.Security.Permissions, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
Cannot find a matching type for System.Net.Mail.SmtpPermissionAttribute
Failed to resolve assembly: 'System.Security.Permissions, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
Cannot find a matching type for System.Net.Mail.SmtpPermission
Failed to resolve assembly: 'System.Security.Permissions, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
Cannot find a matching type for System.Configuration.SettingsBase
Failed to resolve assembly: 'System.Configuration.ConfigurationManager, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
Cannot find a matching type for System.Configuration.ApplicationSettingsBase
Failed to resolve assembly: 'System.Configuration.ConfigurationManager, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
[...]
802 failures total: net451 build log.txt
That's produced by this code:
Once ReadingMode.Deferred is used it will be interesting to see if/where we need to add another catch block.
This is alpha 77 on Shouldly's Ubuntu build:
I'm not sure whether this is recoverable or whether it should just be turned into a nicer error.
Stack trace: