Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2021-06-30 19:13:42 +0300
committerMarek Safar <marek.safar@gmail.com>2021-06-30 19:13:42 +0300
commitcfb80b23787949a6fa5e3e3d6af35d86287517e9 (patch)
treef0da81c6aa2dd83a5309775aa9da05bd1f459b27 /Mono.Cecil/AssemblyReader.cs
parente069cd8d25d5b61b0e28fe65e75959c20af7aa80 (diff)
parent96c159d4687ea7493893011f3bd4a6e098dab163 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'Mono.Cecil/AssemblyReader.cs')
-rw-r--r--Mono.Cecil/AssemblyReader.cs58
1 files changed, 33 insertions, 25 deletions
diff --git a/Mono.Cecil/AssemblyReader.cs b/Mono.Cecil/AssemblyReader.cs
index 2a59358..9fdcf68 100644
--- a/Mono.Cecil/AssemblyReader.cs
+++ b/Mono.Cecil/AssemblyReader.cs
@@ -182,7 +182,7 @@ namespace Mono.Cecil {
ReadCustomAttributes (module);
var assembly = module.Assembly;
- if (assembly == null)
+ if (module.kind == ModuleKind.NetModule || assembly == null)
return;
ReadCustomAttributes (assembly);
@@ -667,8 +667,10 @@ namespace Mono.Cecil {
AssemblyResolver = module.AssemblyResolver
};
- modules.Add (ModuleDefinition.ReadModule (
- GetModuleFileName (name), parameters));
+ var netmodule = ModuleDefinition.ReadModule (GetModuleFileName (name), parameters);
+ netmodule.assembly = this.module.assembly;
+
+ modules.Add (netmodule);
}
return modules;
@@ -3221,28 +3223,7 @@ namespace Mono.Cecil {
infos.Add (async_body);
} else if (rows [i].Col1 == EmbeddedSourceDebugInformation.KindIdentifier) {
- var signature = ReadSignature (rows [i].Col2);
- var format = signature.ReadInt32 ();
- var length = signature.sig_length - 4;
-
- var info = null as CustomDebugInformation;
-
- if (format == 0) {
- info = new EmbeddedSourceDebugInformation (signature.ReadBytes ((int) length), compress: false);
- } else if (format > 0) {
- var compressed_stream = new MemoryStream (signature.ReadBytes ((int) length));
- var decompressed_document = new byte [format]; // if positive, format is the decompressed length of the document
- var decompressed_stream = new MemoryStream (decompressed_document);
-
- using (var deflate_stream = new DeflateStream (compressed_stream, CompressionMode.Decompress, leaveOpen: true))
- deflate_stream.CopyTo (decompressed_stream);
-
- info = new EmbeddedSourceDebugInformation (decompressed_document, compress: true);
- } else if (format < 0) {
- info = new BinaryCustomDebugInformation (rows [i].Col1, ReadBlob (rows [i].Col2));
- }
-
- infos.Add (info);
+ infos.Add (new EmbeddedSourceDebugInformation (rows [i].Col2, this));
} else if (rows [i].Col1 == SourceLinkDebugInformation.KindIdentifier) {
infos.Add (new SourceLinkDebugInformation (Encoding.UTF8.GetString (ReadBlob (rows [i].Col2))));
} else {
@@ -3254,6 +3235,33 @@ namespace Mono.Cecil {
return infos;
}
+
+ public byte [] ReadRawEmbeddedSourceDebugInformation (uint index)
+ {
+ var signature = ReadSignature (index);
+ return signature.ReadBytes ((int) signature.sig_length);
+ }
+
+ public Row<byte [], bool> ReadEmbeddedSourceDebugInformation (uint index)
+ {
+ var signature = ReadSignature (index);
+ var format = signature.ReadInt32 ();
+ var length = signature.sig_length - 4;
+
+ if (format == 0) {
+ return new Row<byte [], bool> (signature.ReadBytes ((int) length), false);
+ } else if (format > 0) {
+ var compressed_stream = new MemoryStream (signature.ReadBytes ((int) length));
+ var decompressed_document = new byte [format]; // if positive, format is the decompressed length of the document
+ var decompressed_stream = new MemoryStream (decompressed_document);
+
+ using (var deflate_stream = new DeflateStream (compressed_stream, CompressionMode.Decompress, leaveOpen: true))
+ deflate_stream.CopyTo (decompressed_stream);
+
+ return new Row<byte [], bool> (decompressed_document, true);
+ } else
+ throw new NotSupportedException ();
+ }
}
sealed class SignatureReader : ByteBuffer {