Imported Upstream version 3.10.0

Former-commit-id: 172c8e3c300b39d5785c7a3e8dfb08ebdbc1a99b
This commit is contained in:
Jo Shields
2014-10-04 11:27:48 +01:00
parent fe777c5c82
commit 8b9b85e7f5
970 changed files with 20242 additions and 31308 deletions

View File

@@ -157,7 +157,7 @@ namespace IKVM.Reflection
throw new BadImageFormatException();
}
lazyConstructorArguments = ReadConstructorArguments(module, br, constructor);
lazyNamedArguments = ReadNamedArguments(module, br, br.ReadUInt16(), constructor.DeclaringType);
lazyNamedArguments = ReadNamedArguments(module, br, br.ReadUInt16(), constructor.DeclaringType, true);
}
}
@@ -443,13 +443,17 @@ namespace IKVM.Reflection
return list.AsReadOnly();
}
private static IList<CustomAttributeNamedArgument> ReadNamedArguments(Module context, ByteReader br, int named, Type type)
private static IList<CustomAttributeNamedArgument> ReadNamedArguments(Module context, ByteReader br, int named, Type type, bool required)
{
List<CustomAttributeNamedArgument> list = new List<CustomAttributeNamedArgument>(named);
for (int i = 0; i < named; i++)
{
byte fieldOrProperty = br.ReadByte();
Type fieldOrPropertyType = ReadFieldOrPropType(context, br);
if (fieldOrPropertyType.__IsMissing && !required)
{
return null;
}
string name = br.ReadString();
CustomAttributeTypedArgument value = ReadFixedArg(context, br, fieldOrPropertyType);
MemberInfo member;
@@ -580,7 +584,7 @@ namespace IKVM.Reflection
{
if (lazyConstructorArguments == null)
{
LazyParseArguments();
LazyParseArguments(false);
}
return lazyConstructorArguments;
}
@@ -595,21 +599,21 @@ namespace IKVM.Reflection
if (customAttributeIndex >= 0)
{
// 1) Unresolved Custom Attribute
LazyParseArguments();
LazyParseArguments(true);
}
else
{
// 5) Unresolved declarative security
ByteReader br = new ByteReader(declSecurityBlob, 0, declSecurityBlob.Length);
// LAMESPEC the count of named arguments is a compressed integer (instead of UInt16 as NumNamed in custom attributes)
lazyNamedArguments = ReadNamedArguments(module, br, br.ReadCompressedUInt(), Constructor.DeclaringType);
lazyNamedArguments = ReadNamedArguments(module, br, br.ReadCompressedUInt(), Constructor.DeclaringType, true);
}
}
return lazyNamedArguments;
}
}
private void LazyParseArguments()
private void LazyParseArguments(bool requireNameArguments)
{
ByteReader br = module.GetBlob(module.CustomAttribute.records[customAttributeIndex].Value);
if (br.Length == 0)
@@ -625,7 +629,7 @@ namespace IKVM.Reflection
throw new BadImageFormatException();
}
lazyConstructorArguments = ReadConstructorArguments(module, br, Constructor);
lazyNamedArguments = ReadNamedArguments(module, br, br.ReadUInt16(), Constructor.DeclaringType);
lazyNamedArguments = ReadNamedArguments(module, br, br.ReadUInt16(), Constructor.DeclaringType, requireNameArguments);
}
}

View File

@@ -373,9 +373,9 @@ namespace IKVM.Reflection.Emit
foreach (CustomAttributeBuilder cab in customAttributes)
{
// .NET doesn't support copying blob custom attributes into the version info
if (!cab.HasBlob)
if (!cab.HasBlob || universe.DecodeVersionInfoAttributeBlobs)
{
versionInfo.SetAttribute(cab);
versionInfo.SetAttribute(this, cab);
}
}
ByteBuffer versionInfoData = new ByteBuffer(512);

View File

@@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4CB170EF-DFE6-4A56-9E1B-A85449E827A7}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -22,6 +22,8 @@
</SccAuxPath>
<SccProvider>
</SccProvider>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\ikvm-fork.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

View File

@@ -2040,6 +2040,7 @@ namespace IKVM.Reflection
{
if (this.Assembly == this.Universe.Mscorlib
|| this.Assembly.GetName().Name.Equals("mscorlib", StringComparison.OrdinalIgnoreCase)
|| this.Assembly.GetName().Name.Equals("System.Runtime", StringComparison.OrdinalIgnoreCase)
// check if mscorlib forwards the type (.NETCore profile reference mscorlib forwards System.Enum and System.ValueType to System.Runtime.dll)
|| this.Universe.Mscorlib.FindType(new TypeName(__Namespace, __Name)) == this)
{

View File

@@ -128,6 +128,7 @@ namespace IKVM.Reflection
MetadataOnly = 16,
ResolveMissingMembers = 32,
DisableWindowsRuntimeProjection = 64,
DecodeVersionInfoAttributeBlobs = 128,
}
public sealed class Universe : IDisposable
@@ -1216,5 +1217,10 @@ namespace IKVM.Reflection
{
get { return (options & UniverseOptions.DisableWindowsRuntimeProjection) == 0; }
}
internal bool DecodeVersionInfoAttributeBlobs
{
get { return (options & UniverseOptions.DecodeVersionInfoAttributeBlobs) != 0; }
}
}
}

View File

@@ -50,41 +50,41 @@ namespace IKVM.Reflection.Writer
this.fileName = System.IO.Path.GetFileName(assemblyFileName);
}
internal void SetAttribute(CustomAttributeBuilder cab)
internal void SetAttribute(AssemblyBuilder asm, CustomAttributeBuilder cab)
{
Universe u = cab.Constructor.Module.universe;
Type type = cab.Constructor.DeclaringType;
if (copyright == null && type == u.System_Reflection_AssemblyCopyrightAttribute)
{
copyright = (string)cab.GetConstructorArgument(0);
copyright = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
}
else if (trademark == null && type == u.System_Reflection_AssemblyTrademarkAttribute)
{
trademark = (string)cab.GetConstructorArgument(0);
trademark = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
}
else if (product == null && type == u.System_Reflection_AssemblyProductAttribute)
{
product = (string)cab.GetConstructorArgument(0);
product = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
}
else if (company == null && type == u.System_Reflection_AssemblyCompanyAttribute)
{
company = (string)cab.GetConstructorArgument(0);
company = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
}
else if (description == null && type == u.System_Reflection_AssemblyDescriptionAttribute)
{
description = (string)cab.GetConstructorArgument(0);
description = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
}
else if (title == null && type == u.System_Reflection_AssemblyTitleAttribute)
{
title = (string)cab.GetConstructorArgument(0);
title = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
}
else if (informationalVersion == null && type == u.System_Reflection_AssemblyInformationalVersionAttribute)
{
informationalVersion = (string)cab.GetConstructorArgument(0);
informationalVersion = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
}
else if (fileVersion == null && type == u.System_Reflection_AssemblyFileVersionAttribute)
{
fileVersion = (string)cab.GetConstructorArgument(0);
fileVersion = (string)cab.DecodeBlob(asm).GetConstructorArgument(0);
}
}