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:
-rw-r--r--Directory.Build.props2
-rw-r--r--Mono.Cecil/AssemblyWriter.cs6
-rw-r--r--Mono.Cecil/Import.cs2
-rw-r--r--Mono.Cecil/ModuleDefinition.cs29
-rw-r--r--README.md14
5 files changed, 38 insertions, 15 deletions
diff --git a/Directory.Build.props b/Directory.Build.props
index 6799dfb..cb10f01 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -16,7 +16,7 @@
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net40" Version="1.0.2" />
</ItemGroup>
- <ItemGroup>
+ <ItemGroup Condition="'$(MonoBuild)' != ''">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
diff --git a/Mono.Cecil/AssemblyWriter.cs b/Mono.Cecil/AssemblyWriter.cs
index 3f17a82..c83f997 100644
--- a/Mono.Cecil/AssemblyWriter.cs
+++ b/Mono.Cecil/AssemblyWriter.cs
@@ -1354,6 +1354,12 @@ namespace Mono.Cecil {
MetadataToken GetTypeRefToken (TypeReference type)
{
+ MetadataToken ctoken;
+ if (module.CustomMetadataWriter != null) {
+ if (module.CustomMetadataWriter.CreateTypeRefToken (ref type, out ctoken))
+ return ctoken;
+ }
+
var projection = WindowsRuntimeProjections.RemoveProjection (type);
var row = CreateTypeRefRow (type);
diff --git a/Mono.Cecil/Import.cs b/Mono.Cecil/Import.cs
index 272e960..37cf932 100644
--- a/Mono.Cecil/Import.cs
+++ b/Mono.Cecil/Import.cs
@@ -486,7 +486,7 @@ namespace Mono.Cecil {
this.module = module;
}
- TypeReference ImportType (TypeReference type, ImportGenericContext context)
+ internal virtual TypeReference ImportType (TypeReference type, ImportGenericContext context)
{
if (type.IsTypeSpecification ())
return ImportTypeSpecification (type, context);
diff --git a/Mono.Cecil/ModuleDefinition.cs b/Mono.Cecil/ModuleDefinition.cs
index b17f7c4..84cd969 100644
--- a/Mono.Cecil/ModuleDefinition.cs
+++ b/Mono.Cecil/ModuleDefinition.cs
@@ -177,6 +177,22 @@ namespace Mono.Cecil {
}
}
+ interface ICustomMetadataWriter
+ {
+ /*
+ * Remap TypeReference or create custom TypeRef token.
+ *
+ * Return true to use the returned custom 'token'.
+ *
+ * Return false to create a TypeRef token for 'type'
+ * (which may have been replaced with a different TypeReference).
+ *
+ * This is necessary when types are moved from one assembly to another
+ * to either adjust the scope or replace a TypeRef with a TypeDef token.
+ */
+ bool CreateTypeRefToken (ref TypeReference type, out MetadataToken token);
+ }
+
public sealed class WriterParameters {
uint? timestamp;
@@ -264,6 +280,7 @@ namespace Mono.Cecil {
internal IReflectionImporter reflection_importer;
internal IMetadataImporter metadata_importer;
+ ICustomMetadataWriter custom_writer;
Collection<CustomAttribute> custom_attributes;
Collection<AssemblyNameReference> references;
@@ -382,6 +399,18 @@ namespace Mono.Cecil {
}
}
+ internal void SetMetadataImporter (IMetadataImporter importer)
+ {
+ if (this.metadata_importer != null)
+ throw new InvalidOperationException ();
+ this.metadata_importer = importer;
+ }
+
+ internal ICustomMetadataWriter CustomMetadataWriter {
+ get { return custom_writer; }
+ set { custom_writer = value; }
+ }
+
public IAssemblyResolver AssemblyResolver {
get {
if (assembly_resolver.value == null) {
diff --git a/README.md b/README.md
index c052e4c..3b95784 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,5 @@
Cecil
=====
-Mono.Cecil is a library to generate and inspect programs and libraries in the ECMA CIL form.
+This is a fork of [Cecil](https://github.com/jbevain/cecil) library. Please do any pull requests in the original repository before they are merged into Mono fork.
-To put it simply, you can use Cecil to:
-
-* Analyze .NET binaries using a simple and powerful object model, without having to load assemblies to use Reflection.
-* Modify .NET binaries, add new metadata structures and alter the IL code.
-
-Cecil has been around since 2004 and is [widely used](https://github.com/jbevain/cecil/wiki/Users) in the .NET community. If you're using Cecil, or depend on a framework, project, or product using it, please consider [sponsoring Cecil](https://github.com/sponsors/jbevain/).
-
-Read about the Cecil development on the [development log](http://cecil.pe).
-
-To discuss Cecil, the best place is the [mono-cecil](https://groups.google.com/group/mono-cecil) Google Group.
-
-Cecil is a project under the benevolent umbrella of the [.NET Foundation](http://www.dotnetfoundation.org/).