You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.199
Former-commit-id: f4d318e4b2f128fa9f4d31b37bb3839a3fc0dfb2
This commit is contained in:
parent
536cd135cc
commit
5924117973
@@ -11,6 +11,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Text;
|
||||
|
||||
using Mono;
|
||||
@@ -72,7 +73,13 @@ namespace Mono.Cecil {
|
||||
|
||||
static class ModuleWriter {
|
||||
|
||||
public static void WriteModuleTo (ModuleDefinition module, Disposable<Stream> stream, WriterParameters parameters)
|
||||
public static void WriteModule (ModuleDefinition module, Disposable<Stream> stream, WriterParameters parameters)
|
||||
{
|
||||
using (stream)
|
||||
Write (module, stream, parameters);
|
||||
}
|
||||
|
||||
static void Write (ModuleDefinition module, Disposable<Stream> stream, WriterParameters parameters)
|
||||
{
|
||||
if ((module.Attributes & ModuleAttributes.ILOnly) == 0)
|
||||
throw new NotSupportedException ("Writing mixed-mode assemblies is not supported");
|
||||
@@ -90,13 +97,12 @@ namespace Mono.Cecil {
|
||||
|
||||
var name = module.assembly != null ? module.assembly.Name : null;
|
||||
var fq_name = stream.value.GetFileName ();
|
||||
var timestamp = parameters.Timestamp ?? module.timestamp;
|
||||
var symbol_writer_provider = parameters.SymbolWriterProvider;
|
||||
|
||||
if (symbol_writer_provider == null && parameters.WriteSymbols)
|
||||
symbol_writer_provider = new DefaultSymbolWriterProvider ();
|
||||
|
||||
var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider, parameters);
|
||||
|
||||
#if !NET_CORE
|
||||
if (parameters.StrongNameKeyPair != null && name != null) {
|
||||
name.PublicKey = parameters.StrongNameKeyPair.PublicKey;
|
||||
@@ -104,26 +110,19 @@ namespace Mono.Cecil {
|
||||
}
|
||||
#endif
|
||||
|
||||
var timestamp = parameters.Timestamp ?? module.timestamp;
|
||||
using (var symbol_writer = GetSymbolWriter (module, fq_name, symbol_writer_provider, parameters)) {
|
||||
var metadata = new MetadataBuilder (module, fq_name, timestamp, symbol_writer_provider, symbol_writer);
|
||||
BuildMetadata (module, metadata);
|
||||
|
||||
var metadata = new MetadataBuilder (module, fq_name, timestamp, symbol_writer_provider, symbol_writer);
|
||||
|
||||
BuildMetadata (module, metadata);
|
||||
|
||||
var writer = ImageWriter.CreateWriter (module, metadata, stream);
|
||||
|
||||
stream.value.SetLength (0);
|
||||
|
||||
writer.WriteImage ();
|
||||
|
||||
if (metadata.symbol_writer != null)
|
||||
metadata.symbol_writer.Dispose ();
|
||||
var writer = ImageWriter.CreateWriter (module, metadata, stream);
|
||||
stream.value.SetLength (0);
|
||||
writer.WriteImage ();
|
||||
|
||||
#if !NET_CORE
|
||||
if (parameters.StrongNameKeyPair != null)
|
||||
CryptoService.StrongName (stream.value, writer, parameters.StrongNameKeyPair);
|
||||
if (parameters.StrongNameKeyPair != null)
|
||||
CryptoService.StrongName (stream.value, writer, parameters.StrongNameKeyPair);
|
||||
#endif
|
||||
stream.Dispose ();
|
||||
}
|
||||
}
|
||||
|
||||
static void BuildMetadata (ModuleDefinition module, MetadataBuilder metadata)
|
||||
@@ -776,7 +775,7 @@ namespace Mono.Cecil {
|
||||
}
|
||||
}
|
||||
|
||||
sealed class CustomDebugInformationTable : MetadataTable<CustomDebugInformationRow> {
|
||||
sealed class CustomDebugInformationTable : SortedTable<CustomDebugInformationRow> {
|
||||
|
||||
public override void Write (TableHeapBuffer buffer)
|
||||
{
|
||||
@@ -786,6 +785,11 @@ namespace Mono.Cecil {
|
||||
buffer.WriteBlob (rows [i].Col3); // Value
|
||||
}
|
||||
}
|
||||
|
||||
public override int Compare (CustomDebugInformationRow x, CustomDebugInformationRow y)
|
||||
{
|
||||
return Compare(x.Col1, y.Col1);
|
||||
}
|
||||
}
|
||||
|
||||
sealed class MetadataBuilder {
|
||||
@@ -1046,6 +1050,10 @@ namespace Mono.Cecil {
|
||||
|
||||
if (module.EntryPoint != null)
|
||||
entry_point = LookupToken (module.EntryPoint);
|
||||
|
||||
var pdb_writer = symbol_writer as IMetadataSymbolWriter;
|
||||
if (pdb_writer != null)
|
||||
pdb_writer.WriteModule ();
|
||||
}
|
||||
|
||||
void BuildAssembly ()
|
||||
@@ -2347,7 +2355,7 @@ namespace Mono.Cecil {
|
||||
return signature;
|
||||
}
|
||||
|
||||
void AddCustomDebugInformations (ICustomDebugInformationProvider provider)
|
||||
public void AddCustomDebugInformations (ICustomDebugInformationProvider provider)
|
||||
{
|
||||
if (!provider.HasCustomDebugInformations)
|
||||
return;
|
||||
@@ -2367,6 +2375,12 @@ namespace Mono.Cecil {
|
||||
case CustomDebugInformationKind.StateMachineScope:
|
||||
AddStateMachineScopeDebugInformation (provider, (StateMachineScopeDebugInformation) custom_info);
|
||||
break;
|
||||
case CustomDebugInformationKind.EmbeddedSource:
|
||||
AddEmbeddedSourceDebugInformation (provider, (EmbeddedSourceDebugInformation) custom_info);
|
||||
break;
|
||||
case CustomDebugInformationKind.SourceLink:
|
||||
AddSourceLinkDebugInformation (provider, (SourceLinkDebugInformation) custom_info);
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
@@ -2403,6 +2417,36 @@ namespace Mono.Cecil {
|
||||
AddCustomDebugInformation (provider, async_method, signature);
|
||||
}
|
||||
|
||||
void AddEmbeddedSourceDebugInformation (ICustomDebugInformationProvider provider, EmbeddedSourceDebugInformation embedded_source)
|
||||
{
|
||||
var signature = CreateSignatureWriter ();
|
||||
var content = embedded_source.content ?? Empty<byte>.Array;
|
||||
if (embedded_source.compress) {
|
||||
signature.WriteInt32 (content.Length);
|
||||
|
||||
var decompressed_stream = new MemoryStream (content);
|
||||
var content_stream = new MemoryStream ();
|
||||
|
||||
using (var compress_stream = new DeflateStream (content_stream, CompressionMode.Compress, leaveOpen: true))
|
||||
decompressed_stream.CopyTo (compress_stream);
|
||||
|
||||
signature.WriteBytes (content_stream.ToArray ());
|
||||
} else {
|
||||
signature.WriteInt32 (0);
|
||||
signature.WriteBytes (content);
|
||||
}
|
||||
|
||||
AddCustomDebugInformation (provider, embedded_source, signature);
|
||||
}
|
||||
|
||||
void AddSourceLinkDebugInformation (ICustomDebugInformationProvider provider, SourceLinkDebugInformation source_link)
|
||||
{
|
||||
var signature = CreateSignatureWriter ();
|
||||
signature.WriteBytes (Encoding.UTF8.GetBytes (source_link.content));
|
||||
|
||||
AddCustomDebugInformation (provider, source_link, signature);
|
||||
}
|
||||
|
||||
void AddCustomDebugInformation (ICustomDebugInformationProvider provider, CustomDebugInformation custom_info, SignatureWriter signature)
|
||||
{
|
||||
AddCustomDebugInformation (provider, custom_info, GetBlobIndex (signature));
|
||||
@@ -2507,6 +2551,8 @@ namespace Mono.Cecil {
|
||||
|
||||
document.token = token;
|
||||
|
||||
AddCustomDebugInformations (document);
|
||||
|
||||
document_map.Add (document.Url, token);
|
||||
|
||||
return token;
|
||||
|
||||
Reference in New Issue
Block a user