Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Jan 9, 2024
2 parents 1c9bc82 + efdd3ee commit aff110d
Show file tree
Hide file tree
Showing 216 changed files with 20,594 additions and 17,586 deletions.
5 changes: 4 additions & 1 deletion src/IKVM.Reflection/AmbiguousMatchException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Jeroen Frijters

namespace IKVM.Reflection
{
[Serializable]

[Serializable]
public sealed class AmbiguousMatchException : Exception
{
public AmbiguousMatchException()
Expand All @@ -46,5 +47,7 @@ private AmbiguousMatchException(System.Runtime.Serialization.SerializationInfo i
: base(info, context)
{
}

}

}
102 changes: 102 additions & 0 deletions src/IKVM.Reflection/ArrayType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
Copyright (C) 2009-2015 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
[email protected]
*/
using System;
using System.Collections.Generic;

namespace IKVM.Reflection
{
sealed class ArrayType : ElementHolderType
{
internal static Type Make(Type type, CustomModifiers mods)
{
return type.Universe.CanonicalizeType(new ArrayType(type, mods));
}

private ArrayType(Type type, CustomModifiers mods)
: base(type, mods, Signature.ELEMENT_TYPE_SZARRAY)
{
}

public override Type BaseType
{
get { return elementType.Module.universe.System_Array; }
}

public override Type[] __GetDeclaredInterfaces()
{
return new Type[] {
this.Module.universe.Import(typeof(IList<>)).MakeGenericType(elementType),
this.Module.universe.Import(typeof(ICollection<>)).MakeGenericType(elementType),
this.Module.universe.Import(typeof(IEnumerable<>)).MakeGenericType(elementType)
};
}

public override MethodBase[] __GetDeclaredMethods()
{
Type[] int32 = new Type[] { this.Module.universe.System_Int32 };
List<MethodBase> list = new List<MethodBase>();
list.Add(new BuiltinArrayMethod(this.Module, this, "Set", CallingConventions.Standard | CallingConventions.HasThis, this.Module.universe.System_Void, new Type[] { this.Module.universe.System_Int32, elementType }));
list.Add(new BuiltinArrayMethod(this.Module, this, "Address", CallingConventions.Standard | CallingConventions.HasThis, elementType.MakeByRefType(), int32));
list.Add(new BuiltinArrayMethod(this.Module, this, "Get", CallingConventions.Standard | CallingConventions.HasThis, elementType, int32));
list.Add(new ConstructorInfoImpl(new BuiltinArrayMethod(this.Module, this, ".ctor", CallingConventions.Standard | CallingConventions.HasThis, this.Module.universe.System_Void, int32)));
for (Type type = elementType; type.__IsVector; type = type.GetElementType())
{
Array.Resize(ref int32, int32.Length + 1);
int32[int32.Length - 1] = int32[0];
list.Add(new ConstructorInfoImpl(new BuiltinArrayMethod(this.Module, this, ".ctor", CallingConventions.Standard | CallingConventions.HasThis, this.Module.universe.System_Void, int32)));
}
return list.ToArray();
}

public override TypeAttributes Attributes
{
get { return TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.Serializable; }
}

public override int GetArrayRank()
{
return 1;
}

public override bool Equals(object o)
{
return EqualsHelper(o as ArrayType);
}

public override int GetHashCode()
{
return elementType.GetHashCode() * 5;
}

internal override string GetSuffix()
{
return "[]";
}

protected override Type Wrap(Type type, CustomModifiers mods)
{
return Make(type, mods);
}
}
}
33 changes: 15 additions & 18 deletions src/IKVM.Reflection/Assembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public abstract class Assembly : ICustomAttributeProvider
protected string fullName; // AssemblyBuilder needs access to this field to clear it when the name changes
protected List<ModuleResolveEventHandler> resolvers;

/// <summary>
/// Initializes a new instance.
/// </summary>
/// <param name="universe"></param>
internal Assembly(Universe universe)
{
this.universe = universe;
Expand All @@ -50,10 +54,7 @@ public event ModuleResolveEventHandler ModuleResolve
{
add
{
if (resolvers == null)
{
resolvers = new List<ModuleResolveEventHandler>();
}
resolvers ??= new List<ModuleResolveEventHandler>();
resolvers.Add(value);
}
remove
Expand Down Expand Up @@ -119,14 +120,11 @@ public bool ReflectionOnly

public Type[] GetExportedTypes()
{
List<Type> list = new List<Type>();
foreach (Type type in GetTypes())
{
var list = new List<Type>();
foreach (var type in GetTypes())
if (type.IsVisible)
{
list.Add(type);
}
}

return list.ToArray();
}

Expand All @@ -139,12 +137,11 @@ public IEnumerable<TypeInfo> DefinedTypes
{
get
{
Type[] types = GetTypes();
TypeInfo[] typeInfos = new TypeInfo[types.Length];
var types = GetTypes();
var typeInfos = new TypeInfo[types.Length];
for (int i = 0; i < types.Length; i++)
{
typeInfos[i] = types[i].GetTypeInfo();
}

return typeInfos;
}
}
Expand Down Expand Up @@ -172,6 +169,7 @@ public Type GetType(string name, bool throwOnError, bool ignoreCase)
else
return null;
}

var typeName = TypeName.Split(TypeNameParser.Unescape(parser.FirstNamePart));
var type = ignoreCase ? FindTypeIgnoreCase(typeName.ToLowerInvariant()) : FindType(typeName);
if (type == null && __IsMissing)
Expand Down Expand Up @@ -224,11 +222,10 @@ public string CodeBase
{
get
{
string path = this.Location.Replace(System.IO.Path.DirectorySeparatorChar, '/');
if (!path.StartsWith("/"))
{
var path = this.Location.Replace(System.IO.Path.DirectorySeparatorChar, '/');
if (path.StartsWith("/") == false)
path = "/" + path;
}

return "file://" + path;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/IKVM.Reflection/AssemblyComparisonResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ Jeroen Frijters

namespace IKVM.Reflection
{

public enum AssemblyComparisonResult
{

Unknown = 0,
EquivalentFullMatch = 1,
EquivalentWeakNamed = 2,
Expand All @@ -38,5 +40,7 @@ public enum AssemblyComparisonResult
EquivalentPartialUnified = 9,
EquivalentPartialFXUnified = 10,
NonEquivalentPartialVersion = 11,

}

}
35 changes: 35 additions & 0 deletions src/IKVM.Reflection/AssemblyContentType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Copyright (C) 2009-2012 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
[email protected]
*/
namespace IKVM.Reflection
{

public enum AssemblyContentType
{

Default = 0,
WindowsRuntime = 1,

}

}
36 changes: 36 additions & 0 deletions src/IKVM.Reflection/AssemblyHashAlgorithm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright (C) 2009-2012 Jeroen Frijters
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jeroen Frijters
[email protected]
*/
namespace IKVM.Reflection
{

public enum AssemblyHashAlgorithm
{

None = 0,
MD5 = 0x8003,
SHA1 = 0x8004,

}

}
15 changes: 6 additions & 9 deletions src/IKVM.Reflection/AssemblyName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ Jeroen Frijters

namespace IKVM.Reflection
{

public sealed class AssemblyName
: ICloneable
{

private string name;
private string culture;
private Version version;
Expand Down Expand Up @@ -85,7 +87,7 @@ public AssemblyName(string assemblyName)
if (parsed.PublicKeyToken != null)
{
if (parsed.PublicKeyToken.Equals("null", StringComparison.OrdinalIgnoreCase))
publicKeyToken = Empty<byte>.Array;
publicKeyToken = Array.Empty<byte>();
else if (parsed.PublicKeyToken.Length != 16)
throw new FileLoadException();
else
Expand Down Expand Up @@ -127,13 +129,9 @@ static int ParseHexDigit(char digit)
{
digit |= (char)0x20;
if (digit >= 'a' && digit <= 'f')
{
return 10 + digit - 'a';
}
else
{
throw new FileLoadException();
}
}
}

Expand Down Expand Up @@ -183,7 +181,7 @@ public string EscapedCodeBase
get
{
// HACK use the real AssemblyName to escape the codebase
System.Reflection.AssemblyName tmp = new System.Reflection.AssemblyName();
var tmp = new System.Reflection.AssemblyName();
tmp.CodeBase = codeBase;
return tmp.EscapedCodeBase;
}
Expand Down Expand Up @@ -217,9 +215,7 @@ public AssemblyContentType ContentType
set
{
if (value >= AssemblyContentType.Default && value <= AssemblyContentType.WindowsRuntime)
{
flags = (flags & ~(AssemblyNameFlags)0xE00) | (AssemblyNameFlags)((int)value << 9);
}
}
}

Expand Down Expand Up @@ -269,6 +265,7 @@ public string FullName
ushort versionMinor = 0xFFFF;
ushort versionBuild = 0xFFFF;
ushort versionRevision = 0xFFFF;

if (version != null)
{
versionMajor = (ushort)version.Major;
Expand Down Expand Up @@ -413,7 +410,7 @@ public object Clone()
return copy;
}

private static byte[] Copy(byte[] b)
static byte[] Copy(byte[] b)
{
return b == null || b.Length == 0 ? b : (byte[])b.Clone();
}
Expand Down
Loading

0 comments on commit aff110d

Please sign in to comment.