Obfuscar 2.2.28 throws ResolutionException

695 Views Asked by At

Obfuscar 2.2.28 throws ResolutionException for an obfuscated item:

Unhandled Exception: Mono.Cecil.ResolutionException: Failed to resolve A.h
   at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)
   at Mono.Cecil.MetadataBuilder.GetConstantType(TypeReference constant_type, Object constant)
   at Mono.Cecil.MetadataBuilder.AddConstant(IConstantProvider owner, TypeReference type)
   at Mono.Cecil.MetadataBuilder.AddField(FieldDefinition field)
   at Mono.Cecil.MetadataBuilder.AddFields(TypeDefinition type)
   at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
   at Mono.Cecil.MetadataBuilder.AddTypes()
   at Mono.Cecil.MetadataBuilder.BuildTypes()
   at Mono.Cecil.MetadataBuilder.BuildModule()
   at Mono.Cecil.MetadataBuilder.BuildMetadata()
   at Mono.Cecil.ModuleWriter.<>c.<BuildMetadata>b__2_0(MetadataBuilder builder, MetadataReader _)
   at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
   at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
   at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
   at Obfuscar.Obfuscator.SaveAssemblies(Boolean throwException)
   at Obfuscar.Obfuscator.RunRules()
   at Obfuscar.Program.Main(String[] args)

I did change some obfuscation attributes (add more enumerations to be obfuscated) and then this error started to occur.

The projects I am obfuscating are targeting .NET Framework 4.6.2.

UPDATE: I have also tried with version 2.2.25 and 2.2.26 and the result is the same. Unfortunately there is no log file, so it is very hard to see what is causing the issue.

UPDATE 2: I have narrowed it down in my (large) project to one specific enumeration. When I exclude that enumeration from obfuscation, obfuscation runs fine. When I obfuscate that enumeration, the exception is thrown. The situation is as follows. The problematic enumeration is in a library that is obfuscated completely. However, the enumeration is also used in a unit test. The assembly with the unit tests is also part of the obfuscation (I want to run my unit tests on the actually obfuscated libraries that are delivered), but the test classes in it are not obfuscated. This means that only references to classes/enumerations defined in the completely obfuscated libraries should be updated in the test assembly. When I remove the usage of this enumeration from the unit test, obfuscation also works again. So it seems to be the reference to an obfuscated enumeration in a non-obfuscated class that is posing the issue.

0

There are 0 best solutions below