Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant serialization #886

Open
Unkorunk opened this issue Dec 1, 2022 · 0 comments · May be fixed by #702
Open

Constant serialization #886

Unkorunk opened this issue Dec 1, 2022 · 0 comments · May be fixed by #702

Comments

@Unkorunk
Copy link

Unkorunk commented Dec 1, 2022

Imagine the situation: you have assembly A and it depends on assembly B which you don't have. You read assembly A and immedity try to write to file and you get error! Why? Because assembly A have constant with enum type which contains in assembly B and Mono.Cecil try to resolve this type and don't can. I think if you can read assembly, you should be able to write this assembly back!

Example: Program.zip

Unhandled exception. Mono.Cecil.ResolutionException: Failed to resolve System.Threading.Tasks.TaskCreationOptions
   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.AddParameter(UInt16 sequence, ParameterDefinition parameter, ParamTable table)
   at Mono.Cecil.MetadataBuilder.AddParameters(MethodDefinition method)
   at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)
   at Mono.Cecil.MetadataBuilder.AddMethods(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.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
   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 Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
   at Mono.Cecil.AssemblyDefinition.Write(String fileName, WriterParameters parameters)
   at Mono.Cecil.AssemblyDefinition.Write(String fileName)
   at Example123.Example123.Main(String[] args) in Program.cs:line 94
@Unkorunk Unkorunk closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2022
@Unkorunk Unkorunk reopened this Dec 29, 2022
@teo-tsirpanis teo-tsirpanis linked a pull request Feb 1, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant