Imported Upstream version 6.12.0.86

Former-commit-id: 7a84ce7d08c42c458ac8e74b27186ca863315d79
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-07-10 08:44:59 +00:00
parent 92747312ea
commit 0b380204a4
812 changed files with 26901 additions and 9053 deletions

1
external/cecil/.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1 @@
github: jbevain

View File

@@ -12,10 +12,10 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' ">
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<FrameworkPathOverride Condition=" '$(net40FrameworkPathOverride)' != '' ">$(net40FrameworkPathOverride)</FrameworkPathOverride>
<FrameworkPathOverride Condition=" '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true' AND '$(net40FrameworkPathOverride)' == '' ">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.0-api/</FrameworkPathOverride>
<FrameworkPathOverride Condition=" '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true' AND '$(net40FrameworkPathOverride)' == '' ">/usr/lib/mono/4.0-api/</FrameworkPathOverride>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net40" Version="1.0.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@@ -229,6 +229,16 @@ namespace Mono.Cecil.Cil {
instructions.Insert (index + 1, instruction);
}
public void InsertAfter (int index, Instruction instruction)
{
if (index < 0 || index >= instructions.Count)
throw new ArgumentOutOfRangeException ("index");
if (instruction == null)
throw new ArgumentNullException ("instruction");
instructions.Insert (index + 1, instruction);
}
public void Append (Instruction instruction)
{
if (instruction == null)
@@ -248,6 +258,15 @@ namespace Mono.Cecil.Cil {
Remove (target);
}
public void Replace (int index, Instruction instruction)
{
if (instruction == null)
throw new ArgumentNullException ("instruction");
InsertAfter (index, instruction);
RemoveAt (index);
}
public void Remove (Instruction instruction)
{
if (instruction == null)
@@ -256,5 +275,13 @@ namespace Mono.Cecil.Cil {
if (!instructions.Remove (instruction))
throw new ArgumentOutOfRangeException ("instruction");
}
public void RemoveAt (int index)
{
if (index < 0 || index >= instructions.Count)
throw new ArgumentOutOfRangeException ("index");
instructions.RemoveAt (index);
}
}
}

View File

@@ -92,7 +92,7 @@ namespace Mono.Cecil.Cil {
var parameter_type = method.DeclaringType as TypeReference;
if (parameter_type.HasGenericParameters) {
var instance = new GenericInstanceType (parameter_type);
var instance = new GenericInstanceType (parameter_type, parameter_type.GenericParameters.Count);
for (int i = 0; i < parameter_type.GenericParameters.Count; i++)
instance.GenericArguments.Add (parameter_type.GenericParameters [i]);

View File

@@ -2,7 +2,7 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Mono.Cecil</id>
<version>0.11.0.0</version>
<version>0.11.1.0</version>
<title>Mono.Cecil</title>
<authors>Jb Evain</authors>
<owners>Jb Evain</owners>

View File

@@ -1 +1 @@
1728338c6228125c82803b552e530972592837b2
b64846368fef5b8e0e61dc51c6e0b8226ec59ad4

View File

@@ -63,5 +63,11 @@ namespace Mono.Cecil {
: base (method)
{
}
internal GenericInstanceMethod (MethodReference method, int arity)
: this (method)
{
this.arguments = new Collection<TypeReference> (arity);
}
}
}

View File

@@ -61,5 +61,11 @@ namespace Mono.Cecil {
base.IsValueType = type.IsValueType;
this.etype = MD.ElementType.GenericInst;
}
internal GenericInstanceType (TypeReference type, int arity)
: this (type)
{
this.arguments = new Collection<TypeReference> (arity);
}
}
}

View File

@@ -259,8 +259,8 @@ namespace Mono.Cecil {
TypeReference ImportGenericInstance (Type type, ImportGenericContext context)
{
var element_type = ImportType (type.GetGenericTypeDefinition (), context, ImportGenericKind.Definition);
var instance = new GenericInstanceType (element_type);
var arguments = type.GetGenericArguments ();
var instance = new GenericInstanceType (element_type, arguments.Length);
var instance_arguments = instance.GenericArguments;
context.Push (element_type);
@@ -633,9 +633,8 @@ namespace Mono.Cecil {
case ElementType.GenericInst:
var instance = (GenericInstanceType) type;
var element_type = ImportType (instance.ElementType, context);
var imported_instance = new GenericInstanceType (element_type);
var arguments = instance.GenericArguments;
var imported_instance = new GenericInstanceType (element_type, arguments.Count);
var imported_arguments = imported_instance.GenericArguments;
for (int i = 0; i < arguments.Count; i++)

View File

@@ -296,7 +296,7 @@ namespace Mono.Cecil {
if (generic_arguments.IsNullOrEmpty ())
return type;
var instance = new GenericInstanceType (type);
var instance = new GenericInstanceType (type, generic_arguments.Length);
var instance_arguments = instance.GenericArguments;
for (int i = 0; i < generic_arguments.Length; i++)

View File

@@ -104,7 +104,9 @@ namespace Mono.Collections.Generic {
if (capacity < 0)
throw new ArgumentOutOfRangeException ();
items = new T [capacity];
items = capacity == 0
? Empty<T>.Array
: new T [capacity];
}
public Collection (ICollection<T> items)

View File

@@ -15,6 +15,6 @@ using System.Runtime.InteropServices;
[assembly: ComVisible (false)]
[assembly: AssemblyVersion ("0.11.0.0")]
[assembly: AssemblyFileVersion ("0.11.0.0")]
[assembly: AssemblyInformationalVersion ("0.11.0.0")]
[assembly: AssemblyVersion ("0.11.1.0")]
[assembly: AssemblyFileVersion ("0.11.1.0")]
[assembly: AssemblyInformationalVersion ("0.11.1.0")]

View File

@@ -2,3 +2,4 @@ Cecil
=====
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.

View File

@@ -42,7 +42,7 @@ namespace Mono.Cecil.Tests {
if (self.GenericParameters.Count != arguments.Length)
throw new ArgumentException ();
var instance = new GenericInstanceType (self);
var instance = new GenericInstanceType (self, arguments.Length);
foreach (var argument in arguments)
instance.GenericArguments.Add (argument);

View File

@@ -53,6 +53,30 @@ namespace Mono.Cecil.Tests {
AssertOpCodeSequence (new [] { OpCodes.Ldloc_0, OpCodes.Ldloc_1, OpCodes.Ldloc_2, OpCodes.Ldloc_3 }, method);
}
[Test]
public void InsertAfterUsingIndex ()
{
var method = CreateTestMethod (OpCodes.Ldloc_0, OpCodes.Ldloc_2, OpCodes.Ldloc_3);
var il = method.GetILProcessor ();
il.InsertAfter (
0,
il.Create (OpCodes.Ldloc_1));
AssertOpCodeSequence (new [] { OpCodes.Ldloc_0, OpCodes.Ldloc_1, OpCodes.Ldloc_2, OpCodes.Ldloc_3 }, method);
}
[Test]
public void ReplaceUsingIndex ()
{
var method = CreateTestMethod (OpCodes.Ldloc_0, OpCodes.Ldloc_2, OpCodes.Ldloc_3);
var il = method.GetILProcessor ();
il.Replace (1, il.Create (OpCodes.Nop));
AssertOpCodeSequence (new [] { OpCodes.Ldloc_0, OpCodes.Nop, OpCodes.Ldloc_3 }, method);
}
static void AssertOpCodeSequence (OpCode [] expected, MethodBody body)
{
var opcodes = body.Instructions.Select (i => i.OpCode).ToArray ();

View File

@@ -68,7 +68,7 @@ namespace Mono.Cecil.Rocks {
if (self.GenericParameters.Count != arguments.Length)
throw new ArgumentException ();
var instance = new GenericInstanceType (self);
var instance = new GenericInstanceType (self, arguments.Length);
foreach (var argument in arguments)
instance.GenericArguments.Add (argument);